Method: CGenerator::Library#literal_symbol
- Defined in:
- lib/cgen/cgen.rb
#literal_symbol(sym, cfile = nil) ⇒ Object
Like Library#declare_symbol, but converts the ID to a VALUE at library initialization time. Useful for looking up hash values keyed by symbol objects, for example. sym
is a string or symbol.
1280 1281 1282 1283 1284 1285 1286 |
# File 'lib/cgen/cgen.rb', line 1280 def literal_symbol sym, cfile = nil c_name = "SYM_#{CGenerator::make_c_name sym}" declare sym => "VALUE #{c_name}" (cfile || self).declare_extern sym => "extern VALUE #{c_name}" setup sym => "#{c_name} = ID2SYM(rb_intern(\"#{sym}\"))" c_name.intern end |