Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/generators/cpp/gen/cppGenClassImplementation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -977,20 +977,20 @@ let generate_managed_class base_ctx tcpp_class =
if List.length tcpp_class.tcl_functions > 0 || List.length tcpp_class.tcl_static_functions > 0 then (

let dump_script is_static f acc =
if not f.tcf_is_overriding && f.tcf_name <> "toString" then (* toString implicitly overrides hx::Object::toString *)
let signature = generate_script_function is_static f.tcf_field ("__s_" ^ f.tcf_field.cf_name) f.tcf_name in
let superCall = if is_static then "0" else "__s_" ^ f.tcf_field.cf_name ^ "<true>" in
let named =
Printf.sprintf
"\t::hx::ScriptNamedFunction(\"%s\", __s_%s, \"%s\", %s HXCPP_CPPIA_SUPER_ARG(%s))"
f.tcf_field.cf_name
f.tcf_field.cf_name
signature
(if is_static then "true" else "false")
superCall in

named :: acc
else acc
let signature = generate_script_function is_static f.tcf_field ("__s_" ^ f.tcf_field.cf_name) f.tcf_name in
let superCall = if is_static then "0" else "__s_" ^ f.tcf_field.cf_name ^ "<true>" in
let named =
Printf.sprintf
"\t::hx::ScriptNamedFunction(\"%s\", __s_%s, \"%s\", %s, %s HXCPP_CPPIA_SUPER_ARG(%s))"
f.tcf_field.cf_name
f.tcf_field.cf_name
signature
(if is_static then "true" else "false")
(* toString implicitly overrides hx::Object::toString *)
(if f.tcf_is_overriding || f.tcf_name = "toString" then "true" else "false")
superCall in

named :: acc
in

let sigs =
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/src/scripthost/Issue12413.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package scripthost;

#if cpp
@:keep class HostParent12413 {
public function new() {}

public function methodA() {
return "HostParent";
}
}

@:keep class HostChild12413 extends HostParent12413 {
override function methodA() {
return super.methodA() + ", HostChild";
}
}
#end
20 changes: 20 additions & 0 deletions tests/unit/src/unit/issues/Issue12413.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package unit.issues;

import scripthost.Issue12413;

class Issue12413 extends Test {
#if cppia
public function test() {
var child:ScriptChild = new ScriptChild();
eq('HostParent, HostChild, ScriptChild', child.methodA());
}
#end
}

#if cppia
private class ScriptChild extends HostChild12413 {
override function methodA() {
return super.methodA() + ", ScriptChild";
}
}
#end
Loading