Skip to content

Commit

Permalink
Fix returning is_plain (#86)
Browse files Browse the repository at this point in the history
* Refs #18687. Fix returning is_plain.

Only a MemberedTypeCode is plain if the extensibility is final.
Also added exception RuntimeGenerationException.

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

* Refs #18687. Include TypeCode.default_extensibility

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 Sep 18, 2023
1 parent 0dec761 commit ef8f83a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package com.eprosima.idl.parser.exception;

import com.eprosima.log.ColorMessage;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Token;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.eprosima.idl.parser.exception;

import java.lang.Exception;
import com.eprosima.log.ColorMessage;

public class RuntimeGenerationException extends Exception
{
public RuntimeGenerationException()
{
super("");
}

public RuntimeGenerationException(String message)
{
super(ColorMessage.error() + message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,20 @@ public boolean addMember(Member member)
@Override
public boolean isIsPlain()
{
for (Member member : m_members.values())
if (isAnnotationFinal())
{
if (!member.isIsPlain())
for (Member member : m_members.values())
{
return false;
if (!member.isIsPlain())
{
return false;
}
}

return true;
}
return true;

return false;
}

@Override
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/eprosima/idl/parser/typecode/TypeCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public int get_value()
}
};

public static ExtensibilityKind default_extensibility = ExtensibilityKind.APPENDABLE;
public static STGroup idltypesgr = null;
public static STGroup cpptypesgr = null;
public static STGroup ctypesgr = null;
Expand Down Expand Up @@ -369,6 +370,12 @@ void calculate_extensibility()
{
extensibility_ = ExtensibilityKind.FINAL;
}
else if (null != m_annotations.get(Annotation.appendable_str) ||
(null != m_annotations.get(Annotation.extensibility_str) &&
m_annotations.get(Annotation.extensibility_str).getValue().equals(Annotation.ex_appendable_str)))
{
extensibility_ = ExtensibilityKind.APPENDABLE;
}
else if (null != m_annotations.get(Annotation.mutable_str) ||
(null != m_annotations.get(Annotation.extensibility_str) &&
m_annotations.get(Annotation.extensibility_str).getValue().equals(Annotation.ex_mutable_str)))
Expand All @@ -377,7 +384,7 @@ else if (null != m_annotations.get(Annotation.mutable_str) ||
}
else
{
extensibility_ = ExtensibilityKind.APPENDABLE;
extensibility_ = default_extensibility;
}
}
}
Expand Down

0 comments on commit ef8f83a

Please sign in to comment.