Commit ea662de3 authored by gsamain's avatar gsamain Committed by Xavier Thompson

Introduction of tristate lock mode

parent fd559d44
......@@ -1520,7 +1520,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:
......@@ -1547,7 +1547,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
......
......@@ -3793,6 +3793,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')
......@@ -3821,7 +3824,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
......@@ -3847,6 +3850,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
#----------------------------------------------
#
......
......@@ -4041,8 +4041,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)
......
......@@ -628,7 +628,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
......@@ -639,7 +639,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