Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
ad29903d
Commit
ad29903d
authored
5 years ago
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cypclass type in PyrexTypes
parent
50f5aa5a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
3 deletions
+54
-3
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+54
-3
No files found.
Cython/Compiler/PyrexTypes.py
View file @
ad29903d
...
...
@@ -242,6 +242,7 @@ class PyrexType(BaseType):
is_cfunction
=
0
is_struct_or_union
=
0
is_cpp_class
=
0
is_cyp_class
=
0
is_cpp_string
=
0
is_struct
=
0
is_enum
=
0
...
...
@@ -2566,8 +2567,9 @@ class CPtrType(CPointerBaseType):
return
self
.
base_type
.
pointer_assignable_from_resolved_type
(
other_type
)
else
:
return
0
if
(
self
.
base_type
.
is_cpp_class
and
other_type
.
is_ptr
and
other_type
.
base_type
.
is_cpp_class
and
other_type
.
base_type
.
is_subclass
(
self
.
base_type
)):
if
(
self
.
base_type
.
is_cpp_class
and
(
other_type
.
is_ptr
and
other_type
.
base_type
.
is_cpp_class
and
other_type
.
base_type
.
is_subclass
(
self
.
base_type
)
or
other_type
.
is_cyp_class
and
other_type
.
is_subclass
(
self
.
base_type
))):
return
1
if
other_type
.
is_array
or
other_type
.
is_ptr
:
return
self
.
base_type
.
is_void
or
self
.
base_type
.
same_as
(
other_type
.
base_type
)
...
...
@@ -3544,7 +3546,7 @@ class CppClassType(CType):
subtypes
=
[
'templates'
]
def
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
=
None
,
template_type
=
None
):
def
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
=
None
,
template_type
=
None
,
nogil
=
0
):
self
.
name
=
name
self
.
cname
=
cname
self
.
scope
=
scope
...
...
@@ -3558,6 +3560,7 @@ class CppClassType(CType):
else
:
self
.
specializations
=
{}
self
.
is_cpp_string
=
cname
in
cpp_string_conversions
self
.
nogil
=
nogil
def
use_conversion_utility
(
self
,
from_or_to
):
pass
...
...
@@ -3869,6 +3872,8 @@ class CppClassType(CType):
# Make it "nogil" if the base classes allow it.
nogil
=
True
for
base
in
self
.
base_classes
:
if
base
is
cy_object_type
:
continue
base_constructor
=
base
.
scope
.
lookup
(
'<init>'
)
if
base_constructor
and
not
base_constructor
.
type
.
nogil
:
nogil
=
False
...
...
@@ -3883,6 +3888,50 @@ class CppClassType(CType):
error
(
pos
,
"C++ class must have a nullary constructor to be %s"
%
msg
)
class
CypClassType
(
CppClassType
):
is_cyp_class
=
1
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
,
template_params
=
None
):
if
entity_code
:
entity_code
=
"*%s"
%
entity_code
return
super
(
CypClassType
,
self
).
declaration_code
(
entity_code
,
for_display
=
for_display
,
dll_linkage
=
dll_linkage
,
pyrex
=
pyrex
,
template_params
=
template_params
)
def
check_nullary_constructor
(
self
,
pos
,
msg
=
"stack allocated"
):
# We are wrapping the constructor => we manipulate the object through pointers like PyExtTypes => don't care about this check
return
def
cast_code
(
self
,
expr_code
):
return
"((%s)%s)"
%
(
self
.
declaration_code
(
''
),
expr_code
)
def
assignable_from_resolved_type
(
self
,
other_type
):
if
other_type
.
is_ptr
and
other_type
.
base_type
.
is_cpp_class
and
other_type
.
base_type
.
is_subclass
(
self
):
return
1
return
super
(
CypClassType
,
self
).
assignable_from_resolved_type
(
other_type
)
def
get_constructor
(
self
,
pos
):
# This is (currently) only called by new statements.
# In cypclass, it means direct memory allocation:
# regardless of __init__ presence/absence,
# new is forced to be called without any arguments,
# and doesn't call any __init__
# (the mapping from cython __init__ to c++ constructors isn't done
# for cypclass, instead a default empty constructor is declared,
# and calls to __init__ are performed by wrappers)
# As we do not care about declared __init__ in the scope,
# we just return a correct but fake entry.
from
.
import
Symtab
init_type
=
CFuncType
(
c_void_type
,
[],
nogil
=
1
)
init_cname
=
"__unused__"
init_name
=
"<unused>"
init_entry
=
Symtab
.
Entry
(
init_name
,
init_cname
,
init_type
,
pos
=
pos
)
init_entry
.
is_cfunction
=
1
return
init_entry
class
TemplatePlaceholderType
(
CType
):
def
__init__
(
self
,
name
,
optional
=
False
):
...
...
@@ -4140,6 +4189,8 @@ unspecified_type = UnspecifiedType()
py_object_type
=
PyObjectType
()
cy_object_type
=
CypClassType
(
'cyobject'
,
None
,
"CyObject"
,
None
)
c_void_type
=
CVoidType
()
c_uchar_type
=
CIntType
(
0
,
UNSIGNED
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment