MCPcopy Create free account
hub / github.com/anjo76/angelscript / Factory

Method Factory

sdk/tests/test_feature/source/test_inheritance.cpp:43–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 int m_value;
42
43 static FooScripted *Factory()
44 {
45 asIScriptContext *ctx = asGetActiveContext();
46
47 // Get the function that is calling the factory so we can be certain it is the FooScript class
48 asIScriptFunction *func = ctx->GetFunction(0);
49 if( func->GetObjectType() == 0 || std::string(func->GetObjectType()->GetName()) != "FooScripted" )
50 {
51 ctx->SetException("Invalid attempt to manually instantiate FooScript_t");
52 return 0;
53 }
54
55 // Get the this pointer from the calling function
56 asIScriptObject *obj = reinterpret_cast<asIScriptObject*>(ctx->GetThisPointer(0));
57
58 return new FooScripted(obj);
59 }
60
61 void AddRef()
62 {

Callers

nothing calls this directly

Calls 5

SetExceptionMethod · 0.80
GetThisPointerMethod · 0.80
GetFunctionMethod · 0.45
GetObjectTypeMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected