Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
e632b1fd
Commit
e632b1fd
authored
9 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
unix/modjni: Factor out is_object_type().
parent
941040e9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unix/modjni.c
+16
-10
16 additions, 10 deletions
unix/modjni.c
with
16 additions
and
10 deletions
unix/modjni.c
+
16
−
10
View file @
e632b1fd
...
...
@@ -77,6 +77,18 @@ typedef struct _mp_obj_jmethod_t {
bool
is_static
;
}
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
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) {
// it.
#define MATCH(s, static) (!strncmp(s, static, sizeof(static) - 1))
STATIC
mp_obj_t
jvalue2py
(
const
char
*
jtypesig
,
jobject
arg
)
{
const
char
*
org_jtype
=
jtypesig
;
if
(
arg
==
NULL
||
MATCH
(
jtypesig
,
"void"
))
{
return
mp_const_none
;
}
else
if
(
MATCH
(
jtypesig
,
"boolean"
))
{
return
mp_obj_new_bool
((
bool
)
arg
);
}
else
if
(
MATCH
(
jtypesig
,
"int"
))
{
return
mp_obj_new_int
((
mp_int_t
)
arg
);
}
else
{
while
(
*
jtypesig
!=
' '
&&
*
jtypesig
)
{
if
(
*
jtypesig
==
'.'
)
{
// Non-primitive, object type
return
new_jobject
(
arg
);
}
jtypesig
++
;
}
}
else
if
(
is_object_type
(
jtypesig
))
{
// Non-primitive, object type
return
new_jobject
(
arg
);
}
printf
(
"Unknown return type: %s
\n
"
,
org_
jtype
);
printf
(
"Unknown return type: %s
\n
"
,
jtype
sig
);
return
MP_OBJ_NULL
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment