summaryrefslogtreecommitdiff
path: root/src/ai/api/squirrel_export.awk
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-02-12 22:25:53 +0000
committerrubidium <rubidium@openttd.org>2009-02-12 22:25:53 +0000
commitdea3490b2fb3ed9bf67eafd45b0a524a7ea15750 (patch)
tree3e221a4c240d5e3816d46d5d1e22664047944955 /src/ai/api/squirrel_export.awk
parent3314ef39d21f8a2c0ffbe2c39d0d12ca73b041a2 (diff)
downloadopenttd-dea3490b2fb3ed9bf67eafd45b0a524a7ea15750.tar.xz
(svn r15460) -Fix [NoAI]: don't require an instance to exist in the scope for static functions and limit exposure of the internal function GetClassName.
Diffstat (limited to 'src/ai/api/squirrel_export.awk')
-rw-r--r--src/ai/api/squirrel_export.awk9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ai/api/squirrel_export.awk b/src/ai/api/squirrel_export.awk
index 877586722..9ce3ff26b 100644
--- a/src/ai/api/squirrel_export.awk
+++ b/src/ai/api/squirrel_export.awk
@@ -23,7 +23,7 @@ function dump_class_templates(name) {
print " template <> const " name " *GetParam(ForceType<const " name " *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (" name " *)instance; }"
print " template <> const " name " &GetParam(ForceType<const " name " &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(" name " *)instance; }"
if (name == "AIEvent") {
- print " template <> int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"" name "\", res, NULL, DefSQDestructorCallback<" name ">); return 1; }"
+ print " template <> int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"" name "\", res, NULL, DefSQDestructorCallback<" name ">); return 1; }"
} else {
print " template <> int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"" name "\", res, NULL, DefSQDestructorCallback<" name ">); return 1; }"
}
@@ -342,7 +342,11 @@ BEGIN {
} else if (funcname == "") next
split(param_s, params, ",")
- types = "x"
+ if (is_static) {
+ types = "?"
+ } else {
+ types = "x"
+ }
for (len = 1; params[len] != ""; len++) {
sub("^[ ]*", "", params[len])
if (match(params[len], "\\*") || match(params[len], "&")) {
@@ -370,6 +374,7 @@ BEGIN {
cls_param[1] = len;
cls_param[2] = types;
} else if (substr(funcname, 0, 1) == "_" && types != "v") {
+ } else if (funcname == "GetClassName" && types == "?") {
} else if (is_static) {
static_method_size++
static_methods[static_method_size, 0] = funcname