Browse Source

Differentiate between Int and Bool return types when exporting to cppia

hughsando 6 years ago
parent
commit
1edc7ff7bf
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/generators/gencpp.ml

+ 2 - 1
src/generators/gencpp.ml

@@ -6149,9 +6149,10 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
          let isTemplated = not isStatic && not class_def.cl_interface in
          let isTemplated = not isStatic && not class_def.cl_interface in
          if isTemplated then output_cpp ("\ntemplate<bool _HX_SUPER=false>");
          if isTemplated then output_cpp ("\ntemplate<bool _HX_SUPER=false>");
          output_cpp ("\nstatic void CPPIA_CALL " ^ scriptName ^ "(hx::CppiaCtx *ctx) {\n");
          output_cpp ("\nstatic void CPPIA_CALL " ^ scriptName ^ "(hx::CppiaCtx *ctx) {\n");
-         let ret = script_signature return_type false in
+         let ret = match cpp_type_of ctx return_type with TCppScalar("bool") -> "b" | _ -> script_signature return_type false in
          if (ret<>"v") then output_cpp ("ctx->return" ^ (script_type return_type false) ^ "(");
          if (ret<>"v") then output_cpp ("ctx->return" ^ (script_type return_type false) ^ "(");
 
 
+
          let dump_call cast =
          let dump_call cast =
             if class_def.cl_interface then begin
             if class_def.cl_interface then begin
                output_cpp (class_name ^ "::" ^ callName ^ "(ctx->getThis()" ^ (if (List.length args) > 0 then "," else ""));
                output_cpp (class_name ^ "::" ^ callName ^ "(ctx->getThis()" ^ (if (List.length args) > 0 then "," else ""));