本文介绍了如何在Cheerp中保留变量名(从C ++到JavaScript的编译器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cheerp( https://www.leaningtech.com/cheerp/ ),将一些C ++代码转换为JavaScript.是否有保留变量名的选项?看起来名字总是被弄乱了

I'm using Cheerp (https://www.leaningtech.com/cheerp/) to transpile some C++ code into JavaScript.Is there any option to preserve variable names? Looks like the names get always mangled

原始C ++代码:

void myClass::myMethod(int32_T myParam, boolean_T *rty_Result)
{

  switch (myParam) {
   case Mycase1:
   case Mycase2:
   case Mycase3:
   case Mycase4:
   case Mycase5:

    *rty_Result = true;
    break;

   case Mycase6:

    *rty_Result = (filter.field1.field2 == 1);
    break;

   default:
    *rty_Result = false;
    break;
  }
}

Cheerp的输出:

Output from Cheerp:

function __ZN8JsBridge12AvailabilityEP9bFilter_Ti(Lthis,filter,myParam){
    var tmp0=0;
    switch(myParam|0){
        case 5:
        {
            tmp0=filter.a3.i2|0;
            return (((tmp0|0)===1?1:0)?1:0)|0;
            break;
        }
        case 1:
        case 2:
        case 4:
        case 6:
        case 3:
        {
            return 1|0;
            break;
        }
        default:{
            return 0|0;
            break;
        }
    }
}

我在文档中找不到任何选项: https://github.com/leaningtech/cheerp-meta/wiki

I don't find any options in the documentation:https://github.com/leaningtech/cheerp-meta/wiki

推荐答案

您可以尝试通过以下选项:

You can try to pass the option:

-cheerp-pretty-code

来源: https://github.com/leaningtech/cheerp-meta/wiki/JavaScript-interoperability#clobbering-names

如果这不起作用,那么我很确定这很不幸无法实现.

If that doesn't work, then I'm quite sure that this just unfortunately cannot be accomplished.

这篇关于如何在Cheerp中保留变量名(从C ++到JavaScript的编译器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-10 11:07