interface
| 3490 | |
| 3491 | // interface |
| 3492 | int 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 |
| 3522 | int asCScriptEngine::GetStringFactory(asDWORD* flags, asIStringFactory **factory) const |