Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2006
- 5 participants
- 6 discussions
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Quentin Hocquet <mefyl(a)lrde.epita.fr>
Scool parser.
* tools: New.
* tools/test.yml: New.
* tools/transformer: New.
* tools/transformer/scoolc.str: New.
* tools/transformer/Makefile: New.
* tools/tests: New.
* tools/tests/syntax error: New.
* tools/tests/syntax error/wrong.scl: New.
* tools/tests/parse-ref: New.
* tools/tests/parse-ref/vardec.ref: New.
* tools/tests/parse-ref/fundec.ref: New.
* tools/tests/parse-ref/funcall_no-args.ref: New.
* tools/tests/parse-ref/emtpy-class_dec.ref: New.
* tools/tests/parse-ref/empty-class_dec.ref: New.
* tools/tests/parse-ref/varinit.ref: New.
* tools/tests/parse-ref/no-args_funtype.ref: New.
* tools/tests/parse-ref/manydec.ref: New.
* tools/tests/parse-ref/class_dec.ref: New.
* tools/tests/parse-ref/wiki1.ref: New.
* tools/tests/parse-ref/funcall.ref: New.
* tools/tests/parse-ref/bi-exp.ref: New.
* tools/tests/parse-ref/function.ref: New.
* tools/tests/parse-ref/wiki2.ref: New.
* tools/tests/parse-ref/consinit.ref: New.
* tools/tests/parse-ref/wiki3.ref: New.
* tools/tests/parse-ref/funtype.ref: New.
* tools/tests/parse-ref/empty.ref: New.
* tools/tests/parse-ref/type_static-call.ref: New.
* tools/tests/parse-ref/guard.ref: New.
* tools/tests/good: New.
* tools/tests/good/type_static-call.scl: New.
* tools/tests/good/guard.scl: New.
* tools/tests/good/fundec.scl: New.
* tools/tests/good/vardec.scl: New.
* tools/tests/good/funcall_no-args.scl: New.
* tools/tests/good/varinit.scl: New.
* tools/tests/good/empty-class_dec.scl: New.
* tools/tests/good/manydec.scl: New.
* tools/tests/good/class_dec.scl: New.
* tools/tests/good/no-args_funtype.scl: New.
* tools/tests/good/bi-exp.scl: New.
* tools/tests/good/wiki1.scl: New.
* tools/tests/good/funcall.scl: New.
* tools/tests/good/wiki2.scl: New.
* tools/tests/good/function.scl: New.
* tools/tests/good/consinit.scl: New.
* tools/tests/good/wiki3.scl: New.
* tools/tests/good/funtype.scl: New.
* tools/tests/good/empty.scl: New.
* tools/scoolc: New.
* tools/gen.yml: New.
* tools/parser: New.
* tools/parser/grammar: New.
* tools/parser/grammar/Class.sdf: New.
* tools/parser/grammar/Decl.sdf: New.
* tools/parser/grammar/Exp.sdf: New.
* tools/parser/grammar/ExpOrType.sdf: New.
* tools/parser/grammar/Scool.sdf: New.
* tools/parser/grammar/Lexical.sdf: New.
* tools/parser/grammar/Type.sdf: New.
* tools/parser/grammar/Guard.sdf: New.
* tools/parser/grammar/Stm.sdf: New.
* tools/parser/parse-scool: New.
* tools/parser/Makefile: New.
* tools/Makefile: New.
Makefile | 14 ++++++++++
gen.yml | 9 ++++++
parser/Makefile | 20 ++++++++++++++
parser/grammar/Class.sdf | 18 +++++++++++++
parser/grammar/Decl.sdf | 48
+++++++++++++++++++++++++++++++++++
parser/grammar/Exp.sdf | 43
+++++++++++++++++++++++++++++++
parser/grammar/ExpOrType.sdf | 12 ++++++++
parser/grammar/Guard.sdf | 10 +++++++
parser/grammar/Lexical.sdf | 28 ++++++++++++++++++++
parser/grammar/Scool.sdf | 11 ++++++++
parser/grammar/Stm.sdf | 17 ++++++++++++
parser/grammar/Type.sdf | 18 +++++++++++++
parser/parse-scool | 8 +++++
scoolc | 4 ++
test.yml | 18 +++++++++++++
tests/good/bi-exp.scl | 1
tests/good/class_dec.scl | 15 ++++++++++
tests/good/consinit.scl | 1
tests/good/empty-class_dec.scl | 1
tests/good/funcall.scl | 4 ++
tests/good/funcall_no-args.scl | 4 ++
tests/good/function.scl | 4 ++
tests/good/fundec.scl | 2 +
tests/good/funtype.scl | 1
tests/good/guard.scl | 1
tests/good/manydec.scl | 4 ++
tests/good/no-args_funtype.scl | 1
tests/good/type_static-call.scl | 1
tests/good/vardec.scl | 1
tests/good/varinit.scl | 1
tests/good/wiki1.scl | 9 ++++++
tests/good/wiki2.scl | 5 +++
tests/good/wiki3.scl | 9 ++++++
tests/parse-ref/bi-exp.ref | 1
tests/parse-ref/class_dec.ref | 1
tests/parse-ref/consinit.ref | 1
tests/parse-ref/empty-class_dec.ref | 1
tests/parse-ref/empty.ref | 1
tests/parse-ref/funcall.ref | 1
tests/parse-ref/funcall_no-args.ref | 1
tests/parse-ref/function.ref | 1
tests/parse-ref/fundec.ref | 1
tests/parse-ref/funtype.ref | 1
tests/parse-ref/guard.ref | 1
tests/parse-ref/manydec.ref | 1
tests/parse-ref/no-args_funtype.ref | 1
tests/parse-ref/type_static-call.ref | 1
tests/parse-ref/vardec.ref | 1
tests/parse-ref/varinit.ref | 1
tests/parse-ref/wiki1.ref | 1
tests/parse-ref/wiki2.ref | 1
tests/parse-ref/wiki3.ref | 1
tests/syntax | 1
transformer/Makefile | 6 ++++
transformer/scoolc.str | 6 ++++
55 files changed, 375 insertions(+)
Index: tools/test.yml
--- tools/test.yml (revision 0)
+++ tools/test.yml (revision 0)
@@ -0,0 +1,18 @@
+---
+Test of the Scool parser: !S::Suite
+ contents:
+ - Valid input tests: !S::Iterate
+ over: !pathlist <<pwd>>/tests/good/(*).scl
+ iter: [it_file, it_name]
+ test:
+ Test <<it_name>>: !S::Cmd
+ command: parser/parse-scool "<<it_file>>"
+ exit: 0
+ output: !path "tests/parse-ref/<<it_name>>.ref"
+ - Wrong input tests: !S::Iterate
+ over: !pathlist "<<pwd>>/tests/syntax error/(*).scl"
+ iter: [it_file, it_name]
+ test:
+ Test <<it_name>>: !S::Cmd
+ command: parser/parse-scool "<<it_file>>"
+ exit: 1
Index: tools/transformer/scoolc.str
--- tools/transformer/scoolc.str (revision 0)
+++ tools/transformer/scoolc.str (revision 0)
@@ -0,0 +1,6 @@
+module scoolc
+
+imports liblib Scool
+
+strategies
+ main = io-wrap(id)
Index: tools/transformer/Makefile
--- tools/transformer/Makefile (revision 0)
+++ tools/transformer/Makefile (revision 0)
@@ -0,0 +1,6 @@
+
+scoolc: scoolc.str
+ strc -i $< -I ../parser -la stratego-lib
+
+clean:
+ rm -rf scoolc scoolc.dep scoolc.o scoolc.c .libs
Index: tools/tests/syntax error/wrong.scl
--- tools/tests/syntax error/wrong.scl (revision 0)
+++ tools/tests/syntax error/wrong.scl (revision 0)
@@ -0,0 +1 @@
+var i::int;
Index: tools/tests/parse-ref/vardec.ref
--- tools/tests/parse-ref/vardec.ref (revision 0)
+++ tools/tests/parse-ref/vardec.ref (revision 0)
@@ -0,0 +1 @@
+Program([VarDec("i",Var("int"))])
Index: tools/tests/parse-ref/fundec.ref
--- tools/tests/parse-ref/fundec.ref (revision 0)
+++ tools/tests/parse-ref/fundec.ref (revision 0)
@@ -0,0 +1 @@
+Program([FunDec("f",[("a",Var("int")),("b",Var("int"))],Var("bool"),[])])
Index: tools/tests/parse-ref/funcall_no-args.ref
--- tools/tests/parse-ref/funcall_no-args.ref (revision 0)
+++ tools/tests/parse-ref/funcall_no-args.ref (revision 0)
@@ -0,0 +1 @@
+Program([FunDec("doit",[],Var("int"),[Return(FunCall("chiche",[]))])])
Index: tools/tests/parse-ref/emtpy-class_dec.ref
Index: tools/tests/parse-ref/empty-class_dec.ref
--- tools/tests/parse-ref/empty-class_dec.ref (revision 0)
+++ tools/tests/parse-ref/empty-class_dec.ref (revision 0)
@@ -0,0 +1 @@
+Program([ConsDec("foo",Class,Class([]))])
Index: tools/tests/parse-ref/varinit.ref
--- tools/tests/parse-ref/varinit.ref (revision 0)
+++ tools/tests/parse-ref/varinit.ref (revision 0)
@@ -0,0 +1 @@
+Program([VarDec("i",Var("int"),Int("42"))])
Index: tools/tests/parse-ref/no-args_funtype.ref
--- tools/tests/parse-ref/no-args_funtype.ref (revision 0)
+++ tools/tests/parse-ref/no-args_funtype.ref (revision 0)
@@ -0,0 +1 @@
+Program([VarDec("f",FunType([],Var("void")))])
Index: tools/tests/parse-ref/manydec.ref
--- tools/tests/parse-ref/manydec.ref (revision 0)
+++ tools/tests/parse-ref/manydec.ref (revision 0)
@@ -0,0 +1 @@
+Program([ConsDec("answer",Var("int"),Int("42")),VarDec("i",Var("int")),VarDec("j",Var("int"),Var("i"))])
Index: tools/tests/parse-ref/class_dec.ref
--- tools/tests/parse-ref/class_dec.ref (revision 0)
+++ tools/tests/parse-ref/class_dec.ref (revision 0)
@@ -0,0 +1 @@
+Program([ConsDec("point",Class,Class([Accessblock(Public,[FunDec("x",[],Var("int"),[Return(Var("x"))])]),Accessblock(Private,[VarDec("x",Var("int")),VarDec("y",Var("int"))])]))])
Index: tools/tests/parse-ref/wiki1.ref
--- tools/tests/parse-ref/wiki1.ref (revision 0)
+++ tools/tests/parse-ref/wiki1.ref (revision 0)
@@ -0,0 +1 @@
+Program([FunDec("f",[],Var("void"),[ConsDec("i",Var("int16"),Int("3")),ExpStm(Affect(Var("i"),Int("4"))),VarDec("j",Var("int16"),Int("3")),ExpStm(Affect(Var("j"),Int("4")))])])
Index: tools/tests/parse-ref/funcall.ref
--- tools/tests/parse-ref/funcall.ref (revision 0)
+++ tools/tests/parse-ref/funcall.ref (revision 0)
@@ -0,0 +1 @@
+Program([FunDec("doit",[],Var("int"),[Return(FunCall("chiche",[String("\"pelle\""),String("\"branle\"")]))])])
Index: tools/tests/parse-ref/bi-exp.ref
--- tools/tests/parse-ref/bi-exp.ref (revision 0)
+++ tools/tests/parse-ref/bi-exp.ref (revision 0)
@@ -0,0 +1 @@
+Program([ConsDec("i",Var("int"),BiFunCall("pow",[Int("4")],[Int("3")]))])
Index: tools/tests/parse-ref/function.ref
--- tools/tests/parse-ref/function.ref (revision 0)
+++ tools/tests/parse-ref/function.ref (revision 0)
@@ -0,0 +1 @@
+Program([FunDec("answer",[],Var("int"),[Return(Int("42"))])])
Index: tools/tests/parse-ref/wiki2.ref
--- tools/tests/parse-ref/wiki2.ref (revision 0)
+++ tools/tests/parse-ref/wiki2.ref (revision 0)
@@ -0,0 +1 @@
+Program([FunDec("f",[],Var("void"),[VarDec("a",StaticFunCall("array",[Int("2"),Var("int16")])),VarDec("i",Var("int16"),MethodCall("a","at",[Int("0")]))])])
Index: tools/tests/parse-ref/consinit.ref
--- tools/tests/parse-ref/consinit.ref (revision 0)
+++ tools/tests/parse-ref/consinit.ref (revision 0)
@@ -0,0 +1 @@
+Program([ConsDec("i",Var("int"),Int("3"))])
Index: tools/tests/parse-ref/wiki3.ref
--- tools/tests/parse-ref/wiki3.ref (revision 0)
+++ tools/tests/parse-ref/wiki3.ref (revision 0)
@@ -0,0 +1 @@
+Program([FunDec("f",[],Var("void"),[VarDec("i",Var("int")),VarDec("j",Var("int")),ExpStm(Affect(Var("i"),Int("0"))),ExpStm(Affect(Var("j"),Var("i"))),ExpStm(Affect(Var("i"),Sum(Var("j"),Var("i"))))])])
Index: tools/tests/parse-ref/funtype.ref
--- tools/tests/parse-ref/funtype.ref (revision 0)
+++ tools/tests/parse-ref/funtype.ref (revision 0)
@@ -0,0 +1 @@
+Program([VarDec("f",FunType([Var("int"),Var("bool")],Var("float")))])
Index: tools/tests/parse-ref/empty.ref
--- tools/tests/parse-ref/empty.ref (revision 0)
+++ tools/tests/parse-ref/empty.ref (revision 0)
@@ -0,0 +1 @@
+Program([])
Index: tools/tests/parse-ref/type_static-call.ref
--- tools/tests/parse-ref/type_static-call.ref (revision 0)
+++ tools/tests/parse-ref/type_static-call.ref (revision 0)
@@ -0,0 +1 @@
+Program([VarDec("l",StaticFunCall("list",[Var("int")]))])
Index: tools/tests/parse-ref/guard.ref
--- tools/tests/parse-ref/guard.ref (revision 0)
+++ tools/tests/parse-ref/guard.ref (revision 0)
@@ -0,0 +1 @@
+Program([BiFunDec("f",[("i",Var("int"),Guard(Sup(Var("i"),Int("0"))))],[],Var("int"),[])])
Index: tools/tests/good/type_static-call.scl
--- tools/tests/good/type_static-call.scl (revision 0)
+++ tools/tests/good/type_static-call.scl (revision 0)
@@ -0,0 +1 @@
+var l : list[int];
Index: tools/tests/good/guard.scl
--- tools/tests/good/guard.scl (revision 0)
+++ tools/tests/good/guard.scl (revision 0)
@@ -0,0 +1 @@
+f : [i : int where i > 0]() -> int = {}
\ No newline at end of file
Index: tools/tests/good/fundec.scl
--- tools/tests/good/fundec.scl (revision 0)
+++ tools/tests/good/fundec.scl (revision 0)
@@ -0,0 +1,2 @@
+f : (a: int, b : int) -> bool =
+{}
Index: tools/tests/good/vardec.scl
--- tools/tests/good/vardec.scl (revision 0)
+++ tools/tests/good/vardec.scl (revision 0)
@@ -0,0 +1 @@
+var i : int;
Index: tools/tests/good/funcall_no-args.scl
--- tools/tests/good/funcall_no-args.scl (revision 0)
+++ tools/tests/good/funcall_no-args.scl (revision 0)
@@ -0,0 +1,4 @@
+doit : () -> int =
+{
+ -> chiche();
+}
\ No newline at end of file
Index: tools/tests/good/varinit.scl
--- tools/tests/good/varinit.scl (revision 0)
+++ tools/tests/good/varinit.scl (revision 0)
@@ -0,0 +1 @@
+var i : int := 42;
Index: tools/tests/good/empty-class_dec.scl
--- tools/tests/good/empty-class_dec.scl (revision 0)
+++ tools/tests/good/empty-class_dec.scl (revision 0)
@@ -0,0 +1 @@
+foo : class = {};
\ No newline at end of file
Index: tools/tests/good/manydec.scl
--- tools/tests/good/manydec.scl (revision 0)
+++ tools/tests/good/manydec.scl (revision 0)
@@ -0,0 +1,4 @@
+answer : int = 42;
+
+var i : int;
+var j : int := i;
Index: tools/tests/good/class_dec.scl
--- tools/tests/good/class_dec.scl (revision 0)
+++ tools/tests/good/class_dec.scl (revision 0)
@@ -0,0 +1,15 @@
+point : class =
+{
+ public
+ {
+ x : () -> int =
+ {
+ -> x;
+ }
+ }
+ private
+ {
+ var x :int;
+ var y :int;
+ }
+};
\ No newline at end of file
Index: tools/tests/good/no-args_funtype.scl
--- tools/tests/good/no-args_funtype.scl (revision 0)
+++ tools/tests/good/no-args_funtype.scl (revision 0)
@@ -0,0 +1 @@
+var f : () -> void;
\ No newline at end of file
Index: tools/tests/good/bi-exp.scl
--- tools/tests/good/bi-exp.scl (revision 0)
+++ tools/tests/good/bi-exp.scl (revision 0)
@@ -0,0 +1 @@
+i : int = pow[4](3);
\ No newline at end of file
Index: tools/tests/good/wiki1.scl
--- tools/tests/good/wiki1.scl (revision 0)
+++ tools/tests/good/wiki1.scl (revision 0)
@@ -0,0 +1,9 @@
+
+f : () -> void =
+{
+ i : int16 = 3;
+ i := 4;
+
+ var j : int16 := 3;
+ j := 4;
+}
\ No newline at end of file
Index: tools/tests/good/funcall.scl
--- tools/tests/good/funcall.scl (revision 0)
+++ tools/tests/good/funcall.scl (revision 0)
@@ -0,0 +1,4 @@
+doit : () -> int =
+{
+ -> chiche("pelle", "branle");
+}
\ No newline at end of file
Index: tools/tests/good/wiki2.scl
--- tools/tests/good/wiki2.scl (revision 0)
+++ tools/tests/good/wiki2.scl (revision 0)
@@ -0,0 +1,5 @@
+f : () -> void =
+{
+ var a : array[2,int16];
+ var i : int16 := a.at(0);
+}
Index: tools/tests/good/function.scl
--- tools/tests/good/function.scl (revision 0)
+++ tools/tests/good/function.scl (revision 0)
@@ -0,0 +1,4 @@
+answer : () -> int =
+{
+ -> 42;
+}
\ No newline at end of file
Index: tools/tests/good/consinit.scl
--- tools/tests/good/consinit.scl (revision 0)
+++ tools/tests/good/consinit.scl (revision 0)
@@ -0,0 +1 @@
+i : int = 3;
\ No newline at end of file
Index: tools/tests/good/wiki3.scl
--- tools/tests/good/wiki3.scl (revision 0)
+++ tools/tests/good/wiki3.scl (revision 0)
@@ -0,0 +1,9 @@
+f : () -> void =
+{
+ var i : int;
+ var j : int;
+
+ i := 0;
+ j := i;
+ i := j + i;
+}
Index: tools/tests/good/funtype.scl
--- tools/tests/good/funtype.scl (revision 0)
+++ tools/tests/good/funtype.scl (revision 0)
@@ -0,0 +1 @@
+var f : (int, bool) -> float;
\ No newline at end of file
Index: tools/tests/good/empty.scl
Index: tools/scoolc
--- tools/scoolc (revision 0)
+++ tools/scoolc (revision 0)
@@ -0,0 +1,4 @@
+#!/bin/sh
+# -*- sh -*-
+
+parser/parse-scool $1 | transformer/scoolc
Property changes on: tools/scoolc
___________________________________________________________________
Name: svn:executable
+ *
Index: tools/gen.yml
--- tools/gen.yml (revision 0)
+++ tools/gen.yml (revision 0)
@@ -0,0 +1,9 @@
+---
+Autogeneration of the Scool parser references: !S::Suite
+ contents:
+ - Generation: !S::Iterate
+ over: !pathlist <<pwd>>/tests/good/(*).scl
+ iter: [it_file, it_name]
+ test:
+ Generation <<it_name>>: !S::Cmd
+ command: parser/parse-scool "<<it_file>>" >
"<<pwd>>/tests/good/<<it_name>>.ref"
Index: tools/parser/grammar/Class.sdf
--- tools/parser/grammar/Class.sdf (revision 0)
+++ tools/parser/grammar/Class.sdf (revision 0)
@@ -0,0 +1,18 @@
+module Class
+
+imports
+ Lexical Decl
+
+exports
+ sorts Class AccessBlock AccessModifier
+ context-free syntax
+ "{" AccessBlock* "}" -> Class {cons("Class")}
+
+ AccessModifier "{" Decl* "}" -> AccessBlock {cons("Accessblock")}
+
+ "public" -> AccessModifier {cons("Public")}
+ "protected" -> AccessModifier {cons("Protected")}
+ "private" -> AccessModifier {cons("Private")}
+
+ lexical restrictions
+ AccessModifier -/- [A-Za-z]
Index: tools/parser/grammar/Decl.sdf
--- tools/parser/grammar/Decl.sdf (revision 0)
+++ tools/parser/grammar/Decl.sdf (revision 0)
@@ -0,0 +1,48 @@
+module Decl
+
+imports
+ Lexical Type Guard Stm
+
+exports
+ sorts Decl
+ context-free syntax
+
+ "var" Id ":" Type ";" -> Decl {cons("VarDec")}
+ "var" Id ":" Type ":=" Exp ";" -> Decl {cons("VarDec")}
+ Id ":" Type "=" Exp ";" -> Decl {cons("ConsDec")}
+ Id ":" Type ";" -> Decl {cons("ConsDec")}
+
+ Id ":" "(" {(Id ":" Type) ","}* ")" "->" Type
+ "=" "{" Stm* "}" -> Decl {cons("FunDec")}
+
+ Id ":" "[" {(Id ":" Type Guard) ","}* "]" "->" Type
+ "=" "{" Stm* "}" -> Decl {cons("StaticFunDec")}
+
+ Id ":" "[" {(Id ":" Type Guard) ","}* "]" "(" {(Id ":" Type) ","}* ")"
"->" Type
+ "=" "{" Stm* "}" -> Decl {cons("BiFunDec")}
+
+ Id ":" "(" {(Id ":" Type) ","}* ")" "->" Type
+ "=>" Exp -> Decl {cons("FunDec")}
+
+ Id ":" "[" {(Id ":" Type Guard) ","}* "]" "->" Type
+ "=>" Exp -> Decl {cons("StaticFunDec")}
+
+ Id ":" "[" {(Id ":" Type Guard) ","}* "]" "(" {(Id ":" Type) ","}* ")"
"->" Type
+ "=>" Exp -> Decl {cons("BiFunDec")}
+
+
+ "decl" Id ":" "(" {(Type | (Id ":" Type)) ","}* ")"
+ "->" Type ";" -> Decl {cons("FunPreDec")}
+
+
+ Id ":" "[" {(Id ":" Type) ","}* "]" "->" Type
+ "=" "{" Stm* "}" -> Decl {cons("StaticFunDec")}
+
+ Id ":" "[" {(Id ":" Type) ","}* "]" "(" {(Id ":" Type) ","}* ")" "->" Type
+ "=" "{" Stm* "}" -> Decl {cons("BiFunDec")}
+
+ Id ":" "[" {(Id ":" Type) ","}* "]" "->" Type
+ "=>" Exp -> Decl {cons("StaticFunDec")}
+
+ Id ":" "[" {(Id ":" Type) ","}* "]" "(" {(Id ":" Type) ","}* ")" "->" Type
+ "=>" Exp -> Decl {cons("BiFunDec")}
\ No newline at end of file
Index: tools/parser/grammar/Exp.sdf
--- tools/parser/grammar/Exp.sdf (revision 0)
+++ tools/parser/grammar/Exp.sdf (revision 0)
@@ -0,0 +1,43 @@
+module Exp
+
+imports
+ Lexical Type ExpOrType Class
+
+exports
+ sorts Exp
+ context-free syntax
+
+ ExpOrType -> Exp
+ Int -> Exp {cons("Int")}
+ String -> Exp {cons("String")}
+ Id "(" {Exp ","}* ")" -> Exp {cons("FunCall")}
+ Id "[" {Exp ","}* "]"
+ "(" {Exp ","}* ")" -> Exp {cons("BiFunCall")}
+ Exp "+" Exp -> Exp {cons("Sum")}
+ Exp "-" Exp -> Exp {cons("Sub")}
+ Exp "*" Exp -> Exp {cons("Mul")}
+ Exp "/" Exp -> Exp {cons("Div")}
+ Exp "=" Exp -> Exp {cons("Eq")}
+ Exp "!=" Exp -> Exp {cons("Neq")}
+ Exp "<" Exp -> Exp {cons("Inf")}
+ Exp ">" Exp -> Exp {cons("Sup")}
+ Exp ">=" Exp -> Exp {cons("SupEq")}
+ Exp "<=" Exp -> Exp {cons("InfEq")}
+ Exp ":=" Exp -> Exp {cons("Affect")}
+ Class -> Exp
+ Exp "." Id -> Exp {cons("Field")}
+ Id "." Id "(" {Exp ","}* ")" -> Exp {cons("MethodCall")}
+
+ context-free priorities
+
+ {left:
+ Exp "/" Exp -> Exp
+ Exp "*" Exp -> Exp
+ }
+> {left:
+ Exp "+" Exp -> Exp
+ Exp "-" Exp -> Exp
+ }
+> {right:
+ Exp ":=" Exp -> Exp
+ }
\ No newline at end of file
Index: tools/parser/grammar/ExpOrType.sdf
--- tools/parser/grammar/ExpOrType.sdf (revision 0)
+++ tools/parser/grammar/ExpOrType.sdf (revision 0)
@@ -0,0 +1,12 @@
+module ExpOrType
+
+imports
+ Lexical Exp
+
+exports
+
+ sorts ExpOrType
+ context-free syntax
+ Id "[" {Exp ","}* "]" -> ExpOrType {cons("StaticFunCall")}
+ Id -> ExpOrType {cons("Var")}
+ Id "::" Exp -> ExpOrType {cons("Scope")}
Index: tools/parser/grammar/Scool.sdf
--- tools/parser/grammar/Scool.sdf (revision 0)
+++ tools/parser/grammar/Scool.sdf (revision 0)
@@ -0,0 +1,11 @@
+module Scool
+
+imports
+ Decl
+
+exports
+ sorts Program
+ context-free start-symbols Program
+ context-free syntax
+
+ Decl* -> Program {cons("Program")}
Index: tools/parser/grammar/Lexical.sdf
--- tools/parser/grammar/Lexical.sdf (revision 0)
+++ tools/parser/grammar/Lexical.sdf (revision 0)
@@ -0,0 +1,28 @@
+module Lexical
+
+exports
+ sorts Id Int String Asterisk Slash BlockComment CommentPart Cpp
+ lexical syntax
+
+ [A-Za-z][A-Za-z0-9\_]* -> Id {cons("Id")}
+ [0-9]+ -> Int {cons("Int")}
+ "\"" [A-Za-z0-9]* "\"" -> String {cons("String")}
+ "//" ~[\n]* [\n] -> LAYOUT
+ [\ \t\n] -> LAYOUT
+ "/+" ~[]* "+/" -> Cpp
+ "class" -> Id {reject}
+
+ BlockComment -> LAYOUT
+
+ "/*" CommentPart* "*/" -> BlockComment
+ ~[\/\*] -> CommentPart
+ Asterisk -> CommentPart
+ Slash -> CommentPart
+ BlockComment -> CommentPart
+ [\/] -> Slash
+ [\*] -> Asterisk
+
+ lexical restrictions
+ Id -/- [A-Za-z]
+ Asterisk -/- [\/]
+ Slash -/- [\*]
Index: tools/parser/grammar/Type.sdf
--- tools/parser/grammar/Type.sdf (revision 0)
+++ tools/parser/grammar/Type.sdf (revision 0)
@@ -0,0 +1,18 @@
+module Type
+
+imports
+ ExpOrType
+
+
+exports
+
+ sorts Type
+ context-free syntax
+
+ ExpOrType -> Type
+ "(" {Type ","}* ")" "->" Type -> Type {cons("FunType")}
+ "[" {Type ","}* "]" "->" Type -> Type {cons("StaticFunType")}
+ "[" {Type ","}* "]"
+ "(" {Type ","}* ")" "->" Type -> Type {cons("BiFunType")}
+ "class" -> Type {cons("Class")}
+ "class" "<" Type -> Type {cons("Class")}
Index: tools/parser/grammar/Guard.sdf
--- tools/parser/grammar/Guard.sdf (revision 0)
+++ tools/parser/grammar/Guard.sdf (revision 0)
@@ -0,0 +1,10 @@
+module Guard
+
+imports
+ Exp
+
+exports
+ sorts Guard
+ context-free syntax
+
+ "where" Exp -> Guard {cons("Guard")}
Index: tools/parser/grammar/Stm.sdf
--- tools/parser/grammar/Stm.sdf (revision 0)
+++ tools/parser/grammar/Stm.sdf (revision 0)
@@ -0,0 +1,17 @@
+module Stm
+
+imports
+ Lexical Exp Decl
+
+exports
+ sorts Stm
+ context-free syntax
+
+ ";" -> Stm {cons("EmptyStm")}
+ Exp ";" -> Stm {cons("ExpStm")}
+ "->" Exp ";" -> Stm {cons("Return")}
+ "{" Stm* "}" -> Stm {cons("Block")}
+ "if" "(" Exp ")" Stm ("else" Stm)? -> Stm {cons("If")}
+ "while" "(" Exp ")" Stm -> Stm {cons("While")}
+ Decl -> Stm
+ Cpp -> Stm {cons("CppStm")}
Index: tools/parser/parse-scool
--- tools/parser/parse-scool (revision 0)
+++ tools/parser/parse-scool (revision 0)
@@ -0,0 +1,8 @@
+#!/bin/sh
+# -*- sh -*-
+
+if [ $# -eq 0 ]; then
+ echo "usage: parse-scool file.scl"
+else
+ sglri -p parser/Scool.tbl -i $1
+fi
Property changes on: tools/parser/parse-scool
___________________________________________________________________
Name: svn:executable
+ *
Index: tools/parser/Makefile
--- tools/parser/Makefile (revision 0)
+++ tools/parser/Makefile (revision 0)
@@ -0,0 +1,20 @@
+SDF = $(wildcard grammar/*.sdf)
+OUT = Scool
+
+all: Scool.def Scool.tbl Scool.str
+
+Scool.def: $(SDF)
+ pack-sdf -i grammar/Scool.sdf -o $@
+
+Scool.tbl: Scool.def
+ sdf2table -i $< -o $@ -m Scool
+
+Scool.rtg: Scool.def
+ sdf2rtg -i $< -m Scool -o $@
+
+Scool.str: Scool.rtg
+ rtg2sig --module Scool -i $< -o $@
+
+clean:
+ rm -rf Scool.* log.*
+
Index: tools/Makefile
--- tools/Makefile (revision 0)
+++ tools/Makefile (revision 0)
@@ -0,0 +1,14 @@
+all:
+ cd parser && make
+ cd transformer && make
+
+clean:
+ rm -rf log.*
+ cd parser && make clean
+ cd transformer && make clean
+
+check: all
+ uttk test.yml
+
+gen: all
+ uttk gen.yml
2
1
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Thomas Moulard <thomas.moulard(a)lrde.epita.fr>
Add stc::exact.
* static/tests/exact.cc: test suite of stc::exact (new file).
* static/stc/exact.hh: implementation of stc::exact (new file).
* static/stc/any.hh: adding a typedef exact_t in stc::any.
* metalic/mlc/case.hh: fixing a bug in the protected defaults cases.
metalic/mlc/case.hh | 30 ++-----
static/stc/any.hh | 6 +
static/stc/exact.hh | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++
static/tests/exact.cc | 161 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 373 insertions(+), 22 deletions(-)
Index: static/tests/exact.cc
--- static/tests/exact.cc (revision 0)
+++ static/tests/exact.cc (revision 0)
@@ -0,0 +1,161 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
+// Development Laboratory.
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#include <iostream>
+#include <exact.hh> // FIXME: was stc/exact.hh
+
+template <typename E>
+struct abstraction : public stc::any<E>
+{
+};
+
+
+template <typename E>
+struct sub_abstraction : public abstraction<E>
+{
+};
+
+struct itself {};
+
+
+template <typename T = itself>
+struct concrete_ : public sub_abstraction< concrete_<T> >
+{
+ void foo() const
+ {
+ std::cout << "foo() " << std::endl;
+ }
+};
+
+typedef concrete_<> concrete;
+
+
+int main()
+{
+ //-----------------------------------------
+
+ {
+ std::cout << stc::exact(42) << std::endl;
+ }
+
+ {
+ int i = 42;
+ std::cout << stc::exact(i) << std::endl;
+ }
+
+ {
+ const int i = 42;
+ std::cout << stc::exact(i) << std::endl;
+ }
+
+
+ {
+ int i = 42;
+ int * pi = &i;
+ std::cout << pi << " = "
+ << stc::exact(pi) << std::endl;
+ }
+
+ {
+ int i = 42;
+ int * const pi = &i;
+ std::cout << pi << " = "
+ << stc::exact(pi) << std::endl;
+ }
+
+ {
+ int i = 42;
+ const int * pi = &i;
+ std::cout << pi << " = "
+ << stc::exact(pi) << std::endl;
+ }
+
+ {
+ int i = 42;
+ const int * const pi = &i;
+ std::cout << pi << " = "
+ << stc::exact(pi) << std::endl;
+ }
+
+ // FIXME: Doesn't work!
+
+// {
+// int i = 42;
+// int * pi = &i;
+// int ** ppi = π
+// // stc::exact(ppi);
+
+// const int ci = 42;
+// const int * cpi = &ci;
+// const int ** cppi = &cpi;
+// stc::exact(cppi);
+// }
+
+ //-----------------------------------------
+ {
+ concrete t;
+ const concrete::exact_t& tmp = stc::exact(t);
+ std::cout << &t << " = "
+ << &tmp << std::endl;
+ }
+ {
+ concrete *t = new concrete;
+ std::cout << t << " = "
+ << stc::exact(t) << std::endl;
+ }
+
+ //-----------------------------------------
+ {
+ concrete t;
+ sub_abstraction<concrete>& st = t;
+ const sub_abstraction<concrete>::exact_t& tmp = stc::exact(st);
+ std::cout << &t << " = "
+ << &tmp << std::endl;
+ tmp.foo();
+ }
+ {
+ sub_abstraction<concrete> *t = new concrete;
+ std::cout << t << " = "
+ << stc::exact(t) << std::endl;
+ }
+
+ //-----------------------------------------
+ {
+ concrete t;
+ abstraction<concrete>& a = t;
+ const abstraction<concrete>::exact_t& tmp = stc::exact(a);
+ std::cout << &t << " = "
+ << &tmp << std::endl;
+ }
+ {
+ abstraction<concrete> *t = new concrete;
+ std::cout << t << " = "
+ << stc::exact(t) << std::endl;
+ }
+
+}
Property changes on: static/tests/exact.cc
___________________________________________________________________
Name: svn:executable
+ *
Index: static/stc/exact.hh
--- static/stc/exact.hh (revision 0)
+++ static/stc/exact.hh (revision 0)
@@ -0,0 +1,198 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
+// Development Laboratory.
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef STATIC_EXACT_HH
+# define STATIC_EXACT_HH
+
+# include <stc/any.hh>
+
+# include <mlc/is_a.hh>
+# include <mlc/case.hh>
+# include <mlc/bexpr.hh>
+
+
+
+
+# define stc_internal_is_any(T) \
+mlc::bexpr_< sizeof(internal::any_select(internal::makePtr< T >())) == sizeof(internal::yes_) >
+
+
+
+namespace stc
+{
+
+ namespace internal
+ {
+ typedef char yes_;
+ struct no_ { char dummy[2]; };
+
+ template <typename E, typename P>
+ yes_ any_select(const stc::any<E,P>* arg);
+
+ no_ any_select(...);
+
+ template <typename T>
+ T* makePtr();
+
+ }
+
+ template <typename T>
+ struct is_any_
+ : public stc_internal_is_any(T)
+ {
+ };
+
+ template <typename T>
+ struct is_any_ < T* >;
+
+ template <typename T>
+ struct is_any_ < const T >;
+
+} // end of namespace stc
+
+
+mlc_case_equipment_for_namespace(stc);
+
+
+namespace stc
+{
+
+
+ namespace tag
+ {
+ struct exact;
+ }
+
+
+ template <class T>
+ struct case_<tag::exact, T, 1> : public mlc::where_ < stc::is_any_<T> >
+ {
+ struct protected_
+ {
+ typedef typename T::exact_t ret;
+
+ static inline ret& impl(T& t)
+ {
+ return t.exact();
+ }
+ };
+ };
+
+ template <typename T>
+ struct default_case_<tag::exact, T>
+ {
+ struct protected_
+ {
+ typedef T ret;
+
+ static inline ret& impl(T& t)
+ {
+ return t;
+ }
+ };
+
+ };
+
+
+ template <typename T>
+ struct to_exact_
+ {
+ typedef typename switch_<tag::exact, T>::ret ret;
+
+ static inline ret& impl(const T& t)
+ {
+ typedef typename case_<tag::exact, T>::ret case_t;
+ return case_t::impl(const_cast<T&>(t));
+ }
+ };
+
+
+ template <typename T>
+ struct to_exact_ < const T >
+ {
+ typedef const typename to_exact_<T>::ret ret;
+
+ static inline ret& impl(const T& t)
+ {
+ return to_exact_<T>::impl(const_cast<T&>(t));
+ }
+ };
+
+
+ template <typename T>
+ struct to_exact_ < T* >
+ {
+ typedef typename to_exact_<T>::ret * ret;
+
+ static inline ret impl(T* t)
+ {
+ return & to_exact_<T>::impl(*t);
+ }
+ };
+
+
+
+ template <typename T>
+ const typename to_exact_<const T>::ret&
+ exact(const T& t)
+ {
+ return to_exact_<const T>::impl(t);
+ }
+
+ template <typename T>
+ typename to_exact_<T>::ret&
+ exact(T& t)
+ {
+ return to_exact_<T>::impl(t);
+ }
+
+ template <typename T>
+ typename to_exact_<const T*>::ret
+ exact(const T* t)
+ {
+ return to_exact_<const T*>::impl(t);
+ }
+
+ template <typename T>
+ typename to_exact_<T*>::ret
+ exact(T* t)
+ {
+ return to_exact_<T*>::impl(t);
+ }
+
+
+ template <typename T>
+ void exact(const T** t);
+
+ template <typename T>
+ void exact(T** t);
+
+
+} // end of namespace stc
+
+#endif // ! STATIC_EXACT_HH
Property changes on: static/stc/exact.hh
___________________________________________________________________
Name: svn:executable
+ *
Index: static/stc/any.hh
--- static/stc/any.hh (revision 485)
+++ static/stc/any.hh (working copy)
@@ -67,6 +67,8 @@
struct any <E,
dispatch_policy::best_speed>
{
+ typedef E exact_t;
+
E& exact() {
precondition(exact_ptr != 0);
return *exact_ptr;
@@ -129,6 +131,8 @@
struct any <E,
dispatch_policy::best_memory>
{
+ typedef E exact_t;
+
E& exact() {
# if defined __GNUC__ && __GNUC__ >= 3
return static_cast<E&>(*this);
@@ -185,6 +189,8 @@
struct any <E,
dispatch_policy::simple>
{
+ typedef E exact_t;
+
E& exact() {
return *(E*)(void*)this;
}
Index: metalic/mlc/case.hh
--- metalic/mlc/case.hh (revision 485)
+++ metalic/mlc/case.hh (working copy)
@@ -264,9 +264,15 @@
\
{ \
typedef NAMESPACE::default_case_<context, data> case_t; \
+ typedef typename protected_in_<case_t>::the protected_case_t; \
+ \
+ typedef typename mlc::if_< mlc::is_found_<protected_case_t>, \
+ protected_case_t, \
+ case_t >::ret eff_case_t; \
+ \
typedef typename mlc::if_<mlc_is_a(case_t, mlc::undefined), \
mlc::none, \
- case_t>::ret ret; \
+ eff_case_t>::ret ret; \
}; \
\
\
@@ -339,27 +345,7 @@
mlc::where_), \
mlc_is_a(mlc_comma_2(NAMESPACE::case_<context, data, i>), \
mlc::undefined) >, \
- mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >, \
- \
- private mlc::assert_< mlc::implies_< mlc::and_< mlc::eq_<use, mlc::internal::a_switch_case>, \
- mlc::is_defined_< NAMESPACE::case_<context, data, i> > >, \
- mlc::or_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
- typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
- mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_EITHER_A_ret_OR_A_protected >, \
- \
- private mlc::assert_< mlc::implies_< mlc::and_list_< mlc::eq_<use, mlc::internal::a_switch_case>, \
- mlc::is_defined_< NAMESPACE::case_<context, data, i> >, \
- mlc::or_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
- typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
- mlc::xor_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
- typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
- mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_NOT_HAVE_BOTH_A_ret_AND_A_protected >, \
- \
- private mlc::assert_< mlc::implies_< mlc::and_list_< mlc::eq_<use, mlc::internal::a_switch_case>, \
- mlc::is_defined_< NAMESPACE::case_<context, data, i> >, \
- typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found >, \
- typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found_with_ret >, \
- mlc::ERROR::THE_protected_PART_OF_A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret > \
+ mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ > \
{ \
typedef mlc_is_a(mlc_comma_2(NAMESPACE::case_<context, data, i+1>), \
mlc::case_selected) next_case_is_selected; \
2
1
15 May '06
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr>
Fix bugs and update snakes for multi segmentation.
* oln/appli/snakes/snakes.cc: Fix bugs.
* oln/appli/snakes/snakes.hh: Update snakes for multi segmentation.
snakes.cc | 289 +++++++++++++++++++++++++++++++++++++++++++++-----------------
snakes.hh | 75 +++++++++++-----
2 files changed, 269 insertions(+), 95 deletions(-)
Index: oln/appli/snakes/snakes.cc
--- oln/appli/snakes/snakes.cc (revision 484)
+++ oln/appli/snakes/snakes.cc (working copy)
@@ -24,12 +24,8 @@
mask[*it] = true;
for_all(p)
- {
if (mask[p] == true)
out[p] = 255;
- else
- out[p] = input[p];
- }
}
template <typename T>
@@ -52,17 +48,30 @@
for (; it2 != vec.end(); it2++)
mask[*it2] = true;
}
-
for_all(p)
- {
if (mask[p] == true)
out[p] = 255;
- else
- out[p] = input[p];
- }
}
+template <typename T>
+void my_copy(const oln::image2d<T>& input,
+ oln::image2d<T>& out)
+{
+ oln_iter_type(oln::image2d<T>) p(input);
+ for_all(p)
+ out[p] = input[p];
+}
+
+template <typename T>
+bool is_element_vec(const std::vector<T>& v, const T& elt)
+{
+ typename std::vector<T>::const_iterator it = v.begin();
+ for (; it != v.end(); it++)
+ if (*it == elt)
+ return true;
+ return false;
+}
bool nearly_equal(int x1, int x2, int y1, int y2)
{
@@ -70,78 +79,130 @@
}
template <typename T>
-std::vector<oln::point2d> tri_vec(const oln::image2d<T>& ima,
+int chemin(const std::vector<oln::point2d>& v,
+ const oln::image2d<T>& ima,
+ std::vector<oln::point2d>& seen,
+ // const oln::point2d& pred,
+ const oln::point2d& p,
+ oln::point2d& f,
+ oln::point2d& tmp,
+ int& max,
+ bool& stop)
+{
+ oln_neighb_type(oln::window2d) q(oln::win_c8p(), p);
+ bool end = true;
+ seen.push_back(p);
+ for_all (q)
+ {
+ if (is_element_vec(seen, (oln::point2d)(q)) == 0 and
+ is_element_vec(v, (oln::point2d)(q)))
+ {
+ int res = 1 + chemin(v, ima, seen, q, f, tmp, max, stop);
+ if (res > max)
+ {
+ max = res;
+ f = tmp;
+ }
+ end = false;
+ }
+ }
+ if (end)
+ {
+ tmp = p;
+ return 1;
+ }
+ return 0;
+}
+
+
+std::vector<oln::point2d> verify_snaxels(const std::vector<oln::point2d>& v_init,
const std::vector<oln::point2d>& v)
{
std::vector<oln::point2d> res;
+
+ if (v_init.size() - v.size() > 5)
+ {
std::vector<oln::point2d>::const_iterator it;
- std::vector<oln::point2d>::iterator it2;
+ for (it = v_init.begin(); it != v_init.end(); it++)
+ if (is_element_vec(v, *it) == 0)
+ res.push_back(*it);
+ }
+ return res;
+}
- int ex_1_x = -100;
- int ex_1_y = -100;
- int ex_2_x = 0;
- int ex_2_y = 0;
- int save_x = -1;
- int save_y = -1;
- for (int i = 0; i < 2; i++)
+template <typename T>
+std::vector<oln::point2d> tri_vec(const oln::image2d<T>& ima,
+ const std::vector<oln::point2d>& v,
+ snake_type type) // OUVERT || FERME
{
- double min = 100000000;
+ std::vector<oln::point2d> res;
+ std::vector<oln::point2d>::const_iterator it;
+ std::vector<oln::point2d>::iterator it2;
+ oln::point2d dep;
+ oln::point2d tmp2;
+ oln::point2d arr;
+
+ bool stop = false;
+ oln::point2d beg(-1,-1);
for (it = v.begin(); it != v.end(); it++)
{
- if (i and nearly_equal((*it).row(), ex_1_x, (*it).col(), ex_1_y))
- continue;
-
- double tmp1 = oln::snakes::impl::euclidian_distance((*it).row(), 0, 0, 0);
- double tmp2 = oln::snakes::impl::euclidian_distance((*it).row(), ima.nrows(), 0, 0);
- double tmp3 = oln::snakes::impl::euclidian_distance(0, 0, (*it).col(), 0);
- double tmp4 = oln::snakes::impl::euclidian_distance(0, 0, (*it).col(), ima.ncols());
-
- double tmp_min;
-
- if (tmp1 <= tmp2 and tmp1 <= tmp3 and tmp1 <= tmp4)
- tmp_min = tmp1;
- if (tmp2 <= tmp1 and tmp2 <= tmp3 and tmp2 <= tmp4)
- tmp_min = tmp2;
- if (tmp3 <= tmp1 and tmp3 <= tmp2 and tmp3 <= tmp4)
- tmp_min = tmp3;
- if (tmp4 <= tmp1 and tmp4 <= tmp2 and tmp4 <= tmp3)
- tmp_min = tmp4;
-
- if (tmp_min < min)
- {
- min = tmp_min;
- save_x = (*it).row();
- save_y = (*it).col();
+ unsigned nb_nbh = 0;
+ oln_neighb_type(oln::window2d) q(oln::win_c8p(), *it);
+ for_all (q)
+ if ((oln::point2d)(q) != *it and ima.hold(q) and is_element_vec(v, (oln::point2d)(q)))
+ ++nb_nbh;
+ if (nb_nbh == 2)
+ {
+ beg = *it;
+ break;
}
}
- if (not i)
+ if (beg.row() == -1)
+ beg = *(v.begin() + v.size() / 2);
+
+ dep = beg;
+ arr = beg;
+ std::vector<oln::point2d> seen;
+
+ int i = 0;
+ oln_neighb_type(oln::window2d) q(oln::win_c8p(), beg);
+ for_all (q)
{
- ex_1_x = save_x;
- ex_1_y = save_y;
- }
- else
+ if ((oln::point2d)(q) != beg and ima.hold(q) and is_element_vec(v, (oln::point2d)(q)))
{
- ex_2_x = save_x;
- ex_2_y = save_y;
+ bool s = false;
+ int max = 0;
+
+ seen.push_back(beg);
+ if (not i)
+ chemin(v, ima, seen, (oln::point2d)(q), dep, tmp2, max, s);
+ else
+ chemin(v, ima, seen, (oln::point2d)(q), arr, tmp2, max, s);
+
+ seen.clear();
+ i++;
}
}
-
- res.push_back(oln::point2d(ex_1_x, ex_1_y));
+ res.push_back(dep);
std::vector<oln::point2d> tmp;
for (it = v.begin(); it != v.end(); it++)
- if (((*it).row() != ex_1_x or (*it).col() != ex_1_y) and
- ((*it).row() != ex_2_x or (*it).col() != ex_2_y))
+ if (*it != dep)
+ if (type == OUVERT)
+ {
+ if (*it != arr)
+ tmp.push_back(*it);
+ }
+ else
tmp.push_back(*it);
- bool stop = false;
-
- int tmp_x = ex_1_x;
- int tmp_y = ex_1_y;
+ stop = false;
+ int tmp_x = dep.row();
+ int tmp_y = dep.col();
while (stop == false)
{
@@ -160,23 +221,83 @@
p_ref = it2;
}
}
+ if (min <= 10)
res.push_back(p);
tmp.erase(p_ref);
+ if (min <= 10)
+ {
tmp_x = p.row();
tmp_y = p.col();
}
- else
- {
- res.push_back(oln::point2d(tmp.front().row(), tmp.front().col()));
+ if (tmp.size() == 1)
stop = true;
}
}
- res.push_back(oln::point2d(ex_2_x, ex_2_y));
+ if (type == OUVERT or is_element_vec(res, arr) == 0)
+ res.push_back(arr);
+ return res;
+}
+
+
+std::vector<std::vector<oln::point2d> > filter_size(std::vector<std::vector<oln::point2d> >& v)
+{
+ std::vector<std::vector<oln::point2d> > res;
+
+ for (int i = 0; i < v.size(); i++)
+ if (v[i].size() > 4)
+ res.push_back(v[i]);
+
return res;
}
+void decoup_set(std::vector<std::vector<oln::point2d> >& v)
+{
+ std::vector<oln::point2d>::iterator it;
+ std::vector<oln::point2d>::iterator it2;
+ bool stop = false;
+
+ for (int i = 0; stop == false and i < v.size(); i++)
+ for (int j = i + 1; stop == false and j < v.size(); j++)
+ for (it = v[i].begin(); stop == false and it != v[i].end(); it++)
+ for (it2 = v[j].begin(); stop == false and it2 != v[j].end(); it2++)
+ if (nearly_equal((*it).row(), (*it2).row(), (*it).col(), (*it2).col()))
+ {
+ std::vector<oln::point2d> n1;
+ std::vector<oln::point2d> n2;
+
+ std::vector<oln::point2d>::iterator it3;
+ std::vector<oln::point2d>::iterator it4;
+
+ if (it + 1 != v[i].end() and it + 2 != v[i].end() and it + 3 != v[i].end() and
+ it != v[i].begin() and it + 1 != v[i].begin() and it + 2 != v[i].begin())
+ {
+ for (it3 = it + 1; it3 != v[i].end(); it3++)
+ n1.push_back(*it3);
+ v[i].erase(it + 1, v[i].end() - 1);
+ }
+
+ if (it2 + 1 != v[j].end() and it2 + 2 != v[j].end() and it2 + 3 != v[j].end() and
+ it2 != v[j].begin() and it2 + 1 != v[j].begin() and it2 + 2 != v[j].begin())
+ {
+ for (it4 = it2 + 1; it4 != v[j].end(); it4++)
+ n2.push_back(*it4);
+ v[j].erase(it2 + 1, v[j].end() - 1);
+ }
+ if (n1.size())
+ v.push_back(n1);
+ if (n2.size())
+ v.push_back(n2);
+ if (n2.size() or n1.size())
+ decoup_set(v);
+ stop = true;
+ }
+
+}
+
+
+
int main(int argc, char **argv)
{
using namespace oln;
@@ -187,18 +308,33 @@
exit(1);
}
- std::vector<oln::point2d> v;
+ std::vector<std::vector<oln::point2d> > v;
unsigned max_pts = (unsigned)atoi(argv[7]);
oln::image2d<ntg::bin> mask = load(argv[8]);
oln::image2d<int_u8> input1 = load(argv[9]);
v = morpho::watersnakes(input1, mask, win_c8p(), 5);
+ v = filter_size(v);
+ // decoup_set(v);
- v = tri_vec(input1, v);
-
- if (max_pts)
- v = oln::snakes::impl::redispatch(v, max_pts);
+ for (int cpt = 0; cpt < v.size(); cpt++)
+ {
+ std::vector<oln::point2d> v_new = tri_vec(input1, v[cpt], (snake_type)atoi(argv[6]));
+ std::vector<oln::point2d> v_verif = verify_snaxels(v[cpt], v_new);
+ v[cpt] = v_new;
+ if (v_verif.size() > 0)
+ v.push_back(v_verif);
+ if (v[cpt].size() > max_pts)
+ v[cpt] = oln::snakes::impl::redispatch(v[cpt], max_pts);
+ }
+
+ std::vector<unsigned> v_max_pts;
+ for (int cpt = 0; cpt < v.size(); cpt++)
+ if ((unsigned)((float)(v[cpt].size()) * 0.6) > max_pts)
+ v_max_pts.push_back(max_pts);
+ else
+ v_max_pts.push_back((unsigned)((float)(v[cpt].size()) * 0.6));
for (int i = 9; i < argc; i++)
{
@@ -209,16 +345,19 @@
oln::image2d<int_u8> out(input.size());
unsigned nb_gen = 0;
- if (i == 9)
- nb_gen = (unsigned)atoi(argv[3]);
- else
- nb_gen = 1;
-
- v = oln::snakes::snakes(input, v, (force_type)(atoi(argv[1])), (unsigned)atoi(argv[2]), nb_gen, max_pts, atof(argv[4]), (unsigned)atoi(argv[5]), (snake_type)atoi(argv[6]));
+ my_copy(input, out);
- aff_droites(input, v, out);
- // aff_points(input, v, out);
+ nb_gen = (unsigned)atoi(argv[3]);
+ for (int cpt = 0; cpt < v.size(); cpt++)
+ {
+ if (v[cpt].size() > v_max_pts[cpt])
+ v[cpt] = oln::snakes::impl::redispatch(v[cpt], v_max_pts[cpt]);
+ else
+ v[cpt] = oln::snakes::impl::redispatch_normal(v[cpt], v[cpt].size());
+ v[cpt] = oln::snakes::snakes(input, v[cpt], (force_type)(atoi(argv[1])), (unsigned)atoi(argv[2]), nb_gen, v_max_pts[cpt], atof(argv[4]), (unsigned)atoi(argv[5]), (snake_type)atoi(argv[6]));
+ aff_droites(input, v[cpt], out);
+ }
char t[30];
sprintf(t, "snakes_%d.pgm", i - 8);
Index: oln/appli/snakes/snakes.hh
--- oln/appli/snakes/snakes.hh (revision 484)
+++ oln/appli/snakes/snakes.hh (working copy)
@@ -40,7 +40,6 @@
typedef enum FORCE_TYPE { GRADIENT = 0, VARIANCE = 1 } force_type;
const float PI = 3.14159265;
-
namespace oln {
namespace snakes {
@@ -80,22 +79,17 @@
y2 = force.ncols() - 1;
}
-
std::vector<point2d> draw_line_(const point2d& p,
const point2d& q)
{
std::vector<point2d> res;
-
point2d p_cur = p;
+
if (q.col() == p.col()) // cas vertical
{
int sens = q.row() > p.row() ? 1 : -1;
while (p_cur != q)
{
- double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
- double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
- double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
-
res.push_back(p_cur);
p_cur.row() = p_cur.row() + sens;
}
@@ -107,10 +101,6 @@
int sens = q.col() > p.col() ? 1 : -1;
while (p_cur != q)
{
- double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
- double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
- double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
-
res.push_back(p_cur);
p_cur.col() = p_cur.col() + sens;
}
@@ -132,10 +122,6 @@
while (p_cur != q)
{
- double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
- double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
- double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
-
res.push_back(p_cur);
if (abs(decalage) >= abs(denom))
@@ -154,8 +140,6 @@
return res;
}
-
-
template <typename T>
std::vector<point2d> compute_normal_points_(const image2d<T>& force,
const point2d& p1,
@@ -163,9 +147,12 @@
const point2d& p3,
unsigned int dmax)
{
+ point2d pp1(p1.row(), p1.col());
+ point2d pp3(p3.row(), p3.col());
+
float x_c = p2.row();
float y_c = p2.col();
- float a_p1_p3 = (p1.col() - p3.col()) != 0 ? (float)(((float)(p1.row() - p3.row())) / (p1.col() - p3.col())) : 0;
+ float a_p1_p3 = (pp1.col() - pp3.col()) != 0 ? (float)(((float)(pp1.row() - pp3.row())) / (pp1.col() - pp3.col())) : 0;
float a = -a_p1_p3;
float b = p2.col() - a * p2.row(); // use of - slope of p1 et p3
@@ -203,11 +190,21 @@
}
else
{
+ if (pp3.row() == pp1.row())
+ {
x1 = p2.row() - dmax;
y1 = p2.col();
x2 = p2.row() + dmax;
y2 = p2.col();
}
+ else
+ {
+ x1 = p2.row();
+ y1 = p2.col() - dmax;
+ x2 = p2.row();
+ y2 = p2.col() + dmax;
+ }
+ }
verify_integrity_(force, x1, x2, y1, y2);
@@ -226,6 +223,7 @@
return sqr(180 - angle) / sqr(180);
}
+
template <typename T>
double variance(const image2d<T>& input,
const point2d& p,
@@ -255,6 +253,7 @@
return res / sqr(fen);
}
+
template <typename T>
std::vector<point2d> gen_snakes_(const image2d<T>& force,
const std::vector<point2d>& v,
@@ -267,6 +266,9 @@
std::vector<point2d>::const_iterator it = v.begin();
std::vector<point2d> res;
+ if (type == OUVERT)
+ res.push_back(*(v.begin()));
+
for (; it != v.end(); it++)
{
point2d p1 = *it;
@@ -322,7 +324,6 @@
}
else
res.push_back(*(v.end() - 1));
-
return res;
}
@@ -376,9 +377,16 @@
int nb_pts = v.size() * 2;
int cpt = 0;
+ if (tmp.size() > nb_pts)
+ {
for (it2 = tmp.begin(); it2 != tmp.end(); it2++, cpt++)
if ((cpt % (tmp.size() / nb_pts)) == 0)
res.push_back(*it2);
+ }
+ else
+ for (it2 = tmp.begin(); it2 != tmp.end(); it2++, cpt++)
+ res.push_back(*it2);
+
if (type == FERME)
{
@@ -391,7 +399,6 @@
return res;
}
-
std::vector<point2d> redispatch(const std::vector<point2d>& v,
int nb_snaxels)
{
@@ -418,6 +425,33 @@
}
+ std::vector<point2d> redispatch_normal(const std::vector<point2d>& v,
+ int nb_snaxels)
+ {
+ std::vector<point2d> res;
+ std::vector<point2d> tmp;
+ std::vector<point2d>::const_iterator it = v.begin();
+ int cpt = 0;
+
+ for (; it + 1 != v.end(); it++)
+ {
+ std::vector<point2d> vec = draw_line_(*it, *(it+1));
+ std::vector<point2d>::const_iterator it2 = vec.begin();
+
+ for (; it2 != vec.end(); it2++)
+ tmp.push_back(*it2);
+ }
+
+ for (it = tmp.begin(); it != tmp.end(); it++, cpt++)
+ if ((cpt % (int)(roundf(((float)(tmp.size()) / nb_snaxels)))) == 0)
+ res.push_back(*it);
+
+ res.push_back(*(v.end() - 1));
+ return res;
+ }
+
+
+
template <typename T>
void clean_ima(image2d<T>& ima)
{
@@ -475,6 +509,7 @@
while (i < nb_gen)
{
res = gen_snakes_(force, res, f, fen, lambda, dmax, type);
+ if (res.size() > max_pts)
res = redispatch(res, max_pts);
i++;
if (i < nb_gen)
1
0
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr>
Update Watersnake for multi segmentation.
* oln/morpho/watersnakes.hh: Update for multi segmentation.
watersnakes.hh | 44 +++++++++++++++++++++++++++-----------------
1 file changed, 27 insertions(+), 17 deletions(-)
Index: oln/morpho/watersnakes.hh
--- oln/morpho/watersnakes.hh (revision 483)
+++ oln/morpho/watersnakes.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_MORPHO_WATERSNAKES_HH
# include <string>
+# include <map>
# include <oln/basics.hh>
# include <oln/morpho/erosion.hh>
@@ -409,7 +410,7 @@
}
template<typename T, typename T2>
- std::vector<point2d>
+ std::vector<std::vector<point2d> >
watershed_line(const image2d<T>& input,
const image2d<T>& orig,
const image2d<T2>& marqueur,
@@ -417,12 +418,14 @@
int b,
version v)
{
- image2d<int> final(input.size());
image2d<int> label;
image2d<T2> mark(input.size());
oln_iter_type(image2d<T>) p(input);
image2d<bool> is_wshed_line(input.size());
- std::vector<point2d> res;
+ std::vector<point2d> tmp;
+ std::vector<std::vector<point2d> > res;
+ std::map<std::pair<int, int>, int> num_wshed;
+ int cpt = 0;
unsigned nb_compo = 0;
for_all(p)
@@ -432,7 +435,6 @@
propagate_minima_(input, mark, ng, p);
image2d<T> recon;
-
if (v == NORMAL)
recon = reconstruction_by_erosion(input, mark);
else
@@ -441,10 +443,9 @@
op_type op(marqueur, input, ng);
recon = op.output;
}
- image2d<float> LS = lower_slope(recon, ng);
+ image2d<float> LS = lower_slope(recon, ng);
label = init_watershed_(recon, mark, ng, nb_compo);
-
image2d<float*> topo = topographic_distance(recon, LS, mark, label, ng, nb_compo);
for_all(p)
@@ -463,21 +464,30 @@
while (snake_iteration(label, topo, b))
;
- level::fill(final, 0);
for_all(p)
{
oln_neighb_type(window2d) q(win_c4p(), p);
for_all (q)
if (input.hold(q))
- if (label[p] != label[q] and final[q] != WSHED)
- final[p] = WSHED;
- if (final[p] == 0)
- final[p] = orig[p];
+ if (label[p] != label[q])
+ {
+ int p1 = std::min(label[p], label[q]);
+ int p2 = std::max(label[p], label[q]);
+ if (num_wshed.find(std::pair<int, int>(p1, p2)) == num_wshed.end())
+ {
+ num_wshed[std::pair<int, int>(p1, p2)] = cpt++;
+ std::vector<point2d> tmp;
+ tmp.push_back(p);
+ res.push_back(tmp);
+ }
+ else
+ {
+ if (res[(*(num_wshed.find(std::pair<int, int>(p1, p2)))).second].back() != p)
+ if (label[p] == p1)
+ res[(*(num_wshed.find(std::pair<int, int>(p1, p2)))).second].push_back(p);
+ }
+ }
}
-
- for_all(p)
- if (final[p] == WSHED)
- res.push_back(p);
return res;
}
@@ -485,7 +495,7 @@
template<typename T, typename T2>
- std::vector<point2d>
+ std::vector<std::vector<point2d> >
watersnakes_(const image2d<T>& input,
const image2d<T2>& marqueur,
const window2d& ng,
@@ -503,7 +513,7 @@
template<typename T, typename T2>
- std::vector<point2d>
+ std::vector<std::vector<point2d> >
watersnakes(const image2d<T>& input,
const image2d<T2>& marqueur,
const window2d& ng,
1
0
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Quentin Hocquet <quentin.hocquet(a)lrde.epita.fr>
Fix previous patch
* Fix error in svn external link to transformers
* tools: .
* tools/tests/good/funcall_no-args.scl, tools/tests/good/funcall.scl:
fix typo
funcall.scl | 2 +-
funcall_no-args.scl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Index: tools/tests/good/funcall_no-args.scl
--- tools/tests/good/funcall_no-args.scl (revision 482)
+++ tools/tests/good/funcall_no-args.scl (working copy)
@@ -1,4 +1,4 @@
doit : () -> int =
{
- -> chiche();
+ -> foo();
}
\ No newline at end of file
Index: tools/tests/good/funcall.scl
--- tools/tests/good/funcall.scl (revision 482)
+++ tools/tests/good/funcall.scl (working copy)
@@ -1,4 +1,4 @@
doit : () -> int =
{
- -> chiche("pelle", "branle");
+ -> foo("bar", "baz");
}
1
0
481: Fix a duplicate where-clause and perform some aesthetic changes in image abstractions.
by Roland Levillain 02 May '06
by Roland Levillain 02 May '06
02 May '06
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix a duplicate where-clause and perform some aesthetic changes in
image abstractions.
* oln/core/abstract/image_dimension.hh: Move the static switch
statement before the cases.
Aesthetic changes.
* olena/oln/core/abstract/image_typeness.hh: Likewise.
(case_<value_type_tag, value_type, 2>): Fix a copy-and-paste bug:
remove a duplicate `unsigned char' type in the where-clause and
replace it with `signed char'.
* oln/core/abstract/image_typeness_integre.hh,
* tests/image_entry.cc: Aesthetic changes.
oln/core/abstract/image_dimension.hh | 58 +++++++++++++++++++---------
oln/core/abstract/image_typeness.hh | 58 ++++++++++++++++++----------
oln/core/abstract/image_typeness_integre.hh | 7 +--
tests/image_entry.cc | 4 -
4 files changed, 84 insertions(+), 43 deletions(-)
Index: tests/image_entry.cc
--- tests/image_entry.cc (revision 480)
+++ tests/image_entry.cc (working copy)
@@ -28,7 +28,7 @@
/// Test oln::abstract::image_entry.
// FIXME: Check also with a (possibly fake) ntg::int_u<1, B> type, to
-// stress image_typeness.hh. This should be done in another test, of
+// stress image_typeness.hh. This might be done in another test, of
// course.
#include <oln/core/1d/grid1d.hh>
@@ -64,7 +64,7 @@
namespace my
{
- // A very simple 1D image.
+ // A very simple 1-D image.
class image : public oln::set_super_type<my::image>::ret
{
typedef image self_type;
Index: oln/core/abstract/image_dimension.hh
--- oln/core/abstract/image_dimension.hh (revision 480)
+++ oln/core/abstract/image_dimension.hh (working copy)
@@ -65,13 +65,17 @@
*/
+/*-------------------------.
+| Dimension abstractions. |
+`-------------------------*/
+
namespace oln
{
namespace abstract
{
- /// Class of 1D images.
+ /// Class of 1-D images.
template <typename E>
struct image1d : public virtual image<E>
{
@@ -80,7 +84,7 @@
image1d() {}
};
- /// Class of 2D images.
+ /// Class of 2-D images.
template <typename E>
struct image2d : public virtual image<E>
{
@@ -89,7 +93,7 @@
image2d() {}
};
- /// Class of 3d images.
+ /// Class of 3-D images.
template <typename E>
struct image3d : public virtual image<E>
{
@@ -100,21 +104,45 @@
} // end of namespace oln::abstract
+} // end of namespace oln
+
/*-------------------.
| Dimension switch. |
`-------------------*/
+namespace oln
+{
+ /// Case tag for the dimension.
+ struct grid_dim_tag;
+}
+
+
+// Register the dimension switch for oln::abstract::image_entry.
+namespace stc
+{
+ template <typename I>
+ struct set_entry_node<I, oln::abstract::dimension_tag> :
+ public oln::switch_< oln::grid_dim_tag, oln_type_of(I, grid) >::ret
+ ::template instantiated_with<I>::ret
+ {
+ };
+} // end of namespace stc
+
+
+namespace oln
+{
+
// Forward declarations.
class grid1d;
class grid2d;
class grid3d;
- /// Case tag for the dimension.
- struct grid_dim_tag;
/// Switch on on the grid dimension.
/// \{
+
+ /// 1-D case.
template <typename grid_type>
struct case_<grid_dim_tag, grid_type, 1> :
// Test.
@@ -124,6 +152,7 @@
typedef stc::abstraction_as_type<abstract::image1d> ret;
};
+ /// 2-D case.
template <typename grid_type>
struct case_<grid_dim_tag, grid_type, 2> :
// Test.
@@ -133,6 +162,7 @@
typedef stc::abstraction_as_type<abstract::image2d> ret;
};
+ /// 3-D case.
template <typename grid_type>
struct case_<grid_dim_tag, grid_type, 3> :
// Test.
@@ -142,7 +172,7 @@
typedef stc::abstraction_as_type<abstract::image3d> ret;
};
- /// Abort when grid_type is not handled by the previous cases.
+ /// Default case: abort when grid_type is not handled by the previous cases.
template <typename grid_type>
struct default_case_<grid_dim_tag, grid_type>
{
@@ -153,19 +183,11 @@
} // end of namespace oln
-// Register the dimension switch for oln::abstract::image_entry.
-namespace stc
-{
- template <typename I>
- struct set_entry_node<I, oln::abstract::dimension_tag> :
- public oln::switch_< oln::grid_dim_tag, oln_type_of(I, grid) >::ret
- ::template instantiated_with<I>::ret
- {
- };
-} // end of namespace stc
-
+/*----------------------------------.
+| Dimension external virtual type. |
+`----------------------------------*/
-// FIXME: Is this external property really useful?
+// FIXME: Is this external vtype really useful?
namespace oln
{
/// Image dimension type as an external vtype of abstract::image.
Index: oln/core/abstract/image_typeness_integre.hh
--- oln/core/abstract/image_typeness_integre.hh (revision 480)
+++ oln/core/abstract/image_typeness_integre.hh (working copy)
@@ -77,11 +77,12 @@
} // end of namespace ntg
+/*--------------------------.
+| Typeness switch (cont.). |
+`--------------------------*/
+
namespace oln {
- /*--------------------.
- | Value type switch. |
- `--------------------*/
/// Switch on on the value type.
/// \{
Index: oln/core/abstract/image_typeness.hh
--- oln/core/abstract/image_typeness.hh (revision 480)
+++ oln/core/abstract/image_typeness.hh (working copy)
@@ -68,7 +68,12 @@
*/
-namespace oln {
+/*------------------------.
+| Typeness abstractions. |
+`------------------------*/
+
+namespace oln
+{
namespace abstract
{
@@ -142,9 +147,9 @@
};
- /*---------------------.
- | Conjunctions types. |
- `---------------------*/
+ // -------------------- //
+ // Conjunctions types. //
+ // -------------------- //
namespace internal
{
@@ -204,13 +209,34 @@
} // end of namespace oln::abstract
+} // end of namespace oln
+
- /*--------------------.
- | Value type switch. |
- `--------------------*/
+/*------------------.
+| Typeness switch. |
+`------------------*/
+namespace oln
+{
/// Case tag for the dimension.
struct value_type_tag;
+}
+
+
+// Register the dimension switch/case for oln::abstract::image_entry.
+namespace stc
+{
+ template <typename I>
+ struct set_entry_node<I, oln::abstract::typeness_tag> :
+ public oln::case_< oln::value_type_tag, oln_type_of(I, value) >::ret
+ ::super_type::template instantiated_with<I>::ret
+ {
+ };
+} // end of namespace stc
+
+
+namespace oln
+{
/// Switch on on the grid dimension.
/// \{
@@ -236,7 +262,7 @@
struct case_<value_type_tag, value_type, 2> :
public mlc::where_<
mlc::or_list_< mlc_eq(value_type, char),
- mlc_eq(value_type, unsigned char),
+ mlc_eq(value_type, signed char),
mlc_eq(value_type, unsigned char) > >
{
// Definition of the super class corresponding to this case
@@ -273,19 +299,11 @@
} // end of namespace oln
-// Register the dimension switch/case for oln::abstract::image_entry.
-namespace stc
-{
- template <typename I>
- struct set_entry_node<I, oln::abstract::typeness_tag> :
- public oln::case_< oln::value_type_tag, oln_type_of(I, value) >::ret
- ::super_type::template instantiated_with<I>::ret
- {
- };
-} // end of namespace stc
-
+/*---------------------------------.
+| Typeness external virtual type. |
+`---------------------------------*/
-// FIXME: Is this external property really useful?
+// FIXME: Is this external vtype really useful?
namespace oln
{
/// Image ``typeness'' as an external vtype of abstract::image.
1
0