@@ -5,13 +5,6 @@ use oo_bindgen::native_struct::StructElementType;
55use oo_bindgen:: * ;
66
77pub fn define ( lib : & mut LibraryBuilder ) -> Result < ( ) , BindingError > {
8- let other_structure = lib. declare_native_struct ( "OtherStructure" ) ?;
9- let other_structure = lib
10- . define_native_struct ( & other_structure) ?
11- . add ( "test" , StructElementType :: Uint16 ( Some ( 41 ) ) , "test" ) ?
12- . doc ( "Structure within a structure" ) ?
13- . build ( ) ?;
14-
158 let structure_enum = lib
169 . define_native_enum ( "StructureEnum" ) ?
1710 . push ( "Var1" , "Var1" ) ?
@@ -20,6 +13,26 @@ pub fn define(lib: &mut LibraryBuilder) -> Result<(), BindingError> {
2013 . doc ( "Enum" ) ?
2114 . build ( ) ?;
2215
16+ let other_structure = lib. declare_native_struct ( "OtherStructure" ) ?;
17+ let other_structure = lib
18+ . define_native_struct ( & other_structure) ?
19+ . add ( "test" , StructElementType :: Uint16 ( Some ( 41 ) ) , "test" ) ?
20+ // The following pattern used to crash in Java because of the way we handled boolean
21+ . add (
22+ "first_enum_value" ,
23+ StructElementType :: Enum ( structure_enum. clone ( ) , Some ( "Var2" . to_string ( ) ) ) ,
24+ "first_enum_value" ,
25+ ) ?
26+ . add ( "bool1" , StructElementType :: Sint16 ( Some ( 1 ) ) , "bool1" ) ?
27+ . add ( "bool2" , StructElementType :: Bool ( Some ( false ) ) , "bool2" ) ?
28+ . add (
29+ "second_enum_value" ,
30+ StructElementType :: Enum ( structure_enum. clone ( ) , Some ( "Var2" . to_string ( ) ) ) ,
31+ "second_enum_value" ,
32+ ) ?
33+ . doc ( "Structure within a structure" ) ?
34+ . build ( ) ?;
35+
2336 let structure = lib. declare_native_struct ( "Structure" ) ?;
2437
2538 let structure_interface = lib
@@ -33,11 +46,26 @@ pub fn define(lib: &mut LibraryBuilder) -> Result<(), BindingError> {
3346
3447 let structure = lib
3548 . define_native_struct ( & structure) ?
49+ . add (
50+ "enum_value" ,
51+ StructElementType :: Enum ( structure_enum. clone ( ) , Some ( "Var2" . to_string ( ) ) ) ,
52+ "enum_value" ,
53+ ) ?
3654 . add (
3755 "boolean_value" ,
3856 StructElementType :: Bool ( Some ( true ) ) ,
3957 "boolean_value" ,
4058 ) ?
59+ . add (
60+ "boolean_value2" ,
61+ StructElementType :: Bool ( Some ( true ) ) ,
62+ "boolean_value2" ,
63+ ) ?
64+ . add (
65+ "enum_value2" ,
66+ StructElementType :: Enum ( structure_enum, Some ( "Var2" . to_string ( ) ) ) ,
67+ "enum_value2" ,
68+ ) ?
4169 . add (
4270 "uint8_value" ,
4371 StructElementType :: Uint8 ( Some ( 1 ) ) ,
@@ -98,11 +126,6 @@ pub fn define(lib: &mut LibraryBuilder) -> Result<(), BindingError> {
98126 Type :: Struct ( other_structure) ,
99127 "structure_value" ,
100128 ) ?
101- . add (
102- "enum_value" ,
103- StructElementType :: Enum ( structure_enum, Some ( "Var2" . to_string ( ) ) ) ,
104- "enum_value" ,
105- ) ?
106129 . add (
107130 "interface_value" ,
108131 Type :: Interface ( structure_interface) ,
0 commit comments