Method: Inline::C#reader
- Defined in:
- lib/inline.rb
#reader(method, type, member = method) ⇒ Object
Adds a reader for a C struct member wrapped via Data_Wrap_Struct. method is the ruby name to give the reader, type is the C type. Unless the C member name is overridden with member, the method name is used as the struct member. See #accessor for an example.
456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/inline.rb', line 456 def reader(method, type, member = method) raise "struct name not set for reader #{method} #{type}" unless @struct_name c "VALUE \#{method}(void) {\n \#{@struct_name} *pointer;\n\n Data_Get_Struct(self, \#{@struct_name}, pointer);\n\n return \#{c2ruby type}(pointer->\#{member});\n}\n C\nend\n" |