提交 7c70b97b authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Add a way for COps to pass parameter outside of the inputs.

上级 f1f74ac5
...@@ -1146,6 +1146,17 @@ class COp(Op): ...@@ -1146,6 +1146,17 @@ class COp(Op):
raise ValueError("No valid section marker was found in file " raise ValueError("No valid section marker was found in file "
"%s" % self.func_files[i]) "%s" % self.func_files[i])
def get_op_params(self):
"""
Returns a list of (name, value) pairs that will be turned into
macros for use within the op code. This is intended to allow
an op's properties to influence the generated C code.
The names must be strings that are not a C keyword and the
values must be strings of litteral C representations.
"""
return []
def c_code_cache_version(self): def c_code_cache_version(self):
return hash(tuple(self.func_codes)) return hash(tuple(self.func_codes))
...@@ -1208,6 +1219,10 @@ class COp(Op): ...@@ -1208,6 +1219,10 @@ class COp(Op):
"str##_%s" % name)) "str##_%s" % name))
undef_macros.append(undef_template % "APPLY_SPECIFIC") undef_macros.append(undef_template % "APPLY_SPECIFIC")
for n, v in self.get_op_params():
define_macros.append(define_template % (n, v))
undef_macros.append(undef_template % (n,))
return os.linesep.join(define_macros), os.linesep.join(undef_macros) return os.linesep.join(define_macros), os.linesep.join(undef_macros)
def _lquote_macro(self, txt): def _lquote_macro(self, txt):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论