|
@@ -1340,6 +1340,7 @@ let hx_stack_push ctx output clazz func_name pos =
|
|
type tcpp =
|
|
type tcpp =
|
|
| TCppDynamic
|
|
| TCppDynamic
|
|
| TCppObject
|
|
| TCppObject
|
|
|
|
+ | TCppObjectPtr
|
|
| TCppVoid
|
|
| TCppVoid
|
|
| TCppNull
|
|
| TCppNull
|
|
| TCppEnum of tenum
|
|
| TCppEnum of tenum
|
|
@@ -1425,6 +1426,7 @@ and tcppfuncloc =
|
|
| FuncSuper of tcppthis * tclass_field
|
|
| FuncSuper of tcppthis * tclass_field
|
|
| FuncNew of tcpp
|
|
| FuncNew of tcpp
|
|
| FuncDynamic of tcppexpr
|
|
| FuncDynamic of tcppexpr
|
|
|
|
+ | FuncFunctionPtr of tcppexpr
|
|
| FuncInternal of tcppexpr * string * string
|
|
| FuncInternal of tcppexpr * string * string
|
|
| FuncGlobal of string
|
|
| FuncGlobal of string
|
|
| FuncFromStaticFunction
|
|
| FuncFromStaticFunction
|
|
@@ -1537,6 +1539,7 @@ let rec s_tcpp = function
|
|
| CppCall (FuncSuper _,_) -> "CppCallSuper"
|
|
| CppCall (FuncSuper _,_) -> "CppCallSuper"
|
|
| CppCall (FuncNew _,_) -> "CppCallNew"
|
|
| CppCall (FuncNew _,_) -> "CppCallNew"
|
|
| CppCall (FuncDynamic _,_) -> "CppCallDynamic"
|
|
| CppCall (FuncDynamic _,_) -> "CppCallDynamic"
|
|
|
|
+ | CppCall (FuncFunctionPtr _,_) -> "CppCallFunctionPtr"
|
|
| CppCall (FuncInternal _,_) -> "CppCallInternal"
|
|
| CppCall (FuncInternal _,_) -> "CppCallInternal"
|
|
| CppCall (FuncGlobal _,_) -> "CppCallGlobal"
|
|
| CppCall (FuncGlobal _,_) -> "CppCallGlobal"
|
|
| CppCall (FuncFromStaticFunction,_) -> "CppCallFromStaticFunction"
|
|
| CppCall (FuncFromStaticFunction,_) -> "CppCallFromStaticFunction"
|
|
@@ -1580,6 +1583,7 @@ let rec s_tcpp = function
|
|
and tcpp_to_string_suffix suffix tcpp = match tcpp with
|
|
and tcpp_to_string_suffix suffix tcpp = match tcpp with
|
|
| TCppDynamic -> " ::Dynamic"
|
|
| TCppDynamic -> " ::Dynamic"
|
|
| TCppObject -> " ::Dynamic"
|
|
| TCppObject -> " ::Dynamic"
|
|
|
|
+ | TCppObjectPtr -> " ::hx::Object *"
|
|
| TCppReference t -> (tcpp_to_string t) ^" &"
|
|
| TCppReference t -> (tcpp_to_string t) ^" &"
|
|
| TCppStar t -> (tcpp_to_string t) ^" *"
|
|
| TCppStar t -> (tcpp_to_string t) ^" *"
|
|
| TCppVoid -> "void"
|
|
| TCppVoid -> "void"
|
|
@@ -1763,6 +1767,7 @@ let rec cpp_type_of ctx haxe_type =
|
|
| ([], "Class"),_ -> TCppClass
|
|
| ([], "Class"),_ -> TCppClass
|
|
| ([], "Enum"),_ -> TCppClass
|
|
| ([], "Enum"),_ -> TCppClass
|
|
| (["cpp"], "Char"),_ -> TCppScalar("char")
|
|
| (["cpp"], "Char"),_ -> TCppScalar("char")
|
|
|
|
+ | (["cpp"], "Object"),_ -> TCppObjectPtr
|
|
| (["cpp"], "Float32"),_ -> TCppScalar("float")
|
|
| (["cpp"], "Float32"),_ -> TCppScalar("float")
|
|
| (["cpp"], "Float64"),_ -> TCppScalar("double")
|
|
| (["cpp"], "Float64"),_ -> TCppScalar("double")
|
|
| (["cpp"], "Int8"),_ -> TCppScalar("signed char")
|
|
| (["cpp"], "Int8"),_ -> TCppScalar("signed char")
|
|
@@ -1790,7 +1795,8 @@ let rec cpp_type_of ctx haxe_type =
|
|
TCppRawPointer("const ", cpp_type_of ctx p)
|
|
TCppRawPointer("const ", cpp_type_of ctx p)
|
|
| (["cpp"],"Function"), [function_type; abi] ->
|
|
| (["cpp"],"Function"), [function_type; abi] ->
|
|
cpp_function_type_of ctx function_type abi;
|
|
cpp_function_type_of ctx function_type abi;
|
|
- | (["cpp"],"Callable"), [function_type] ->
|
|
|
|
|
|
+ | (["cpp"],"Callable"), [function_type]
|
|
|
|
+ | (["cpp"],"CallableData"), [function_type] ->
|
|
cpp_function_type_of_string ctx function_type "";
|
|
cpp_function_type_of_string ctx function_type "";
|
|
| (("cpp"::["objc"]),"BlockPtr"), [function_type] ->
|
|
| (("cpp"::["objc"]),"BlockPtr"), [function_type] ->
|
|
let args,ret = (cpp_function_type_of_args_ret ctx function_type) in
|
|
let args,ret = (cpp_function_type_of_args_ret ctx function_type) in
|
|
@@ -1808,6 +1814,7 @@ let rec cpp_type_of ctx haxe_type =
|
|
TCppDynamicArray
|
|
TCppDynamicArray
|
|
|
|
|
|
| TCppObject
|
|
| TCppObject
|
|
|
|
+ | TCppObjectPtr
|
|
| TCppReference _
|
|
| TCppReference _
|
|
| TCppStar _
|
|
| TCppStar _
|
|
| TCppEnum _
|
|
| TCppEnum _
|
|
@@ -1957,6 +1964,7 @@ let cpp_class_name klass =
|
|
let cpp_variant_type_of t = match t with
|
|
let cpp_variant_type_of t = match t with
|
|
| TCppDynamic
|
|
| TCppDynamic
|
|
| TCppObject
|
|
| TCppObject
|
|
|
|
+ | TCppObjectPtr
|
|
| TCppReference _
|
|
| TCppReference _
|
|
| TCppStar _
|
|
| TCppStar _
|
|
| TCppVoid
|
|
| TCppVoid
|
|
@@ -2483,12 +2491,18 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
|
|
|
|
|
|
| TCall( func, args ) ->
|
|
| TCall( func, args ) ->
|
|
let retypedFunc = retype TCppDynamic func in
|
|
let retypedFunc = retype TCppDynamic func in
|
|
- if retypedFunc.cpptype=TCppNull then
|
|
|
|
|
|
+ (match retypedFunc.cpptype with
|
|
|
|
+ | TCppNull ->
|
|
CppNullAccess, TCppDynamic
|
|
CppNullAccess, TCppDynamic
|
|
- else begin
|
|
|
|
- let cppType = cpp_type_of expr.etype in
|
|
|
|
|
|
+ | TCppFunction(argTypes,retType,_) ->
|
|
|
|
+ let retypedArgs = List.map2 (fun arg wantedType ->
|
|
|
|
+ retype wantedType arg
|
|
|
|
+ ) args argTypes in
|
|
|
|
+ CppCall( FuncFunctionPtr(retypedFunc) ,retypedArgs), retType
|
|
|
|
+ | _ ->
|
|
let retypedArgs = List.map (retype TCppDynamic ) args in
|
|
let retypedArgs = List.map (retype TCppDynamic ) args in
|
|
- match retypedFunc.cppexpr with
|
|
|
|
|
|
+ let cppType = cpp_type_of expr.etype in
|
|
|
|
+ (match retypedFunc.cppexpr with
|
|
| CppFunction(FuncFromStaticFunction ,returnType) ->
|
|
| CppFunction(FuncFromStaticFunction ,returnType) ->
|
|
( match retypedArgs with
|
|
( match retypedArgs with
|
|
| [ {cppexpr=CppFunction( FuncStatic(clazz,false,member), funcReturn)} ] ->
|
|
| [ {cppexpr=CppFunction( FuncStatic(clazz,false,member), funcReturn)} ] ->
|
|
@@ -2557,7 +2571,8 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
|
|
CppCall( FuncDynamic(retypedFunc) ,retypedArgs), cppType
|
|
CppCall( FuncDynamic(retypedFunc) ,retypedArgs), cppType
|
|
| _ ->
|
|
| _ ->
|
|
CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
|
|
CppCall( FuncDynamic(retypedFunc), retypedArgs), TCppDynamic
|
|
- end
|
|
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
|
|
| TNew (clazz,params,args) ->
|
|
| TNew (clazz,params,args) ->
|
|
(* New DynamicArray ? *)
|
|
(* New DynamicArray ? *)
|
|
@@ -2838,6 +2853,7 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
|
|
| TCppScalarArray _
|
|
| TCppScalarArray _
|
|
| TCppNativePointer _
|
|
| TCppNativePointer _
|
|
| TCppDynamicArray
|
|
| TCppDynamicArray
|
|
|
|
+ | TCppObjectPtr
|
|
| TCppInst _
|
|
| TCppInst _
|
|
-> mk_cppexpr (CppCast(cppExpr,return_type)) return_type
|
|
-> mk_cppexpr (CppCast(cppExpr,return_type)) return_type
|
|
|
|
|
|
@@ -2866,6 +2882,9 @@ let retype_expression ctx request_type function_args expression_tree forInjectio
|
|
| TCppStar(TCppDynamic), TCppStar(_) -> cppExpr
|
|
| TCppStar(TCppDynamic), TCppStar(_) -> cppExpr
|
|
| TCppStar(TCppDynamic), t ->
|
|
| TCppStar(TCppDynamic), t ->
|
|
mk_cppexpr retypedExpr (TCppStar(t))
|
|
mk_cppexpr retypedExpr (TCppStar(t))
|
|
|
|
+ | TCppObjectPtr, TCppObjectPtr -> cppExpr
|
|
|
|
+ | _, TCppObjectPtr ->
|
|
|
|
+ mk_cppexpr (CppCast(cppExpr,TCppObjectPtr)) TCppObjectPtr
|
|
| _ -> cppExpr
|
|
| _ -> cppExpr
|
|
in
|
|
in
|
|
retype request_type expression_tree
|
|
retype request_type expression_tree
|
|
@@ -3043,7 +3062,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
|
|
out rename
|
|
out rename
|
|
else
|
|
else
|
|
(out (cpp_class_name clazz); out ("::" ^ (cpp_member_name_of field) ^ "_dyn()"))
|
|
(out (cpp_class_name clazz); out ("::" ^ (cpp_member_name_of field) ^ "_dyn()"))
|
|
- | FuncDynamic(expr) ->
|
|
|
|
|
|
+ | FuncDynamic(expr) | FuncFunctionPtr(expr) ->
|
|
gen expr;
|
|
gen expr;
|
|
| FuncGlobal(name) ->
|
|
| FuncGlobal(name) ->
|
|
out ("::" ^ name);
|
|
out ("::" ^ name);
|
|
@@ -3168,7 +3187,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
|
|
|
|
|
|
| FuncGlobal(name) ->
|
|
| FuncGlobal(name) ->
|
|
out ("::" ^ name);
|
|
out ("::" ^ name);
|
|
- | FuncDynamic(expr) ->
|
|
|
|
|
|
+ | FuncDynamic(expr) | FuncFunctionPtr(expr) ->
|
|
gen expr;
|
|
gen expr;
|
|
);
|
|
);
|
|
let sep = ref "" in
|
|
let sep = ref "" in
|
|
@@ -3551,9 +3570,9 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
|
|
| CppCall( FuncInternal _, _) ->
|
|
| CppCall( FuncInternal _, _) ->
|
|
gen expr; out (".StaticCast< " ^ tcpp_to_string toType ^" >()")
|
|
gen expr; out (".StaticCast< " ^ tcpp_to_string toType ^" >()")
|
|
| _ ->
|
|
| _ ->
|
|
- (match tcpp_to_string toType with
|
|
|
|
- | " ::hx::Object *" -> out ("hx::DynamicPtr("); gen expr; out (")")
|
|
|
|
- | t -> out ("( ("^ t ^")("); gen expr; out (") )")
|
|
|
|
|
|
+ (match toType with
|
|
|
|
+ | TCppObjectPtr -> out ("hx::DynamicPtr("); gen expr; out (")")
|
|
|
|
+ | t -> out ("( ("^ tcpp_to_string t ^")("); gen expr; out (") )")
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
|