Class: Rubydex::Declaration
- Inherits:
-
Object
- Object
- Rubydex::Declaration
- Defined in:
- lib/rubydex/declaration.rb,
ext/rubydex/declaration.c
Direct Known Subclasses
ClassVariable, Constant, ConstantAlias, GlobalVariable, InstanceVariable, Method, Namespace
Instance Method Summary collapse
-
#definitions ⇒ Enumerator[Rubydex::Definition]
Returns an enumerator that yields all definitions for this declaration lazily.
- #initialize ⇒ Object constructor
-
#name ⇒ String?
Returns the fully qualified declaration name.
-
#owner ⇒ Rubydex::Declaration
Returns the owner declaration.
-
#references ⇒ Object
abstract
: () -> Enumerable.
-
#unqualified_name ⇒ String?
Returns the declaration name without namespace qualification.
Constructor Details
#initialize ⇒ Object
Instance Method Details
#definitions ⇒ Enumerator[Rubydex::Definition]
Returns an enumerator that yields all definitions for this declaration lazily.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'ext/rubydex/declaration.c', line 127
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;
void *graph = rdxi_graph_from_handle(self, &data);
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 ⇒ String?
Returns the fully qualified declaration name.
60 61 62 63 64 65 66 |
# File 'ext/rubydex/declaration.c', line 60
static VALUE rdxr_declaration_name(VALUE self) {
HandleData *data;
void *graph = rdxi_graph_from_handle(self, &data);
const char *name = rdx_declaration_name(graph, data->id);
return rdxi_owned_c_string_to_ruby(name);
}
|
#owner ⇒ Rubydex::Declaration
Returns the owner declaration.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'ext/rubydex/declaration.c', line 233
static VALUE rdxr_declaration_owner(VALUE self) {
HandleData *data;
void *graph = rdxi_graph_from_handle(self, &data);
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);
}
|
#references ⇒ Object
This method is abstract.
: () -> Enumerable
18 19 20 |
# File 'lib/rubydex/declaration.rb', line 18 def references raise NotImplementedError, "Subclasses must implement #references" end |
#unqualified_name ⇒ String?
Returns the declaration name without namespace qualification.
74 75 76 77 78 79 80 |
# File 'ext/rubydex/declaration.c', line 74
static VALUE rdxr_declaration_unqualified_name(VALUE self) {
HandleData *data;
void *graph = rdxi_graph_from_handle(self, &data);
const char *name = rdx_declaration_unqualified_name(graph, data->id);
return rdxi_owned_c_string_to_ruby(name);
}
|