Sha256: 8c7d6997047a3acaedb8589bc68b6e91eca5c6531d67727b0d070a977644442d

Contents?: true

Size: 591 Bytes

Versions: 1

Compression:

Stored size: 591 Bytes

Contents

#include "attribute.h"

ID fcall;

VALUE attribute_default(VALUE self) {
  VALUE value = rb_iv_get(self, "@default");

  if (NIL_P(value) || rb_special_const_p(value))
    return value;
  else if (rb_respond_to(value, fcall))
    return rb_funcall(value, fcall, 0);
  else
    return rb_obj_dup(value);
}

void init_swift_attribute() {
  VALUE mSwift          = rb_define_module("Swift");
  VALUE cSwiftAttribute = rb_define_class_under(mSwift, "Attribute", rb_cObject);

  fcall = rb_intern("call");
  rb_define_method(cSwiftAttribute, "default", RUBY_METHOD_FUNC(attribute_default), 0);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swift-0.7.0 ext/attribute.cc