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 argument to change default unbounded countainer max size [20066] #270

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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