| 221 | } |
| 222 | |
| 223 | void* ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHandle& interfaceType) |
| 224 | { |
| 225 | if (!obj || !interfaceType) |
| 226 | return nullptr; |
| 227 | const ScriptingType& objectType = obj->GetType(); |
| 228 | const ScriptingType::InterfaceImplementation* interface = objectType.GetInterface(interfaceType); |
| 229 | void* result = nullptr; |
| 230 | if (interface && interface->IsNative) |
| 231 | { |
| 232 | // Native interface so just offset pointer to the interface vtable start |
| 233 | result = (byte*)obj + interface->VTableOffset; |
| 234 | } |
| 235 | else if (interface) |
| 236 | { |
| 237 | // Interface implemented in scripting (eg. C# class inherits C++ interface) |
| 238 | const ScriptingObjectsInterfaceKey key(obj, interfaceType); |
| 239 | if (!ScriptingObjectsInterfaceWrappers.TryGet(key, result)) |
| 240 | { |
| 241 | result = interfaceType.GetType().Interface.GetInterfaceWrapper(obj); |
| 242 | ScriptingObjectsInterfaceWrappers.Add(key, result); |
| 243 | } |
| 244 | } |
| 245 | return result; |
| 246 | } |
| 247 | |
| 248 | ScriptingObject* ScriptingObject::ToNative(MObject* obj) |
| 249 | { |
nothing calls this directly
no test coverage detected