Method: CGenerator::Library#initialize

Defined in:
lib/cgen/cgen.rb

#initialize(name) ⇒ Library

Returns a new instance of Library.



605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/cgen/cgen.rb', line 605

def initialize name
  super name
  
  @show_times_flag = @purge_source_dir = false
  @committed = false
  @source_file = nil
  @include_dirs = []
  
  @rtime = Time.now.to_f
  @ptime = process_times

  unless name =~ /\A[A-Za-z_]\w*\z/
    raise NameError,
      "\n  Not a valid library name: '#{name}'." +
      "\n  Name must be a C identifier."
  end
  
  @include_file, @source_file = add_file "libmain"
  @include_file.include '<ruby.h>'
  
  @init_library_function = define_c_function "Init_" + name
  @init_library_function.scope :extern
  
  @init_library_function.body     \
      rb_define_method!,
      rb_define_module_function!,
      rb_define_global_function!,
      rb_define_singleton_method!,
      rb_define_alloc_func!
    ## odd, putting an accum inside
    ## a template which is not the parent
end