diff options
author | truebrain <truebrain@openttd.org> | 2011-11-29 22:24:30 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-11-29 22:24:30 +0000 |
commit | 00877dd6d36ca52b1a8720cbbd4a013c958f7fad (patch) | |
tree | ac1c05499e12228624c695b93368246217425469 /src/ai/api/squirrel_export.awk | |
parent | 96249564fd219f8747c9cd54bc934215fb1b5e44 (diff) | |
download | openttd-00877dd6d36ca52b1a8720cbbd4a013c958f7fad.tar.xz |
(svn r23352) -Add: support dynamically adding an API prefix when returning a C++ class to Squirrel
Diffstat (limited to 'src/ai/api/squirrel_export.awk')
-rw-r--r-- | src/ai/api/squirrel_export.awk | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ai/api/squirrel_export.awk b/src/ai/api/squirrel_export.awk index 20060af01..bece800d6 100644 --- a/src/ai/api/squirrel_export.awk +++ b/src/ai/api/squirrel_export.awk @@ -26,14 +26,17 @@ function array_sort(ARRAY, ELEMENTS, temp, i, j) function dump_class_templates(name) { + realname = name + gsub("^AI", "", realname) + print " template <> inline " name " *GetParam(ForceType<" name " *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (" name " *)instance; }" print " template <> inline " name " &GetParam(ForceType<" name " &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(" name " *)instance; }" print " template <> inline 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 <> inline 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 <> inline 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 <> inline int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"" realname "\", res, NULL, DefSQDestructorCallback<" name ">, true); return 1; }" } else { - print " template <> inline 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; }" + print " template <> inline int Return<" name " *>(HSQUIRRELVM vm, " name " *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"" realname "\", res, NULL, DefSQDestructorCallback<" name ">, true); return 1; }" } } |