MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / Interface

Class Interface

tools/api.py:1145–1233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1143
1144
1145class Interface(Handle):
1146 def __init__(self, name: str, ctype: str, cpptype: str) -> None:
1147 super().__init__(name, ctype, cpptype, skip_def=True)
1148 self.ifunctions: List[Function] = []
1149 self.members: List[str] = []
1150
1151 def mname(self, name: str) -> str:
1152 return name + "_f"
1153
1154 def constructor( # type: ignore
1155 self,
1156 name: str,
1157 params: Optional[List[Parameter]] = None,
1158 **kwargs) -> 'Interface':
1159 create = self.substitute('allocate<${opaque_type}>($@)')
1160
1161 initial_params = gparams(obj='void*',
1162 c=self.cname('copy'),
1163 d=self.cname('delete'))
1164
1165 add_function(self.cname(name),
1166 params=initial_params + (params or []),
1167 invoke=create,
1168 returns=self.opaque_type,
1169 return_name=self.name,
1170 **kwargs)
1171 return self
1172
1173 def method(self, *args, **kwargs) -> 'Interface':
1174 super().method(*args, **kwargs)
1175 return self
1176
1177 def virtual(self,
1178 name: str,
1179 params: Optional[List[Parameter]] = None,
1180 const: Optional[bool] = None,
1181 **kwargs) -> 'Interface':
1182
1183 # Add this parameter to the function
1184 this = Parameter('obj', 'void*', this=True)
1185 this.virtual_read = ['object_ptr.data']
1186 exception_msg = Parameter('exception_msg', 'char*', hidden=True)
1187 exception_msg.virtual_read = ['${name}.data()']
1188 exception_msg_size = Parameter('exception_msg_size',
1189 'size_t',
1190 hidden=True)
1191 exception_msg_size.virtual_read = ['exception_msg.size()']
1192 f = Function(name,
1193 params=[this, exception_msg, exception_msg_size] +
1194 (params or []),
1195 virtual=True,
1196 **kwargs)
1197 self.ifunctions.append(f)
1198
1199 add_function(self.cname('set_' + name),
1200 params=gparams(obj=self.opaque_type,
1201 input=self.cname(name)),
1202 invoke='${{obj}}->{name} = ${{input}}'.format(

Callers 1

with_interfaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected