Is this for all script functions or just in some cases? What does the script function look like?
None work, here is a test case
#include <angelscript.h>
#include <scripthelper.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
void MessageCallback(const asSMessageInfo *msg, void *param)
{
const char *type = "ERR ";
if( msg->type == asMSGTYPE_WARNING )
type = "WARN";
else if( msg->type == asMSGTYPE_INFORMATION )
type = "INFO";
printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);
}
void printMethods(void *ref, int typeId)
{
asIObjectType* objType = asGetActiveContext()->GetEngine()->GetObjectTypeById(typeId);
uint32_t count = objType->GetMethodCount();
for( uint32_t i=0; i<count; i++ )
{
asIScriptFunction* method = objType->GetMethodByIndex(i);
uint32_t paramCount = method->GetParamCount();
for( uint32_t j=0; j<count; j++ )
{
int paramTypeId;
const char *paramName;
method->GetParam(j, ¶mTypeId, 0, ¶mName);
printf("%s\n", paramName);
}
}
}
const char *script =
"class Test {\n"
" void test(int argumentName) { }\n"
"}\n"
"void test() {\n"
" Test t;\n"
" printMethods(t);\n"
"}\n";
int main()
{
asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL);
int r = engine->RegisterGlobalFunction("void printMethods(?&in)", asFUNCTION(printMethods), asCALL_CDECL); assert(r>=0);
asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
r = mod->AddScriptSection("script", script, strlen(script));assert(r>=0);
r = mod->Build(); assert(r>=0);
asIScriptContext* ctx = engine->CreateContext();
ctx->Prepare(mod->GetFunctionByDecl("void test()"));
ctx->Execute();
engine->Release();
return 0;
}
Am I doing something wrong?