RPMessage.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* ----------------------------------------------------------------------------
  2. * This file was automatically generated by SWIG (http://www.swig.org).
  3. * Version 2.0.9
  4. *
  5. * Do not make changes to this file unless you know what you are doing--modify
  6. * the SWIG interface file instead.
  7. * ----------------------------------------------------------------------------- */
  8. namespace org.doubango.tinyWRAP {
  9. using System;
  10. using System.Runtime.InteropServices;
  11. public class RPMessage : IDisposable {
  12. private HandleRef swigCPtr;
  13. protected bool swigCMemOwn;
  14. internal RPMessage(IntPtr cPtr, bool cMemoryOwn) {
  15. swigCMemOwn = cMemoryOwn;
  16. swigCPtr = new HandleRef(this, cPtr);
  17. }
  18. internal static HandleRef getCPtr(RPMessage obj) {
  19. return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  20. }
  21. ~RPMessage() {
  22. Dispose();
  23. }
  24. public virtual void Dispose() {
  25. lock(this) {
  26. if (swigCPtr.Handle != IntPtr.Zero) {
  27. if (swigCMemOwn) {
  28. swigCMemOwn = false;
  29. tinyWRAPPINVOKE.delete_RPMessage(swigCPtr);
  30. }
  31. swigCPtr = new HandleRef(null, IntPtr.Zero);
  32. }
  33. GC.SuppressFinalize(this);
  34. }
  35. }
  36. public byte[] getPayload() {
  37. uint clen = this.getPayloadLength();
  38. if(clen>0){
  39. IntPtr ptr = Marshal.AllocHGlobal((int)clen);
  40. this.getPayload(ptr, clen);
  41. byte[] bytes = new byte[clen];
  42. Marshal.Copy(ptr, bytes, 0, bytes.Length);
  43. Marshal.FreeHGlobal(ptr);
  44. return bytes;
  45. }
  46. return null;
  47. }
  48. public RPMessage() : this(tinyWRAPPINVOKE.new_RPMessage(), true) {
  49. }
  50. public twrap_rpmessage_type_t getType() {
  51. twrap_rpmessage_type_t ret = (twrap_rpmessage_type_t)tinyWRAPPINVOKE.RPMessage_getType(swigCPtr);
  52. return ret;
  53. }
  54. public uint getPayloadLength() {
  55. uint ret = tinyWRAPPINVOKE.RPMessage_getPayloadLength(swigCPtr);
  56. return ret;
  57. }
  58. public uint getPayload(IntPtr output, uint maxsize) {
  59. uint ret = tinyWRAPPINVOKE.RPMessage_getPayload(swigCPtr, output, maxsize);
  60. return ret;
  61. }
  62. }
  63. }