Class: GL::Registry::NativeType

Inherits:
Object
  • Object
show all
Defined in:
lib/opengl/registry/native_type.rb

Overview

Describes the native type for a return or parameter value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, base, group) ⇒ NativeType

Creates a new instance fo the GL::Registry::NativeType class.

Parameters:

  • type (String)

    The full native type, including constant constraints, pointer symbols, etc.

  • base (String?)

    The basic type, excluding any constant constraints, pointer symbols, etc.

  • group (String?)

    A group that is associated with this type.



28
29
30
31
32
# File 'lib/opengl/registry/native_type.rb', line 28

def initialize(type, base, group)
  @type = type.strip
  @base = base ? base.to_sym : :GLvoid
  @group = group
end

Instance Attribute Details

#baseSymbol (readonly)

Returns the basic type, excluding any constant constraints, pointer symbols, etc. as a Symbol.

Returns:

  • (Symbol)

    the basic type, excluding any constant constraints, pointer symbols, etc. as a Symbol.



16
17
18
# File 'lib/opengl/registry/native_type.rb', line 16

def base
  @base
end

#groupString? (readonly)

Returns a group that is associated with this type.

Returns:

  • (String?)

    a group that is associated with this type.



20
21
22
# File 'lib/opengl/registry/native_type.rb', line 20

def group
  @group
end

#typeString (readonly)

Note:

This is essentially the "raw" and fully-qualified type as it would appear in the C language.

Returns the full native type, including constant constraints, pointer symbols, etc.

Returns:

  • (String)

    the full native type, including constant constraints, pointer symbols, etc.



12
13
14
# File 'lib/opengl/registry/native_type.rb', line 12

def type
  @type
end

Instance Method Details

#const?Boolean

Returns true if value is a C-style pointer that can not be modified, otherwise false.

Returns:

  • (Boolean)

    true if value is a C-style pointer that can not be modified, otherwise false.



42
43
44
# File 'lib/opengl/registry/native_type.rb', line 42

def const?
  /^const /.match?(@type)
end

#out?Boolean

Returns true if value is a C-style pointer that may be modified, otherwise false.

Returns:

  • (Boolean)

    true if value is a C-style pointer that may be modified, otherwise false.



48
49
50
# File 'lib/opengl/registry/native_type.rb', line 48

def out?
  @type.include?('*') && !/\bconst\b/.match?(@type)
end

#pointer?Boolean

Returns true if this a C-style pointer type, otherwise false.

Returns:

  • (Boolean)

    true if this a C-style pointer type, otherwise false.



36
37
38
# File 'lib/opengl/registry/native_type.rb', line 36

def pointer?
  @type.include?('*')
end

#to_sString

Returns the string representation of this object.

Returns:

  • (String)

    the string representation of this object.



54
55
56
# File 'lib/opengl/registry/native_type.rb', line 54

def to_s
  @type
end