$search
00001 #ifdef HAS_RUBY_SOURCE 00002 extern "C" { 00003 #include "/usr/include/ruby-1.9.1/ruby-1.9.3-p0/vm_core.h" 00004 } 00005 00006 static VALUE env_references(VALUE rbenv) 00007 { 00008 rb_env_t* env; 00009 00010 VALUE result = rb_ary_new(); 00011 GetEnvPtr(rbenv, env); 00012 if (env->env) 00013 { 00014 for (int i = 0; i < env->env_size; ++i) 00015 rb_ary_push(result, rb_obj_id(env->env[i])); 00016 } 00017 return result; 00018 } 00019 00020 static VALUE proc_references(VALUE rbproc) 00021 { 00022 rb_proc_t* proc; 00023 GetProcPtr(rbproc, proc); 00024 00025 if (!NIL_P(proc->envval)) 00026 return env_references(proc->envval); 00027 return rb_ary_new(); 00028 } 00029 #else 00030 #warning "RUBY_SOURCE_DIR is not set, Proc#references will not be available" 00031 #endif 00032 00033 extern "C" void Init_proc() 00034 { 00035 #ifdef HAS_RUBY_SOURCE 00036 rb_define_method(rb_cProc, "references", RUBY_METHOD_FUNC(proc_references), 0); 00037 #endif 00038 }