Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Ext.cpp class
- #include <iostream>
- class Ext
- {
- public:
- Ext(int init){
- std::cout << "you made me\n";
- b = init;
- }
- void squawk()
- {
- std::cout << "hello ext\n";
- }
- int adderize(int a)
- {
- b+=a;
- std::cout << "b is now "<<b<<"\n";
- return b;
- }
- private:
- int b;
- };
- //Ext.hx class
- package;
- import cpp.Pointer;
- @:include("./Ext.cpp")
- @:structAccess
- extern class Ext
- {
- @:native("new Ext")
- public static function create (init:Int) : Pointer<Ext>;
- @:native("squawk")
- public function squawk():Void;
- @:native("adderize")
- public function adderize(a:Int):Int;
- public function bleet():Void{
- trace("I'm a real boy!");
- }
- }
- //Main.hx
- package;
- class Main
- {
- static function main()
- {
- var ext = Ext.create(35); //you made me
- var myext = ext.get_ref();
- myext.squawk(); //hello ext
- trace(myext.adderize(2)); //b is now 37 \n Main.hx:16:37
- //myext.bleet(); //uncomment for compile error: ./src/Main.cpp(42): error C2039: 'bleet': is not a member of 'Ext'
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement