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
a57a9bce
Commit
a57a9bce
authored
Jul 24, 2019
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call `MRB_SET_INSTANCE_TT` for `Complex` and `Rational`.
parent
e968bdf6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
mrbgems/mruby-complex/src/complex.c
mrbgems/mruby-complex/src/complex.c
+5
-1
mrbgems/mruby-rational/src/rational.c
mrbgems/mruby-rational/src/rational.c
+5
-2
No files found.
mrbgems/mruby-complex/src/complex.c
View file @
a57a9bce
...
...
@@ -132,7 +132,11 @@ void mrb_mruby_complex_gem_init(mrb_state *mrb)
mrb_assert
(
sizeof
(
struct
mrb_complex
)
<
ISTRUCT_DATA_SIZE
);
#endif
comp
=
mrb_define_class
(
mrb
,
"Complex"
,
mrb_class_get
(
mrb
,
"Numeric"
));
//MRB_SET_INSTANCE_TT(comp, MRB_TT_ISTRUCT);
#ifdef COMPLEX_USE_ISTRUCT
MRB_SET_INSTANCE_TT
(
comp
,
MRB_TT_ISTRUCT
);
#else
MRB_SET_INSTANCE_TT
(
comp
,
MRB_TT_DATA
);
#endif
mrb_undef_class_method
(
mrb
,
comp
,
"new"
);
mrb_define_class_method
(
mrb
,
comp
,
"rectangular"
,
complex_s_rect
,
MRB_ARGS_REQ
(
1
)
|
MRB_ARGS_OPT
(
1
));
mrb_define_class_method
(
mrb
,
comp
,
"rect"
,
complex_s_rect
,
MRB_ARGS_REQ
(
1
)
|
MRB_ARGS_OPT
(
1
));
...
...
mrbgems/mruby-rational/src/rational.c
View file @
a57a9bce
...
...
@@ -183,10 +183,13 @@ void mrb_mruby_rational_gem_init(mrb_state *mrb)
{
struct
RClass
*
rat
;
#ifdef COMPLEX_USE_RATIONAL
rat
=
mrb_define_class
(
mrb
,
"Rational"
,
mrb_class_get
(
mrb
,
"Numeric"
));
#ifdef RATIONAL_USE_ISTRUCT
MRB_SET_INSTANCE_TT
(
rat
,
MRB_TT_ISTRUCT
);
mrb_assert
(
sizeof
(
struct
mrb_rational
)
<
ISTRUCT_DATA_SIZE
);
#else
MRB_SET_INSTANCE_TT
(
rat
,
MRB_TT_DATA
);
#endif
rat
=
mrb_define_class
(
mrb
,
"Rational"
,
mrb_class_get
(
mrb
,
"Numeric"
));
mrb_undef_class_method
(
mrb
,
rat
,
"new"
);
mrb_define_class_method
(
mrb
,
rat
,
"_new"
,
rational_s_new
,
MRB_ARGS_REQ
(
2
));
mrb_define_method
(
mrb
,
rat
,
"numerator"
,
rational_numerator
,
MRB_ARGS_NONE
());
...
...
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