Commit 6b8a3e9b authored by gsamain's avatar gsamain

Introduction of tristate lock mode

parent a0c15ac2
......@@ -1522,7 +1522,7 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
error(self.pos, "Required template parameters must precede optional template parameters.")
self.entry = env.declare_cpp_class(
self.name, None, self.pos, self.cname,
base_classes=[], visibility=self.visibility, templates=template_types, cypclass=self.cypclass)
base_classes=[], visibility=self.visibility, templates=template_types, cypclass=self.cypclass, lock_mode=self.lock_mode)
def analyse_declarations(self, env):
if self.templates is None:
......@@ -1549,7 +1549,7 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
base_class_types = filter(base_ok, base_types_list)
self.entry = env.declare_cpp_class(
self.name, scope, self.pos,
self.cname, base_class_types, visibility=self.visibility, templates=template_types, cypclass=self.cypclass)
self.cname, base_class_types, visibility=self.visibility, templates=template_types, cypclass=self.cypclass, lock_mode=self.lock_mode)
if self.entry is None:
return
self.entry.is_cpp_class = 1
......
......@@ -3797,6 +3797,9 @@ def p_cpp_class_definition(s, pos, ctx):
if s.sy == '[':
error(s.position(), "Name options not allowed for C++ class")
nogil = p_nogil(s) or cypclass
lock_mode = None
if cypclass:
lock_mode = p_cypclass_lock_mode(s)
if s.sy == ':':
s.next()
s.expect('NEWLINE')
......@@ -3822,7 +3825,7 @@ def p_cpp_class_definition(s, pos, ctx):
visibility = ctx.visibility,
in_pxd = ctx.level == 'module_pxd',
attributes = attributes,
templates = templates, cypclass=cypclass)
templates = templates, cypclass=cypclass, lock_mode=lock_mode)
def p_cpp_class_attribute(s, ctx):
decorators = None
......@@ -3848,6 +3851,14 @@ def p_cpp_class_attribute(s, ctx):
node.decorators = decorators
return node
def p_cypclass_lock_mode(s):
if s.sy == 'IDENT' and s.systring in ('nolock', 'checklock', 'autolock'):
mode = s.systring
s.next()
return mode
else:
return None
#----------------------------------------------
#
......
......@@ -3896,8 +3896,14 @@ class CppClassType(CType):
class CypClassType(CppClassType):
# lock_mode string (tri-state: "nolock"/"checklock"/"autolock")
is_cyp_class = 1
def __init__(self, name, scope, cname, base_classes, templates=None, template_type=None, nogil=0, lock_mode=None):
CppClassType.__init__(self, name, scope, cname, base_classes, templates, template_type, nogil)
self.lock_mode = lock_mode if lock_mode else "checklock"
def empty_declaration_code(self):
if self._empty_declaration is None:
self._empty_declaration = self.declaration_code('', deref=1)
......
......@@ -600,7 +600,7 @@ class Scope(object):
def declare_cpp_class(self, name, scope,
pos, cname = None, base_classes = (),
visibility = 'extern', templates = None, cypclass=0):
visibility = 'extern', templates = None, cypclass=0, lock_mode=None):
if cname is None:
if self.in_cinclude or (visibility != 'private'):
cname = name
......@@ -611,7 +611,7 @@ class Scope(object):
if not entry:
if cypclass:
type = PyrexTypes.CypClassType(
name, scope, cname, base_classes, templates = templates)
name, scope, cname, base_classes, templates = templates, lock_mode=lock_mode)
else:
type = PyrexTypes.CppClassType(
name, scope, cname, base_classes, templates = templates)
......
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