AtomicInterop.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace AtomicEngine
  4. {
  5. internal static class AtomicInterop
  6. {
  7. [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  8. delegate IntPtr CSComponentCreateDelegate (string name);
  9. static IntPtr CSComponentCreate(string name)
  10. {
  11. return ComponentCore.CreateCSComponent (name);
  12. }
  13. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  14. private static extern void csb_AtomicEngine_AtomicInterop_Set_CSComponentCreate(CSComponentCreateDelegate method);
  15. // ----
  16. [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  17. delegate void CSComponentCallMethodDelegate (uint componentID, CSComponentMethod method, float value);
  18. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  19. private static extern void csb_AtomicEngine_AtomicInterop_Set_CSComponentCallMethod(CSComponentCallMethodDelegate method);
  20. static void CSComponentCallMethod(uint componentID, CSComponentMethod method, float value)
  21. {
  22. ComponentCore.CallComponentMethod (componentID, method, value);
  23. }
  24. // Events
  25. [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  26. delegate void CSBeginSendEventDelegate (uint senderRefId, uint eventType, IntPtr eventData);
  27. [DllImport (Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  28. private static extern void csb_AtomicEngine_AtomicInterop_Set_CSBeginSendEvent(CSBeginSendEventDelegate method);
  29. static void CSBeginSendEvent(uint senderRefId, uint eventType, IntPtr eventData)
  30. {
  31. EventCore.BeginSendEvent (senderRefId, eventType, eventData);
  32. }
  33. public static void Initialize()
  34. {
  35. csb_AtomicEngine_AtomicInterop_Set_CSComponentCreate (CSComponentCreate);
  36. csb_AtomicEngine_AtomicInterop_Set_CSComponentCallMethod (CSComponentCallMethod);
  37. csb_AtomicEngine_AtomicInterop_Set_CSBeginSendEvent (CSBeginSendEvent);
  38. }
  39. }
  40. }