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
f6b5a829
Commit
f6b5a829
authored
Jun 22, 2015
by
take_cheeze
Committed by
Yukihiro "Matz" Matsumoto
Jul 15, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use class array instead of variadic.
parent
cdd72d9c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
include/mruby/error.h
include/mruby/error.h
+2
-1
mrbgems/mruby-error/src/exception.c
mrbgems/mruby-error/src/exception.c
+6
-8
mrbgems/mruby-error/test/exception.c
mrbgems/mruby-error/test/exception.c
+3
-1
No files found.
include/mruby/error.h
View file @
f6b5a829
...
...
@@ -35,7 +35,8 @@ MRB_API mrb_value mrb_ensure(mrb_state *mrb, mrb_func_t body, mrb_value b_data,
MRB_API
mrb_value
mrb_rescue
(
mrb_state
*
mrb
,
mrb_func_t
body
,
mrb_value
b_data
,
mrb_func_t
rescue
,
mrb_value
r_data
);
MRB_API
mrb_value
mrb_rescue_exceptions
(
mrb_state
*
mrb
,
mrb_func_t
body
,
mrb_value
b_data
,
mrb_func_t
rescue
,
mrb_value
r_data
,
...);
mrb_func_t
rescue
,
mrb_value
r_data
,
mrb_int
len
,
struct
RClass
**
classes
);
#if defined(__cplusplus)
}
/* extern "C" { */
...
...
mrbgems/mruby-error/src/exception.c
View file @
f6b5a829
#include <stdarg.h>
#include "mruby.h"
#include "mruby/throw.h"
#include "mruby/error.h"
...
...
@@ -52,18 +51,19 @@ MRB_API mrb_value
mrb_rescue
(
mrb_state
*
mrb
,
mrb_func_t
body
,
mrb_value
b_data
,
mrb_func_t
rescue
,
mrb_value
r_data
)
{
return
mrb_rescue_exceptions
(
mrb
,
body
,
b_data
,
rescue
,
r_data
,
mrb
->
eStandardError_class
,
NULL
);
return
mrb_rescue_exceptions
(
mrb
,
body
,
b_data
,
rescue
,
r_data
,
1
,
&
mrb
->
eStandardError_class
);
}
MRB_API
mrb_value
mrb_rescue_exceptions
(
mrb_state
*
mrb
,
mrb_func_t
body
,
mrb_value
b_data
,
mrb_func_t
rescue
,
mrb_value
r_data
,
...)
mrb_rescue_exceptions
(
mrb_state
*
mrb
,
mrb_func_t
body
,
mrb_value
b_data
,
mrb_func_t
rescue
,
mrb_value
r_data
,
mrb_int
len
,
struct
RClass
**
classes
)
{
struct
mrb_jmpbuf
*
prev_jmp
=
mrb
->
jmp
;
struct
mrb_jmpbuf
c_jmp
;
mrb_value
result
;
va_list
excs
;
struct
RClass
*
cls
;
mrb_bool
error_matched
=
FALSE
;
mrb_int
i
;
MRB_TRY
(
&
c_jmp
)
{
mrb
->
jmp
=
&
c_jmp
;
...
...
@@ -72,14 +72,12 @@ mrb_rescue_exceptions(mrb_state *mrb, mrb_func_t body, mrb_value b_data, mrb_fun
}
MRB_CATCH
(
&
c_jmp
)
{
mrb
->
jmp
=
prev_jmp
;
va_start
(
excs
,
r_data
);
while
((
cls
=
va_arg
(
excs
,
struct
RClass
*
)))
{
if
(
mrb_obj_is_kind_of
(
mrb
,
mrb_obj_value
(
mrb
->
exc
),
cls
))
{
for
(
i
=
0
;
i
<
len
;
++
i
)
{
if
(
mrb_obj_is_kind_of
(
mrb
,
mrb_obj_value
(
mrb
->
exc
),
classes
[
i
]))
{
error_matched
=
TRUE
;
break
;
}
}
va_end
(
excs
);
if
(
!
error_matched
)
{
MRB_THROW
(
mrb
->
jmp
);
}
...
...
mrbgems/mruby-error/test/exception.c
View file @
f6b5a829
...
...
@@ -40,8 +40,10 @@ static mrb_value
run_rescue_exceptions
(
mrb_state
*
mrb
,
mrb_value
self
)
{
mrb_value
b
,
r
;
struct
RClass
*
cls
[
1
];
mrb_get_args
(
mrb
,
"oo"
,
&
b
,
&
r
);
return
mrb_rescue_exceptions
(
mrb
,
protect_cb
,
b
,
protect_cb
,
r
,
E_TYPE_ERROR
,
NULL
);
cls
[
0
]
=
E_TYPE_ERROR
;
return
mrb_rescue_exceptions
(
mrb
,
protect_cb
,
b
,
protect_cb
,
r
,
1
,
cls
);
}
void
...
...
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