Created
July 17, 2011 09:02
-
-
Save gaspard/1087380 to your computer and use it in GitHub Desktop.
Simple C++ class with C interface for Luajit ffi bindings
This file contains hidden or 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
// g++ simple.cpp -shared -o libsimple.dylib | |
#include <stdio.h> | |
class Simple { | |
int id_; | |
public: | |
Simple(int id); | |
~Simple(); | |
int id(); | |
}; | |
Simple::Simple(int id) : id_(id) { | |
printf("[%p:%i] Simple()\n", this, id_); | |
} | |
Simple::~Simple() { | |
printf("[%p:%i] ~Simple()\n", this, id_); | |
} | |
int Simple::id() { | |
return id_; | |
} | |
extern "C" { | |
Simple *Simple_Simple(int id) { | |
return new Simple(id); | |
} | |
void Simple__gc(Simple *this_) { | |
delete this_; | |
} | |
int Simple_id(Simple *this_) { | |
return this_->id(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment