Skip to content

Commit

Permalink
Progress on OpenCyphal#91
Browse files Browse the repository at this point in the history
  • Loading branch information
thirtytwobits committed Nov 6, 2019
1 parent 5ab9cb7 commit 0b171f6
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 144 deletions.
11 changes: 10 additions & 1 deletion src/nunavut/jinja/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ def is_serializable(value: pydsdl.Any) -> bool:
""" # noqa: E501
return isinstance(value, pydsdl.SerializableType)

@staticmethod
def is_None(value: typing.Any) -> bool:
return (value is None)

@staticmethod
def is_padding(value: pydsdl.Field) -> bool:
return isinstance(value, pydsdl.PaddingField)

# +-----------------------------------------------------------------------+

def __init__(self,
Expand Down Expand Up @@ -375,7 +383,8 @@ def __init__(self,
keep_trailing_newline=True,
lstrip_blocks=lstrip_blocks,
trim_blocks=trim_blocks,
auto_reload=False)
auto_reload=False,
cache_size=0)

self._add_language_support()

Expand Down
12 changes: 9 additions & 3 deletions src/nunavut/lang/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,21 @@ def to_c_float(self) -> str:
else:
return 'double'

def to_c_type(self, value: pydsdl.PrimitiveType, use_standard_types: bool = True) -> str:
def to_c_type(self,
value: pydsdl.PrimitiveType,
use_standard_types: bool = True,
inttype_prefix: typing.Optional[str] = None) -> str:
safe_prefix = '' if inttype_prefix is None else inttype_prefix
if isinstance(value, pydsdl.UnsignedIntegerType):
return (self.to_c_int(False) if not use_standard_types else self.to_std_int(False))
return safe_prefix + (self.to_c_int(False) if not use_standard_types else self.to_std_int(False))
elif isinstance(value, pydsdl.SignedIntegerType):
return (self.to_c_int(True) if not use_standard_types else self.to_std_int(True))
return safe_prefix + (self.to_c_int(True) if not use_standard_types else self.to_std_int(True))
elif isinstance(value, pydsdl.FloatType):
return self.to_c_float()
elif isinstance(value, pydsdl.BooleanType):
return ('BOOL' if not use_standard_types else 'bool')
elif isinstance(value, pydsdl.VoidType):
return 'void'
else:
raise RuntimeError("{} is not a known PrimitiveType".format(type(value).__name__))

Expand Down
Loading

0 comments on commit 0b171f6

Please sign in to comment.