Skip to content

Commit

Permalink
New argument -genapi [19958] (#261)
Browse files Browse the repository at this point in the history
* Refs #19944. Initial -genapi

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

* Refs #19944. Remove default templates

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

* Refs #19944. Update scope when getting typecodes

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

* Refs #19944. Fix compilation error

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

* Refs #19944. Apply suggestions

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

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware authored Nov 20, 2023
1 parent 5b69944 commit c09a47b
Show file tree
Hide file tree
Showing 30 changed files with 460 additions and 1,960 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ on:
- 'master'

pull_request:
branches:
- 'master'

jobs:
ubuntu-build-test:
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/eprosima/fastcdr/idl/context/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public interface Context

public boolean isGenerateTypeObject();

public boolean isGenerateTypesC();

public boolean isGenerateTypesROS2();

public boolean isCdr();
Expand Down
72 changes: 14 additions & 58 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ $definition_list$
} // namespace $module.name$
>>

definition_list(definitions) ::= <<
$definitions; separator="\n"$
>>

annotation(ctx, annotation) ::= <<
namespace $annotation.name$ {
$annotation.enums : { enum | $enum_type(ctx=ctx, parent=annotation, enum=enum)$}; separator="\n"$
Expand All @@ -146,27 +142,6 @@ public:
};
>>

export_list(exports) ::= <<
$exports; separator="\n"$
>>

exception(ctx, parent, exception) ::= <<>>

operation(ctx, parent, operation, param_list, operation_type) ::= <<

$operation_type$
$param_list$

>>

param_list(parameters) ::= <<>>

param(parameter, parameter_type) ::= <<

$parameter_type$

>>

const_decl(ctx, parent, const, const_type) ::= <<$const_type$$if(ctx.inScopedFile)$$if(const.parent)$$if(const.parent.isInterface)$static $endif$$endif$const $const.typeCode.cppTypename$ $const.name$$if(!const.parent)$ = $const.value$$elseif(!const.parent.isInterface)$ = $const.value$$elseif(!const.typeCode.isType_5)$$if(!const.typeCode.isType_6)$ = $const.value$$endif$$endif$;$endif$>>

typedef_decl(ctx, parent, typedefs, typedefs_type, declarator_type) ::= <<
Expand Down Expand Up @@ -258,13 +233,6 @@ private:
};
>>

member_type(ctx, member, type_member, declarators) ::= <<

$type_member$
$declarators$

>>

union_type(ctx, parent, union, extensions, switch_type) ::= <<
$switch_type$
/*!
Expand Down Expand Up @@ -358,13 +326,6 @@ private:
};
>>

element_type(ctx, element, type_element, declarator) ::= <<

$type_element$
$declarator$

>>

bitset_type(ctx, parent, bitset, extensions) ::= <<
/*!
* @brief This class represents the structure $bitset.name$ defined by the user in the IDL file.
Expand Down Expand Up @@ -471,25 +432,6 @@ class $type.name$;

>>

sequence_type(ctx, sequence, type_sequence) ::= <<

$type_sequence$

>>

map_type(ctx, map, key_type, value_type) ::= <<

$key_type$
$value_type$

>>

string_type(ctx, string) ::= <<>>

wide_string_type(ctx, wstring) ::= <<>>

array_declarator(ctx, array, array_type) ::= <<>>

/***** Utils *****/

public_struct_inheritances(parent) ::= <<$parent.scopedname$>>
Expand Down Expand Up @@ -801,3 +743,17 @@ private:
void free_memory();
};
>>

//{ Fast DDS-Gen extensions
module_conversion(ctx, parent, modules, definition_list) ::= <<
$modules : { module |
namespace $module.name$ {
}; separator="\n"$

$definition_list$

$reverse(modules) : { module |
\} // namespace $module.name$
}; separator="\n"$
>>
//}
60 changes: 14 additions & 46 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,12 @@ $if(ctx.cdr_both)$
$endif$
>>

// TODO name -> module
module(ctx, parent, module, definition_list) ::= <<
namespace $module.name$ {
$definition_list$
} // namespace $module.name$
>>

definition_list(definitions) ::= <<
$definitions; separator="\n"$
>>

annotation(ctx, annotation) ::= <<
namespace $annotation.name$ {
$annotation.enums : { enum | $enum_type(ctx=ctx, parent=annotation, enum=enum)$}; separator="\n"$
Expand All @@ -138,10 +133,6 @@ public:
};
>>

export_list(exports) ::= <<
$exports; separator="\n"$
>>

exception(ctx, parent, exception) ::= <<
$if(ctx.printexception)$
/*!
Expand Down Expand Up @@ -210,10 +201,6 @@ virtual $paramRetType(operation.rettype)$ $operation.name$($paramDeclarations(pa
$endif$
>>

param_list(parameters) ::= <<>>

param(parameter) ::= <<>>

const_decl(ctx, parent, const, const_type) ::= <<
$ctx.setCdrv1Templates$
$const_type$
Expand Down Expand Up @@ -556,39 +543,6 @@ enum $bitmask.name$Bits$bitmask.boundType$
typedef $bitmask.castingType$ $bitmask.name$;
>>

sequence_type(ctx, sequence, type_sequence) ::= <<

$type_sequence$

>>

map_type(ctx, map, key_type, value_type) ::= <<

$key_type$
$value_type$

>>

string_type(ctx, string) ::= <<>>

wide_string_type(ctx, wstring) ::= <<>>

array_declarator(ctx, array, array_type) ::= <<>>

member_type(ctx, member, type_member, declarators) ::= <<

$type_member$
$declarators$

>>

element_type(ctx, element, type_element, declarator) ::= <<

$type_element$
$declarator$

>>

/***** Utils *****/

public_struct_inheritances(parent) ::= <<$parent.scopedname$>>
Expand Down Expand Up @@ -950,3 +904,17 @@ private:
void free_memory();
};
>>

//{ Fast DDS-Gen extensions
module_conversion(ctx, parent, modules, definition_list) ::= <<
$modules : { module |
namespace $module.name$ {
}; separator="\n"$

$definition_list$

$reverse(modules) : { module |
\} // namespace $module.name$
}; separator="\n"$
>>
//}
86 changes: 14 additions & 72 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg
Original file line number Diff line number Diff line change
Expand Up @@ -77,39 +77,6 @@ $definition_list$
} // namespace $module.name$
>>

definition_list(definitions) ::= <<
$definitions; separator="\n"$

>>

annotation(ctx, annotation) ::= <<>>

interface(ctx, parent, interface, export_list) ::= <<
$export_list$
>>

export_list(exports) ::= <<
$exports; separator="\n"$

>>

exception(ctx, parent, exception) ::= <<>>

operation(ctx, parent, operation, param_list, operation_type) ::= <<

$operation_type$
$param_list$

>>

param_list(parameters) ::= <<>>

param(parameter, parameter_type) ::= <<

$parameter_type$

>>

const_decl(ctx, parent, const, const_type) ::= <<
$const_type$
$if(const.parent)$
Expand All @@ -123,8 +90,6 @@ $endif$
$endif$
>>

fwd_decl(ctx, parent, type) ::= <<>>

typedef_decl(ctx, parent, typedefs, typedefs_type, declarator_type) ::= <<
$declarator_type$
$typedefs_type$
Expand Down Expand Up @@ -257,13 +222,6 @@ $struct.members:{ member | $public_member_declaration(class=struct.name, member=
$extensions : { extension | $extension$}; separator="\n"$
>>

member_type(ctx, member, type_member, declarators) ::= <<

$type_member$
$declarators$

>>

bitset_type(ctx, parent, bitset) ::= <<
$bitset.name$::$bitset.name$()$if(bitset.inheritance)$
: $bitset_inherit_default_init(bitset.inheritance)$$endif$
Expand Down Expand Up @@ -571,36 +529,6 @@ void $union.name$::deserialize(
$endif$
>>

element_type(ctx, element, type_element, declarator) ::= <<

$type_element$
$declarator$

>>

enum_type(ctx, parent, enum) ::= <<>>

bitmask_type(ctx, parent, bitmask) ::= <<>>

sequence_type(ctx, sequence, type_sequence) ::= <<

$type_sequence$

>>

map_type(ctx, map, key_type, value_type) ::= <<

$key_type$
$value_type$

>>

string_type(ctx, string) ::= <<>>

wide_string_type(ctx, wstring) ::= <<>>

array_declarator(ctx, array, array_type) ::= <<>>

/***** Utils *****/

public_member_declaration(class, member) ::= <<
Expand Down Expand Up @@ -1411,3 +1339,17 @@ void $scopedtypename$::free_memory()

$endif$
>>

//{ Fast DDS-Gen extensions
module_conversion(ctx, parent, modules, definition_list) ::= <<
$modules : { module |
namespace $module.name$ {
}; separator="\n"$

$definition_list$

$reverse(modules) : { module |
\} // namespace $module.name$
}; separator="\n"$
>>
//}
Loading

0 comments on commit c09a47b

Please sign in to comment.