Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
e632b1fd
Commit
e632b1fd
authored
Sep 23, 2015
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unix/modjni: Factor out is_object_type().
parent
941040e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
unix/modjni.c
unix/modjni.c
+16
-10
No files found.
unix/modjni.c
View file @
e632b1fd
...
@@ -77,6 +77,18 @@ typedef struct _mp_obj_jmethod_t {
...
@@ -77,6 +77,18 @@ typedef struct _mp_obj_jmethod_t {
bool
is_static
;
bool
is_static
;
}
mp_obj_jmethod_t
;
}
mp_obj_jmethod_t
;
// Utility functions
STATIC
bool
is_object_type
(
const
char
*
jtypesig
)
{
while
(
*
jtypesig
!=
' '
&&
*
jtypesig
)
{
if
(
*
jtypesig
==
'.'
)
{
return
true
;
}
jtypesig
++
;
}
return
false
;
}
// jclass
// jclass
STATIC
void
jclass_print
(
const
mp_print_t
*
print
,
mp_obj_t
self_in
,
mp_print_kind_t
kind
)
{
STATIC
void
jclass_print
(
const
mp_print_t
*
print
,
mp_obj_t
self_in
,
mp_print_kind_t
kind
)
{
...
@@ -281,24 +293,18 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
...
@@ -281,24 +293,18 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
// it.
// it.
#define MATCH(s, static) (!strncmp(s, static, sizeof(static) - 1))
#define MATCH(s, static) (!strncmp(s, static, sizeof(static) - 1))
STATIC
mp_obj_t
jvalue2py
(
const
char
*
jtypesig
,
jobject
arg
)
{
STATIC
mp_obj_t
jvalue2py
(
const
char
*
jtypesig
,
jobject
arg
)
{
const
char
*
org_jtype
=
jtypesig
;
if
(
arg
==
NULL
||
MATCH
(
jtypesig
,
"void"
))
{
if
(
arg
==
NULL
||
MATCH
(
jtypesig
,
"void"
))
{
return
mp_const_none
;
return
mp_const_none
;
}
else
if
(
MATCH
(
jtypesig
,
"boolean"
))
{
}
else
if
(
MATCH
(
jtypesig
,
"boolean"
))
{
return
mp_obj_new_bool
((
bool
)
arg
);
return
mp_obj_new_bool
((
bool
)
arg
);
}
else
if
(
MATCH
(
jtypesig
,
"int"
))
{
}
else
if
(
MATCH
(
jtypesig
,
"int"
))
{
return
mp_obj_new_int
((
mp_int_t
)
arg
);
return
mp_obj_new_int
((
mp_int_t
)
arg
);
}
else
{
}
else
if
(
is_object_type
(
jtypesig
))
{
while
(
*
jtypesig
!=
' '
&&
*
jtypesig
)
{
if
(
*
jtypesig
==
'.'
)
{
// Non-primitive, object type
// Non-primitive, object type
return
new_jobject
(
arg
);
return
new_jobject
(
arg
);
}
}
jtypesig
++
;
}
}
printf
(
"Unknown return type: %s
\n
"
,
org_jtype
);
printf
(
"Unknown return type: %s
\n
"
,
jtypesig
);
return
MP_OBJ_NULL
;
return
MP_OBJ_NULL
;
}
}
...
...
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