This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% ./test.lua | |
101 | |
202 | |
x=101, y=202 | |
number | |
number | |
function | |
/***** struct metatable *****/ | |
.type Point | |
__gc function: 0x7fced2eaf0a1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/lua | |
package.loadlib('./example.so', 'luaopen_example')() | |
A = example.Point() | |
A.x = 101 | |
A.y = 202 | |
print(A.x) | |
print(A.y) | |
A:greet() | |
print(swig_type(A.x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "example.hpp" | |
#include <cstdio> | |
void Point::greet() | |
{ | |
printf("x=%d, y=%d\n", x, y); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Point | |
{ | |
int x; | |
int y; | |
void greet(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/lua | |
package.loadlib('./example.so', 'luaopen_example')() | |
A = example.MyClass(6, 7) | |
A:greet() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <example.hpp> | |
#include <ctime> | |
#include <cstdio> | |
MyClass::MyClass(int a, int b): x(a), y(b) {} | |
void MyClass::greet() | |
{ | |
printf("Hello, world: x=%d y=%d\n", x, y); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
{ | |
public: | |
MyClass(int a, int b); | |
void greet(); | |
private: | |
int x; | |
int y; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%module example | |
%{ | |
/* Includes the header in the wrapper code */ | |
#include "example.hpp" | |
%} | |
/* Parse the header file to generate wrappers */ | |
%include "example.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <example.hpp> | |
#include <ctime> | |
double My_variable = 3.0; | |
int fact(int n) { | |
if (n <= 1) return 1; | |
else return n*fact(n-1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern double My_variable; | |
int fact(int n); | |
int my_mod(int x, int y); | |
char *get_time(); |
NewerOlder