Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
64e9f278
Unverified
Commit
64e9f278
authored
Dec 20, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Dec 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4874 from dearblue/method-list
Fix for `#methods` to include methods that were `undef`
parents
87809742
184ad732
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
11 deletions
+22
-11
mrbgems/mruby-metaprog/src/metaprog.c
mrbgems/mruby-metaprog/src/metaprog.c
+22
-11
No files found.
mrbgems/mruby-metaprog/src/metaprog.c
View file @
64e9f278
...
@@ -172,7 +172,7 @@ mrb_local_variables(mrb_state *mrb, mrb_value self)
...
@@ -172,7 +172,7 @@ mrb_local_variables(mrb_state *mrb, mrb_value self)
KHASH_DECLARE
(
st
,
mrb_sym
,
char
,
FALSE
)
KHASH_DECLARE
(
st
,
mrb_sym
,
char
,
FALSE
)
static
void
static
void
method_entry_loop
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
khash_t
(
st
)
*
set
)
method_entry_loop
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
khash_t
(
st
)
*
set
,
khash_t
(
st
)
*
undef
)
{
{
khint_t
i
;
khint_t
i
;
...
@@ -181,20 +181,28 @@ method_entry_loop(mrb_state *mrb, struct RClass* klass, khash_t(st)* set)
...
@@ -181,20 +181,28 @@ method_entry_loop(mrb_state *mrb, struct RClass* klass, khash_t(st)* set)
for
(
i
=
0
;
i
<
kh_end
(
h
);
i
++
)
{
for
(
i
=
0
;
i
<
kh_end
(
h
);
i
++
)
{
if
(
kh_exist
(
h
,
i
))
{
if
(
kh_exist
(
h
,
i
))
{
mrb_method_t
m
=
kh_value
(
h
,
i
);
mrb_method_t
m
=
kh_value
(
h
,
i
);
if
(
MRB_METHOD_UNDEF_P
(
m
))
continue
;
if
(
MRB_METHOD_UNDEF_P
(
m
))
{
kh_put
(
st
,
mrb
,
set
,
kh_key
(
h
,
i
));
if
(
undef
)
{
kh_put
(
st
,
mrb
,
undef
,
kh_key
(
h
,
i
));
}
}
else
if
(
undef
==
NULL
||
kh_get
(
st
,
mrb
,
undef
,
kh_key
(
h
,
i
))
==
kh_end
(
undef
))
{
kh_put
(
st
,
mrb
,
set
,
kh_key
(
h
,
i
));
}
}
}
}
}
}
}
static
mrb_value
static
mrb_value
mrb_class_instance_method_list
(
mrb_state
*
mrb
,
mrb_bool
recur
,
struct
RClass
*
klass
,
int
obj
)
mrb_class_instance_method_list
(
mrb_state
*
mrb
,
mrb_bool
recur
,
struct
RClass
*
klass
,
int
obj
)
{
{
khint_t
i
;
khint_t
i
;
mrb_value
ary
;
mrb_value
ary
;
mrb_bool
prepended
=
FALSE
;
mrb_bool
prepended
=
FALSE
;
struct
RClass
*
oldklass
;
struct
RClass
*
oldklass
;
khash_t
(
st
)
*
set
=
kh_init
(
st
,
mrb
);
khash_t
(
st
)
*
set
=
kh_init
(
st
,
mrb
);
khash_t
(
st
)
*
undef
=
(
recur
?
kh_init
(
st
,
mrb
)
:
NULL
);
if
(
!
recur
&&
(
klass
->
flags
&
MRB_FL_CLASS_IS_PREPENDED
))
{
if
(
!
recur
&&
(
klass
->
flags
&
MRB_FL_CLASS_IS_PREPENDED
))
{
MRB_CLASS_ORIGIN
(
klass
);
MRB_CLASS_ORIGIN
(
klass
);
...
@@ -203,7 +211,7 @@ mrb_class_instance_method_list(mrb_state *mrb, mrb_bool recur, struct RClass* kl
...
@@ -203,7 +211,7 @@ mrb_class_instance_method_list(mrb_state *mrb, mrb_bool recur, struct RClass* kl
oldklass
=
0
;
oldklass
=
0
;
while
(
klass
&&
(
klass
!=
oldklass
))
{
while
(
klass
&&
(
klass
!=
oldklass
))
{
method_entry_loop
(
mrb
,
klass
,
set
);
method_entry_loop
(
mrb
,
klass
,
set
,
undef
);
if
((
klass
->
tt
==
MRB_TT_ICLASS
&&
!
prepended
)
||
if
((
klass
->
tt
==
MRB_TT_ICLASS
&&
!
prepended
)
||
(
klass
->
tt
==
MRB_TT_SCLASS
))
{
(
klass
->
tt
==
MRB_TT_SCLASS
))
{
}
}
...
@@ -221,6 +229,7 @@ mrb_class_instance_method_list(mrb_state *mrb, mrb_bool recur, struct RClass* kl
...
@@ -221,6 +229,7 @@ mrb_class_instance_method_list(mrb_state *mrb, mrb_bool recur, struct RClass* kl
}
}
}
}
kh_destroy
(
st
,
mrb
,
set
);
kh_destroy
(
st
,
mrb
,
set
);
if
(
undef
)
kh_destroy
(
st
,
mrb
,
undef
);
return
ary
;
return
ary
;
}
}
...
@@ -313,18 +322,19 @@ mrb_obj_singleton_methods(mrb_state *mrb, mrb_bool recur, mrb_value obj)
...
@@ -313,18 +322,19 @@ mrb_obj_singleton_methods(mrb_state *mrb, mrb_bool recur, mrb_value obj)
{
{
khint_t
i
;
khint_t
i
;
mrb_value
ary
;
mrb_value
ary
;
struct
RClass
*
klass
;
struct
RClass
*
klass
;
khash_t
(
st
)
*
set
=
kh_init
(
st
,
mrb
);
khash_t
(
st
)
*
set
=
kh_init
(
st
,
mrb
);
khash_t
(
st
)
*
undef
=
(
recur
?
kh_init
(
st
,
mrb
)
:
NULL
);
klass
=
mrb_class
(
mrb
,
obj
);
klass
=
mrb_class
(
mrb
,
obj
);
if
(
klass
&&
(
klass
->
tt
==
MRB_TT_SCLASS
))
{
if
(
klass
&&
(
klass
->
tt
==
MRB_TT_SCLASS
))
{
method_entry_loop
(
mrb
,
klass
,
set
);
method_entry_loop
(
mrb
,
klass
,
set
,
undef
);
klass
=
klass
->
super
;
klass
=
klass
->
super
;
}
}
if
(
recur
)
{
if
(
recur
)
{
while
(
klass
&&
((
klass
->
tt
==
MRB_TT_SCLASS
)
||
(
klass
->
tt
==
MRB_TT_ICLASS
)))
{
while
(
klass
&&
((
klass
->
tt
==
MRB_TT_SCLASS
)
||
(
klass
->
tt
==
MRB_TT_ICLASS
)))
{
method_entry_loop
(
mrb
,
klass
,
set
);
method_entry_loop
(
mrb
,
klass
,
set
,
undef
);
klass
=
klass
->
super
;
klass
=
klass
->
super
;
}
}
}
}
...
@@ -336,6 +346,7 @@ mrb_obj_singleton_methods(mrb_state *mrb, mrb_bool recur, mrb_value obj)
...
@@ -336,6 +346,7 @@ mrb_obj_singleton_methods(mrb_state *mrb, mrb_bool recur, mrb_value obj)
}
}
}
}
kh_destroy
(
st
,
mrb
,
set
);
kh_destroy
(
st
,
mrb
,
set
);
if
(
undef
)
kh_destroy
(
st
,
mrb
,
undef
);
return
ary
;
return
ary
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment