Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
20cff19f
Commit
20cff19f
authored
Oct 10, 2017
by
Sylvain Berfini
🎩
Browse files
Improvements on enums and exceptions
parent
ec8327d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
wrappers/java/genwrapper.py
wrappers/java/genwrapper.py
+9
-1
wrappers/java/java_class.mustache
wrappers/java/java_class.mustache
+7
-2
wrappers/java/java_enum.mustache
wrappers/java/java_enum.mustache
+5
-1
No files found.
wrappers/java/genwrapper.py
View file @
20cff19f
...
...
@@ -104,7 +104,8 @@ class JavaTranslator(object):
if
name
in
ENUMS_LIST
:
className
=
ENUMS_LIST
[
name
]
if
name
.
startswith
(
className
):
name
=
className
+
'.'
+
name
[
len
(
className
):]
name
=
name
[
len
(
className
):]
name
=
className
+
'.'
+
name
return
name
elif
type
(
_type
)
is
AbsApi
.
BaseType
:
if
_type
.
name
==
'string'
:
...
...
@@ -115,6 +116,10 @@ class JavaTranslator(object):
return
'float'
elif
_type
.
name
==
'size'
:
return
'int'
elif
_type
.
name
==
'status'
:
if
native
:
return
'int'
return
'void'
return
_type
.
name
def
translate_argument
(
self
,
_arg
,
native
=
False
):
...
...
@@ -144,6 +149,7 @@ class JavaTranslator(object):
methodDict
[
'name'
]
=
_method
.
name
.
to_camel_case
(
lower
=
True
)
methodDict
[
'exception'
]
=
self
.
throws_exception
(
_method
.
returnType
)
methodDict
[
'enumCast'
]
=
type
(
_method
.
returnType
)
is
AbsApi
.
EnumType
methodDict
[
'params'
]
=
''
methodDict
[
'native_params'
]
=
'long nativePtr'
methodDict
[
'static_native_params'
]
=
''
...
...
@@ -167,6 +173,8 @@ class JavaTranslator(object):
methodDict
[
'native_params_impl'
]
+=
'longArray'
else
:
methodDict
[
'native_params_impl'
]
+=
self
.
translate_argument_name
(
arg
.
name
)
elif
type
(
arg
.
type
)
is
AbsApi
.
EnumType
:
methodDict
[
'native_params_impl'
]
+=
self
.
translate_argument_name
(
arg
.
name
)
+
'.toInt()'
else
:
methodDict
[
'native_params_impl'
]
+=
self
.
translate_argument_name
(
arg
.
name
)
...
...
wrappers/java/java_class.mustache
View file @
20cff19f
...
...
@@ -53,7 +53,7 @@ public interface {{className}} {
mValue = value;
}
static p
rotected
{{
className
}}
fromInt(int value) throws CoreException {
static p
ublic
{{
className
}}
fromInt(int value) throws CoreException {
switch(value) {
{{#
values
}}
case
{{
value
}}
: return
{{
name
}}
;
...
...
@@ -62,6 +62,10 @@ public interface {{className}} {
throw new CoreException("Unhandled enum value " + value + " for
{{
className
}}
");
}
}
public int toInt() {
return mValue;
}
};
{{/
enums
}}
...
...
@@ -142,7 +146,8 @@ class {{classImplName}} implements {{className}} {
return
classArray
;
{{/
convertOutputClassArrayToLongArray
}}
{{#
classicMethod
}}
{{
return_keyword
}}{{
name
}}
(
nativePtr
{{
native_params_impl
}}
);
{{#
exception
}}
int
exceptionResult =
{{/
exception
}}{{
return_keyword
}}{{#
enumCast
}}{{
return
}}
.
fromInt
(
{{/
enumCast
}}{{
name
}}
(
nativePtr
{{
native_params_impl
}}
)
{{#
enumCast
}}
)
{{/
enumCast
}}
;
{{#
exception
}}
if
(
exceptionResult
!=
0)
throw
new
CoreException
("
{{
name
}}
returned
value
"
+
exceptionResult
)
{{/
exception
}}
{{/
classicMethod
}}
}
...
...
wrappers/java/java_enum.mustache
View file @
20cff19f
...
...
@@ -48,7 +48,7 @@ public enum {{className}} {
mValue = value;
}
static p
rotected
{{
className
}}
fromInt(int value) throws CoreException {
static p
ublic
{{
className
}}
fromInt(int value) throws CoreException {
switch(value) {
{{#
values
}}
case
{{
value
}}
: return
{{
name
}}
;
...
...
@@ -57,4 +57,8 @@ public enum {{className}} {
throw new CoreException("Unhandled enum value " + value + " for
{{
className
}}
");
}
}
public int toInt() {
return mValue;
}
}
\ No newline at end of file
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