Skip to content

Instantly share code, notes, and snippets.

@Skarsnik
Created January 6, 2016 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skarsnik/003b499ec8a0ad20193d to your computer and use it in GitHub Desktop.
Save Skarsnik/003b499ec8a0ad20193d to your computer and use it in GitHub Desktop.
root@testperl6:~/piko/gptrixie# perl6 -I lib bin/gptrixie --functions --define-enum=TestType:HELLO_ --structs examples/test.h
Calling GCCXML : gccxml examples/test.h -fxml=plop.xml
Parsing the XML file
Doing magic
Time to generate stuff
enum TestType is export = (
HELLO_INT => 0,
HELLO_FLOAT => 1,
HELLO_TEXT => 3
);
sub do_stuff is native(LIB) returns Pointer (s1 $s, size_t $piko, bool $b) is export { * }
sub pretty_print is native(LIB) (Str $toprint) is export { * }
class s1 is repr('CStruct') is export {
has int32 $.a; # int a
has num32 $.b; # float b
has num64 $.c; # double c
has Str $.d; # char* d
}
class s2 is repr('CStruct') is export {
HAS s1 $.a; # s1 a
has my64bits $.b; # Typedef(my64bits)->long long unsigned int b
has CArray[int32] $.c; # int[] c
has CArray[num64] $.d; # double[4] d
}
root@testperl6:~/piko/gptrixie#
#include <stdbool.h>
#include <stddef.h>
#define HELLO_INT 0
#define HELLO_FLOAT 1
#define HELLO_TEXT 3
typedef unsigned long long int my64bits;
typedef struct s1 {
int a;
float b;
double c;
char *d;
};
struct s2 {
s1 a;
my64bits b;
int c[];
double d[4];
};
void pretty_print(const char *toprint);
void *do_stuff(s1 s,
size_t piko,
bool b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment