(svn r9509) [NoAI] -Add: inner-class/struct support for parameters.
--- a/src/ai/api/squirrel_export.awk Tue Mar 27 13:58:24 2007 +0000
+++ b/src/ai/api/squirrel_export.awk Tue Mar 27 21:39:38 2007 +0000
@@ -35,7 +35,17 @@
{ print $0; }
# We only want to have public functions exported for now
-/^( *)class/ { if (cls_level == 0) { public = "false"; cls = $2;} cls_level++; next; }
+/^( *)class/ {
+ if (cls_level == 0) {
+ public = "false"
+ cls = $2
+ } else if (cls_level == 1) {
+ struct_size++
+ structs[struct_size] = cls "::" $2
+ }
+ cls_level++
+ next
+}
/^( *)public/ { if (cls_level == 1) public = "true"; next; }
/^( *)protected/ { if (cls_level == 1) public = "false"; next; }
/^( *)private/ { if (cls_level == 1) public = "false"; next; }
@@ -50,9 +60,10 @@
# We need to make specialized conversions for structs
/^( *)struct/ {
cls_level++
-# if (public == "false") next;
-# struct_size++
-# structs[struct_size] = cls "::" $2
+ if (public == "false") next
+ if (cls_level != 1) next
+ struct_size++
+ structs[struct_size] = cls "::" $2
next
}
@@ -102,6 +113,19 @@
}
}
+ # Then check whether we have structs/classes to print
+ if (struct_size != 0) {
+ if (namespace_opened == "false") {
+ print "namespace SQConvert {"
+ namespace_opened = "true"
+ }
+ print " /* Allow inner classes/structs to be used as Squirrel parameters */"
+ for (i = 1; i <= struct_size; i++) {
+ print " template <> " structs[i] " *GetParam(ForceType<" structs[i] " *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (" structs[i] " *)instance; }"
+ delete structs[i]
+ }
+ }
+
if (namespace_opened == "false") {
print "namespace SQConvert {"
namespace_opened = "true"