File tree Expand file tree Collapse file tree 8 files changed +58
-0
lines changed
src/test/scala/org/scalanative/bindgen/samples Expand file tree Collapse file tree 8 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include "Enum.h"
2
+
3
+ enum days get_WEDNESDAY () { return WEDNESDAY ; }
4
+
5
+ char * check_BIG_NEG_A (enum bigNegativeValues big_neg_a ) {
6
+ if (big_neg_a == BIG_NEG_A ) {
7
+ return "OK" ;
8
+ }
9
+ return "FAIL" ;
10
+ }
Original file line number Diff line number Diff line change @@ -21,3 +21,7 @@ enum { // anonymous enum
21
21
enum negativeValues { NEG_A = -1 , NEG_B = -2 };
22
22
23
23
enum bigNegativeValues { BIG_NEG_A = -10000000000 , BIG_NEG_B = -1 };
24
+
25
+ enum days get_WEDNESDAY ();
26
+
27
+ char * check_BIG_NEG_A (enum bigNegativeValues big_neg_a );
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ object Enum {
10
10
type enum_bigValues = native.CUnsignedLong
11
11
type enum_negativeValues = native.CInt
12
12
type enum_bigNegativeValues = native.CLong
13
+ def get_WEDNESDAY (): enum_days = native.extern
14
+ def check_BIG_NEG_A (big_neg_a : enum_bigNegativeValues): native.CString = native.extern
13
15
}
14
16
15
17
import Enum ._
Original file line number Diff line number Diff line change
1
+ #include "Struct.h"
2
+ #include <stdlib.h>
3
+
4
+ point_s getPoint () {
5
+ point_s point = malloc (sizeof (struct point ));
6
+ point -> x = 10 ;
7
+ point -> y = 20 ;
8
+ return point ;
9
+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ struct point {
4
4
};
5
5
6
6
typedef struct point * point_s ;
7
+
8
+ point_s getPoint ();
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import scala.scalanative.native._
8
8
object Struct {
9
9
type point_s = native.Ptr [struct_point]
10
10
type struct_point = native.CStruct2 [native.CInt , native.CInt ]
11
+ def getPoint (): native.Ptr [struct_point] = native.extern
11
12
}
12
13
13
14
import Struct ._
Original file line number Diff line number Diff line change
1
+ package org .scalanative .bindgen .samples
2
+
3
+ import utest ._
4
+ import scalanative .native ._
5
+
6
+ object EnumTests extends TestSuite {
7
+ val tests = Tests {
8
+ ' get_WEDNESDAY - {
9
+ assert(Enum .get_WEDNESDAY() == EnumEnums .enum_days_WEDNESDAY)
10
+ }
11
+
12
+ ' check_BIG_NEG_A - {
13
+ assert(Enum .check_BIG_NEG_A(EnumEnums .enum_bigNegativeValues_BIG_NEG_A) == c " OK " )
14
+ }
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ package org .scalanative .bindgen .samples
2
+
3
+ import utest ._
4
+ import org .scalanative .bindgen .samples .StructHelpers ._
5
+
6
+ object StructTests extends TestSuite {
7
+ val tests = Tests {
8
+ ' getPoint - {
9
+ val point = Struct .getPoint()
10
+ assert(point.x == 10 )
11
+ assert(point.y == 20 )
12
+ }
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments