CefFocusHandler.g.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // DO NOT MODIFY! THIS IS AUTOGENERATED FILE!
  3. //
  4. namespace Xilium.CefGlue
  5. {
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Diagnostics;
  9. using System.Runtime.InteropServices;
  10. using System.Threading;
  11. using Xilium.CefGlue.Interop;
  12. // Role: HANDLER
  13. public abstract unsafe partial class CefFocusHandler
  14. {
  15. private static Dictionary<IntPtr, CefFocusHandler> _roots = new Dictionary<IntPtr, CefFocusHandler>();
  16. private int _refct;
  17. private cef_focus_handler_t* _self;
  18. private cef_focus_handler_t.add_ref_delegate _ds0;
  19. private cef_focus_handler_t.release_delegate _ds1;
  20. private cef_focus_handler_t.has_one_ref_delegate _ds2;
  21. private cef_focus_handler_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_focus_handler_t.on_take_focus_delegate _ds4;
  23. private cef_focus_handler_t.on_set_focus_delegate _ds5;
  24. private cef_focus_handler_t.on_got_focus_delegate _ds6;
  25. protected CefFocusHandler()
  26. {
  27. _self = cef_focus_handler_t.Alloc();
  28. _ds0 = new cef_focus_handler_t.add_ref_delegate(add_ref);
  29. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  30. _ds1 = new cef_focus_handler_t.release_delegate(release);
  31. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  32. _ds2 = new cef_focus_handler_t.has_one_ref_delegate(has_one_ref);
  33. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  34. _ds3 = new cef_focus_handler_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  35. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  36. _ds4 = new cef_focus_handler_t.on_take_focus_delegate(on_take_focus);
  37. _self->_on_take_focus = Marshal.GetFunctionPointerForDelegate(_ds4);
  38. _ds5 = new cef_focus_handler_t.on_set_focus_delegate(on_set_focus);
  39. _self->_on_set_focus = Marshal.GetFunctionPointerForDelegate(_ds5);
  40. _ds6 = new cef_focus_handler_t.on_got_focus_delegate(on_got_focus);
  41. _self->_on_got_focus = Marshal.GetFunctionPointerForDelegate(_ds6);
  42. }
  43. ~CefFocusHandler()
  44. {
  45. Dispose(false);
  46. }
  47. protected virtual void Dispose(bool disposing)
  48. {
  49. if (_self != null)
  50. {
  51. cef_focus_handler_t.Free(_self);
  52. _self = null;
  53. }
  54. }
  55. private void add_ref(cef_focus_handler_t* self)
  56. {
  57. if (Interlocked.Increment(ref _refct) == 1)
  58. {
  59. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  60. }
  61. }
  62. private int release(cef_focus_handler_t* self)
  63. {
  64. if (Interlocked.Decrement(ref _refct) == 0)
  65. {
  66. lock (_roots) { _roots.Remove((IntPtr)_self); }
  67. return 1;
  68. }
  69. return 0;
  70. }
  71. private int has_one_ref(cef_focus_handler_t* self)
  72. {
  73. return _refct == 1 ? 1 : 0;
  74. }
  75. private int has_at_least_one_ref(cef_focus_handler_t* self)
  76. {
  77. return _refct != 0 ? 1 : 0;
  78. }
  79. internal cef_focus_handler_t* ToNative()
  80. {
  81. add_ref(_self);
  82. return _self;
  83. }
  84. [Conditional("DEBUG")]
  85. private void CheckSelf(cef_focus_handler_t* self)
  86. {
  87. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  88. }
  89. }
  90. }