Last active
August 29, 2015 14:28
-
-
Save back2dos/1e21fbc3506aec285055 to your computer and use it in GitHub Desktop.
Out args for hxcpp.
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
| #ifndef INCLUDED_Main | |
| #define INCLUDED_Main | |
| #ifndef HXCPP_H | |
| #include <hxcpp.h> | |
| #endif | |
| HX_DECLARE_CLASS0(Main) | |
| class HXCPP_CLASS_ATTRIBUTES Main_obj : public hx::Object{ | |
| public: | |
| typedef hx::Object super; | |
| typedef Main_obj OBJ_; | |
| Main_obj(); | |
| Void __construct(); | |
| public: | |
| inline void *operator new( size_t inSize, bool inContainer=false,const char *inName="Main") | |
| { return hx::Object::operator new(inSize,inContainer,inName); } | |
| static hx::ObjectPtr< Main_obj > __new(); | |
| static Dynamic __CreateEmpty(); | |
| static Dynamic __Create(hx::DynamicArray inArgs); | |
| //~Main_obj(); | |
| HX_DO_RTTI_ALL; | |
| static bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp); | |
| static void __register(); | |
| ::String __ToString() const { return HX_HCSTRING("Main","\x59","\x64","\x2f","\x33"); } | |
| static Void modify_String( ::String * x,::String value); | |
| static Void modify_Int( int * x,int value); | |
| static Void main( ); | |
| static Dynamic main_dyn(); | |
| }; | |
| #endif /* INCLUDED_Main */ |
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
| package; | |
| import cpp.*; | |
| class Main { | |
| static function main() { | |
| var x = 3; | |
| modify(x, 4); | |
| trace(x);//4 | |
| var y = 'foo'; | |
| modify(y, null); | |
| trace(y);//null | |
| modify(y, 'bar'); | |
| trace(y);//bar | |
| var x = 4; | |
| } | |
| @:unreflective //this avoids "error: conversion from 'const Dynamic' to '<T>*' is ambiguous" caused by STATIC_HX_DEFINE_DYNAMIC_FUNC - which is of no concern for externs | |
| @:generic //this avoids "no known conversion for argument 1 from '<T>*' to 'Dynamic*'" - which is only due to type parameters, so should not be an issue for most externs | |
| static function modify<T>(x:RawOut<T>, value:T):Void { | |
| Pointer.fromRaw(x).set_ref(value); | |
| } | |
| } | |
| @:notNull | |
| abstract RawOut<T>(RawPointer<T>) from RawPointer<T> to RawPointer<T> { | |
| @:from @:extern static inline function of<T>(v:T):RawOut<T> { | |
| return untyped __cpp__("&{0}", v); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment