Commit 0e5a9292 authored by gsamain's avatar gsamain Committed by Xavier Thompson

Put interface acthon injection in the builtins

parent 1858459e
This diff is collapsed.
......@@ -144,7 +144,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
else:
env.doc = self.doc
env.directives = self.directives
env.inject_acthon_interfaces()
self.body.analyse_declarations(env)
def prepare_utility_code(self):
......@@ -1176,7 +1175,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("}")
def generate_cyp_class_activated_class(self, entry, code):
result_interface_entry = entry.scope.lookup_here("ActhonResultInterface")
result_interface_entry = entry.scope.lookup("ActhonResultInterface")
# TODO: handle inheritance
activable_bases = ["public %s::Activated" % base.cname for base in entry.type.base_classes if base.activable]
if activable_bases:
......
......@@ -1544,7 +1544,7 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
for base_type in base_types_list:
activable_base = activable_base or base_type.activable
if not activable_base:
activable_base_entry = env.lookup_here("ActhonActivableClass")
activable_base_entry = env.lookup("ActhonActivableClass")
base_types_list.append(activable_base_entry.type)
cyobject_base = False
......
......@@ -1337,139 +1337,6 @@ class ModuleScope(Scope):
self.declare_var(EncodedString(var_name), py_object_type, None)
self.process_include(Code.IncludeCode("Python.h", initial=True))
def inject_acthon_interfaces(self):
# XXX - Moving this to the builtin scope would make much more sense
# XXX - than redeclaring acthon builtins in every module.
# cypclass ActhonResultInterface(CyObject):
# void pushVoidStarResult(void* result){}
# void* getVoidStarResult(){}
# void pushIntResult(int result){}
# int getIntResult(){}
# operator int() { return this->getIntResult(); }
result_scope = CppClassScope("ActhonResultInterface", self)
result_type = PyrexTypes.CypClassType(
"ActhonResultInterface", result_scope, "ActhonResultInterface", (PyrexTypes.cy_object_type,),
lock_mode="nolock", activable=False)
result_scope.type = result_type
#result_type.set_scope is a little bit overkill here, because parent_type is only used when doing scope inheritance
result_entry = self.declare("ActhonResultInterface", None, result_type, "ActhonResultInterface", "extern")
result_entry.is_type = 1
result_pushVoidStar_arg_type = PyrexTypes.CFuncTypeArg("result", PyrexTypes.c_void_ptr_type, None)
result_pushVoidStar_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [result_pushVoidStar_arg_type], nogil = 1)
result_pushVoidStar_entry = result_scope.declare_cfunction("pushVoidStarResult", result_pushVoidStar_type,
None, cname="pushVoidStarResult", defining = 1)
result_getVoidStar_type = PyrexTypes.CFuncType(PyrexTypes.c_void_ptr_type, [], nogil = 1)
result_getVoidStar_entry = result_scope.declare_cfunction("getVoidStarResult", result_getVoidStar_type,
None, cname="getVoidStarResult", defining = 1)
result_pushInt_arg_type = PyrexTypes.CFuncTypeArg("result", PyrexTypes.c_int_type, None)
result_pushInt_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [result_pushInt_arg_type], nogil = 1)
result_pushInt_entry = result_scope.declare_cfunction("pushIntResult", result_pushInt_type,
None, cname="pushIntResult", defining = 1)
result_getInt_type = PyrexTypes.CFuncType(PyrexTypes.c_int_type, [], nogil = 1)
result_pushInt_entry = result_scope.declare_cfunction("getIntResult", result_getInt_type,
None, cname="getIntResult", defining = 1)
result_int_typecast_type = PyrexTypes.CFuncType(PyrexTypes.c_int_type, [], nogil = 1)
result_int_typecast_entry = result_scope.declare_cfunction("operator int", result_int_typecast_type,
None, cname="operator int", defining = 1)
# cypclass ActhonMessageInterface
message_scope = CppClassScope("ActhonMessageInterface", self)
message_type = PyrexTypes.CypClassType(
"ActhonMessageInterface", message_scope, "ActhonMessageInterface", (PyrexTypes.cy_object_type,),
lock_mode="nolock", activable=False)
message_scope.type = message_type
# cypclass ActhonSyncInterface(CyObject):
# bool isActivable(){}
# bool isCompleted(){}
# void insertActivity(ActhonMessageInterface msg){}
# void removeActivity(ActhonMessageInterface msg){}
sync_scope = CppClassScope("ActhonSyncInterface", self)
sync_type = PyrexTypes.CypClassType(
"ActhonSyncInterface", sync_scope, "ActhonSyncInterface", (PyrexTypes.cy_object_type,),
lock_mode="nolock", activable=False)
sync_scope.type = sync_type
sync_entry = self.declare("ActhonSyncInterface", None, sync_type, "ActhonSyncInterface", "extern")
sync_entry.is_type = 1
sync_isActivable_type = PyrexTypes.CFuncType(PyrexTypes.c_bint_type, [], nogil = 1)
sync_isActivable_entry = sync_scope.declare_cfunction("isActivable", sync_isActivable_type,
None, cname="isActivable", defining = 1)
sync_isCompleted_type = PyrexTypes.CFuncType(PyrexTypes.c_bint_type, [], nogil = 1)
sync_isCompleted_entry = sync_scope.declare_cfunction("isCompleted", sync_isCompleted_type,
None, cname="isCompleted", defining = 1)
sync_msg_arg = PyrexTypes.CFuncTypeArg("msg", message_type, None)
sync_insertActivity_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [sync_msg_arg], nogil = 1)
sync_removeActivity_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [sync_msg_arg], nogil = 1)
sync_insertActivity_entry = sync_scope.declare_cfunction("insertActivity", sync_insertActivity_type,
None, cname="insertActivity", defining = 1)
sync_removeActivity_entry = sync_scope.declare_cfunction("removeActivity", sync_removeActivity_type,
None, cname="removeActivity", defining = 1)
# cypclass ActhonMessageInterface(CyObject):
# ActhonSyncInterface _sync_method
# ActhonResultInterface _result
# bool activate(){}
message_entry = self.declare("ActhonMessageInterface", None, message_type, "ActhonMessageInterface", "extern")
message_entry.is_type = 1
message_sync_attr_entry = message_scope.declare_var("_sync_method", sync_type, None)
message_result_attr_entry = message_scope.declare_var("_result", result_type, None)
message_activate_type = PyrexTypes.CFuncType(PyrexTypes.c_bint_type, [], nogil = 1)
message_activate_entry = message_scope.declare_cfunction("activate", message_activate_type,
None, cname="activate", defining = 1)
# cypclass ActhonQueueInterface(CyObject):
# void push(ActhonMessageInterface message){}
# bool activate(){}
queue_scope = CppClassScope("ActhonQueueInterface", self)
queue_type = PyrexTypes.CypClassType(
"ActhonQueueInterface", queue_scope, "ActhonQueueInterface", (PyrexTypes.cy_object_type,),
lock_mode="nolock", activable=False)
queue_scope.type = queue_type
queue_entry = self.declare("ActhonQueueInterface", None, queue_type, "ActhonQueueInterface", "extern")
queue_entry.is_type = 1
queue_msg_arg = PyrexTypes.CFuncTypeArg("msg", message_type, None)
queue_push_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [queue_msg_arg], nogil = 1)
queue_push_entry = queue_scope.declare_cfunction("push", queue_push_type,
None, cname="push", defining = 1)
queue_activate_type = PyrexTypes.CFuncType(PyrexTypes.c_bint_type, [], nogil = 1)
queue_activate_entry = queue_scope.declare_cfunction("activate", queue_activate_type,
None, cname="activate", defining = 1)
# cdef cypclass ActivableClass:
# ResultInterface (*_active_result_class)()
# QueueInterface _active_queue_class
activable_scope = CppClassScope("ActhonActivableClass", self)
activable_type = PyrexTypes.CypClassType(
"ActhonActivableClass", activable_scope, "ActhonActivableClass", (PyrexTypes.cy_object_type,),
lock_mode="nolock", activable=False)
activable_entry = self.declare("ActhonActivableClass", None, activable_type, "ActhonActivableClass", "extern")
activable_entry.is_type = 1
activable_result_attr_type = PyrexTypes.CPtrType(PyrexTypes.CFuncType(result_entry.type, []))
activable_result_attr_entry = activable_scope.declare_var("_active_result_class", activable_result_attr_type, None)
activable_queue_attr_entry = activable_scope.declare_var("_active_queue_class", queue_entry.type, None)
def qualifying_scope(self):
return self.parent_module
......
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