void MethodVisibility::Info::show(STATE, Object* self, int level) { MethodVisibility* mv = as<MethodVisibility>(self); class_header(state, self); indent_attribute(++level, "visibility"); mv->visibility()->show(state, level); indent_attribute(level, "method"); mv->method()->show(state, level); close_body(level); }
void capi_define_method(const char* file, VALUE target, const char* name, CApiGenericFunction fptr, int arity, CApiMethodKind kind) { NativeMethodEnvironment* env = NativeMethodEnvironment::get(); VM* state = env->state(); Symbol* method_name = state->symbol(name); Module* module = NULL; if (kind == cCApiSingletonMethod) { module = c_as<Module>(env->get_object(target)->metaclass(env->state())); } else { module = c_as<Module>(env->get_object(target)); } NativeMethod* method = NULL; method = NativeMethod::create(state, String::create(state, file), module, method_name, fptr, Fixnum::from(arity)); MethodVisibility* visibility = MethodVisibility::create(state); visibility->method(state, method); switch(kind) { case cCApiPrivateMethod: visibility->visibility(state, state->symbol("private")); break; case cCApiProtectedMethod: visibility->visibility(state, state->symbol("protected")); break; default: /* Also catches singletons for now. @todo Verify OK. --rue */ visibility->visibility(state, state->symbol("public")); break; } module->method_table()->store(state, method_name, visibility); state->global_cache->clear(module, method_name); }