提交 3465a406 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Fix ParamsType when used with CLinker.

上级 9520fdec
......@@ -655,7 +655,7 @@ class ParamsType(Type):
return list(sorted(list(c_support_code_set))) + [final_struct_code]
def c_code_cache_version(self):
return ((2,), tuple(t.c_code_cache_version() for t in self.types))
return ((3,), tuple(t.c_code_cache_version() for t in self.types))
# As this struct has constructor and destructor, it could be instanciated on stack,
# but current implementations of C ops will then pass the instance by value at functions,
......@@ -684,6 +684,7 @@ class ParamsType(Type):
/* Seems c_init() is not called for a op param. So I call `new` here. */
%(name)s = new %(struct_name)s;
{ // This need a separate namespace for Clinker
const char* fields[] = {%(fields_list)s};
if (py_%(name)s == Py_None) {
PyErr_SetString(PyExc_ValueError, "ParamsType: expected an object, not None.");
......@@ -703,5 +704,6 @@ class ParamsType(Type):
%(fail)s
}
}
}
""" % dict(name=name, struct_name=self.name, length=self.length, fail=sub['fail'],
fields_list='"%s"' % '", "'.join(self.fields))
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论