what does the last argument to SWIG_NewPointerObj mean?

后端 未结 1 875
醉酒成梦
醉酒成梦 2021-02-19 07:32

I have a compatibility library that uses SWIG to access a C++ library. I would find it useful to be able to create a SWIG-wrapped Python object inside this layer (as opposed to

1条回答
  •  不思量自难忘°
    2021-02-19 08:00

    When you create new pointer objects with SWIG_NewPointerObj, you may pass the following flags:

    SWIG_POINTER_OWN
    SWIG_POINTER_NOSHADOW
    

    If SWIG_POINTER_OWN is set, the destructor of the underlying C++ class will be called when the Python pointer is finalized. By default, the destructor will not be called. See Memory Management

    For your use case, you don't need to set any flags at all.

    From what I can see in the sources, if SWIG_POINTER_NOSHADOW is set, then a basic wrapped pointer is returned. You will not be able to access member variables in Python. All you'll have is an opaque pointer.

    Reference: /usr/share/swig/2.0.7/python/pyrun.swg

    0 讨论(0)
提交回复
热议问题