Skip to content

Commit

Permalink
Merge pull request #852 from apotschka/master
Browse files Browse the repository at this point in the history
Problem: No support for double precision floating point variables.
  • Loading branch information
sappo authored Feb 1, 2017
2 parents c5d30ab + 4d6d6f7 commit dfb1af3
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Michal Hrušecký
Dave Meehan
Wes Young
Kouhei Sutou
Andreas Potschka
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,9 @@ file:
<method name = "tutorial">
<argument name = "void pointer" type = "anything" />
<argument name = "standard int" type = "integer" />
<argument name = "standard float" type = "real" />
<argument name = "default float" type = "real" />
<argument name = "standard float" type = "real" size = "4" />
<argument name = "standard double" type = "real" size = "8" />
<argument name = "standard bool" type = "boolean" />
<argument name = "fixed size unsigned integer" type = "number" size = "4">
Supported sizes are 1, 2, 4, and 8.
Expand Down Expand Up @@ -939,7 +941,7 @@ This is an incomplete list of API types:

* "number" -- unsigned number, with 'size = "1|2|4|8"'.

* "real" -- single-precision floating point. [TODO: single? why not double?]
* "real" -- single-precision floating point with 'size = "4"' (default) or double-precision with 'size = "8"'.

* "buffer" -- byte array. When passing a buffer argument, if the next argument has type 'size', the binding may fill the size automatically. To return a buffer, you should specify 'size' attribute that defines how to set the buffer size. This can be a constant, 'size = "ZUUID_LEN"', or a dot followed by method name in the same class, e.g. 'size = ".size"'.

Expand Down
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ This is an incomplete list of API types:

* "number" -- unsigned number, with 'size = "1|2|4|8"'.

* "real" -- single-precision floating point. [TODO: single? why not double?]
* "real" -- single-precision floating point with 'size = "4"' (default) or double-precision with 'size = "8"'.

* "buffer" -- byte array. When passing a buffer argument, if the next argument has type 'size', the binding may fill the size automatically. To return a buffer, you should specify 'size' attribute that defines how to set the buffer size. This can be a constant, 'size = "ZUUID_LEN"', or a dot followed by method name in the same class, e.g. 'size = ".size"'.

Expand Down
4 changes: 3 additions & 1 deletion api/myclass.api
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@
<method name = "tutorial">
<argument name = "void pointer" type = "anything" />
<argument name = "standard int" type = "integer" />
<argument name = "standard float" type = "real" />
<argument name = "default float" type = "real" />
<argument name = "standard float" type = "real" size = "4" />
<argument name = "standard double" type = "real" size = "8" />
<argument name = "standard bool" type = "boolean" />
<argument name = "fixed size unsigned integer" type = "number" size = "4">
Supported sizes are 1, 2, 4, and 8.
Expand Down
3 changes: 2 additions & 1 deletion mkapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def __init__(self, name, size=None):
("uint16_t", "") : ZT("number", 2),
("uint32_t", "") : ZT("number", 4),
("uint64_t", "") : ZT("number", 8),
("float", "") : ZT("real"),
("float", "") : ZT("real", 4),
("double", "") : ZT("real", 8),
("char", "*") : ZT("string"),
("byte", "*") : ZT("buffer"),
("off_t", "") : ZT("file_size"),
Expand Down
12 changes: 10 additions & 2 deletions zproject_class_api.gsl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ function resolve_c_container (container)
endif

my.type = my.container.type
my.size = my.container.size? 1
if my.type = "real" # use different default for backwards compatibility
my.size = my.container.size? 4
else
my.size = my.container.size? 1
endif
my.c_type = ""
my.stars = ""

Expand All @@ -115,7 +119,11 @@ function resolve_c_container (container)
elsif my.type = "size"
my.c_type = "size_t"
elsif my.type = "real"
my.c_type = "float"
if my.size = 4
my.c_type = "float"
elsif my.size = 8
my.c_type = "double"
endif
elsif my.type = "number"
if my.size = 1
my.c_type = "uint8_t"
Expand Down
9 changes: 7 additions & 2 deletions zproject_java_lib.gsl
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ function resolve_container (container)
endif

elsif my.container.type = "real"
my.container.jni_java_type = "float"
my.container.jni_jni_type = "jfloat"
if my.container.size ?= "4"
my.container.jni_java_type = "float"
my.container.jni_jni_type = "jfloat"
elsif my.container.size ?= "8"
my.container.jni_java_type = "double"
my.container.jni_jni_type = "jdouble"
endif

elsif my.container.type = "buffer"
if my.container.by_reference
Expand Down
6 changes: 5 additions & 1 deletion zproject_python.gsl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ function resolve_container (container)
elsif my.container.type = "size"
my.container.python_type = "c_size_t"
elsif my.container.type = "real"
my.container.python_type = "c_float"
if my.container.size = "4"
my.container.python_type = "c_float"
elsif my.container.size = "8"
my.container.python_type = "c_double"
endif
elsif my.container.type = "buffer"
# my.container.python_type = "POINTER(c_byte)"
my.container.python_type = "c_void_p"
Expand Down

0 comments on commit dfb1af3

Please sign in to comment.