NETCoreThunk.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "NETCore.h"
  2. #include "NETManaged.h"
  3. #include "NETCoreThunk.h"
  4. namespace Atomic
  5. {
  6. static AtomicNETCoreThunk_t AtomicNETCoreThunk;
  7. void Atomic_NETManaged_SetCSComponentCreate(CSComponentCreateFunctionPtr method)
  8. {
  9. NETCore::GetContext()->GetSubsystem<NETManaged>()->SetCSComponentCreate(method);
  10. }
  11. void Atomic_NETManaged_SetCSComponentCallMethod(CSComponentCallMethodFunctionPtr method)
  12. {
  13. NETCore::GetContext()->GetSubsystem<NETManaged>()->SetCSComponentCallMethod(method);
  14. }
  15. // Event Handling
  16. void Atomic_NETManaged_SetCSBeginSendEvent(CSBeginSendEventFunctionPtr method)
  17. {
  18. NETCore::GetContext()->GetSubsystem<NETManaged>()->SetCSBeginSendEvent(method);
  19. }
  20. void Atomic_AObject_SendEvent(Object* object, const char* eventType)
  21. {
  22. object->SendEvent(eventType);
  23. }
  24. ClassID Atomic_RefCounted_GetClassID(RefCounted* refCounted)
  25. {
  26. if (!refCounted)
  27. return 0;
  28. return refCounted->GetClassID();
  29. }
  30. RefCounted* AtomicEngine_GetSubsystem(const char* name)
  31. {
  32. return NETCore::GetContext()->GetSubsystem(name);
  33. }
  34. void Atomic_RefCounted_SafeAddRef(unsigned id)
  35. {
  36. RefCounted* ref = RefCounted::GetByID(id);
  37. if (ref)
  38. ref->AddRef();
  39. }
  40. void Atomic_RefCounted_SafeReleaseRef(unsigned id)
  41. {
  42. RefCounted* ref = RefCounted::GetByID(id);
  43. if (ref)
  44. ref->ReleaseRef();
  45. }
  46. unsigned Atomic_StringToStringHash(const char* stringValue)
  47. {
  48. StringHash hash = stringValue;
  49. return hash.Value();
  50. }
  51. // Variant Map
  52. RefCounted* Atomic_VariantMap_GetInstance(VariantMap& vmap, const char* key)
  53. {
  54. return vmap[key].GetPtr();
  55. }
  56. void NetCoreThunkInit()
  57. {
  58. AtomicNETCoreThunk.__Atomic_NETManaged_SetCSBeginSendEvent = Atomic_NETManaged_SetCSBeginSendEvent;
  59. AtomicNETCoreThunk.__Atomic_NETManaged_SetCSComponentCallMethod = Atomic_NETManaged_SetCSComponentCallMethod;
  60. AtomicNETCoreThunk.__Atomic_NETManaged_SetCSComponentCreate = Atomic_NETManaged_SetCSComponentCreate;
  61. AtomicNETCoreThunk.__Atomic_AObject_SendEvent = Atomic_AObject_SendEvent;
  62. AtomicNETCoreThunk.__AtomicEngine_GetSubsystem = AtomicEngine_GetSubsystem;
  63. AtomicNETCoreThunk.__Atomic_StringToStringHash = Atomic_StringToStringHash;
  64. AtomicNETCoreThunk.__Atomic_VariantMap_GetInstance = Atomic_VariantMap_GetInstance;
  65. AtomicNETCoreThunk.__Atomic_RefCounted_SafeAddRef = Atomic_RefCounted_SafeAddRef;
  66. AtomicNETCoreThunk.__Atomic_RefCounted_SafeReleaseRef = Atomic_RefCounted_SafeReleaseRef;
  67. AtomicNETCoreThunk.__Atomic_RefCounted_GetClassID = Atomic_RefCounted_GetClassID;
  68. }
  69. }