[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3492 - trunk/sexpr
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3492 - trunk/sexpr |
Date: |
Sun, 4 Nov 2007 19:06:11 +0100 |
Author: grumbel
Date: 2007-11-04 19:06:11 +0100 (Sun, 04 Nov 2007)
New Revision: 3492
Modified:
trunk/sexpr/level-syntax.scm
trunk/sexpr/schema.rb
Log:
- added Color and Size types
Modified: trunk/sexpr/level-syntax.scm
===================================================================
--- trunk/sexpr/level-syntax.scm 2007-11-04 15:10:47 UTC (rev 3491)
+++ trunk/sexpr/level-syntax.scm 2007-11-04 18:06:11 UTC (rev 3492)
@@ -75,7 +75,7 @@
(element (name "hotspot")
(type (mapping
(children
- (element (name "speed") (type (color))
(deprecated #t))
+ (element (name "speed") (type (integer))
(deprecated #t))
(element (name "parallax") (type (real))
(deprecated #t))
(element (name "position") (type (vector3i)))
(element (name "surface") (type (surface)))))))
@@ -96,7 +96,7 @@
(element (name "release-rate") (type (integer)))
(element (name "position") (type
(vector3i)))
(element (name "direction") (type
(enumeration (values "left" "right" "misc"))))
- (element (name "type") (type
(enumeration (values "generic"))))
+ (element (name "type") (type
(enumeration (values "generic" "woodthing" "cloud"))))
))))
(element (name "solidcolor-background")
Modified: trunk/sexpr/schema.rb
===================================================================
--- trunk/sexpr/schema.rb 2007-11-04 15:10:47 UTC (rev 3491)
+++ trunk/sexpr/schema.rb 2007-11-04 18:06:11 UTC (rev 3492)
@@ -219,7 +219,7 @@
def validate(sexprlst)
if sexprlst.length() != 1 then
- Schema.report "#{sexprlst.pos}: expected a single String got
#{sexprlst.to_s}"
+ Schema.report "#{sexprlst.pos}: expected a single String got
#{sexprlst.to_sexpr}"
else
if not sexprlst[0].is_a?(String) then
Schema.report "#{sexprlst.pos}: expected String got
#{sexprlst[0].class}"
@@ -276,6 +276,16 @@
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.to_sexpr}"
+ elsif sexprlst[0].value < 0 or sexprlst[1].value < 0 then
+ Schema.report "#{sexprlst.pos}: size values must be >= 0: got
#{sexprlst.to_sexpr}"
+ else
+ end
+ end
end
end
@@ -284,6 +294,24 @@
end
def validate(sexprlst)
+ if sexprlst.length() != 4 then
+ Schema.report "#{sexprlst.pos}: expected a four Real got
#{sexprlst.to_s}"
+ else
+ if not (sexprlst[0].is_a?(Integer) or sexprlst[0].is_a?(Real)) or
+ not (sexprlst[1].is_a?(Integer) or sexprlst[1].is_a?(Real)) or
+ not (sexprlst[2].is_a?(Integer) or sexprlst[2].is_a?(Real)) or
+ not (sexprlst[3].is_a?(Integer) or sexprlst[3].is_a?(Real))
+ then
+ Schema.report "#{sexprlst.pos}: expected three Real got
#{sexprlst.to_sexpr}"
+ elsif not (sexprlst[0].value >= 0 and sexprlst[0].value <= 1.0 and
+ sexprlst[1].value >= 0 and sexprlst[1].value <= 1.0 and
+ sexprlst[2].value >= 0 and sexprlst[2].value <= 1.0 and
+ sexprlst[3].value >= 0 and sexprlst[3].value <= 1.0) then
+ Schema.report "#{sexprlst.pos}: Color values must be within [0,1]
got #{sexprlst.to_sexpr}"
+ else
+ # ok
+ end
+ end
end
end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3492 - trunk/sexpr,
grumbel at BerliOS <=