Commit 7f1cf72d authored by Xavier Thompson's avatar Xavier Thompson

Fix reference counting in acthon implementation

parent 23778224
...@@ -1087,38 +1087,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1087,38 +1087,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
sync_attr_cname = message_base_type.scope.lookup_here("_sync_method").cname sync_attr_cname = message_base_type.scope.lookup_here("_sync_method").cname
result_attr_cname = message_base_type.scope.lookup_here("_result").cname result_attr_cname = message_base_type.scope.lookup_here("_result").cname
def put_cypclass_op_on_narg_optarg(op_lbda, func_type, opt_arg_name, code):
opt_arg_count = func_type.optional_arg_count
narg_count = len(func_type.args) - opt_arg_count
for narg in func_type.args[:narg_count]:
if narg.type.is_cyp_class:
code.putln("%s(this->%s);" % (op_lbda(narg), narg.cname))
if opt_arg_count:
opt_arg_guard = code.insertion_point()
code.increase_indent()
num_if = 0
for opt_idx, optarg in enumerate(func_type.args[narg_count:]):
if optarg.type.is_cyp_class:
code.putln("if (this->%s->%sn > %s) {" %
(opt_arg_name,
Naming.pyrex_prefix,
opt_idx
))
code.putln("%s(this->%s->%s);" %
(op_lbda(optarg),
opt_arg_name,
func_type.opt_arg_cname(optarg.name)
))
num_if += 1
for _ in range(num_if):
code.putln("}")
if num_if:
opt_arg_guard.putln("if (this->%s != NULL) {" % opt_arg_name)
code.putln("}")
else:
code.decrease_indent()
for reified_function_entry in entry.type.scope.reified_entries: for reified_function_entry in entry.type.scope.reified_entries:
reifying_class_name = "%s%s" % (Naming.cypclass_reified_prefix, reified_function_entry.name) 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) reifying_class_full_name = "%s::%s" % (entry.type.empty_declaration_code(), reifying_class_name)
...@@ -1186,7 +1154,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1186,7 +1154,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("}") code.putln("}")
# Acquire a ref on CyObject, as we don't know when the message will be processed # Acquire a ref on CyObject, as we don't know when the message will be processed
put_cypclass_op_on_narg_optarg(lambda _: "Cy_INCREF", reified_function_entry.type, Naming.optional_args_cname, code)
code.putln("Cy_INCREF(this->%s);" % target_object_cname) code.putln("Cy_INCREF(this->%s);" % target_object_cname)
code.putln("}") code.putln("}")
...@@ -1231,7 +1198,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1231,7 +1198,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# Destructor # Destructor
code.putln("virtual ~%s() {" % class_name) code.putln("virtual ~%s() {" % class_name)
code.putln("Cy_DECREF(this->%s);" % target_object_cname) code.putln("Cy_DECREF(this->%s);" % target_object_cname)
put_cypclass_op_on_narg_optarg(lambda _: "Cy_DECREF", reified_function_entry.type, Naming.optional_args_cname, code)
if opt_arg_count: if opt_arg_count:
code.putln("free(this->%s);" % Naming.optional_args_cname) code.putln("free(this->%s);" % Naming.optional_args_cname)
code.putln("}") code.putln("}")
......
...@@ -388,7 +388,6 @@ ...@@ -388,7 +388,6 @@
ActhonQueueInterface *_active_queue_class = NULL; ActhonQueueInterface *_active_queue_class = NULL;
ActhonResultInterface *(*_active_result_class)(void); ActhonResultInterface *(*_active_result_class)(void);
ActhonActivableClass(){} // Used in Activated classes inheritance chain (base Activated calls this, derived calls the 2 args version below) ActhonActivableClass(){} // Used in Activated classes inheritance chain (base Activated calls this, derived calls the 2 args version below)
ActhonActivableClass(ActhonQueueInterface * queue_object, ActhonResultInterface *(*result_constructor)(void));
virtual ~ActhonActivableClass(); virtual ~ActhonActivableClass();
}; };
...@@ -909,7 +908,6 @@ void CyObject::CyObject_UNWLOCK() const ...@@ -909,7 +908,6 @@ void CyObject::CyObject_UNWLOCK() const
ActhonMessageInterface::ActhonMessageInterface(ActhonSyncInterface* sync_method, ActhonMessageInterface::ActhonMessageInterface(ActhonSyncInterface* sync_method,
ActhonResultInterface* result_object) : _sync_method(sync_method), _result(result_object) ActhonResultInterface* result_object) : _sync_method(sync_method), _result(result_object)
{ {
Cy_INCREF(this->_sync_method);
Cy_INCREF(this->_result); Cy_INCREF(this->_result);
} }
...@@ -919,12 +917,6 @@ ActhonMessageInterface::~ActhonMessageInterface() ...@@ -919,12 +917,6 @@ ActhonMessageInterface::~ActhonMessageInterface()
Cy_XDECREF(this->_result); Cy_XDECREF(this->_result);
} }
ActhonActivableClass::ActhonActivableClass(ActhonQueueInterface * queue_object, ActhonResultInterface *(*result_constructor)(void))
: _active_queue_class(queue_object), _active_result_class(result_constructor)
{
Cy_INCREF(this->_active_queue_class);
}
ActhonActivableClass::~ActhonActivableClass() ActhonActivableClass::~ActhonActivableClass()
{ {
Cy_XDECREF(this->_active_queue_class); Cy_XDECREF(this->_active_queue_class);
......
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