[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3489 - trunk/sexpr
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3489 - trunk/sexpr |
Date: |
Sun, 4 Nov 2007 14:54:28 +0100 |
Author: grumbel
Date: 2007-11-04 14:54:27 +0100 (Sun, 04 Nov 2007)
New Revision: 3489
Modified:
trunk/sexpr/level-syntax.scm
trunk/sexpr/schema.rb
trunk/sexpr/sexpr.rb
Log:
- some more validation, added vector3i
Modified: trunk/sexpr/level-syntax.scm
===================================================================
--- trunk/sexpr/level-syntax.scm 2007-11-04 13:36:29 UTC (rev 3488)
+++ trunk/sexpr/level-syntax.scm 2007-11-04 13:54:27 UTC (rev 3489)
@@ -46,7 +46,7 @@
(type (mapping
(children
(element (name "type") (type (string)))
- (element (name "position") (type (vector2i)))
+ (element (name "position") (type (vector3i)))
(element (name "surface") (type (surface)))))))
(element (name "surface-background")
@@ -60,14 +60,14 @@
(element (name "keep-aspect") (type (boolean)))
(element (name "para-x") (type (real)))
(element (name "para-y") (type (real)))
- (element (name "position") (type (vector2i)))
+ (element (name "position") (type (vector3i)))
(element (name "surface") (type
(surface)))))))
(element (name "liquid")
(type (mapping
(children
(element (name "speed") (type (integer))
(deprecated #t))
- (element (name "position") (type (vector2i)))
+ (element (name "position") (type (vector3i)))
(element (name "surface") (type (surface)))
(element (name "repeat") (type (integer (min
1))))
))))
@@ -77,7 +77,7 @@
(children
(element (name "speed") (type (color))
(deprecated #t))
(element (name "parallax") (type (real))
(deprecated #t))
- (element (name "position") (type (vector2i)))
+ (element (name "position") (type (vector3i)))
(element (name "surface") (type (surface)))))))
@@ -85,7 +85,7 @@
(type (mapping
(children
(element (name "owner-id") (type (integer)))
- (element (name "position") (type (vector2i)))
+ (element (name "position") (type (vector3i)))
(element (name "surface") (type (surface)))
))))
@@ -94,7 +94,7 @@
(children
(element (name "owner-id") (type (any)))
(element (name "release-rate") (type (integer)))
- (element (name "position") (type (vector2i)))
+ (element (name "position") (type (vector3i)))
(element (name "direction") (type (any)))
(element (name "type") (type (any)))
))))
Modified: trunk/sexpr/schema.rb
===================================================================
--- trunk/sexpr/schema.rb 2007-11-04 13:36:29 UTC (rev 3488)
+++ trunk/sexpr/schema.rb 2007-11-04 13:54:27 UTC (rev 3489)
@@ -83,6 +83,9 @@
when "vector2i"
return Vector2iType.new(reader)
+ when "vector3i"
+ return Vector3iType.new(reader)
+
when "size"
return SizeType.new(reader)
@@ -148,6 +151,7 @@
end
def validate(sexprlst)
+ # always ok
end
end
@@ -156,6 +160,15 @@
end
def validate(sexprlst)
+ if sexprlst.length() != 1 then
+ Schema.report "#{sexpr.pos}: expected a single Symbol got
#{sexpr.to_s}"
+ else
+ if not sexprlst[0].is_a?(Symbol) then
+ Schema.report "#{sexpr.pos}: expected Symbol got #{sexpr[0].class}"
+ else
+ # ok
+ end
+ end
end
end
@@ -164,6 +177,15 @@
end
def validate(sexprlst)
+ if sexprlst.length() != 1 then
+ Schema.report "#{sexpr.pos}: expected a single String got
#{sexpr.to_s}"
+ else
+ if not sexprlst[0].is_a?(String) then
+ Schema.report "#{sexprlst.pos}: expected String got
#{sexprlst[0].class}"
+ else
+ # ok
+ end
+ end
end
end
@@ -172,6 +194,15 @@
end
def validate(sexprlst)
+ if sexprlst.length() != 1 then
+ Schema.report "#{sexprlst.pos}: expected a single boolean got
#{sexprlst.to_s}"
+ else
+ if not sexprlst[0].is_a?(Boolean) then
+ Schema.report "#{sexprlst.pos}: expected Boolean got
#{sexprlst[0].class}"
+ else
+ # ok
+ end
+ end
end
end
@@ -180,10 +211,38 @@
end
def validate(sexprlst)
-
+ if sexprlst.length() != 2 then
+ Schema.report "#{sexprlst.pos}: expected a two Integer got
#{sexprlst.to_s}"
+ else
+ if not sexprlst[0].is_a?(Integer) or not sexprlst[1].is_a?(Integer)
then
+ Schema.report "#{sexprlst.pos}: expected two Integer got
#{sexprlst.map{|i| i.class}.join(", ")}"
+ else
+ # ok
+ end
+ end
end
end
+ class Vector3iType
+ def initialize(reader)
+ end
+
+ def validate(sexprlst)
+ if sexprlst.length() != 3 then
+ Schema.report "#{sexprlst.pos}: expected a three Integer got
#{sexprlst.to_s}"
+ else
+ if not sexprlst[0].is_a?(Integer) or
+ not sexprlst[1].is_a?(Integer) or
+ not sexprlst[2].is_a?(Integer)
+ then
+ Schema.report "#{sexprlst.pos}: expected three Integer got
#{sexprlst.map{|i| i.class}.join(", ")}"
+ else
+ # ok
+ end
+ end
+ end
+ end
+
class SizeType
def initialize(reader)
end
Modified: trunk/sexpr/sexpr.rb
===================================================================
--- trunk/sexpr/sexpr.rb 2007-11-04 13:36:29 UTC (rev 3488)
+++ trunk/sexpr/sexpr.rb 2007-11-04 13:54:27 UTC (rev 3489)
@@ -140,7 +140,11 @@
def [](idx)
if idx.is_a?(Range) then
- return List.new(@value[idx])
+ if idx.begin < @value.length then
+ return List.new(@value[idx], @value[idx.begin].pos)
+ else # FIXME: When is this called?
+ return List.new(@value[idx], self.pos)
+ end
else
return @value[idx]
end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3489 - trunk/sexpr,
grumbel at BerliOS <=