Skip to content

Commit a5c4bf1

Browse files
committed
Re-add shared_ptr_test.pyx as it's a hand-written fixture, not generated
1 parent 6aaf356 commit a5c4bf1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from libcpp.memory cimport shared_ptr
2+
from libcpp.string cimport string as std_string
3+
from cython.operator cimport dereference as deref
4+
5+
6+
cdef class Holder:
7+
8+
cdef shared_ptr[std_string] inst
9+
10+
def __init__(self, bytes what):
11+
cdef std_string p = <std_string> what
12+
self.inst = shared_ptr[std_string](new std_string(p))
13+
14+
def count(self):
15+
return self.inst.use_count()
16+
17+
18+
def getRef(self):
19+
cdef Holder res = Holder.__new__(Holder)
20+
res.inst = self.inst
21+
return res
22+
23+
def getCopy(self):
24+
cdef Holder res = Holder.__new__(Holder)
25+
res.inst = shared_ptr[std_string](new std_string(deref(self.inst.get())))
26+
return res
27+
28+
def addX(self):
29+
self.inst.get().push_back("x")
30+
31+
def size(self):
32+
return self.inst.get().size()

0 commit comments

Comments
 (0)