CefReadHandler.g.cs 3.9 KB

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