CefDisplayHandler.g.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 CefDisplayHandler
  14. {
  15. private static Dictionary<IntPtr, CefDisplayHandler> _roots = new Dictionary<IntPtr, CefDisplayHandler>();
  16. private int _refct;
  17. private cef_display_handler_t* _self;
  18. private cef_display_handler_t.add_ref_delegate _ds0;
  19. private cef_display_handler_t.release_delegate _ds1;
  20. private cef_display_handler_t.has_one_ref_delegate _ds2;
  21. private cef_display_handler_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_display_handler_t.on_address_change_delegate _ds4;
  23. private cef_display_handler_t.on_title_change_delegate _ds5;
  24. private cef_display_handler_t.on_favicon_urlchange_delegate _ds6;
  25. private cef_display_handler_t.on_fullscreen_mode_change_delegate _ds7;
  26. private cef_display_handler_t.on_tooltip_delegate _ds8;
  27. private cef_display_handler_t.on_status_message_delegate _ds9;
  28. private cef_display_handler_t.on_console_message_delegate _dsa;
  29. private cef_display_handler_t.on_auto_resize_delegate _dsb;
  30. private cef_display_handler_t.on_loading_progress_change_delegate _dsc;
  31. private cef_display_handler_t.on_cursor_change_delegate _dsd;
  32. protected CefDisplayHandler()
  33. {
  34. _self = cef_display_handler_t.Alloc();
  35. _ds0 = new cef_display_handler_t.add_ref_delegate(add_ref);
  36. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  37. _ds1 = new cef_display_handler_t.release_delegate(release);
  38. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  39. _ds2 = new cef_display_handler_t.has_one_ref_delegate(has_one_ref);
  40. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  41. _ds3 = new cef_display_handler_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  42. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  43. _ds4 = new cef_display_handler_t.on_address_change_delegate(on_address_change);
  44. _self->_on_address_change = Marshal.GetFunctionPointerForDelegate(_ds4);
  45. _ds5 = new cef_display_handler_t.on_title_change_delegate(on_title_change);
  46. _self->_on_title_change = Marshal.GetFunctionPointerForDelegate(_ds5);
  47. _ds6 = new cef_display_handler_t.on_favicon_urlchange_delegate(on_favicon_urlchange);
  48. _self->_on_favicon_urlchange = Marshal.GetFunctionPointerForDelegate(_ds6);
  49. _ds7 = new cef_display_handler_t.on_fullscreen_mode_change_delegate(on_fullscreen_mode_change);
  50. _self->_on_fullscreen_mode_change = Marshal.GetFunctionPointerForDelegate(_ds7);
  51. _ds8 = new cef_display_handler_t.on_tooltip_delegate(on_tooltip);
  52. _self->_on_tooltip = Marshal.GetFunctionPointerForDelegate(_ds8);
  53. _ds9 = new cef_display_handler_t.on_status_message_delegate(on_status_message);
  54. _self->_on_status_message = Marshal.GetFunctionPointerForDelegate(_ds9);
  55. _dsa = new cef_display_handler_t.on_console_message_delegate(on_console_message);
  56. _self->_on_console_message = Marshal.GetFunctionPointerForDelegate(_dsa);
  57. _dsb = new cef_display_handler_t.on_auto_resize_delegate(on_auto_resize);
  58. _self->_on_auto_resize = Marshal.GetFunctionPointerForDelegate(_dsb);
  59. _dsc = new cef_display_handler_t.on_loading_progress_change_delegate(on_loading_progress_change);
  60. _self->_on_loading_progress_change = Marshal.GetFunctionPointerForDelegate(_dsc);
  61. _dsd = new cef_display_handler_t.on_cursor_change_delegate(on_cursor_change);
  62. _self->_on_cursor_change = Marshal.GetFunctionPointerForDelegate(_dsd);
  63. }
  64. ~CefDisplayHandler()
  65. {
  66. Dispose(false);
  67. }
  68. protected virtual void Dispose(bool disposing)
  69. {
  70. if (_self != null)
  71. {
  72. cef_display_handler_t.Free(_self);
  73. _self = null;
  74. }
  75. }
  76. private void add_ref(cef_display_handler_t* self)
  77. {
  78. if (Interlocked.Increment(ref _refct) == 1)
  79. {
  80. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  81. }
  82. }
  83. private int release(cef_display_handler_t* self)
  84. {
  85. if (Interlocked.Decrement(ref _refct) == 0)
  86. {
  87. lock (_roots) { _roots.Remove((IntPtr)_self); }
  88. return 1;
  89. }
  90. return 0;
  91. }
  92. private int has_one_ref(cef_display_handler_t* self)
  93. {
  94. return _refct == 1 ? 1 : 0;
  95. }
  96. private int has_at_least_one_ref(cef_display_handler_t* self)
  97. {
  98. return _refct != 0 ? 1 : 0;
  99. }
  100. internal cef_display_handler_t* ToNative()
  101. {
  102. add_ref(_self);
  103. return _self;
  104. }
  105. [Conditional("DEBUG")]
  106. private void CheckSelf(cef_display_handler_t* self)
  107. {
  108. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  109. }
  110. }
  111. }