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

Add support for extern variable declarations #70

Closed
jonas opened this issue Jun 25, 2018 · 5 comments
Closed

Add support for extern variable declarations #70

jonas opened this issue Jun 25, 2018 · 5 comments
Assignees
Labels
bindgen Binding generator
Milestone

Comments

@jonas
Copy link
Member

jonas commented Jun 25, 2018

The following declarations are not currently supported.

extern int forty_two;
extern enum { SYSTEM, USER } who;
extern const char version[];
extern struct {
    int major;
    int minor;
    int patch;
} semver;

AST

> clang -Xclang -ast-dump -fsyntax-only tests/samples/Extern.h
TranslationUnitDecl 0x7fcd6b004ae8 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x7fcd6b005060 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x7fcd6b004d80 '__int128'
|-TypedefDecl 0x7fcd6b0050d0 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x7fcd6b004da0 'unsigned __int128'
|-TypedefDecl 0x7fcd6b0053a8 <<invalid sloc>> <invalid sloc> implicit __NSConstantString 'struct __NSConstantString_tag'
| `-RecordType 0x7fcd6b0051b0 'struct __NSConstantString_tag'
|   `-Record 0x7fcd6b005128 '__NSConstantString_tag'
|-TypedefDecl 0x7fcd6b005440 <<invalid sloc>> <invalid sloc> implicit __builtin_ms_va_list 'char *'
| `-PointerType 0x7fcd6b005400 'char *'
|   `-BuiltinType 0x7fcd6b004b80 'char'
|-TypedefDecl 0x7fcd6b005708 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list 'struct __va_list_tag [1]'
| `-ConstantArrayType 0x7fcd6b0056b0 'struct __va_list_tag [1]' 1
|   `-RecordType 0x7fcd6b005520 'struct __va_list_tag'
|     `-Record 0x7fcd6b005498 '__va_list_tag'
|-VarDecl 0x7fcd6b005778 <tests/samples/Extern.h:1:1, col:12> col:12 forty_two 'int' extern
|-EnumDecl 0x7fcd6b849440 <line:2:8, col:28> col:8
| |-EnumConstantDecl 0x7fcd6b849500 <col:15> col:15 SYSTEM 'int'
| `-EnumConstantDecl 0x7fcd6b849548 <col:23> col:23 USER 'int'
|-VarDecl 0x7fcd6b8495e0 <col:1, col:30> col:30 who 'enum (anonymous enum at tests/samples/Extern.h:2:8)':'enum (anonymous at tests/samples/Extern.h:2:8)' extern
|-VarDecl 0x7fcd6b8496d8 <line:3:1, col:27> col:19 version 'const char []' extern
|-RecordDecl 0x7fcd6b849738 <line:4:8, line:8:1> line:4:8 struct definition
target
| |-FieldDecl 0x7fcd6b8497f8 <line:5:5, col:9> col:9 major 'int'
| |-FieldDecl 0x7fcd6b849858 <line:6:5, col:9> col:9 minor 'int'
| `-FieldDecl 0x7fcd6b8498b8 <line:7:5, col:9> col:9 patch 'int'
`-VarDecl 0x7fcd6b849950 <line:4:1, line:8:3> col:3 semver 'struct (anonymous struct at tests/samples/Extern.h:4:8)':'struct (anonymous at tests/samples/Extern.h:4:8)' extern
@jonas jonas added this to the 0.2 milestone Jun 25, 2018
@kornilova203
Copy link
Member

#62 has related code

@jonas
Copy link
Member Author

jonas commented Jun 25, 2018

OK, I will review it tomorrow.

@jonas
Copy link
Member Author

jonas commented Jun 25, 2018

I assume you mean it has related code for the IR representation?

@kornilova203
Copy link
Member

#62 adds VisitVarDecl method that also should be used here
So it will be more convenient to wait until the pr is merged

@jonas jonas added the bindgen Binding generator label Jun 25, 2018
@jonas jonas self-assigned this Jun 28, 2018
jonas added a commit that referenced this issue Jun 28, 2018
Due to scala-native/scala-native#202 it is not possible to use `var` so
for now `val`s are used although not semantically correct.

References #70
jonas added a commit that referenced this issue Jun 28, 2018
Due to scala-native/scala-native#202 it is not possible to use `var` so
for now `val`s are used although not semantically correct.

References #70
@jonas
Copy link
Member Author

jonas commented Jun 29, 2018

Partially fixed in #80 with limitations due to scala-native/scala-native#202

@jonas jonas closed this as completed Jun 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindgen Binding generator
Projects
None yet
Development

No branches or pull requests

2 participants