Skip to content

Commit

Permalink
C++: support "export struct ..."
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Feb 21, 2024
1 parent 8362c9b commit b99e979
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Units/parser-cxx.r/export-2.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ french input.cpp /^ char const* french() { return "Salut!"; }$/;" f namespac
x input.cpp /^export enum x { a = 1 };$/;" g file: properties:export
a input.cpp /^export enum x { a = 1 };$/;" e enum:x file:
td input.cpp /^export typedef int td;$/;" t typeref:typename:int file: properties:export
s_ input.cpp /^struct s_ {$/;" s file:
mbr input.cpp /^ int mbr;$/;" m struct:s_ typeref:typename:int file:
s input.cpp /^export struct s {$/;" s file: properties:export
mbr input.cpp /^ int mbr;$/;" m struct:s typeref:typename:int file:
s__ input.cpp /^struct s__ {$/;" s file:
mbr input.cpp /^ int mbr;$/;" m struct:s__ typeref:typename:int file:
12 changes: 12 additions & 0 deletions Units/parser-cxx.r/export-2.d/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ export namespace hi
export enum x { a = 1 };

export typedef int td;

struct s_ {
int mbr;
};

export struct s {
int mbr;
};

struct s__ {
int mbr;
};
4 changes: 4 additions & 0 deletions Units/parser-cxx.r/export-3.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ X input.cpp /^namespace X {$/;" n file:
a input.cpp /^ int a;$/;" v namespace:X typeref:typename:int
x input.cpp /^ int x;$/;" v namespace:X typeref:typename:int properties:export
f input.cpp /^ int f(int i);$/;" p namespace:X typeref:typename:int file: properties:export
u input.cpp /^ union u {$/;" u namespace:X file: properties:export
mbr input.cpp /^ int mbr;$/;" m union:X::u typeref:typename:int file:
b input.cpp /^ int b;$/;" v namespace:X typeref:typename:int
m input.cpp /^int m;$/;" v typeref:typename:int
z input.cpp /^ int z;$/;" v typeref:typename:int properties:export
E input.cpp /^ enum E { a = 1 };$/;" g file: properties:export
a input.cpp /^ enum E { a = 1 };$/;" e enum:E file:
td input.cpp /^ typedef int td;$/;" t typeref:typename:int file: properties:export
c input.cpp /^ class c {$/;" c file: properties:export
mbr input.cpp /^ int mbr;$/;" m class:c typeref:typename:int file:
n input.cpp /^int n;$/;" v typeref:typename:int
7 changes: 7 additions & 0 deletions Units/parser-cxx.r/export-3.d/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace X {
export {
int x;
int f(int i);
union u {
int mbr;
};

}
int b;
};
Expand All @@ -15,5 +19,8 @@ export {
int z;
enum E { a = 1 };
typedef int td;
class c {
int mbr;
};
}
int n;
9 changes: 9 additions & 0 deletions parsers/cxx/cxx_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,9 +1361,18 @@ static bool cxxParserParseClassStructOrUnionInternal(

tag->isFileScope = !isInputHeaderFile();

unsigned int uProperties = 0;
if(uInitialKeywordState & CXXParserKeywordStateSeenExport)
uProperties |= CXXTagPropertyExport;
vString * pszProperties = NULL;

if(uProperties)
pszProperties = cxxTagSetProperties(uProperties);

iCorkQueueIndex = cxxTagCommit(&iCorkQueueIndexFQ);
cxxTagUseTokenAsPartOfDefTag(iCorkQueueIndex, pClassName);

vStringDelete (pszProperties); /* NULL is acceptable. */
}

cxxScopePush(
Expand Down

0 comments on commit b99e979

Please sign in to comment.