/usr/include/swiginac/typemaps.i is in python-swiginac 1.5.1.1-1+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | /*
(c) Copyright 2003, 2004, 2005
Author: Ola Skavhaug and Ondrej Certik
This file is part of swiginac.
swiginac is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
swiginac is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with swiginac; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%typemap(in) (int idx0, int idx1) {
if(PyTuple_Check($input))
{
$1 = PyInt_AsLong(PyTuple_GetItem($input,0));
if(PyTuple_Size($input) > 1)
$2 = PyInt_AsLong(PyTuple_GetItem($input,1));
else
$2 = 0;
}
else
{
$1 = PyInt_AsLong($input);
$2 = 0;
}
}
%typemap(in) lst & {
$1=list2lst($input);
if (!$1) return NULL;
}
%typemap(in) const lst & {
$1=list2lst($input);
if (!$1) return NULL;
}
%typemap(typecheck, precedence=1200) lst & {
$1 = (PyList_Check($input)) ? 1 : 0;
}
%{
// class to handle deleting a temporary resource in an input typemap
template<class T>
class TDeleter
{
public:
T * obj;
TDeleter():
obj(0)
{
//std::cout << "TDeleter constructor." << std::endl;
}
~TDeleter()
{
//std::cout << "TDeleter destructor, obj = " << obj << std::endl;
if(obj)
{
//std::cout << "TDeleter deleting obj:" << std::endl;
delete obj;
//std::cout << "TDeleter done deleting obj." << std::endl;
}
//std::cout << "TDeleter is now destroyed." << std::endl;
}
};
typedef TDeleter<GiNaC::ex> ex_deleter;
typedef TDeleter<const GiNaC::ex> const_ex_deleter;
%}
%typemap(in) ex & (ex_deleter deleter) {
$1 = type2ex($input);
if ($1 == NULL ) {
return NULL;
}
deleter.obj = $1;
}
%typemap(in) const ex & (const_ex_deleter deleter) {
$1 = type2ex($input);
if ($1 == NULL ) {
return NULL;
}
deleter.obj = $1;
}
//%typemap(in) const ex & = ex &;
%typemap(in) ex {
ex *tmp = type2ex($input);
if (tmp == NULL ) {
return NULL;
}
$1 = *(tmp);
delete tmp;
}
%typemap(in) const ex = ex;
%typemap(in) numeric & {
$1 = type2numeric($input);
if (!$1) return NULL;
}
%typemap(typecheck, precedence=1210) ex & {
$1 = (checktype2ex($input)) ? 1 : 0;
}
%typemap(typecheck, precedence=1209) ex {
$1 = (checktype2ex($input)) ? 1 : 0; // TODO: This could be wrong, while ex& is treated as a pointer by swig, ex is not, at least in the typemap(in) above.
}
%typemap(out) ex {
$result = ex2type(&($1));
}
//%typemap(out) ex *{
// $result = ex2type($1);
// delete $1;
//}
%typemap(out) exvector {
$result = exvector2list(&($1));
}
%typemap(out) lst & {
$result = lst2list($1);
}
//it seems we don't need these
/*
%typemap(out) ex &{
$result = ex2type($1);
}*/
// vim:ft=cpp:
|