Sha256: 5e1deb9f4996c4d2364831faef9e7e4cde6f80df1dc6e2a17c8d8698d4247047

Contents?: true

Size: 1.02 KB

Versions: 18

Compression:

Stored size: 1.02 KB

Contents

#include "polyphony.h"

VALUE Socket_send(VALUE self, VALUE msg, VALUE flags) {
  return Backend_send(BACKEND(), self, msg, flags);
}

VALUE Socket_write(int argc, VALUE *argv, VALUE self) {
  VALUE ary = rb_ary_new_from_values(argc, argv);
  VALUE result = Backend_sendv(BACKEND(), self, ary, INT2NUM(0));
  RB_GC_GUARD(ary);
  return result;
}

VALUE Socket_double_chevron(VALUE self, VALUE msg) {
  Backend_send(BACKEND(), self, msg, INT2NUM(0));
  return self;
}

void Init_SocketExtensions() {
  VALUE cSocket;
  VALUE cTCPSocket;

  rb_require("socket");

  cSocket = rb_const_get(rb_cObject, rb_intern("Socket"));
  cTCPSocket = rb_const_get(rb_cObject, rb_intern("TCPSocket"));

  rb_define_method(cSocket, "send", Socket_send, 2);
  rb_define_method(cTCPSocket, "send", Socket_send, 2);

  rb_define_method(cSocket, "write", Socket_write, -1);
  rb_define_method(cTCPSocket, "write", Socket_write, -1);

  rb_define_method(cSocket, "<<", Socket_double_chevron, 1);
  rb_define_method(cTCPSocket, "<<", Socket_double_chevron, 1);
}

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
polyphony-0.90 ext/polyphony/socket_extensions.c
polyphony-0.89 ext/polyphony/socket_extensions.c
polyphony-0.87 ext/polyphony/socket_extensions.c
polyphony-0.86 ext/polyphony/socket_extensions.c
polyphony-0.85 ext/polyphony/socket_extensions.c
polyphony-0.84.1 ext/polyphony/socket_extensions.c
polyphony-0.84 ext/polyphony/socket_extensions.c
polyphony-0.83 ext/polyphony/socket_extensions.c
polyphony-0.82 ext/polyphony/socket_extensions.c
polyphony-0.81.1 ext/polyphony/socket_extensions.c
polyphony-0.81 ext/polyphony/socket_extensions.c
polyphony-0.80 ext/polyphony/socket_extensions.c
polyphony-0.79 ext/polyphony/socket_extensions.c
polyphony-0.78 ext/polyphony/socket_extensions.c
polyphony-0.77 ext/polyphony/socket_extensions.c
polyphony-0.76 ext/polyphony/socket_extensions.c
polyphony-0.75 ext/polyphony/socket_extensions.c
polyphony-0.74 ext/polyphony/socket_extensions.c