Class: Rubydex::Declaration
- Inherits:
-
Object
- Object
- Rubydex::Declaration
- Defined in:
- ext/rubydex/declaration.c
Direct Known Subclasses
ClassVariable, Constant, ConstantAlias, GlobalVariable, InstanceVariable, Method, Namespace
Instance Method Summary collapse
-
#definitions ⇒ Object
Returns an enumerator that yields all definitions for this declaration lazily.
- #initialize ⇒ Object constructor
-
#name ⇒ Object
Declaration#name -> String.
-
#owner ⇒ Object
Declaration#owner -> Declaration.
-
#unqualified_name ⇒ Object
Declaration#unqualified_name -> String.
Constructor Details
#initialize ⇒ Object
Instance Method Details
#definitions ⇒ Object
Returns an enumerator that yields all definitions for this declaration lazily
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'ext/rubydex/declaration.c', line 131
static VALUE rdxr_declaration_definitions(VALUE self) {
if (!rb_block_given_p()) {
return rb_enumeratorize_with_size(self, rb_str_new2("definitions"), 0, NULL, declaration_definitions_size);
}
HandleData *data;
TypedData_Get_Struct(self, HandleData, &handle_type, data);
void *graph;
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
void *iter = rdx_declaration_definitions_iter_new(graph, data->id);
VALUE args = rb_ary_new_from_args(2, self, ULL2NUM((uintptr_t)iter));
rb_ensure(declaration_definitions_yield, args, declaration_definitions_ensure, args);
return self;
}
|
#name ⇒ Object
Declaration#name -> String
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'ext/rubydex/declaration.c', line 50
static VALUE rdxr_declaration_name(VALUE self) {
HandleData *data;
TypedData_Get_Struct(self, HandleData, &handle_type, data);
void *graph;
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
const char *name = rdx_declaration_name(graph, data->id);
if (name == NULL) {
return Qnil;
}
VALUE str = rb_utf8_str_new_cstr(name);
free_c_string(name);
return str;
}
|
#owner ⇒ Object
Declaration#owner -> Declaration
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'ext/rubydex/declaration.c', line 231
static VALUE rdxr_declaration_owner(VALUE self) {
HandleData *data;
TypedData_Get_Struct(self, HandleData, &handle_type, data);
void *graph;
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
const CDeclaration *decl = rdx_declaration_owner(graph, data->id);
if (decl == NULL) {
rb_raise(rb_eRuntimeError, "owner can never be nil for any declarations");
}
VALUE decl_class = rdxi_declaration_class_for_kind(decl->kind);
VALUE argv[] = {data->graph_obj, ULL2NUM(decl->id)};
free_c_declaration(decl);
return rb_class_new_instance(2, argv, decl_class);
}
|
#unqualified_name ⇒ Object
Declaration#unqualified_name -> String
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'ext/rubydex/declaration.c', line 69
static VALUE rdxr_declaration_unqualified_name(VALUE self) {
HandleData *data;
TypedData_Get_Struct(self, HandleData, &handle_type, data);
void *graph;
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
const char *name = rdx_declaration_unqualified_name(graph, data->id);
if (name == NULL) {
return Qnil;
}
VALUE str = rb_utf8_str_new_cstr(name);
free_c_string(name);
return str;
}
|