Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于 parser 解析的 type 带有空格的问题 #413

Open
hebohang opened this issue Dec 28, 2022 · 3 comments
Open

关于 parser 解析的 type 带有空格的问题 #413

hebohang opened this issue Dec 28, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@hebohang
Copy link
Contributor

在这里的代码:

Utils::replaceAll(m_type, " ", "");

强行把空格去掉会导致带有空格的类型会反射生成失败(例如 std::vector 类型,它生成的反射文件的 type 会去掉空格,导致codegen的时候的static_cast会出现类型unsignedchar,无法解析而失败)

或许可以考虑加在这里(codegen的时候去掉空格):

vector_define.set("vector_useful_name", array_useful_name);

例如:

Utils::replaceAll(array_useful_name, " ", "");
vector_define.set("vector_useful_name", array_useful_name);
@hebohang hebohang added the enhancement New feature or request label Dec 28, 2022
@yangkeshengli
Copy link
Contributor

举个错误解析的例子,为什么会带空格

@hebohang
Copy link
Contributor Author

hebohang commented Jan 29, 2023

举个错误解析的例子,为什么会带空格

就是上面说的,std::vector<unsigned char>,因为对 vector 类型做了特殊处理,在parse field的阶段就去掉空格会导致codegen阶段的类型生成失去空格(即type从unsigned char变为了unsignedchar),从而解析失败。因此我想说可以考虑在codegen阶段去掉空格,改动方法如上。

@yangkeshengli
Copy link
Contributor

可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants