Module: Carbon::Core::Pointer::Access Private
- Included in:
- Carbon::Core::Pointer
- Defined in:
- lib/carbon/core/pointer/access.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Methods that perform accesses on pointers. This is essentially dereferencing and indexing. This defines the following functions:
Carbon::Pointer<T>.value(self): T
Carbon::Pointer<T>.value=(self, value: T): T
Carbon::Pointer<T>.[]<I: Carbon::Numeric>(self, index: I): T
Carbon::Pointer<T>.[]=<I: Carbon::Numeric>(self, index: I, value: T): T
Instance Method Summary collapse
-
#define_access_functions ⇒ void
private
Define all of the access functions.
-
#define_array_get_function(int) ⇒ void
private
Defines the array get function.
-
#define_array_set_function(int) ⇒ void
private
Defines the array set function.
-
#define_value_get_function ⇒ void
private
Defines the value get function.
-
#define_value_set_function ⇒ void
private
Defines the value set function.
Instance Method Details
#define_access_functions ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Define all of the access functions. This iterates over all of the integers, defining the array get/set functions in terms of each integer type. It then defines the value get/set functions.
23 24 25 26 27 28 29 30 31 |
# File 'lib/carbon/core/pointer/access.rb', line 23 def define_access_functions Ints.each do |int| next if int.size == 1 define_array_get_function(int) define_array_set_function(int) end define_value_get_function define_value_set_function end |
#define_array_get_function(int) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Defines the array get function. This function (named []
) gets the
value at a given distance away from the pointer.
77 78 79 80 81 82 83 |
# File 'lib/carbon/core/pointer/access.rb', line 77 def define_array_get_function(int) function_name = PTYPE.call(:[], [PTYPE, int.name]) Core.define(function: function_name) do |function| function[:return] = PTYPEGEN define_array_get_definition(int, function[:definition]) end end |
#define_array_set_function(int) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Defines the array set function. This function (named []=
) sets
the value a given distance away from the pointer.
64 65 66 67 68 69 70 |
# File 'lib/carbon/core/pointer/access.rb', line 64 def define_array_set_function(int) function_name = PTYPE.call(:[]=, [PTYPE, int.name, PTYPEGEN]) Core.define(function: function_name) do |function| function[:return] = PTYPEGEN define_array_set_definition(int, function[:definition]) end end |
#define_value_get_function ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Defines the value get function. This function (named value
) gets
the value at the pointer. This is the same as calling the array
get function with an index of zero (0).
51 52 53 54 55 56 57 |
# File 'lib/carbon/core/pointer/access.rb', line 51 def define_value_get_function function_name = PTYPE.call(:value, [PTYPE]) Core.define(function: function_name) do |function| function[:return] = PTYPEGEN define_value_get_definition(function[:definition]) end end |
#define_value_set_function ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Defines the value set function. This function (named value=
) sets
the value at the pointer. This is the same as calling the array
set function with an index of zero (0).
38 39 40 41 42 43 44 |
# File 'lib/carbon/core/pointer/access.rb', line 38 def define_value_set_function function_name = PTYPE.call(:value=, [PTYPE, PTYPEGEN]) Core.define(function: function_name) do |function| function[:return] = PTYPEGEN define_value_set_definition(function[:definition]) end end |