Commit 8f14ad8c authored by Xavier Thompson's avatar Xavier Thompson

Fix const-correctness of cypclass active methods

parent fb0630cf
......@@ -1124,14 +1124,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
reifying_class_name = "%s%s" % (Naming.cypclass_reified_prefix, reified_function_entry.name)
reifying_class_full_name = "%s::%s" % (entry.type.empty_declaration_code(), reifying_class_name)
class_name = reifying_class_full_name.split('::')[-1]
if reified_function_entry.type.is_const_method:
qualified_target_object_code = "const %s" % target_object_code
else:
qualified_target_object_code = target_object_code
if entry.type.templates:
templates_code = "template <typename %s>" % ", typename ".join(t.name for t in entry.type.templates)
code.putln(templates_code)
code.putln("struct %s : public %s {" % (reifying_class_full_name, message_base_type.empty_declaration_code()))
# Declaring target object & reified method arguments
code.putln("%s;" % target_object_code)
code.putln("%s;" % qualified_target_object_code)
constructor_args_decl_list = [
target_object_code,
qualified_target_object_code,
sync_type.declaration_code(sync_arg_name),
result_type.declaration_code(result_arg_name)
]
......
......@@ -2821,25 +2821,22 @@ class CppClassScope(Scope):
if entry.type.has_varargs:
error(entry.pos, "Could not reify method with ellipsis (you can use optional arguments)")
self.reified_entries.append(entry)
# create corresponding active entry
# create the corresponding active type and entry
from . import Builtin
result_type = Builtin.acthon_result_type
sync_type = Builtin.acthon_sync_type
# create the sync argument type
activated_method_sync_attr_type = PyrexTypes.CFuncTypeArg(
EncodedString("sync_method"),
PyrexTypes.CConstOrVolatileType(sync_type, is_const=1),
entry.pos,
"sync_method",
)
activated_method_type = PyrexTypes.CFuncType(
result_type,
[activated_method_sync_attr_type] + entry.type.args,
nogil=entry.type.nogil,
has_varargs = entry.type.has_varargs,
optional_arg_count = entry.type.optional_arg_count,
)
if hasattr(entry.type, 'op_arg_struct'):
activated_method_type.op_arg_struct = entry.type.op_arg_struct
# create the active method type
activated_method_type = copy.copy(entry.type)
activated_method_type.return_type = result_type
activated_method_type.args = [activated_method_sync_attr_type] + entry.type.args
# create the active method entry
activated_method_cname = "%s%s" % (Naming.cypclass_active_func_prefix, entry.cname)
activated_method_entry = Entry(entry.name, activated_method_cname, activated_method_type, entry.pos)
activated_method_entry.func_cname = "%s::%s" % (self.type.empty_declaration_code(), activated_method_cname)
......@@ -2847,6 +2844,7 @@ class CppClassScope(Scope):
activated_method_entry.scope = self
activated_method_entry.is_cfunction = 1
activated_method_entry.is_variable = 1
# associate the active entry to the passive entry
entry.active_entry = activated_method_entry
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment