Class: OSX::Boxed

Inherits:
Object show all
Defined in:
src/objc/BridgeSupport.m,
src/objc/BridgeSupport.m

Overview

Representaion of C-types and C-structures in Ruby world.

Information of types are described in bridgesupport files located under frameworks.

Examples:

range = OSX.NSMakeRange(1, 3)
=> #<OSX::NSRange location=1, length=3>
OSX::NSRange.superclass
=> OSX::Boxed

Class Method Summary (collapse)

Class Method Details

+ (String) encoding

Returns type encoding.

Examples:

OSX::NSRange.encoding
=> "{_NSRange=QQ}"

Returns:



398
399
400
401
402
# File 'src/objc/BridgeSupport.m', line 398

static VALUE
rb_bs_boxed_get_encoding (VALUE rcv)
{
  return rb_ivar_get(rcv, ivarEncodingID);
}

+ (Array) fields

Returns field names.

Examples:

OSX::NSRect.fields
=> [:origin, :size]
OSX::NSSize.fields
=> [:width, :height]

Returns:



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'src/objc/BridgeSupport.m', line 432

static VALUE
rb_bs_boxed_get_fields (VALUE rcv)
{
  struct bsBoxed *boxed;
  VALUE ary;
  unsigned i;

  boxed = find_bs_boxed_for_klass(rcv);
  ary = rb_ary_new();

  if (boxed->type != bsBoxedStructType)
    return ary;

  for (i = 0; i < boxed->opt.s.field_count; i++) {
    struct bsStructField *  field;

    field = &boxed->opt.s.fields[i];
    rb_ary_push(ary, ID2SYM(rb_intern(field->name))); 
  }

  return ary;
}

+ (Boolean) opaque?

Returns opaque or not.

Examples:

OSX::NSDecimal.opaque?
=> true
OSX::NSRect.opaque?
=> false

Returns:

  • (Boolean)


463
464
465
466
467
468
469
470
471
472
473
# File 'src/objc/BridgeSupport.m', line 463

static VALUE
rb_bs_boxed_is_opaque (VALUE rcv)
{
  struct bsBoxed *boxed;
  BOOL opaque;

  boxed = find_bs_boxed_for_klass(rcv);
  opaque = boxed->type == bsBoxedStructType ? boxed->opt.s.opaque : YES;

  return opaque ? Qtrue : Qfalse;
}

+ (Number) size

Returns allocation size.

Examples:

OSX::NSRect.size
=> 32
OSX::NSSize.size
=> 16

Returns:

  • (Number)


413
414
415
416
417
418
419
420
421
# File 'src/objc/BridgeSupport.m', line 413

static VALUE
rb_bs_boxed_get_size (VALUE rcv)
{
  struct bsBoxed *boxed;

  boxed = find_bs_boxed_for_klass(rcv);

  return LONG2NUM(bs_boxed_size(boxed));
}