I stumbled upon something I think might be a bug in Angelscript. Consider the following scenario: a module->AddScriptSection call with the following parameters:
'section1', 'namespace Test
{
void test()
{
}
}'
Now, I want to add a global function that calls Test::test() to the same module. In the case when I use CompileFunction with the following parameters: 'func0', '
void func0()
{
Test::test();
}
'
the returned value is negative and the actual error message is "No matching signature to 'Test::test()'". Now in the case when I use another AddScriptSection with basically the same parameters as I pass to CompileFunction, everything is fine. Why is it so? I'd like to be able to use CompileFunction to fetch the function pointer directly instead of using smth like GetFunctionByDecl.
Please note that CompileFunction('func0') is actually called before module->Compile, that explains why Test::test(); isn't found around the time of compilation of func0, however there's no way to add a global function to the module to get its asScriptFunction pointer without actually compiling it. I'm kinda stuck with this chicken & egg problem.
The purpose of CompileFunction() is to allow an application to compile a single function using whatever is already existing in the script module. The newly compiled function can optionally be inserted into the scope of the module so subsequent calls to CompileFunction() or it can be executed and then discarded without actually modifying the compiled module.
It is for example used by the ExecuteString() helper function, and also in the console sample application where whatever the user types on the prompt is executed.
I'm not quite sure what you're trying to accomplish. Can you provide a little more information on what you're planning to do?