Octave - SWIG now marshalls a C/C++ NULL pointer into the null matrix, []
SWIG has always marshalled the null matrix into a NULL pointer; this remains and now we have consistency in representing a NULL pointer. This is a pre-requisite for a pending commit to fully support std::unique_ptr.
This commit is contained in:
parent
2cfd77b1c0
commit
ca9eebcb8d
4 changed files with 27 additions and 5 deletions
|
|
@ -7,8 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.1.0 (in progress)
|
||||
===========================
|
||||
|
||||
2022-08-28: wsfulton
|
||||
[Octave] SWIG now marshalls a C/C++ NULL pointer into the null matrix, [].
|
||||
SWIG has always marshalled the null matrix into a NULL pointer; this remains
|
||||
and now we have consistency in representing a NULL pointer.
|
||||
|
||||
2022-08-26: wsfulton
|
||||
[Racket] SWIG now converts a C/C++ NULL pointer into a null value by calling
|
||||
[Racket] SWIG now marshalls a C/C++ NULL pointer into a null value by calling
|
||||
scheme_make_null(), so that scheme's null? is true for a NULL C/C++ pointer value.
|
||||
|
||||
2022-08-18: wsfulton
|
||||
|
|
|
|||
|
|
@ -363,6 +363,10 @@ octave:2> f=swigexample.fopen("not there", "r");
|
|||
error: value on right hand side of assignment is undefined
|
||||
error: evaluating assignment expression near line 2, column 2 </pre></div>
|
||||
|
||||
<p>
|
||||
NULL C/C++ pointers are represented by the Octave null matrix, <tt>[]</tt>.
|
||||
</p>
|
||||
|
||||
<H3><a name="Octave_nn13">30.3.6 Structures and C++ classes</a></H3>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,3 +6,13 @@ endif
|
|||
null_pointer;
|
||||
|
||||
assert(funk([]));
|
||||
null_ptr = getnull();
|
||||
assert(ismatrix(null_ptr))
|
||||
assert(size(null_ptr) == size([]))
|
||||
assert(isequal([], null_ptr))
|
||||
|
||||
# Can't use isnull as a test due to null matrix not being copyable...
|
||||
# n = []
|
||||
# isnull(n) # ans = 0
|
||||
# isnull([]) # ans = 1
|
||||
# isnull(getnull()) # ans = 0
|
||||
|
|
|
|||
|
|
@ -1547,12 +1547,15 @@ octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,swig
|
|||
SWIGRUNTIME octave_value SWIG_Octave_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
|
||||
int own = (flags &SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
|
||||
|
||||
if (ptr) {
|
||||
#ifdef SWIG_DIRECTORS
|
||||
Swig::Director *d = Swig::get_rtdir(ptr);
|
||||
if (d && Swig::swig_director_get_self(d))
|
||||
return Swig::swig_director_get_self(d)->as_value();
|
||||
Swig::Director *d = Swig::get_rtdir(ptr);
|
||||
if (d && Swig::swig_director_get_self(d))
|
||||
return Swig::swig_director_get_self(d)->as_value();
|
||||
#endif
|
||||
return Swig::swig_value_ref(new octave_swig_type(ptr, type, own));
|
||||
return Swig::swig_value_ref(new octave_swig_type(ptr, type, own));
|
||||
}
|
||||
return octave_value(Matrix()); // null matrix
|
||||
}
|
||||
|
||||
SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_type_info *type, int flags, int *own) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue