Skip to content

Commit

Permalink
Add argument to change default unbounded countainer max size (#270)
Browse files Browse the repository at this point in the history
* Refs #20056. Argument to change max size of unbounded containers

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #20056. Update submodule

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

---------

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware authored and adriancampo committed Dec 12, 2023
1 parent 94aab4e commit 7de24c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.eprosima.idl.parser.tree.Annotation;
import com.eprosima.idl.parser.tree.Specification;
import com.eprosima.idl.parser.typecode.Kind;
import com.eprosima.idl.parser.typecode.ContainerTypeCode;
import com.eprosima.idl.parser.typecode.PrimitiveTypeCode;
import com.eprosima.idl.parser.typecode.TypeCode;
import com.eprosima.idl.util.Util;
Expand Down Expand Up @@ -177,6 +178,17 @@ else if (arg.equals("-d"))
throw new BadArgumentException("No URL specified after -d argument");
}
}
else if (arg.equals(default_container_prealloc_size))
{
if (count < args.length)
{
ContainerTypeCode.default_unbounded_max_size = args[count++];
}
else
{
throw new BadArgumentException("No value specified after " + default_container_prealloc_size + " argument");
}
}
else if (arg.equals("-de") || arg.equals("-default_extensibility"))
{
if (count < args.length)
Expand Down Expand Up @@ -529,13 +541,17 @@ private void showVersion()
System.out.println(m_appName + " version " + version);
}

private static String default_container_prealloc_size = "-default-container-prealloc-size";

public static void printHelp()
{
System.out.println(m_appName + " usage:");
System.out.println("\t" + m_appName + " [options] <file> [<file> ...]");
System.out.println("\twhere the options are:");
System.out.println("\t\t-cs: IDL grammar apply case sensitive matching.");
System.out.println("\t\t-d <path>: sets an output directory for generated files.");
System.out.print("\t\t" + default_container_prealloc_size + ": sets the default preallocated size for containers");
System.out.println(" (sequence and maps). Default value: 0");
System.out.print("\t\t-default_extensibility | -de <ext>: sets the default extensibility for types without");
System.out.println(" the @extensibility annotation.");
System.out.println("\t\t Values:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ for(size_t $loopvar$ = 0; $if(typecode.contentTypeCode.forwarded)$!$name$_detect
>>

map_assigment(ctx, typecode, name, originName, p, loopvar) ::= <<
for(size_t $loopvar$ = 0; $loopvar$ < $typecode.maxsize$; ++$loopvar$)
for(size_t $loopvar$ = 0; $loopvar$ < $if(typecode.unbound)$50$else$$typecode.maxsize$$endif$; ++$loopvar$)
{
$if(typecode.valueTypeCode.isSequenceType)$
$map_member_assignment(ctx=ctx, keytypecode=typecode.keyTypeCode, valueTypeCode=typecode.valueTypeCode, name=name,
Expand Down

0 comments on commit 7de24c9

Please sign in to comment.