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

Method RegisterStringFactory

sdk/angelscript/source/as_scriptengine.cpp:3492–3519  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

3490
3491// interface
3492int asCScriptEngine::RegisterStringFactory(const char *datatype, asIStringFactory *factory)
3493{
3494 // TODO: Add check to prohibit registering a new factory if one already is registered
3495 // This is because the engine keeps references to strings in the factory, and
3496 // won't be able to handle it if the string factory is replaced
3497
3498 if (factory == 0)
3499 return ConfigError(asINVALID_ARG, "RegisterStringFactory", datatype, 0);
3500
3501 // Parse the data type
3502 asCBuilder bld(this, 0);
3503 asCDataType dt;
3504 int r = bld.ParseDataType(datatype, &dt, defaultNamespace, true);
3505 if (r < 0)
3506 return ConfigError(asINVALID_TYPE, "RegisterStringFactory", datatype, 0);
3507
3508 // Validate the type. It must not be reference or handle
3509 if (dt.IsReference() || dt.IsObjectHandle())
3510 return ConfigError(asINVALID_TYPE, "RegisterStringFactory", datatype, 0);
3511
3512 // All string literals will be treated as const
3513 dt.MakeReadOnly(true);
3514
3515 stringType = dt;
3516 stringFactory = factory;
3517
3518 return asSUCCESS;
3519}
3520
3521// interface
3522int asCScriptEngine::GetStringFactory(asDWORD* flags, asIStringFactory **factory) const

Callers 15

ConfigEngineFromStreamFunction · 0.80
RegisterStdString_NativeFunction · 0.80
TestFunction · 0.80
test_compiler.cppFile · 0.80
test_condition.cppFile · 0.80
TestUTF16Function · 0.80
RegisterBStrFunction · 0.80
TestFunction · 0.80
TestFunction · 0.80

Calls 4

IsObjectHandleMethod · 0.80
MakeReadOnlyMethod · 0.80
ParseDataTypeMethod · 0.45
IsReferenceMethod · 0.45

Tested by 14

TestFunction · 0.64
TestUTF16Function · 0.64
RegisterBStrFunction · 0.64
TestFunction · 0.64
TestFunction · 0.64
RegisterMethod · 0.64
TestAndrewPriceFunction · 0.64
TestStdWStringFunction · 0.64
TestFunction · 0.64