예제 #1
0
static VALUE
WebKit_CLASS_set_default_web_database_quota(VALUE self, VALUE __v_quota)
{
  guint64 quota; guint64 __orig_quota;
  __orig_quota = quota = rb_num2ull(__v_quota);

#line 51 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"
  webkit_set_default_web_database_quota(quota);
 
  return self;
}
예제 #2
0
static VALUE
pack_tunnel_id( VALUE self, VALUE actions, VALUE options ) {
  VALUE r_tunnel_id = HASH_REF( options, tunnel_id );
  if ( rb_obj_is_kind_of( actions, basic_action_eval ) ) {
    append_action_set_field_tunnel_id( openflow_actions_ptr( actions ), ( const uint64_t ) rb_num2ull( r_tunnel_id ) );
  }
  else if ( rb_obj_is_kind_of( actions, flexible_action_eval ) ) {
    append_oxm_match_tunnel_id( oxm_match_ptr( actions ), ( uint64_t ) rb_num2ull( r_tunnel_id ), 0 );
  }

  return self;
}
예제 #3
0
파일: fwext.c 프로젝트: iZsh/rubyfw
// Read a 32bit value
static VALUE FWDevice_readQuadlet(VALUE Self, VALUE StartAddr)
{
  FWDevice *device;
  Data_Get_Struct(Self, FWDevice, device);
  
  IOCFPlugInInterface **cfPlugInInterface = NULL;
  SInt32 theScore;
  IOFireWireLibDeviceRef fwIntf;  

  IOReturn result = IOCreatePlugInInterfaceForService(device->Device, 
                      kIOFireWireLibTypeID, kIOCFPlugInInterfaceID, 
                      &cfPlugInInterface, &theScore);
  (*cfPlugInInterface)->QueryInterface(cfPlugInInterface,
                          CFUUIDGetUUIDBytes(kIOFireWireDeviceInterfaceID), 
                          (void **) &fwIntf);
  assert((*fwIntf)->InterfaceIsInited(fwIntf));

  VALUE ret;

  if((*fwIntf)->Open(fwIntf) == 0)
  {
    // Set destination adress. Note that the upper 48 bits identify 
    // the device on the bus and the address set by the operating system.
    uint64_t startaddr = rb_num2ull(StartAddr);
    FWAddress fwaddr;

    fwaddr.nodeID = 0;
    fwaddr.addressHi =  startaddr >> 32;
    fwaddr.addressLo = startaddr & 0xffffffffL;

    // do the actual read
    UInt32 val = 0;
    result = (*fwIntf)->ReadQuadlet(fwIntf, device->Device, &fwaddr, &val, false, 0);
    ret = rb_hash_new();
    rb_hash_aset(ret, ID2SYM(rb_intern("value")), INT2FIX(val));
    rb_hash_aset(ret, ID2SYM(rb_intern("resultcode")), INT2FIX(result));
  }
예제 #4
0
bp::Object *
rubyToBPObject(VALUE v)
{
    bp::Object * obj = NULL;
    
    switch (TYPE(v)) {
        case T_FLOAT:
            obj = new bp::Double(rb_num2dbl(v));
            break;
        case T_STRING:
            obj = new bp::String(RSTRING_PTR(v));
            break;
        case T_FIXNUM:
            obj = new bp::Integer(rb_num2ull(v));
            break;
        case T_TRUE:
            obj = new bp::Bool(true);
            break;
        case T_FALSE:
            obj = new bp::Bool(false);
            break;
        case T_HASH:
            obj = new bp::Map;
            rb_hash_foreach(v,
                            (int (*)(ANYARGS)) hashPopulator,
                            (VALUE) obj);
            break;
        case T_ARRAY:
        {
            long i;
            bp::List * l = new bp::List;
            for (i=0; i < RARRAY_LEN(v); i++) {
                l->append(rubyToBPObject(rb_ary_entry(v, i)));
            }
            obj = l;
        }
        break;
        case T_OBJECT: {
            // map Pathname objects into BPTPath types
            VALUE id = rb_intern("Pathname");
            VALUE klass = 0;
            if (rb_const_defined(rb_cObject, id) &&
                (klass = rb_const_get(rb_cObject, id)) &&
                TYPE(klass) == T_CLASS)
            {
                VALUE r = rb_obj_is_kind_of(v, klass);
                if (RTEST(r)) {
                    // convert to abs path
                    int error = 0;
                    VALUE absPath =
                        ruby::invokeFunction(v, "realpath", &error, 0);
                    VALUE pathString =
                        ruby::invokeFunction(absPath, "to_s", &error, 0);
                    if (!error && TYPE(pathString) == T_STRING) {
						obj = new bp::Path((const BPPath) convert::fromUTF8(RSTRING_PTR(pathString)).c_str());
                    }
                    break;
                }
            }
        }
        case T_NIL:
        default:
            obj = new bp::Null();
            break;
    }
    
    return obj;
}