CefWebPluginInfoVisitor.g.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 CefWebPluginInfoVisitor
  14. {
  15. private static Dictionary<IntPtr, CefWebPluginInfoVisitor> _roots = new Dictionary<IntPtr, CefWebPluginInfoVisitor>();
  16. private int _refct;
  17. private cef_web_plugin_info_visitor_t* _self;
  18. private cef_web_plugin_info_visitor_t.add_ref_delegate _ds0;
  19. private cef_web_plugin_info_visitor_t.release_delegate _ds1;
  20. private cef_web_plugin_info_visitor_t.has_one_ref_delegate _ds2;
  21. private cef_web_plugin_info_visitor_t.has_at_least_one_ref_delegate _ds3;
  22. private cef_web_plugin_info_visitor_t.visit_delegate _ds4;
  23. protected CefWebPluginInfoVisitor()
  24. {
  25. _self = cef_web_plugin_info_visitor_t.Alloc();
  26. _ds0 = new cef_web_plugin_info_visitor_t.add_ref_delegate(add_ref);
  27. _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
  28. _ds1 = new cef_web_plugin_info_visitor_t.release_delegate(release);
  29. _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
  30. _ds2 = new cef_web_plugin_info_visitor_t.has_one_ref_delegate(has_one_ref);
  31. _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
  32. _ds3 = new cef_web_plugin_info_visitor_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
  33. _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
  34. _ds4 = new cef_web_plugin_info_visitor_t.visit_delegate(visit);
  35. _self->_visit = Marshal.GetFunctionPointerForDelegate(_ds4);
  36. }
  37. ~CefWebPluginInfoVisitor()
  38. {
  39. Dispose(false);
  40. }
  41. private void Dispose()
  42. {
  43. Dispose(true);
  44. GC.SuppressFinalize(this);
  45. }
  46. protected virtual void Dispose(bool disposing)
  47. {
  48. if (_self != null)
  49. {
  50. cef_web_plugin_info_visitor_t.Free(_self);
  51. _self = null;
  52. }
  53. }
  54. private void add_ref(cef_web_plugin_info_visitor_t* self)
  55. {
  56. if (Interlocked.Increment(ref _refct) == 1)
  57. {
  58. lock (_roots) { _roots.Add((IntPtr)_self, this); }
  59. }
  60. }
  61. private int release(cef_web_plugin_info_visitor_t* self)
  62. {
  63. if (Interlocked.Decrement(ref _refct) == 0)
  64. {
  65. lock (_roots) { _roots.Remove((IntPtr)_self); }
  66. Dispose();
  67. return 1;
  68. }
  69. return 0;
  70. }
  71. private int has_one_ref(cef_web_plugin_info_visitor_t* self)
  72. {
  73. return _refct == 1 ? 1 : 0;
  74. }
  75. private int has_at_least_one_ref(cef_web_plugin_info_visitor_t* self)
  76. {
  77. return _refct != 0 ? 1 : 0;
  78. }
  79. internal cef_web_plugin_info_visitor_t* ToNative()
  80. {
  81. add_ref(_self);
  82. return _self;
  83. }
  84. [Conditional("DEBUG")]
  85. private void CheckSelf(cef_web_plugin_info_visitor_t* self)
  86. {
  87. if (_self != self) throw ExceptionBuilder.InvalidSelfReference();
  88. }
  89. }
  90. }