Skip to content

Commit

Permalink
integers are now 64 bits
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Sep 10, 2024
1 parent 2084c55 commit 2b3b3fe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
7 changes: 7 additions & 0 deletions cognac_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ ${indent_plus}TRY(!aa, "$a argument missing\n");
${indent_plus}s->is_set_$snake_a = 1;
${indent_plus}s->$snake_a = atoi(aa);
$indent_base } else
EOF
elif [ 'long long int' == "$type" ]; then
cat <<EOF
${indent_plus}TRY(!aa, "$a argument missing\n");
${indent_plus}s->is_set_$snake_a = 1;
${indent_plus}s->$snake_a = atoll(aa);
$indent_base } else
EOF
elif [ 'double' == "$type" ]; then
cat <<EOF
Expand Down
4 changes: 4 additions & 0 deletions construct_data.c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ for x in $args ;do
snake_x=$( if [ "default" == "$snake_x" ] ; then echo default_arg; else echo $snake_x; fi )
t=$(get_type $func $x)

if [ "$t" == 'long long int' ]; then
t='int'
fi

if [ "$t" == 'bool' ]; then
cat <<EOF
if (args->is_set_$snake_x) {
Expand Down
4 changes: 2 additions & 2 deletions helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ get_type_direct() {
local have_one_of=$?
if [ $have_type == 0 -a "$types" != 'null' ]; then
if [ "$types" == 'integer' ]; then
echo int
echo "long long int"
return 0
elif [ "$types" == 'number' ]; then
echo double
Expand Down Expand Up @@ -161,7 +161,7 @@ get_type() {
have_type=$?
if [ $have_type == 0 ]; then
if [ "$types" == 'integer' ]; then
echo int
echo "long long int"
return 0
elif [ "$types" == 'number' ]; then
echo double
Expand Down
4 changes: 2 additions & 2 deletions lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ int osc_str_append_bool(struct osc_str *osc_str, int bool)
return 0;
}

int osc_str_append_int(struct osc_str *osc_str, int i)
int osc_str_append_int(struct osc_str *osc_str, long long int i)
{
int len = osc_str->len;
assert(osc_str);

osc_str->buf = osc_realloc(osc_str->buf, len + 64);
if (!osc_str->buf)
return -1;
osc_str->len = len + snprintf(osc_str->buf + len, 64, "%d", i);
osc_str->len = len + snprintf(osc_str->buf + len, 64, "%lld", i);
osc_str->buf[osc_str->len] = 0;
return 0;
}
Expand Down
4 changes: 3 additions & 1 deletion mk_args.c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ type_to_ctype() {
local snake_name="$2"
local c_type="char *"

if [ "$t" == 'int' -o "$t" == 'bool' -o "$t" == 'double' ]; then
if [ "$t" == 'int' -o "$t" == 'bool' -o "$t" == 'double' -o "$t" == 'long long int' ]; then
snake_name=$( if [ "default" == "$snake_name" ] ; then echo default_arg; else echo $snake_name; fi )
echo " int is_set_${snake_name};"
if [ "$t" == 'double' ]; then
c_type="double "
elif [ "$t" == 'long long int' ]; then
c_type="long long int "
else
c_type="int "
fi
Expand Down

0 comments on commit 2b3b3fe

Please sign in to comment.