Callback.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #if !UNITY_WSA_10_0
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.TextModule {
  8. // C++: class Callback
  9. //javadoc: Callback
  10. public class Callback : DisposableOpenCVObject {
  11. protected override void Dispose(bool disposing) {
  12. #if (UNITY_ANDROID && !UNITY_EDITOR)
  13. try {
  14. if (disposing) {
  15. }
  16. if (IsEnabledDispose) {
  17. if (nativeObj != IntPtr.Zero)
  18. text_Callback_delete(nativeObj);
  19. nativeObj = IntPtr.Zero;
  20. }
  21. } finally {
  22. base.Dispose(disposing);
  23. }
  24. #else
  25. return;
  26. #endif
  27. }
  28. protected internal Callback(IntPtr addr)
  29. : base(addr) {
  30. }
  31. public IntPtr getNativeObjAddr() {
  32. return nativeObj;
  33. }
  34. // internal usage only
  35. public static Callback __fromPtr__(IntPtr addr) {
  36. return new Callback(addr);
  37. }
  38. #if (UNITY_ANDROID && !UNITY_EDITOR)
  39. const string LIBNAME = "opencvforunity";
  40. // native support for java finalize()
  41. [DllImport(LIBNAME)]
  42. private static extern void text_Callback_delete(IntPtr nativeObj);
  43. #endif
  44. }
  45. }
  46. #endif