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
7ed26ead
Commit
7ed26ead
authored
Jan 01, 2020
by
dearblue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate `i` and `arg_i` in `mrb_get_args()`
The behavior of these two variables is the same.
parent
fd1cff77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
35 deletions
+16
-35
src/class.c
src/class.c
+16
-35
No files found.
src/class.c
View file @
7ed26ead
...
@@ -589,7 +589,6 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -589,7 +589,6 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
char
c
;
char
c
;
mrb_int
i
=
0
;
mrb_int
i
=
0
;
va_list
ap
;
va_list
ap
;
mrb_int
arg_i
=
0
;
mrb_int
argc
=
mrb
->
c
->
ci
->
argc
;
mrb_int
argc
=
mrb
->
c
->
ci
->
argc
;
mrb_value
*
array_argv
=
mrb
->
c
->
stack
+
1
;
mrb_value
*
array_argv
=
mrb
->
c
->
stack
+
1
;
mrb_bool
argv_on_stack
=
argc
>=
0
;
mrb_bool
argv_on_stack
=
argc
>=
0
;
...
@@ -677,8 +676,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -677,8 +676,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
mrb_value
*
);
p
=
va_arg
(
ap
,
mrb_value
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
*
p
=
argv
[
arg_i
++
];
*
p
=
argv
[
i
++
];
i
++
;
}
}
}
}
break
;
break
;
...
@@ -690,12 +688,11 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -690,12 +688,11 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
mrb_value
ss
;
mrb_value
ss
;
ss
=
argv
[
arg_
i
++
];
ss
=
argv
[
i
++
];
if
(
!
class_ptr_p
(
ss
))
{
if
(
!
class_ptr_p
(
ss
))
{
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%v is not class/module"
,
ss
);
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%v is not class/module"
,
ss
);
}
}
*
p
=
ss
;
*
p
=
ss
;
i
++
;
}
}
}
}
break
;
break
;
...
@@ -705,8 +702,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -705,8 +702,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
mrb_value
*
);
p
=
va_arg
(
ap
,
mrb_value
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
*
p
=
argv
[
arg_i
++
];
*
p
=
argv
[
i
++
];
i
++
;
if
(
!
(
altmode
&&
mrb_nil_p
(
*
p
)))
{
if
(
!
(
altmode
&&
mrb_nil_p
(
*
p
)))
{
mrb_to_str
(
mrb
,
*
p
);
mrb_to_str
(
mrb
,
*
p
);
}
}
...
@@ -719,8 +715,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -719,8 +715,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
mrb_value
*
);
p
=
va_arg
(
ap
,
mrb_value
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
*
p
=
argv
[
arg_i
++
];
*
p
=
argv
[
i
++
];
i
++
;
if
(
!
(
altmode
&&
mrb_nil_p
(
*
p
)))
{
if
(
!
(
altmode
&&
mrb_nil_p
(
*
p
)))
{
*
p
=
to_ary
(
mrb
,
*
p
);
*
p
=
to_ary
(
mrb
,
*
p
);
}
}
...
@@ -733,8 +728,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -733,8 +728,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
mrb_value
*
);
p
=
va_arg
(
ap
,
mrb_value
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
*
p
=
argv
[
arg_i
++
];
*
p
=
argv
[
i
++
];
i
++
;
if
(
!
(
altmode
&&
mrb_nil_p
(
*
p
)))
{
if
(
!
(
altmode
&&
mrb_nil_p
(
*
p
)))
{
*
p
=
to_hash
(
mrb
,
*
p
);
*
p
=
to_hash
(
mrb
,
*
p
);
}
}
...
@@ -750,8 +744,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -750,8 +744,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
ps
=
va_arg
(
ap
,
char
**
);
ps
=
va_arg
(
ap
,
char
**
);
pl
=
va_arg
(
ap
,
mrb_int
*
);
pl
=
va_arg
(
ap
,
mrb_int
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
ss
=
argv
[
arg_i
++
];
ss
=
argv
[
i
++
];
i
++
;
if
(
altmode
&&
mrb_nil_p
(
ss
))
{
if
(
altmode
&&
mrb_nil_p
(
ss
))
{
*
ps
=
NULL
;
*
ps
=
NULL
;
*
pl
=
0
;
*
pl
=
0
;
...
@@ -771,8 +764,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -771,8 +764,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
ps
=
va_arg
(
ap
,
const
char
**
);
ps
=
va_arg
(
ap
,
const
char
**
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
ss
=
argv
[
arg_i
++
];
ss
=
argv
[
i
++
];
i
++
;
if
(
altmode
&&
mrb_nil_p
(
ss
))
{
if
(
altmode
&&
mrb_nil_p
(
ss
))
{
*
ps
=
NULL
;
*
ps
=
NULL
;
}
}
...
@@ -793,8 +785,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -793,8 +785,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
pb
=
va_arg
(
ap
,
mrb_value
**
);
pb
=
va_arg
(
ap
,
mrb_value
**
);
pl
=
va_arg
(
ap
,
mrb_int
*
);
pl
=
va_arg
(
ap
,
mrb_int
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
aa
=
argv
[
arg_i
++
];
aa
=
argv
[
i
++
];
i
++
;
if
(
altmode
&&
mrb_nil_p
(
aa
))
{
if
(
altmode
&&
mrb_nil_p
(
aa
))
{
*
pb
=
0
;
*
pb
=
0
;
*
pl
=
0
;
*
pl
=
0
;
...
@@ -815,14 +806,12 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -815,14 +806,12 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
void
**
);
p
=
va_arg
(
ap
,
void
**
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
ss
=
argv
[
arg_i
];
ss
=
argv
[
i
++
];
if
(
!
mrb_istruct_p
(
ss
))
if
(
!
mrb_istruct_p
(
ss
))
{
{
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%v is not inline struct"
,
ss
);
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"%v is not inline struct"
,
ss
);
}
}
*
p
=
mrb_istruct_ptr
(
ss
);
*
p
=
mrb_istruct_ptr
(
ss
);
arg_i
++
;
i
++
;
}
}
}
}
break
;
break
;
...
@@ -833,9 +822,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -833,9 +822,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
mrb_float
*
);
p
=
va_arg
(
ap
,
mrb_float
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
*
p
=
mrb_to_flo
(
mrb
,
argv
[
arg_i
]);
*
p
=
mrb_to_flo
(
mrb
,
argv
[
i
++
]);
arg_i
++
;
i
++
;
}
}
}
}
break
;
break
;
...
@@ -846,9 +833,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -846,9 +833,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p
=
va_arg
(
ap
,
mrb_int
*
);
p
=
va_arg
(
ap
,
mrb_int
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
*
p
=
mrb_fixnum
(
mrb_to_int
(
mrb
,
argv
[
arg_i
]));
*
p
=
mrb_fixnum
(
mrb_to_int
(
mrb
,
argv
[
i
++
]));
arg_i
++
;
i
++
;
}
}
}
}
break
;
break
;
...
@@ -857,9 +842,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -857,9 +842,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
mrb_bool
*
boolp
=
va_arg
(
ap
,
mrb_bool
*
);
mrb_bool
*
boolp
=
va_arg
(
ap
,
mrb_bool
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
mrb_value
b
=
argv
[
arg_
i
++
];
mrb_value
b
=
argv
[
i
++
];
*
boolp
=
mrb_test
(
b
);
*
boolp
=
mrb_test
(
b
);
i
++
;
}
}
}
}
break
;
break
;
...
@@ -871,9 +855,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -871,9 +855,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
mrb_value
ss
;
mrb_value
ss
;
ss
=
argv
[
arg_
i
++
];
ss
=
argv
[
i
++
];
*
symp
=
to_sym
(
mrb
,
ss
);
*
symp
=
to_sym
(
mrb
,
ss
);
i
++
;
}
}
}
}
break
;
break
;
...
@@ -885,8 +868,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -885,8 +868,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
datap
=
va_arg
(
ap
,
void
**
);
datap
=
va_arg
(
ap
,
void
**
);
type
=
va_arg
(
ap
,
struct
mrb_data_type
const
*
);
type
=
va_arg
(
ap
,
struct
mrb_data_type
const
*
);
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
mrb_value
dd
=
argv
[
arg_i
++
];
mrb_value
dd
=
argv
[
i
++
];
i
++
;
if
(
altmode
&&
mrb_nil_p
(
dd
))
{
if
(
altmode
&&
mrb_nil_p
(
dd
))
{
*
datap
=
0
;
*
datap
=
0
;
}
}
...
@@ -939,16 +921,15 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
...
@@ -939,16 +921,15 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
*
pl
=
argc
-
i
;
*
pl
=
argc
-
i
;
if
(
*
pl
>
0
)
{
if
(
*
pl
>
0
)
{
if
(
nocopy
)
{
if
(
nocopy
)
{
*
var
=
argv
+
arg_
i
;
*
var
=
argv
+
i
;
}
}
else
{
else
{
mrb_value
args
=
mrb_ary_new_from_values
(
mrb
,
*
pl
,
argv
+
arg_
i
);
mrb_value
args
=
mrb_ary_new_from_values
(
mrb
,
*
pl
,
argv
+
i
);
RARRAY
(
args
)
->
c
=
NULL
;
RARRAY
(
args
)
->
c
=
NULL
;
*
var
=
RARRAY_PTR
(
args
);
*
var
=
RARRAY_PTR
(
args
);
}
}
}
}
i
=
argc
;
i
=
argc
;
arg_i
+=
*
pl
;
}
}
else
{
else
{
*
pl
=
0
;
*
pl
=
0
;
...
...
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