Skip to content

Commit

Permalink
XTypes v1.3 refactor (#130)
Browse files Browse the repository at this point in the history
* Several changes to support fastddsgen -genapi [19957] (#105)

* Refs #19944. Context uses TemplateManager

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #19944. Fix setting scope

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>

* Fix union discriminator (#106)

* Refs #19932: fix union discriminator

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19932: apply review suggestions

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

---------

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
Signed-off-by: Ricardo González Moreno <[email protected]>

* Refactor Member and ContainerTypeCode to use common applied annotations API (#107)

* Refs #19968: refactor Member and ContainerTypeCode to use common applied member annotations API

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19968: apply review suggestions

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

---------

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
Signed-off-by: Ricardo González Moreno <[email protected]>

* Remove calling with option -cdr (#109)

Signed-off-by: Ricardo González Moreno <[email protected]>

* Support to have configuration by STGroup (#108)

* Refs #19960. Support to have config by STGroup

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #19960. Fix conding style.

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #19960. Apply suggestions

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>

* Changeable max size for unbounded containers (#111)

Signed-off-by: Ricardo González Moreno <[email protected]>

* Support for C++ enum class (#112)

* Refs #20063. Support C++ enum class

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #20063. Fix bitmasks

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #20063. Accessing through Context

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>

* Fix missing function (#113)

Signed-off-by: Ricardo González Moreno <[email protected]>

* Improve in code (#114)

Signed-off-by: Ricardo González Moreno <[email protected]>

* Fix after rebase

Signed-off-by: Ricardo González Moreno <[email protected]>

* New API and fixes for TypeObject generation (#119)

* Changes to run typeobject tests  (#103)

* Refs #19115: include method to check if type is boolean

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: accesors to primitive types and enum types

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: add scoped name to annotation declarations

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: add API to check verbatim annotation. Sanity check to ensure that given enumeration value is valid

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: remove quotes from annotation value

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: discriminate builtin annotations

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: API for max and min annotation values (@range)

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: expose scoped name in Annotation API

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: include XTypes v1.3 builtin annotations and fix IDL v4.2 builtin annotations

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: throw exception if annotation is not previously defined

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: remove isIsEnumType defined twice (after rebase)

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: try_construct implementation

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: type system only supports single inheritance

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19115: check autoid annotation API

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Added TypeObject tests flag.

Signed-off-by: adriancampo <[email protected]>

* change run() method to work with different types of tests.

Signed-off-by: adriancampo <[email protected]>

* Refs #19595: apply review suggestions

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: revert changes: -typeobject option will be used to generate legacy TypeObject code

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: check autoid annotation API

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: try_construct annotation implementation

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: add API to check @id and @hashid builtin annotations

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: API to get number of members

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: add getBitBound API to enum types

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: add API to get number of annotation parameters

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: fix merge conflicts

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: add API to check if an annotation is builtin

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: add API to check number of applicable labels

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: fix merge conflicts

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: refactor array_type

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: add array API to check bound sequence size

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: fix after rebase

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: remove non-necessary template attribute

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: include API to get number of annotation parameters

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: apply review suggestion: use new scopedname strategy

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: apply review suggestion

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

---------

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
Signed-off-by: adriancampo <[email protected]>
Co-authored-by: JLBuenoLopez-eProsima <[email protected]>

* Fix API for TypeObject code generation (#110)

* Refs #19595: code style

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: return annotation default value

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: add Alias API for container types aliased

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: fix typos in primitive API

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19595: explictly override

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

---------

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19906: fix TypeCode::isAnnotationAutoidHash function

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19906: return correct TypeIdentifier kind

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19906: return correct type identifier

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19906: unbounded collections use small TypeIdentifier

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19906: fixes after rebase

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19906: return correct TypeIdentifier for arrays

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #19906: return correct TypeIdentifier for maps

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: non applied extensibility and try_construct annotations

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: get main project API (generate TypeObject tests only for the main project)

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: fix Annotation Autoid hash return value

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: add getFirstMember API

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: fix bitset holder type

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: fix collection TypeIdentifier

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: recursive types fail generating TypeObject

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: API to check if contained members are forwarded

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: fix bitset bitfields

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: use variables instead of hardcoded strings

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: fixes after rebase

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

* Refs #20129: apply review suggestions

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>

---------

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
Signed-off-by: adriancampo <[email protected]>
Co-authored-by: Adrian del Campo <[email protected]>
Signed-off-by: Ricardo González Moreno <[email protected]>

* Hotfix: extend AliasTypeCode API: getCScopedname (#120)

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
Signed-off-by: Ricardo González Moreno <[email protected]>

* Document isIsBounded and isUnbound API. Correctly use the API (#121)

Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
Signed-off-by: Ricardo González Moreno <[email protected]>

* Fixes after rebase

Signed-off-by: Ricardo González Moreno <[email protected]>

* Fix find and set default value for unions [20587] (#124)

* Refs #19451. Fix find and set default value for unions

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #19451. Remove unused functions

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #19451. Rollback default discriminator

Signed-off-by: Ricardo González Moreno <[email protected]>

* Refs #19451. Apply suggestions

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>

* Apply suggestions

Signed-off-by: Ricardo González Moreno <[email protected]>

* Apply suggestions 2

Signed-off-by: Ricardo González Moreno <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
Signed-off-by: adriancampo <[email protected]>
Co-authored-by: Ricardo González <[email protected]>
Co-authored-by: Adrian del Campo <[email protected]>
  • Loading branch information
3 people authored and EduPonz committed May 14, 2024
1 parent 60ec03c commit 1004bcb
Show file tree
Hide file tree
Showing 37 changed files with 1,859 additions and 580 deletions.
16 changes: 12 additions & 4 deletions src/it/java/com/eprosima/integration/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ public boolean generate(
String generatorName,
String inputPath,
String exampleArch,
String cdr_version,
boolean testFlag)
{
String program = "java -jar " + generatorName + ".jar";
String flags = " -cdr " + cdr_version + " -replace -example" + " " + exampleArch + (testFlag ? " -test" : "");
String flags = " -replace -example" + " " + exampleArch + (testFlag ? " -test -default-container-prealloc-size 50" : "");
String output = " -d " + outputPath;

String idlPath = " " + inputPath + "/" + idl + ".idl";

if (idl.equals("external") || idl.equals("declarations"))
{
flags = flags + " -no-typeobjectsupport";
}

String command = program + flags + output + idlPath;

return Command.execute(command, null, errorOutputOnly, true);
Expand All @@ -63,15 +67,19 @@ public boolean generate(
public boolean generate(
String generatorName,
String inputPath,
String cdr_version,
boolean testFlag)
{
String program = "java -jar " + generatorName + ".jar";
String flags = " -cdr " + cdr_version + " -replace -example" + (testFlag ? " -test" : "");
String flags = " -replace -example" + (testFlag ? " -test -default-container-prealloc-size 50" : "");
String output = " -d " + outputPath;

String idlPath = " " + inputPath + "/" + idl + ".idl";

if (idl.equals("external") || idl.equals("declarations"))
{
flags = flags + " -no-typeobjectsupport";
}

String command = program + flags + output + idlPath;
return Command.execute(command, null, errorOutputOnly, true);
}
Expand Down
9 changes: 2 additions & 7 deletions src/it/java/com/eprosima/integration/TestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ public int getValue()
private String exampleArch;
private List<String> cMakeArgs;
private boolean errorOutputOnly;
private String cdr_version_;

public TestManager(
TestLevel level,
String generatorName,
String inputPath,
String outputPath,
String cdr_version,
List<String> list_tests,
List<String> blacklist_tests)
{
Expand All @@ -59,7 +57,6 @@ public TestManager(
this.exampleArch = null;
this.cMakeArgs = new ArrayList<String>();
this.errorOutputOnly = true;
this.cdr_version_ = cdr_version;
}

public TestManager(
Expand All @@ -68,7 +65,6 @@ public TestManager(
String inputPath,
String outputPath,
String exampleArch,
String cdr_version,
List<String> list_tests,
List<String> blacklist_tests)
{
Expand All @@ -81,7 +77,6 @@ public TestManager(
this.exampleArch = exampleArch;
this.cMakeArgs = new ArrayList<String>();
this.errorOutputOnly = true;
this.cdr_version_ = cdr_version;
}

public void processIDLsDirectory(
Expand Down Expand Up @@ -164,9 +159,9 @@ public boolean generate(Test test)

if (exampleArch == null)
{
return printlnStatus(test.generate(generatorName, inputPath, cdr_version_, level == TestLevel.RUN));
return printlnStatus(test.generate(generatorName, inputPath, level == TestLevel.RUN));
} else {
return printlnStatus(test.generate(generatorName, inputPath, exampleArch, cdr_version_, level == TestLevel.RUN));
return printlnStatus(test.generate(generatorName, inputPath, exampleArch, level == TestLevel.RUN));
}
}

Expand Down
52 changes: 26 additions & 26 deletions src/main/antlr/com/eprosima/idl/parser/grammar/IDL.g4
Original file line number Diff line number Diff line change
Expand Up @@ -177,27 +177,11 @@ module returns [Pair<com.eprosima.idl.parser.tree.Module, TemplateGroup> returnP
if(moduleObject == null)
{
// Create the Module object.
moduleObject = new com.eprosima.idl.parser.tree.Module(ctx.getScopeFile(), ctx.isInScopedFile(), ctx.getScope(), name, tk);
//ctx.addPendingModule(moduleObject);
moduleObject = ctx.createModule(ctx.getScopeFile(), ctx.isInScopedFile(), ctx.getScope(), name, tk);
}

// Add the module to the context.
ctx.addModule(moduleObject);

if(ctx.isInScopedFile() || ctx.isScopeLimitToAll()) {
if(tmanager != null) {
moduleTemplates = tmanager.createTemplateGroup("module");
moduleTemplates.setAttribute("ctx", ctx);
// Set the module object to the TemplateGroup of the module.
moduleTemplates.setAttribute("module", moduleObject);
}
}

// Update to a new namespace.
if(old_scope.isEmpty())
ctx.setScope(name);
else
ctx.setScope(old_scope + "::" + name);
// Add the module to the context and update to the new namespace (internally call ctx.setScope)
moduleTemplates = ctx.addModule(moduleObject);
}
// Each definition is stored in the Module and each TemplateGroup is set as attribute in the TemplateGroup of the module.
LEFT_BRACE
Expand Down Expand Up @@ -1172,8 +1156,10 @@ annotation_def returns [Pair<AnnotationDeclaration, TemplateGroup> returnPair =
@init
{
TemplateGroup annotationTemplates = null;
String old_scope = ctx.getScope();
String name = null;
}
: annotation_header LEFT_BRACE annotation_body[$annotation_header.annotation] RIGHT_BRACE
: annotation_header
{
if($annotation_header.annotation != null)
{
Expand All @@ -1188,9 +1174,24 @@ annotation_def returns [Pair<AnnotationDeclaration, TemplateGroup> returnPair =
}
}

$returnPair = new Pair<AnnotationDeclaration, TemplateGroup>($annotation_header.annotation, annotationTemplates);
name = $annotation_header.annotation.getName();

// Update to a new namespace.
if(old_scope.isEmpty())
ctx.setScope(name);
else
ctx.setScope(old_scope + "::" + name);
}
}
LEFT_BRACE
annotation_body[$annotation_header.annotation]
RIGHT_BRACE
{
// Set the old namespace.
ctx.setScope(old_scope);
// Create the returned data.
$returnPair = new Pair<AnnotationDeclaration, TemplateGroup>($annotation_header.annotation, annotationTemplates);
}
;

annotation_header returns [AnnotationDeclaration annotation = null]
Expand Down Expand Up @@ -1233,7 +1234,7 @@ annotation_inheritance_spec [AnnotationDeclaration annotation]
}
else
{
System.out.println("WARNING (File " + ctx.getFilename() + ", Line " + (_input.LT(1) != null ? _input.LT(1).getLine() - ctx.getCurrentIncludeLine() : "1") + "): Annotation " + $scoped_name.pair.first() + " not supported. Ignoring...");
throw new ParseException($scoped_name.pair.second(), "was not defined previously");
}
}
}
Expand Down Expand Up @@ -1772,7 +1773,7 @@ union_type [Vector<Annotation> annotations, ArrayList<Definition> defs] returns
LEFT_BRACE switch_body[unionTP] RIGHT_BRACE
{
// Calculate default label.
TemplateUtil.setUnionDefaultLabel(defs, unionTP, ctx.getScopeFile(), line);
TemplateUtil.find_and_set_default_discriminator_value(defs, unionTP);
if(ctx.isInScopedFile() || ctx.isScopeLimitToAll())
{
Expand Down Expand Up @@ -1861,7 +1862,7 @@ case_stmt [UnionTypeCode unionTP] returns [TemplateGroup tg = null]
}
: ( KW_CASE const_exp
{
labels.add(TemplateUtil.checkUnionLabel(unionTP.getDiscriminator(), $const_exp.literalStr, ctx.getScopeFile(), _input.LT(1) != null ? _input.LT(1).getLine() - ctx.getCurrentIncludeLine() : 1));
labels.add(TemplateUtil.checkUnionLabel(unionTP.getDiscriminator().getTypecode(), $const_exp.literalStr));
} COLON
| KW_DEFAULT { defaul = true; } COLON
)+
Expand Down Expand Up @@ -2229,7 +2230,6 @@ array_declarator returns [Pair<Pair<Pair<String, Token>, ContainerTypeCode>, Tem
{
arrayTemplates.setAttribute("array", typecode);
arrayTemplates.setAttribute("ctx", ctx);
arrayTemplates.setAttribute("array_type",tk.getText());
}
Pair<String, Token> p = new Pair<String, Token>(tk.getText(), tk);
Pair<Pair<String, Token>, ContainerTypeCode> pp = new Pair<Pair<String, Token>, ContainerTypeCode>(p, typecode);
Expand Down Expand Up @@ -2802,7 +2802,7 @@ annotation_appl returns [Annotation annotation = null]
anndecl = ctx.getAnnotationDeclaration(name);
if(anndecl == null)
{
System.out.println("WARNING (File " + ctx.getFilename() + ", Line " + (_input.LT(1) != null ? _input.LT(1).getLine() - ctx.getCurrentIncludeLine() : "1") + "): Annotation " + name + " not supported. Ignoring...");
throw new ParseException($scoped_name.pair.second(), "was not defined previously");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ case_stmt [UnionTypeCode unionTP]
}
: ( KW_CASE const_exp
{
labels.add(TemplateUtil.checkUnionLabel(unionTP.getDiscriminator(), $const_exp.literalStr, ctx.getScopeFile(), _input.LT(1) != null ? _input.LT(1).getLine() - ctx.getCurrentIncludeLine() : 1));
labels.add(TemplateUtil.checkUnionLabel(unionTP.getDiscriminator().getTypecode(), $const_exp.literalStr, ctx.getScopeFile(), _input.LT(1) != null ? _input.LT(1).getLine() - ctx.getCurrentIncludeLine() : 1));
} COLON
| KW_DEFAULT { defaul = true; } COLON
)+
Expand Down
Loading

0 comments on commit 1004bcb

Please sign in to comment.