get_name xThis means a C primitive type can be accessed using the dot notation provided you supply appropriate projection functions.
1: #line 299 "./lpsrc/flx_tut_bind.pak" 2: #import <flx.flxh> 3: 4: // part 1 5: header """ 6: struct gauss 7: { 8: int x; 9: int y; 10: gauss() : x(0), y(0) {} 11: gauss(int _x, int _y) : x(_x), y(_y) {} 12: 13: }; 14: """; 15: 16: type gauss = "gauss"; 17: fun get_x: gauss -> int = "$1.x"; 18: fun get_y: gauss -> int = "$1.y"; 19: fun mkgauss: int * int -> gauss = "gauss($1,$2)"; 20: 21: val z = mkgauss(1,2); 22: print z.x; 23: print ", "; 24: print z.y; 25: endl; 26: 27: /* 28: THIS FEATURE NOW OBSOLETE. FELIX STRUCTS 29: NO LONGER PROVIDE GET METHODS FOR C INTERFACING. 30: 31: // part 2 32: struct X { 33: x : int; 34: } 35: val i = X(1); 36: print (get_x i); 37: endl; 38: */ 39:
In part 2, the functions get_x and get_y are defined by defining a struct, and they're called directly, without the dot notation.
The dot notation is just syntactic sugar for calling a get function.
What is more, the struct definition is just syntactic sugar for defining an abstract type with some get functions (as well as a constructor).
What this means is that for an arbitrary C++ type, you can create an abstract binding, and define get methods which can be called using dot notation. Just name the methods 'get_' something.
It is also possible to access a Felix struct from C++, although we'll defer disucssion of the C++ representation of Felix data structures until later. [The C++ name of the struct type is not the same as the Felix name]