Advertisement

Add a dynamic script section

Started by August 26, 2009 06:59 PM
12 comments, last by WitchLord 15 years, 2 months ago
hehe,

Quote:
Where ModifiedExecuteString is the version of ExecuteString that wraps the string in str = "int ExecuteString(int value){\n" + str + "\n; return 0;}";


I did this way, it failed to setArgument, since it report asINVALID_ARG error. line 850, as_context.cpp.
if( arg >= (unsigned)initialFunction->parameterTypes.GetLength() ){	status = asEXECUTION_ERROR;	return asINVALID_ARG;}


I check the parameterTypes value, it said 0 parameter0, but the decl for the function is correct inside initialFunction.

:).

Ah, yes. asCBuilder::BuildString is taking a few shortcuts because it assumes no arguments or return value for the function.

You need to modify that function as well to do what is done for ordinary functions in asCBuilder::RegisterScriptFunction, i.e. you need to use determine the type of the return value and the parameters from the parsed nodes using CreateDataTypeFromNode() and ModifyDataTypeFromNode(). Then you need to inform the asCScriptFunction of these as is done in asCModule::AddScriptFunction().

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Thanks a lot.

I copied the codes from the functions(you pointed to me) to asCBuilder::buildString, it works for me.
Do you want to code to merge?
(you can also help me to check the memory leak stuff if you want the code)

:)

Cheers

Quote: Original post by WitchLord
Ah, yes. asCBuilder::BuildString is taking a few shortcuts because it assumes no arguments or return value for the function.

You need to modify that function as well to do what is done for ordinary functions in asCBuilder::RegisterScriptFunction, i.e. you need to use determine the type of the return value and the parameters from the parsed nodes using CreateDataTypeFromNode() and ModifyDataTypeFromNode(). Then you need to inform the asCScriptFunction of these as is done in asCModule::AddScriptFunction().

Regards,
Andreas


Yes, you can send me the code changes that you've made. If possible, send me the actual files you've modified rather than just a patch, as I use WinMerge to compare and merge the code.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement