RefCounted.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace AtomicEngine
  4. {
  5. [ComVisible(true)]
  6. public partial class RefCounted
  7. {
  8. public RefCounted()
  9. {
  10. }
  11. protected RefCounted(IntPtr native)
  12. {
  13. nativeInstance = native;
  14. }
  15. // This method may be called multiple times, called on instance after it is either registered as a new native created in C# (InstantiationType == InstantiationType.INSTANTIATION_NET)
  16. // or a native which has been wrapped ((InstantiationType != InstantiationType.INSTANTIATION_NET)
  17. // Note that RefCounted that get GC'd from script, can still live in native code, and get rewrapped
  18. internal virtual void PostNativeUpdate()
  19. {
  20. }
  21. public static implicit operator IntPtr(RefCounted refCounted)
  22. {
  23. if (refCounted == null)
  24. return IntPtr.Zero;
  25. return refCounted.nativeInstance;
  26. }
  27. public IntPtr nativeInstance = IntPtr.Zero;
  28. [DllImport(Constants.LIBNAME, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  29. public static extern IntPtr csi_Atomic_RefCounted_GetClassID(IntPtr self);
  30. }
  31. }