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

Quite verbose d files generated #263

Closed
andre2007 opened this issue Jun 4, 2020 · 2 comments · Fixed by #336
Closed

Quite verbose d files generated #263

andre2007 opened this issue Jun 4, 2020 · 2 comments · Fixed by #336

Comments

@andre2007
Copy link

For this dockerfile

FROM dlang2/ldc-ubuntu:1.20.0 as ldc

RUN apt-get update && apt-get upgrade -y \
    && apt-get install -y curl clang-9 libclang-9-dev

RUN curl -fskSL https://github.com/open62541/open62541/releases/download/v1.1-rc1/open62541-linux64.tar.gz | tar -xzf - --strip-components=1 open62541-linux64 -C /usr/
RUN ln -s /usr/bin/clang-9 /usr/bin/clang
RUN DFLAGS="-L=-L/usr/lib/llvm-9/lib/" dub build dpp

ADD open62541h.dpp /tmp/
RUN DFLAGS="-L=-L/usr/lib/llvm-9/lib/" dub run dpp -- /tmp/open62541h.dpp \
    --include-path /include/open62541/ \
    --preprocess-only

and the file open62541h.dpp

#include <open62541/client.h>
#include <open62541/client_config_default.h>
#include <open62541/client_highlevel.h>

A 6MB file /tmp/open62541h.d is generated with ~ 142.000 lines. The first 6000 lines looks as expected. After that there are lines with these pattern:

    static if(!is(typeof(UA_NS0ID_OPCUA_BINARYSCHEMA_ROLEPERMISSIONTYPE_DICTIONARYFRAGMENT))) {
        private enum enumMixinStr_UA_NS0ID_OPCUA_BINARYSCHEMA_ROLEPERMISSIONTYPE_DICTIONARYFRAGMENT = `enum UA_NS0ID_OPCUA_BINARYSCHEMA_ROLEPERMISSIONTYPE_DICTIONARYFRAGMENT = 16133;`;
        static if(is(typeof({ mixin(enumMixinStr_UA_NS0ID_OPCUA_BINARYSCHEMA_ROLEPERMISSIONTYPE_DICTIONARYFRAGMENT); }))) {
            mixin(enumMixinStr_UA_NS0ID_OPCUA_BINARYSCHEMA_ROLEPERMISSIONTYPE_DICTIONARYFRAGMENT);
        }
    }




    static if(!is(typeof(UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTROLEPERMISSIONS))) {
        private enum enumMixinStr_UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTROLEPERMISSIONS = `enum UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTROLEPERMISSIONS = 16134;`;
        static if(is(typeof({ mixin(enumMixinStr_UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTROLEPERMISSIONS); }))) {
            mixin(enumMixinStr_UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTROLEPERMISSIONS);
        }
    }




    static if(!is(typeof(UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTUSERROLEPERMISSIONS))) {
        private enum enumMixinStr_UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTUSERROLEPERMISSIONS = `enum UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTUSERROLEPERMISSIONS = 16135;`;
        static if(is(typeof({ mixin(enumMixinStr_UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTUSERROLEPERMISSIONS); }))) {
            mixin(enumMixinStr_UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTUSERROLEPERMISSIONS);
        }
    }

Are the static if / string mixin really needed, or could just instead the line

enum UA_NS0ID_OPCUANAMESPACEMETADATA_DEFAULTROLEPERMISSIONS = 16134;

be added?

@atilaneves
Copy link
Owner

If there was a way to detect that a macro is an integer or string constant, then I'd be all for the change, but I can't think of any.

If you don't care about macros, you can use --ignore-macros, and that code won't get generated.

@andre2007
Copy link
Author

I just saw pr #262 and now think about wheter an argument --accept-macros=foo,bar would solve the issue better.

There is a small list of macros which I need. Beeing able to specify them would be great .

WebFreak001 added a commit to WebFreak001/dpp that referenced this issue Jun 20, 2023
fix atilaneves#263

single token string and integer literals are emitted as-is with this,
without running through the is(typeof()) check.

Since all integers and strings should be representable in D, they should
be fine to be included directly after translation.

still needs a test
WebFreak001 added a commit to WebFreak001/dpp that referenced this issue Jun 21, 2023
WebFreak001 added a commit to WebFreak001/dpp that referenced this issue Jun 21, 2023
fix atilaneves#263

single token string and integer literals are emitted as-is with this,
without running through the is(typeof()) check.

Since all integers and strings should be representable in D, they should
be fine to be included directly after translation.

still needs a test
WebFreak001 added a commit to WebFreak001/dpp that referenced this issue Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants