Skip to content

Commit

Permalink
update generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
PProfizi committed Jan 16, 2024
1 parent bc574d4 commit 7ed0220
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 4 deletions.
4 changes: 2 additions & 2 deletions doc/source/_static/dpf_operators.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class serializer_to_string(Operator):
Parameters
----------
stream_type : int
0 for string (default), and 1 for binary
any_input1 : Any
Any input
any_input2 : Any
Expand All @@ -29,13 +31,16 @@ class serializer_to_string(Operator):
>>> op = dpf.operators.serialization.serializer_to_string()
>>> # Make input connections
>>> my_stream_type = int()
>>> op.inputs.stream_type.connect(my_stream_type)
>>> my_any_input1 = dpf.Any()
>>> op.inputs.any_input1.connect(my_any_input1)
>>> my_any_input2 = dpf.Any()
>>> op.inputs.any_input2.connect(my_any_input2)
>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.serialization.serializer_to_string(
... stream_type=my_stream_type,
... any_input1=my_any_input1,
... any_input2=my_any_input2,
... )
Expand All @@ -44,10 +49,19 @@ class serializer_to_string(Operator):
>>> result_serialized_string = op.outputs.serialized_string()
"""

def __init__(self, any_input1=None, any_input2=None, config=None, server=None):
def __init__(
self,
stream_type=None,
any_input1=None,
any_input2=None,
config=None,
server=None,
):
super().__init__(name="serializer_to_string", config=config, server=server)
self._inputs = InputsSerializerToString(self)
self._outputs = OutputsSerializerToString(self)
if stream_type is not None:
self.inputs.stream_type.connect(stream_type)
if any_input1 is not None:
self.inputs.any_input1.connect(any_input1)
if any_input2 is not None:
Expand All @@ -59,6 +73,12 @@ def _spec():
spec = Specification(
description=description,
map_input_pin_spec={
-1: PinSpecification(
name="stream_type",
type_names=["int32"],
optional=False,
document="""0 for string (default), and 1 for binary""",
),
1: PinSpecification(
name="any_input",
type_names=["any"],
Expand Down Expand Up @@ -128,6 +148,8 @@ class InputsSerializerToString(_Inputs):
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.serializer_to_string()
>>> my_stream_type = int()
>>> op.inputs.stream_type.connect(my_stream_type)
>>> my_any_input1 = dpf.Any()
>>> op.inputs.any_input1.connect(my_any_input1)
>>> my_any_input2 = dpf.Any()
Expand All @@ -136,11 +158,35 @@ class InputsSerializerToString(_Inputs):

def __init__(self, op: Operator):
super().__init__(serializer_to_string._spec().inputs, op)
self._stream_type = Input(
serializer_to_string._spec().input_pin(-1), -1, op, -1
)
self._inputs.append(self._stream_type)
self._any_input1 = Input(serializer_to_string._spec().input_pin(1), 1, op, 0)
self._inputs.append(self._any_input1)
self._any_input2 = Input(serializer_to_string._spec().input_pin(2), 2, op, 1)
self._inputs.append(self._any_input2)

@property
def stream_type(self):
"""Allows to connect stream_type input to the operator.
0 for string (default), and 1 for binary
Parameters
----------
my_stream_type : int
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.serializer_to_string()
>>> op.inputs.stream_type.connect(my_stream_type)
>>> # or
>>> op.inputs.stream_type(my_stream_type)
"""
return self._stream_type

@property
def any_input1(self):
"""Allows to connect any_input1 input to the operator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class string_deserializer(Operator):
Parameters
----------
stream_type : int
0 for string (default), and 1 for binary
serialized_string : str
Expand All @@ -27,11 +29,14 @@ class string_deserializer(Operator):
>>> op = dpf.operators.serialization.string_deserializer()
>>> # Make input connections
>>> my_stream_type = int()
>>> op.inputs.stream_type.connect(my_stream_type)
>>> my_serialized_string = str()
>>> op.inputs.serialized_string.connect(my_serialized_string)
>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.serialization.string_deserializer(
... stream_type=my_stream_type,
... serialized_string=my_serialized_string,
... )
Expand All @@ -40,10 +45,14 @@ class string_deserializer(Operator):
>>> result_any_output2 = op.outputs.any_output2()
"""

def __init__(self, serialized_string=None, config=None, server=None):
def __init__(
self, stream_type=None, serialized_string=None, config=None, server=None
):
super().__init__(name="string_deserializer", config=config, server=server)
self._inputs = InputsStringDeserializer(self)
self._outputs = OutputsStringDeserializer(self)
if stream_type is not None:
self.inputs.stream_type.connect(stream_type)
if serialized_string is not None:
self.inputs.serialized_string.connect(serialized_string)

Expand All @@ -54,6 +63,12 @@ def _spec():
spec = Specification(
description=description,
map_input_pin_spec={
-1: PinSpecification(
name="stream_type",
type_names=["int32"],
optional=False,
document="""0 for string (default), and 1 for binary""",
),
0: PinSpecification(
name="serialized_string",
type_names=["string"],
Expand Down Expand Up @@ -125,17 +140,41 @@ class InputsStringDeserializer(_Inputs):
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.string_deserializer()
>>> my_stream_type = int()
>>> op.inputs.stream_type.connect(my_stream_type)
>>> my_serialized_string = str()
>>> op.inputs.serialized_string.connect(my_serialized_string)
"""

def __init__(self, op: Operator):
super().__init__(string_deserializer._spec().inputs, op)
self._stream_type = Input(string_deserializer._spec().input_pin(-1), -1, op, -1)
self._inputs.append(self._stream_type)
self._serialized_string = Input(
string_deserializer._spec().input_pin(0), 0, op, -1
)
self._inputs.append(self._serialized_string)

@property
def stream_type(self):
"""Allows to connect stream_type input to the operator.
0 for string (default), and 1 for binary
Parameters
----------
my_stream_type : int
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.string_deserializer()
>>> op.inputs.stream_type.connect(my_stream_type)
>>> # or
>>> op.inputs.stream_type(my_stream_type)
"""
return self._stream_type

@property
def serialized_string(self):
"""Allows to connect serialized_string input to the operator.
Expand Down
16 changes: 16 additions & 0 deletions src/ansys/dpf/gate/generated/capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,10 @@ def load_api(path):
dll.Operator_connect_string.argtypes = (ctypes.c_void_p, ctypes.c_int32, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.Operator_connect_string.restype = None

if hasattr(dll, "Operator_connect_string_with_size"):
dll.Operator_connect_string_with_size.argtypes = (ctypes.c_void_p, ctypes.c_int32, ctypes.POINTER(ctypes.c_char), ctypes.c_size_t, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.Operator_connect_string_with_size.restype = None

if hasattr(dll, "Operator_connect_Scoping"):
dll.Operator_connect_Scoping.argtypes = (ctypes.c_void_p, ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.Operator_connect_Scoping.restype = None
Expand Down Expand Up @@ -2604,6 +2608,10 @@ def load_api(path):
dll.Operator_getoutput_string.argtypes = (ctypes.c_void_p, ctypes.c_int32, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.Operator_getoutput_string.restype = ctypes.POINTER(ctypes.c_char)

if hasattr(dll, "Operator_getoutput_string_with_size"):
dll.Operator_getoutput_string_with_size.argtypes = (ctypes.c_void_p, ctypes.c_int32, ctypes.POINTER(ctypes.c_size_t), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.Operator_getoutput_string_with_size.restype = ctypes.POINTER(ctypes.c_char)

if hasattr(dll, "Operator_getoutput_bytearray"):
dll.Operator_getoutput_bytearray.argtypes = (ctypes.c_void_p, ctypes.c_int32, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.Operator_getoutput_bytearray.restype = ctypes.POINTER(ctypes.c_char)
Expand Down Expand Up @@ -4310,6 +4318,10 @@ def load_api(path):
dll.WorkFlow_connect_string.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.WorkFlow_connect_string.restype = None

if hasattr(dll, "WorkFlow_connect_string_with_size"):
dll.WorkFlow_connect_string_with_size.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_char), ctypes.c_size_t, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.WorkFlow_connect_string_with_size.restype = None

if hasattr(dll, "WorkFlow_connect_Scoping"):
dll.WorkFlow_connect_Scoping.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.WorkFlow_connect_Scoping.restype = None
Expand Down Expand Up @@ -4506,6 +4518,10 @@ def load_api(path):
dll.WorkFlow_getoutput_string.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.WorkFlow_getoutput_string.restype = ctypes.POINTER(ctypes.c_char)

if hasattr(dll, "WorkFlow_getoutput_string_with_size"):
dll.WorkFlow_getoutput_string_with_size.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_size_t), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.WorkFlow_getoutput_string_with_size.restype = ctypes.POINTER(ctypes.c_char)

if hasattr(dll, "WorkFlow_getoutput_int"):
dll.WorkFlow_getoutput_int.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.WorkFlow_getoutput_int.restype = ctypes.c_int32
Expand Down
8 changes: 8 additions & 0 deletions src/ansys/dpf/gate/generated/operator_abstract_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def operator_connect_double(op, iPin, value):
def operator_connect_string(op, iPin, value):
raise NotImplementedError

@staticmethod
def operator_connect_string_with_size(op, iPin, value, size):
raise NotImplementedError

@staticmethod
def operator_connect_scoping(op, iPin, scoping):
raise NotImplementedError
Expand Down Expand Up @@ -235,6 +239,10 @@ def operator_getoutput_generic_data_container(op, iOutput):
def operator_getoutput_string(op, iOutput):
raise NotImplementedError

@staticmethod
def operator_getoutput_string_with_size(op, iOutput, size):
raise NotImplementedError

@staticmethod
def operator_getoutput_bytearray(op, iOutput, size):
raise NotImplementedError
Expand Down
20 changes: 20 additions & 0 deletions src/ansys/dpf/gate/generated/operator_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ def operator_connect_string(op, iPin, value):
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def operator_connect_string_with_size(op, iPin, value, size):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
res = capi.dll.Operator_connect_string_with_size(op._internal_obj if op is not None else None, utils.to_int32(iPin), utils.to_char_ptr(value), size, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def operator_connect_scoping(op, iPin, scoping):
errorSize = ctypes.c_int(0)
Expand Down Expand Up @@ -523,6 +532,17 @@ def operator_getoutput_string(op, iOutput):
capi.dll.DataProcessing_String_post_event(res, ctypes.byref(errorSize), ctypes.byref(sError))
return newres

@staticmethod
def operator_getoutput_string_with_size(op, iOutput, size):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
res = capi.dll.Operator_getoutput_string_with_size(op._internal_obj if op is not None else None, utils.to_int32(iOutput), size, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
newres = ctypes.cast(res, ctypes.c_char_p).value.decode("utf-8") if res else None
capi.dll.DataProcessing_String_post_event(res, ctypes.byref(errorSize), ctypes.byref(sError))
return newres

@staticmethod
def operator_getoutput_bytearray(op, iOutput, size):
errorSize = ctypes.c_int(0)
Expand Down
Loading

0 comments on commit 7ed0220

Please sign in to comment.