nanomsg.nut 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. class NanoMsg {
  2. /* Constants that are returned in `ns` member of nn_symbol_properties */
  3. const_NN_NS_NAMESPACE = 0;
  4. const_NN_NS_VERSION = 1;
  5. const_NN_NS_DOMAIN = 2;
  6. const_NN_NS_TRANSPORT = 3;
  7. const_NN_NS_PROTOCOL = 4;
  8. const_NN_NS_OPTION_LEVEL = 5;
  9. const_NN_NS_SOCKET_OPTION = 6;
  10. const_NN_NS_TRANSPORT_OPTION = 7;
  11. const_NN_NS_OPTION_TYPE = 8;
  12. const_NN_NS_OPTION_UNIT = 9;
  13. const_NN_NS_FLAG = 10;
  14. const_NN_NS_ERROR = 11;
  15. const_NN_NS_LIMIT = 12;
  16. const_NN_NS_EVENT = 13;
  17. /* Constants that are returned in `type` member of nn_symbol_properties */
  18. const_NN_TYPE_NONE = 0;
  19. const_NN_TYPE_INT = 1;
  20. const_NN_TYPE_STR = 2;
  21. /* Constants that are returned in the `unit` member of nn_symbol_properties */
  22. const_NN_UNIT_NONE = 0;
  23. const_NN_UNIT_BYTES = 1;
  24. const_NN_UNIT_MILLISECONDS = 2;
  25. const_NN_UNIT_PRIORITY = 3;
  26. const_NN_UNIT_BOOLEAN = 4;
  27. const_NN_MSG = -1;
  28. /* SP address families. */
  29. const_AF_SP = 1;
  30. const_AF_SP_RAW = 2;
  31. /* Max size of an SP address. */
  32. const_NN_SOCKADDR_MAX = 128;
  33. /* Socket option levels: Negative numbers are reserved for transports,
  34. positive for socket types. */
  35. const_NN_SOL_SOCKET = 0;
  36. /* Generic socket options (NN_SOL_SOCKET level). */
  37. const_NN_LINGER = 1;
  38. const_NN_SNDBUF = 2;
  39. const_NN_RCVBUF = 3;
  40. const_NN_SNDTIMEO = 4;
  41. const_NN_RCVTIMEO = 5;
  42. const_NN_RECONNECT_IVL = 6;
  43. const_NN_RECONNECT_IVL_MAX = 7;
  44. const_NN_SNDPRIO = 8;
  45. const_NN_RCVPRIO = 9;
  46. const_NN_SNDFD = 10;
  47. const_NN_RCVFD = 11;
  48. const_NN_DOMAIN = 12;
  49. const_NN_PROTOCOL = 13;
  50. const_NN_IPV4ONLY = 14;
  51. const_NN_SOCKET_NAME = 15;
  52. /* Send/recv options. */
  53. const_NN_DONTWAIT = 1;
  54. /* Ancillary data. */
  55. const_PROTO_SP = 1;
  56. const_SP_HDR = 1;
  57. /* Socket mutliplexing support. */
  58. const_NN_POLLIN = 1;
  59. const_NN_POLLOUT = 2;
  60. </ cfunc = "int nn_socket (int domain, int protocol)" />
  61. constructor(int_domain, int_protocol)
  62. {
  63. }
  64. </ cfunc = "int nn_close (int s)" />
  65. destructor()
  66. {
  67. }
  68. </ cfunc = "int nn_errno (void)" />
  69. function errno() {}
  70. </ cfunc = "const char *nn_strerror (int errnum)" />
  71. function strerror(int_errnum) {}
  72. </ cfunc = "const char *nn_symbol (int i, int *value)" />
  73. function symbol (int_i, value : intPtr) : string {}
  74. </ cfunc = "int nn_symbol_info (int i, struct nn_symbol_properties *buf, int buflen)" />
  75. function symbol_info (int_i) : nn_symbol_properties {}
  76. </ cfunc = "void nn_term (void)" />
  77. function term () {}
  78. </ cfunc = "void *nn_allocmsg (size_t size, int type)" />
  79. function allocmsg (int_size, int_the_type) : msg {}
  80. </ cfunc = "void *nn_reallocmsg (void *msg, size_t size)" />
  81. function reallocmsg (msg : msg, size : size_t) : msg {}
  82. </ cfunc = "int nn_freemsg (void *msg)" />
  83. function freemsg (msg) {}
  84. </ cfunc = "int nn_socket (int domain, int protocol)" />
  85. function socket (int_domain, int_protocol) : int {}
  86. </ cfunc = "int nn_close (int s)" />
  87. function close () : int {}
  88. </ cfunc = "int nn_setsockopt (int s, int level, int option, const void *optval, size_t optvallen)" />
  89. function setsockopt (int_level, int_option, optval : voidPtr, optvallen : size_t) : int {}
  90. </ cfunc = "int nn_getsockopt (int s, int level, int option, void *optval, size_t *optvallen)" />
  91. function getsockopt (int_level, int_option, optval : voidPtr, optvallen: size_tPtr) : int {}
  92. </ cfunc = "int nn_bind (int s, const char *addr)"/>
  93. function bind (str_addr) : int {}
  94. </ cfunc = "int nn_connect (int s, const char *addr)" />
  95. function connect (str_addr) : int {}
  96. </ cfunc = "int nn_shutdown (int s, int how)" />
  97. function shutdown (int_how) : int {}
  98. </ cfunc = "int nn_send (int s, const void *buf, size_t len, int flags)" />
  99. function send (str_buf, int_flags) : int {}
  100. </ cfunc = "int nn_recv (int s, void *buf, size_t len, int flags)" />
  101. function recv (int_flags) : string {}
  102. </ cfunc = "int nn_sendmsg (int s, const struct nn_msghdr *msghdr, int flags)" />
  103. function sendmsg (msghdr : nn_msghdr, flags : int) : int {}
  104. </ cfunc = "int nn_recvmsg (int s, struct nn_msghdr *msghdr, int flags)" />
  105. function recvmsg (int_flags) : nn_msghdr {}
  106. </ cfunc = "int nn_poll (struct nn_pollfd *fds, int nfds, int timeout)" />
  107. function pollfd(fds, int_timeout) {}
  108. </ cfunc = "int nn_device (int s1, int s2)" />
  109. function device(int_s1, int_s2) {}
  110. </ cfunc = "int nn_tcpmuxd (int port)" />
  111. function tcpmuxd(int_port) {}
  112. }
  113. dofile("generate-cpp-class-wrapper.nut");
  114. generateCppClassWrapper(NanoMsg, "NanoMsg");