Skip to content

Commit 319b84b

Browse files
committed
Update to latest gencpp changes
1 parent 9d32634 commit 319b84b

File tree

8 files changed

+285
-196
lines changed

8 files changed

+285
-196
lines changed

src/compiler/compiler.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ module Setup = struct
133133
add_std "php";
134134
"php"
135135
| Cpp ->
136-
Common.define_value com Define.HxcppApiLevel "430";
136+
Common.define_value com Define.HxcppApiLevel "500";
137137
add_std "cpp";
138138
if Common.defined com Define.Cppia then
139139
actx.classes <- (Path.parse_path "cpp.cppia.HostClasses" ) :: actx.classes;

src/generators/cpp/cppAst.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ type tcpp =
6464
| TCppAutoCast
6565
| TCppDynamicArray
6666
| TCppObjectArray of tcpp
67-
| TCppWrapped of tcpp
67+
| TCppCallable of tcpp list * tcpp
6868
| TCppScalarArray of tcpp
6969
| TCppObjC of tclass
7070
| TCppNativePointer of tclass
71-
| TCppVariant
71+
| TCppVariant of tcpp option
7272
| TCppCode of tcpp
7373
| TCppInst of tclass * tcpp list
7474
| TCppInterface of tclass
@@ -100,7 +100,10 @@ and tcppvarloc =
100100
| VarStatic of tclass * bool * tclass_field
101101
| VarInternal of tcppexpr * string * string
102102

103-
and tcppinst = InstPtr | InstObjC | InstStruct
103+
and tcppinst =
104+
| InstPtr of tcpp
105+
| InstObjC
106+
| InstStruct
104107

105108
and tcppfuncloc =
106109
| FuncThis of tclass_field * tcpp
@@ -143,7 +146,7 @@ and tcpp_expr_expr =
143146
| CppThis of tcppthis
144147
| CppSuper of tcppthis
145148
| CppCode of string * tcppexpr list
146-
| CppClosure of tcpp_closure
149+
| CppCallable of tcpp_closure
147150
| CppVar of tcppvarloc
148151
| CppExtern of string * bool
149152
| CppDynamicField of tcppexpr * string
@@ -211,6 +214,7 @@ and tcpp_class_function = {
211214
tcf_field : tclass_field;
212215
tcf_name : string;
213216
tcf_func : tfunc;
217+
tcf_callable : tcpp;
214218

215219
tcf_is_virtual : bool;
216220
tcf_is_reflective : bool;

src/generators/cpp/cppAstTools.ml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ let rec s_tcpp = function
276276
| CppThis _ -> "CppThis"
277277
| CppSuper _ -> "CppSuper"
278278
| CppCode _ -> "CppCode"
279-
| CppClosure _ -> "CppClosure"
279+
| CppCallable _ -> "CppCallable"
280280
| CppVar (VarLocal _) -> "CppVarLocal"
281281
| CppVar (VarClosure _) -> "CppVarClosure"
282282
| CppVar (VarThis _) -> "CppVarThis"
@@ -296,7 +296,7 @@ let rec s_tcpp = function
296296
| CppCall (FuncInstance (obj, inst, field), _) ->
297297
(match inst with
298298
| InstObjC -> "CppCallObjCInstance("
299-
| InstPtr -> "CppCallInstance("
299+
| InstPtr _ -> "CppCallInstance("
300300
| _ -> "CppCallStruct(")
301301
^ tcpp_to_string obj.cpptype ^ "," ^ field.cf_name ^ ")"
302302
| CppCall (FuncInterface _, _) -> "CppCallInterface"
@@ -366,7 +366,13 @@ and tcpp_to_string_suffix suffix tcpp =
366366
| TCppRest _ -> "vaarg_list"
367367
| TCppVarArg -> "vararg"
368368
| TCppAutoCast -> "::cpp::AutoCast"
369-
| TCppVariant -> "::cpp::Variant"
369+
| TCppVariant None -> "::cpp::Variant"
370+
| TCppVariant Some t -> Printf.sprintf "::cpp::Variant( %s )" (tcpp_to_string t)
371+
| TCppCallable (arguments, return) ->
372+
let return_str = tcpp_to_string return in
373+
let arguments_str = arguments |> List.map tcpp_to_string |> String.concat "," in
374+
375+
Printf.sprintf "::hx::Callable< %s ( %s ) >" return_str arguments_str
370376
| TCppEnum enum -> " ::" ^ join_class_path_remap enum.e_path "::" ^ suffix
371377
| TCppScalar scalar -> scalar
372378
| TCppString -> "::String"
@@ -384,7 +390,6 @@ and tcpp_to_string_suffix suffix tcpp =
384390
tcpp_objc_block_struct argTypes retType ^ "::t"
385391
| TCppDynamicArray -> "::cpp::VirtualArray" ^ suffix
386392
| TCppObjectArray _ -> "::Array" ^ suffix ^ "< ::Dynamic>"
387-
| TCppWrapped _ -> " ::Dynamic"
388393
| TCppScalarArray value ->
389394
"::Array" ^ suffix ^ "< " ^ tcpp_to_string value ^ " >"
390395
| TCppObjC klass ->
@@ -647,7 +652,7 @@ let rec cpp_is_native_array_access t =
647652
| _ -> false
648653

649654
let cpp_is_dynamic_type = function
650-
| TCppDynamic | TCppObject | TCppVariant | TCppWrapped _ | TCppGlobal | TCppNull
655+
| TCppDynamic | TCppObject | TCppVariant _ | TCppGlobal | TCppNull
651656
| TCppInterface _
652657
-> true
653658
| _ -> false
@@ -665,10 +670,10 @@ let is_object_element member_type =
665670
| TCppFunction _
666671
| TCppDynamicArray
667672
| TCppObjectArray _
668-
| TCppWrapped _
669673
| TCppScalarArray _
670674
| TCppClass
671-
-> true
675+
| TCppCallable _
676+
-> true
672677
| _ -> false
673678

674679
let cpp_variant_type_of t = match t with
@@ -684,7 +689,6 @@ let cpp_variant_type_of t = match t with
684689
| TCppDynamicArray
685690
| TCppObjectArray _
686691
| TCppScalarArray _
687-
| TCppWrapped _
688692
| TCppObjC _
689693
| TCppObjCBlock _
690694
| TCppRest _
@@ -695,6 +699,7 @@ let cpp_variant_type_of t = match t with
695699
| TCppClass
696700
| TCppGlobal
697701
| TCppNull
702+
| TCppCallable _
698703
| TCppEnum _ -> TCppDynamic
699704
| TCppString -> TCppString
700705
| TCppFunction _
@@ -711,7 +716,7 @@ let cpp_variant_type_of t = match t with
711716
| TCppScalar "double"
712717
| TCppScalar "float" -> TCppScalar("Float")
713718
| TCppScalar _ -> TCppScalar("int")
714-
| TCppVariant -> TCppVariant
719+
| TCppVariant v -> TCppVariant v
715720

716721
let cpp_cast_variant_type_of t = match t with
717722
| TCppObjectArray _

0 commit comments

Comments
 (0)