Skip to content

Including other idl files doesnt work #107

@jtroeth1

Description

@jtroeth1

Hello,

I have an issue with including other types in the python generated code.
For example creating the two files:

TypeTest.idl

#include "OtherType.idl"

module TypeTest
{
    struct Type1
    {
        long type1_long;
    };

    struct Type2
    {
        double type2_d;
        Type1 type2_type1;
        OtherType::Type3 other_type;
    };
};

OtherType.idl:

module OtherType
{
    struct Type3
    {
        double other_type;
    };
};

Using the test code:

#!/usr/bin/python3

import fastdds
from TypeTest import TypeTest
from OtherType import OtherType

t1 = TypeTest.Type1
t1.type1_long = 1111;
print('t1', t1)
print('t1 dir', dir(t1), end='\n\n')

t2 = TypeTest.Type2
print('t2', t2)
print('t2 dir', dir(t2))

t2.type2_d = 18.0
t2.type2_type1 = t1

print('t2 d', t2.type2_d)
print('t2 t1', t2.type2_type1.type1_long)

other = OtherType.Type3
print('other', dir(other), end='\n\n')
print('t2 other', dir(t2.other_type), end='\n\n')

# This is okay
other.other_type = 10.0
print('other type', other.other_type)

#Both of these fail
t2.other_type.other_type = 10.0 #set
print('other', t2.other_type.other_type) #get

Output:

❯ ./test_types.py
t1 <class 'TypeTest.TypeTest.Type1'>
t1 dir ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__weakref__', 'thisown', 'type1_long']

t2 <class 'TypeTest.TypeTest.Type2'>
t2 dir ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__weakref__', 'other_type', 'thisown', 'type2_d', 'type2_type1']
t2 d 18.0
t2 t1 1111
other ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__weakref__', 'other_type', 'thisown']

t2 other ['__class__', '__delattr__', '__delete__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__isabstractmethod__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__set__', '__set_name__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'deleter', 'fdel', 'fget', 'fset', 'getter', 'setter']

other type 10.0
Traceback (most recent call last):
  File "/home/jtroeth/software/Fast-DDS-python/fastdds_python_examples/TypesBug/./test_types.py", line 27, in <module>
    t2.other_type.other_type = 10.0 #set
AttributeError: 'property' object has no attribute 'other_type'

We can see the dir(other) is okay and has a dict method and shows a double variable "other_type".
dir (t2.other_type) has no dict and is missing the double variable other_type.

Setting and getting other_type for struct "other" is okay.
Setting and Getting the variable other_type via TypeTest t2 is invalid.

Is this the expected behavior?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions