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
64d5a40c
Unverified
Commit
64d5a40c
authored
Aug 30, 2021
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Aug 30, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5542 from dearblue/mrb_get_args-cI
Allow `nil` for `c!` and `I!` specifiers of `mrb_get_args()`
parents
84e36d74
f9962043
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
include/mruby.h
include/mruby.h
+2
-1
src/class.c
src/class.c
+19
-9
No files found.
include/mruby.h
View file @
64d5a40c
...
...
@@ -899,12 +899,13 @@ MRB_API struct RClass* mrb_define_module_under_id(mrb_state *mrb, struct RClass
* | `s` | {String} | const char *, {mrb_int} | Receive two arguments; `s!` gives (`NULL`,`0`) for `nil` |
* | `z` | {String} | const char * | `NULL` terminated string; `z!` gives `NULL` for `nil` |
* | `a` | {Array} | const {mrb_value} *, {mrb_int} | Receive two arguments; `a!` gives (`NULL`,`0`) for `nil` |
* | `c` | {Class}/{Module} | strcut RClass * | `c!` gives `NULL` for `nil` |
* | `f` | {Integer}/{Float} | {mrb_float} | |
* | `i` | {Integer}/{Float} | {mrb_int} | |
* | `b` | boolean | {mrb_bool} | |
* | `n` | {String}/{Symbol} | {mrb_sym} | |
* | `d` | data | void *, {mrb_data_type} const | 2nd argument will be used to check data type so it won't be modified; when `!` follows, the value may be `nil` |
* | `I` | inline struct | void *, struct RClass |
|
* | `I` | inline struct | void *, struct RClass |
`I!` gives `NULL` for `nil`
|
* | `&` | block | {mrb_value} | &! raises exception if no block given. |
* | `*` | rest arguments | const {mrb_value} *, {mrb_int} | Receive the rest of arguments as an array; `*!` avoid copy of the stack. |
* | <code>\|</code> | optional | | After this spec following specs would be optional. |
...
...
src/class.c
View file @
64d5a40c
...
...
@@ -884,13 +884,13 @@ void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self);
s: String [const char*,mrb_int] Receive two arguments; s! gives (NULL,0) for nil
z: String [const char*] NUL terminated string; z! gives NULL for nil
a: Array [const mrb_value*,mrb_int] Receive two arguments; a! gives (NULL,0) for nil
c: Class/Module [strcut RClass*]
c: Class/Module [strcut RClass*]
c! gives NULL for nil
f: Integer/Float [mrb_float]
i: Integer/Float [mrb_int]
b: boolean [mrb_bool]
n: String/Symbol [mrb_sym]
d: data [void*,mrb_data_type const] 2nd argument will be used to check data type so it won't be modified; when ! follows, the value may be nil
I: inline struct [void*,struct RClass]
I: inline struct [void*,struct RClass]
I! gives NULL for nil
&: block [mrb_value] &! raises exception if no block given
*: rest argument [const mrb_value*,mrb_int] The rest of the arguments as an array; *! avoid copy of the stack
|: optional Following arguments are optional
...
...
@@ -1042,8 +1042,13 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
struct
RClass
**
);
if
(
pickarg
)
{
ensure_class_type
(
mrb
,
*
pickarg
);
*
p
=
mrb_class_ptr
(
*
pickarg
);
if
(
altmode
&&
mrb_nil_p
(
*
pickarg
))
{
*
p
=
NULL
;
}
else
{
ensure_class_type
(
mrb
,
*
pickarg
);
*
p
=
mrb_class_ptr
(
*
pickarg
);
}
}
}
break
;
...
...
@@ -1116,13 +1121,18 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
void
**
);
klass
=
va_arg
(
ap
,
struct
RClass
*
);
if
(
pickarg
)
{
if
(
!
mrb_obj_is_kind_of
(
mrb
,
*
pickarg
,
klass
))
{
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%v is not a %C"
,
*
pickarg
,
klass
)
;
if
(
altmode
&&
mrb_nil_p
(
*
pickarg
))
{
*
p
=
NULL
;
}
if
(
!
mrb_istruct_p
(
*
pickarg
))
{
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%v is not inline struct"
,
*
pickarg
);
else
{
if
(
!
mrb_obj_is_kind_of
(
mrb
,
*
pickarg
,
klass
))
{
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%v is not a %C"
,
*
pickarg
,
klass
);
}
if
(
!
mrb_istruct_p
(
*
pickarg
))
{
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%v is not inline struct"
,
*
pickarg
);
}
*
p
=
mrb_istruct_ptr
(
*
pickarg
);
}
*
p
=
mrb_istruct_ptr
(
*
pickarg
);
}
}
break
;
...
...
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