本文整理汇总了C++中CScriptBuilder::BuildScriptFromMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ CScriptBuilder::BuildScriptFromMemory方法的具体用法?C++ CScriptBuilder::BuildScriptFromMemory怎么用?C++ CScriptBuilder::BuildScriptFromMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScriptBuilder
的用法示例。
在下文中一共展示了CScriptBuilder::BuildScriptFromMemory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test
bool Test()
{
bool fail = false;
int r = 0;
COutStream out;
// TODO: Preprocessor directives should be alone on the line
asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL);
// Test the parse token method
asETokenClass t = engine->ParseToken("!is");
if( t != asTC_KEYWORD )
fail = true;
// Compile a script with meta data strings
CScriptBuilder builder;
builder.DefineWord("COMPILE");
r = builder.BuildScriptFromMemory(engine, 0, script);
#if AS_PROCESS_METADATA == 1
if( r < 0 )
fail = true;
int funcId = engine->GetModule(0)->GetFunctionIdByName("func1");
string metadata = builder.GetMetadataStringForFunc(funcId);
if( metadata != " my meta data test " )
fail = true;
funcId = engine->GetModule(0)->GetFunctionIdByName("func2");
metadata = builder.GetMetadataStringForFunc(funcId);
if( metadata != " test['hello'] " )
fail = true;
int typeId = engine->GetModule(0)->GetTypeIdByDecl("MyClass");
metadata = builder.GetMetadataStringForType(typeId);
if( metadata != " myclass " )
fail = true;
typeId = engine->GetModule(0)->GetTypeIdByDecl("MyIntf");
metadata = builder.GetMetadataStringForType(typeId);
if( metadata != " myintf " )
fail = true;
int varIdx = engine->GetModule(0)->GetGlobalVarIndexByName("g_var");
metadata = builder.GetMetadataStringForVar(varIdx);
if( metadata != " init " )
fail = true;
varIdx = engine->GetModule(0)->GetGlobalVarIndexByName("g_obj");
metadata = builder.GetMetadataStringForVar(varIdx);
if( metadata != " var of type myclass " )
fail = true;
#endif
engine->Release();
return fail;
}