Fix bool type; its actually 1 byte not 4 in structs. Bug reported by jedahu

db4
Slava Pestov 2009-05-05 18:37:40 -05:00
parent 4ee5815843
commit 58d0e17936
4 changed files with 32 additions and 4 deletions

View File

@ -409,10 +409,10 @@ CONSTANT: primitive-types
"uchar" define-primitive-type
<c-type>
[ alien-unsigned-4 zero? not ] >>getter
[ [ 1 0 ? ] 2dip set-alien-unsigned-4 ] >>setter
4 >>size
4 >>align
[ alien-unsigned-1 zero? not ] >>getter
[ [ 1 0 ? ] 2dip set-alien-unsigned-1 ] >>setter
1 >>size
1 >>align
"box_boolean" >>boxer
"to_boolean" >>unboxer
"bool" define-primitive-type

View File

@ -588,3 +588,16 @@ FUNCTION: complex-float ffi_test_47 ( complex-float x, complex-double y ) ;
C{ 1.0 2.0 }
C{ 1.5 1.0 } ffi_test_47
] unit-test
! Reported by jedahu
C-STRUCT: bool-field-test
{ "char*" "name" }
{ "bool" "on" }
{ "short" "parents" } ;
FUNCTION: short ffi_test_48 ( bool-field-test x ) ;
[ 123 ] [
"bool-field-test" <c-object> 123 over set-bool-field-test-parents
ffi_test_48
] unit-test

View File

@ -319,3 +319,8 @@ _Complex float ffi_test_47(_Complex float x, _Complex double y)
{
return x + 2 * y;
}
short ffi_test_48(struct bool_field_test x)
{
return x.parents;
}

View File

@ -1,3 +1,5 @@
#include <stdbool.h>
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32)
#define F_STDCALL __attribute__((stdcall))
#else
@ -102,3 +104,11 @@ F_EXPORT _Complex float ffi_test_45(int x);
F_EXPORT _Complex double ffi_test_46(int x);
F_EXPORT _Complex float ffi_test_47(_Complex float x, _Complex double y);
struct bool_field_test {
char *name;
bool on;
short parents;
};
F_EXPORT short ffi_test_48(struct bool_field_test x);