1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# (C) Copyright 2015 Enthought, Inc., Austin, TX
# All right reserved.
#
# This file is open source software distributed according to the terms in
# LICENSE.txt
#
from __future__ import absolute_import
 
from weakref import WeakKeyDictionary
 
from ._util import ffi
 
_keep_alive = WeakKeyDictionary()
 
 
def _PyBytes_FromStringAndSize(pointer, size):
    buffer = ffi.buffer(pointer, size)
    return buffer[:]
 
 
def byreference(x):
    return ffi.new(ffi.getctype(ffi.typeof(x), '*'), x)
 
 
def dereference(x):
    return x[0]