Commit 48d0f7f845aabf14786ea7563c180f6204bb48ba

Authored by Jürgen Knödlseder
1 parent ee567a31

Resolve more SWIG warnings

inst/cta/pyext/GCTAResponseTable.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GCTAResponseTable.i - CTA response table class * 2 * GCTAResponseTable.i - CTA response table class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2012-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2012-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -36,76 +36,6 @@ @@ -36,76 +36,6 @@
36 36
37 37
38 /***********************************************************************//** 38 /***********************************************************************//**
39 - * @brief Tuple to index conversion to provide pixel access.  
40 - *  
41 - * The following function provides conversion between a Python tuple and  
42 - * an integer array. This allows CTAResponseTable pixel access via tuples,  
43 - * such as in a[3,5,10] = 10.0 or c = a[2,9].  
44 - ***************************************************************************/  
45 -%{  
46 -static int rsp_table_tuple(PyObject *input, int *ptr) {  
47 - if (PySequence_Check(input)) {  
48 - int size = PyObject_Length(input);  
49 - if (size > 2) {  
50 - PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple");  
51 - return 0;  
52 - }  
53 - ptr[0] = size;  
54 - for (int i = 0; i < size; i++) {  
55 - PyObject *o = PySequence_GetItem(input,i);  
56 - if (!PyInt_Check(o)) {  
57 - Py_XDECREF(o);  
58 - PyErr_SetString(PyExc_ValueError,"Expecting a tuple of integers");  
59 - return 0;  
60 - }  
61 - ptr[i+1] = (int)PyInt_AsLong(o);  
62 - Py_DECREF(o);  
63 - }  
64 - return 1;  
65 - }  
66 - else {  
67 - ptr[0] = 1;  
68 - if (!PyInt_Check(input)) {  
69 - PyErr_SetString(PyExc_ValueError,"Expecting an integer");  
70 - return 0;  
71 - }  
72 - ptr[1] = (int)PyInt_AsLong(input);  
73 - return 1;  
74 - }  
75 -}  
76 -%}  
77 -  
78 -// This is the typemap that makes use of the function defined above  
79 -%typemap(in) int GCTAResponseTableInx[ANY](int temp[3]) {  
80 - if (!rsp_table_tuple($input,temp)) {  
81 - return NULL;  
82 - }  
83 - $1 = &temp[0];  
84 -}  
85 -  
86 -// This typecheck verifies that all arguments are integers. The typecheck  
87 -// is needed for using "int GCTAResponseTableInx" in overloaded methods.  
88 -%typemap(typecheck) int GCTAResponseTableInx[ANY] {  
89 - $1 = 1;  
90 - if (PySequence_Check($input)) {  
91 - int size = PyObject_Length($input);  
92 - for (int i = 0; i < size; i++) {  
93 - PyObject *o = PySequence_GetItem($input,i);  
94 - if (!PyInt_Check(o)) {  
95 - $1 = 0;  
96 - break;  
97 - }  
98 - }  
99 - }  
100 - else {  
101 - if (!PyInt_Check($input)) {  
102 - $1 = 0;  
103 - }  
104 - }  
105 -}  
106 -  
107 -  
108 -/***********************************************************************//**  
109 * @class GCTAResponseTable 39 * @class GCTAResponseTable
110 * 40 *
111 * @brief Interface for the CTA response table class 41 * @brief Interface for the CTA response table class
@@ -171,20 +101,20 @@ public: @@ -171,20 +101,20 @@ public:
171 * @brief GCTAResponse class extension 101 * @brief GCTAResponse class extension
172 ***************************************************************************/ 102 ***************************************************************************/
173 %extend GCTAResponseTable { 103 %extend GCTAResponseTable {
174 - double __getitem__(int GCTAResponseTableInx[]) {  
175 - if (GCTAResponseTableInx[0] == 1) {  
176 - return (*self)(GCTAResponseTableInx[1]); 104 + double __getitem__(int GTuple1D2D[]) {
  105 + if (GTuple1D2D[0] == 1) {
  106 + return (*self)(GTuple1D2D[1]);
177 } 107 }
178 else { 108 else {
179 - return (*self)(GCTAResponseTableInx[1], GCTAResponseTableInx[2]); 109 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
180 } 110 }
181 } 111 }
182 - void __setitem__(int GCTAResponseTableInx[], double value) {  
183 - if (GCTAResponseTableInx[0] == 1) {  
184 - (*self)(GCTAResponseTableInx[1]) = value; 112 + void __setitem__(int GTuple1D2D[], double value) {
  113 + if (GTuple1D2D[0] == 1) {
  114 + (*self)(GTuple1D2D[1]) = value;
185 } 115 }
186 else { 116 else {
187 - (*self)(GCTAResponseTableInx[1], GCTAResponseTableInx[2]) = value; 117 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
188 } 118 }
189 } 119 }
190 GCTAResponseTable copy() { 120 GCTAResponseTable copy() {
inst/cta/pyext/cta.i
@@ -82,7 +82,9 @@ @@ -82,7 +82,9 @@
82 %include stl.i 82 %include stl.i
83 83
84 /* __ Include GammaLib typemaps __________________________________________ */ 84 /* __ Include GammaLib typemaps __________________________________________ */
  85 +%include typemap_GChatter.i
85 %include typemap_GFilename.i 86 %include typemap_GFilename.i
  87 +%include typemap_GTuple.i
86 %include typemap_slices.i 88 %include typemap_slices.i
87 89
88 /* __ Include interface classes __________________________________________ */ 90 /* __ Include interface classes __________________________________________ */
pyext/GCsv.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GCsv.i - Comma-separated values table class * 2 * GCsv.i - Comma-separated values table class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2016 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -31,53 +31,6 @@ @@ -31,53 +31,6 @@
31 31
32 32
33 /***********************************************************************//** 33 /***********************************************************************//**
34 - * @brief Tuple to index conversion to provide element access.  
35 - *  
36 - * The following function provides conversion between a Python tuple and  
37 - * an integer array. This allows table element access via tuples, such as in  
38 - * a[3,5] = 10.0 or c = a[2,9]. Note that the typemap will be globally  
39 - * defined after inclusing of this file.  
40 - ***************************************************************************/  
41 -%{  
42 -static int csv_tuple(PyObject *input, int *ptr) {  
43 - if (PySequence_Check(input)) {  
44 - int size = PyObject_Length(input);  
45 - if (size > 2) {  
46 - PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple");  
47 - return 0;  
48 - }  
49 - for (int i = 0; i < size; i++) {  
50 - PyObject *o = PySequence_GetItem(input,i);  
51 - if (!PyInt_Check(o)) {  
52 - Py_XDECREF(o);  
53 - PyErr_SetString(PyExc_ValueError,"Expecting a tuple of integers");  
54 - return 0;  
55 - }  
56 - ptr[i] = (int)PyInt_AsLong(o);  
57 - Py_DECREF(o);  
58 - }  
59 - return 1;  
60 - }  
61 - else {  
62 - ptr[0] = 1;  
63 - if (!PyInt_Check(input)) {  
64 - PyErr_SetString(PyExc_ValueError,"Expecting an integer");  
65 - return 0;  
66 - }  
67 - ptr[1] = (int)PyInt_AsLong(input);  
68 - return 1;  
69 - }  
70 -}  
71 -%}  
72 -%typemap(in) int GCsvInx[ANY](int temp[2]) {  
73 - if (!csv_tuple($input,temp)) {  
74 - return NULL;  
75 - }  
76 - $1 = &temp[0];  
77 -}  
78 -  
79 -  
80 -/***********************************************************************//**  
81 * @class GCsv 34 * @class GCsv
82 * 35 *
83 * @brief Comma-separated values table class definition 36 * @brief Comma-separated values table class definition
@@ -117,11 +70,11 @@ public: @@ -117,11 +70,11 @@ public:
117 * @brief GCsv class extension 70 * @brief GCsv class extension
118 ***************************************************************************/ 71 ***************************************************************************/
119 %extend GCsv { 72 %extend GCsv {
120 - std::string __getitem__(int GCsvInx[]) {  
121 - return (*self)(GCsvInx[0], GCsvInx[1]); 73 + std::string __getitem__(int GTuple2D[]) {
  74 + return (*self)(GTuple2D[0], GTuple2D[1]);
122 } 75 }
123 - void __setitem__(int GCsvInx[], std::string value) {  
124 - (*self)(GCsvInx[0], GCsvInx[1]) = value; 76 + void __setitem__(int GTuple2D[], std::string value) {
  77 + (*self)(GTuple2D[0], GTuple2D[1]) = value;
125 } 78 }
126 int __len__() { 79 int __len__() {
127 return (self->size()); 80 return (self->size());
pyext/GFitsImageByte.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageByte.i - FITS Byte image class * 2 * GFitsImageByte.i - FITS Byte image class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (unsigned char*)malloc(num*sizeof(unsigned char)); 38 $1 = (unsigned char*)malloc(num*sizeof(unsigned char));
39 - for (int i = 0; i < num; i++) { 39 + for (int i = 0; i < num; ++i) {
40 PyObject *s = PyList_GetItem($input,i); 40 PyObject *s = PyList_GetItem($input,i);
41 if (!PyInt_Check(s)) { 41 if (!PyInt_Check(s)) {
42 free($1); 42 free($1);
pyext/GFitsImageDouble.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageDouble.i - Double precision FITS image class * 2 * GFitsImageDouble.i - Double precision FITS image class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (double*)malloc(num*sizeof(double)); 38 $1 = (double*)malloc(num*sizeof(double));
39 - for (int i = 0; i < num; i++) { 39 + for (int i = 0; i < num; ++i) {
40 PyObject *s = PyList_GetItem($input,i); 40 PyObject *s = PyList_GetItem($input,i);
41 if (!PyFloat_Check(s)) { 41 if (!PyFloat_Check(s)) {
42 free($1); 42 free($1);
pyext/GFitsImageFloat.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageFloat.i - Single precision FITS image class * 2 * GFitsImageFloat.i - Single precision FITS image class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (float*)malloc(num*sizeof(float)); 38 $1 = (float*)malloc(num*sizeof(float));
39 for (int i = 0; i < num; ++i) { 39 for (int i = 0; i < num; ++i) {
pyext/GFitsImageLong.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageLong.i - Long integer FITS image class * 2 * GFitsImageLong.i - Long integer FITS image class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (long*)malloc(num*sizeof(long)); 38 $1 = (long*)malloc(num*sizeof(long));
39 - for (int i = 0; i < num; i++) { 39 + for (int i = 0; i < num; ++i) {
40 PyObject *s = PyList_GetItem($input,i); 40 PyObject *s = PyList_GetItem($input,i);
41 if (!PyInt_Check(s)) { 41 if (!PyInt_Check(s)) {
42 free($1); 42 free($1);
pyext/GFitsImageLongLong.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageLongLong.i - Long long integer FITS image class * 2 * GFitsImageLongLong.i - Long long integer FITS image class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (long long*)malloc(num*sizeof(long long)); 38 $1 = (long long*)malloc(num*sizeof(long long));
39 - for (int i = 0; i < num; i++) { 39 + for (int i = 0; i < num; ++i) {
40 PyObject *s = PyList_GetItem($input,i); 40 PyObject *s = PyList_GetItem($input,i);
41 if (!PyInt_Check(s)) { 41 if (!PyInt_Check(s)) {
42 free($1); 42 free($1);
pyext/GFitsImageSByte.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageSByte.i - Signed Byte FITS image class * 2 * GFitsImageSByte.i - Signed Byte FITS image class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (char*)malloc(num*sizeof(char)); 38 $1 = (char*)malloc(num*sizeof(char));
39 - for (int i = 0; i < num; i++) { 39 + for (int i = 0; i < num; ++i) {
40 PyObject *s = PyList_GetItem($input,i); 40 PyObject *s = PyList_GetItem($input,i);
41 if (!PyInt_Check(s)) { 41 if (!PyInt_Check(s)) {
42 free($1); 42 free($1);
pyext/GFitsImageShort.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageShort.i - Short integer FITS image class * 2 * GFitsImageShort.i - Short integer FITS image class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (short*)malloc(num*sizeof(short)); 38 $1 = (short*)malloc(num*sizeof(short));
39 - for (int i = 0; i < num; i++) { 39 + for (int i = 0; i < num; ++i) {
40 PyObject *s = PyList_GetItem($input,i); 40 PyObject *s = PyList_GetItem($input,i);
41 if (!PyInt_Check(s)) { 41 if (!PyInt_Check(s)) {
42 free($1); 42 free($1);
pyext/GFitsImageULong.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageULong.i - Unsigned long image FITS class * 2 * GFitsImageULong.i - Unsigned long image FITS class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (unsigned long*)malloc(num*sizeof(unsigned long)); 38 $1 = (unsigned long*)malloc(num*sizeof(unsigned long));
39 - for (int i = 0; i < num; i++) { 39 + for (int i = 0; i < num; ++i) {
40 PyObject *s = PyList_GetItem($input,i); 40 PyObject *s = PyList_GetItem($input,i);
41 if (!PyInt_Check(s)) { 41 if (!PyInt_Check(s)) {
42 free($1); 42 free($1);
pyext/GFitsImageUShort.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsImageUShort.i - Unsigned short FITS image class * 2 * GFitsImageUShort.i - Unsigned short FITS image class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -33,10 +33,10 @@ @@ -33,10 +33,10 @@
33 if (!PyList_Check($input)) { 33 if (!PyList_Check($input)) {
34 SWIG_exception(SWIG_ValueError, "List expected"); 34 SWIG_exception(SWIG_ValueError, "List expected");
35 } 35 }
36 - int num = PyList_Size($input); 36 + Py_ssize_t num = PyList_Size($input);
37 if (num > 0) { 37 if (num > 0) {
38 $1 = (unsigned short*)malloc(num*sizeof(unsigned short)); 38 $1 = (unsigned short*)malloc(num*sizeof(unsigned short));
39 - for (int i = 0; i < num; i++) { 39 + for (int i = 0; i < num; ++i) {
40 PyObject *s = PyList_GetItem($input,i); 40 PyObject *s = PyList_GetItem($input,i);
41 if (!PyInt_Check(s)) { 41 if (!PyInt_Check(s)) {
42 free($1); 42 free($1);
pyext/GFitsTable.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTable.i - FITS abstract table base class * 2 * GFitsTable.i - FITS abstract table base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -28,77 +28,6 @@ @@ -28,77 +28,6 @@
28 #include "GFitsTable.hpp" 28 #include "GFitsTable.hpp"
29 %} 29 %}
30 30
31 -/***********************************************************************//**  
32 - * @brief Tuple to index conversion to provide column access.  
33 - *  
34 - * The following function provides conversion between a Python tuple and  
35 - * an integer array. This allows table column access via tuples, such as in  
36 - * a[(3,5,10)] = 10.0 or c = a[(2,9)]. Note that the typemap will be  
37 - * globally defined after inclusing of this file, hence GFitsTable.i has  
38 - * to be included before all table class swig files.  
39 - ***************************************************************************/  
40 -%{  
41 -static int table_column_tuple(PyObject *input, int *ptr) {  
42 - if (PySequence_Check(input)) {  
43 - int size = PyObject_Length(input);  
44 - if (size > 2) {  
45 - PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple");  
46 - return 0;  
47 - }  
48 - ptr[0] = size;  
49 - for (int i = 0; i < size; i++) {  
50 - PyObject *o = PySequence_GetItem(input,i);  
51 - if (!PyInt_Check(o)) {  
52 - Py_XDECREF(o);  
53 - PyErr_SetString(PyExc_ValueError,"Expecting a tuple of integers");  
54 - return 0;  
55 - }  
56 - ptr[i+1] = (int)PyInt_AsLong(o);  
57 - Py_DECREF(o);  
58 - }  
59 - return 1;  
60 - }  
61 - else {  
62 - ptr[0] = 1;  
63 - if (!PyInt_Check(input)) {  
64 - PyErr_SetString(PyExc_ValueError,"Expecting an integer");  
65 - return 0;  
66 - }  
67 - ptr[1] = (int)PyInt_AsLong(input);  
68 - return 1;  
69 - }  
70 -}  
71 -%}  
72 -  
73 -// This is the typemap that makes use of the function defined above  
74 -%typemap(in) int GFitsTableColInx[ANY](int temp[3]) {  
75 - if (!table_column_tuple($input,temp)) {  
76 - return NULL;  
77 - }  
78 - $1 = &temp[0];  
79 -}  
80 -  
81 -// This typecheck verifies that all arguments are integers. The typecheck  
82 -// is needed for using "int GFitsTableColInx" in overloaded methods.  
83 -%typemap(typecheck) int GFitsTableColInx[ANY] {  
84 - $1 = 1;  
85 - if (PySequence_Check($input)) {  
86 - int size = PyObject_Length($input);  
87 - for (int i = 0; i < size; i++) {  
88 - PyObject *o = PySequence_GetItem($input,i);  
89 - if (!PyInt_Check(o)) {  
90 - $1 = 0;  
91 - break;  
92 - }  
93 - }  
94 - }  
95 - else {  
96 - if (!PyInt_Check($input)) {  
97 - $1 = 0;  
98 - }  
99 - }  
100 -}  
101 -  
102 31
103 /***********************************************************************//** 32 /***********************************************************************//**
104 * @class GFitsTable 33 * @class GFitsTable
pyext/GFitsTableBitCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableBitCol.i - FITS table bit column class * 2 * GFitsTableBitCol.i - FITS table bit column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,41 @@ public: @@ -70,43 +70,41 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableBitCol { 72 %extend GFitsTableBitCol {
73 - bool __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + bool __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  83 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 84 }
86 else { 85 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 86 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 87 + GTuple1D2D[2],
  88 + self->elements(GTuple1D2D[1]));
90 } 89 }
91 } 90 }
92 } 91 }
93 - void __setitem__(int GFitsTableColInx[], bool value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 92 + void __setitem__(int GTuple1D2D[], bool value) {
  93 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 94 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 95 + GTuple1D2D[1], self->nrows());
97 } 96 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 97 + if (GTuple1D2D[0] == 1) {
  98 + (*self)(GTuple1D2D[1]) = value;
100 } 99 }
101 else { 100 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 101 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  102 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 103 }
106 else { 104 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 105 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 106 + GTuple1D2D[2],
  107 + self->elements(GTuple1D2D[1]));
110 } 108 }
111 } 109 }
112 } 110 }
pyext/GFitsTableBoolCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableBoolCol.i - FITS table boolean column class * 2 * GFitsTableBoolCol.i - FITS table boolean column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,41 @@ public: @@ -70,43 +70,41 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableBoolCol { 72 %extend GFitsTableBoolCol {
73 - bool __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + bool __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  83 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 84 }
86 else { 85 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 86 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 87 + GTuple1D2D[2],
  88 + self->elements(GTuple1D2D[1]));
90 } 89 }
91 } 90 }
92 } 91 }
93 - void __setitem__(int GFitsTableColInx[], bool value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 92 + void __setitem__(int GTuple1D2D[], bool value) {
  93 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 94 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 95 + GTuple1D2D[1], self->nrows());
97 } 96 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 97 + if (GTuple1D2D[0] == 1) {
  98 + (*self)(GTuple1D2D[1]) = value;
100 } 99 }
101 else { 100 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 101 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  102 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 103 }
106 else { 104 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 105 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 106 + GTuple1D2D[2],
  107 + self->elements(GTuple1D2D[1]));
110 } 108 }
111 } 109 }
112 } 110 }
pyext/GFitsTableByteCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableByteCol.i - FITS table Byte column class * 2 * GFitsTableByteCol.i - FITS table Byte column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,41 @@ public: @@ -70,43 +70,41 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableByteCol { 72 %extend GFitsTableByteCol {
73 - unsigned char __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + unsigned char __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  83 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 84 }
86 else { 85 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 86 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 87 + GTuple1D2D[2],
  88 + self->elements(GTuple1D2D[1]));
90 } 89 }
91 } 90 }
92 } 91 }
93 - void __setitem__(int GFitsTableColInx[], unsigned char value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 92 + void __setitem__(int GTuple1D2D[], unsigned char value) {
  93 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 94 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 95 + GTuple1D2D[1], self->nrows());
97 } 96 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 97 + if (GTuple1D2D[0] == 1) {
  98 + (*self)(GTuple1D2D[1]) = value;
100 } 99 }
101 else { 100 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 101 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  102 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 103 }
106 else { 104 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 105 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 106 + GTuple1D2D[2],
  107 + self->elements(GTuple1D2D[1]));
110 } 108 }
111 } 109 }
112 } 110 }
pyext/GFitsTableCDoubleCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableCDoubleCol.i - FITS table double precision complex column * 2 * GFitsTableCDoubleCol.i - FITS table double precision complex column *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2017 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -74,44 +74,43 @@ public: @@ -74,44 +74,43 @@ public:
74 ***************************************************************************/ 74 ***************************************************************************/
75 %extend GFitsTableCDoubleCol { 75 %extend GFitsTableCDoubleCol {
76 /* 76 /*
77 - GFits::cdouble __getitem__(int GFitsTableColInx[]) {  
78 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 77 + GFits::cdouble __getitem__(int GTuple1D2D[]) {
  78 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
79 throw GException::out_of_range("__getitem__()", "Row index", 79 throw GException::out_of_range("__getitem__()", "Row index",
80 - GFitsTableColInx[1], self->nrows()); 80 + GTuple1D2D[1], self->nrows());
81 } 81 }
82 - if (GFitsTableColInx[0] == 1) {  
83 - return (*self)(GFitsTableColInx[1]); 82 + if (GTuple1D2D[0] == 1) {
  83 + return (*self)(GTuple1D2D[1]);
84 } 84 }
85 else { 85 else {
86 - if (GFitsTableColInx[2] >= 0 &&  
87 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
88 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 86 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  87 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
89 } 88 }
90 else { 89 else {
91 throw GException::out_of_range("__getitem__()", "Column index", 90 throw GException::out_of_range("__getitem__()", "Column index",
92 - GFitsTableColInx[2],  
93 - self->elements(GFitsTableColInx[1])); 91 + GTuple1D2D[2],
  92 + self->elements(GTuple1D2D[1]));
94 } 93 }
95 } 94 }
96 } 95 }
97 */ 96 */
98 - void __setitem__(int GFitsTableColInx[], GFits::cdouble value) {  
99 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 97 + void __setitem__(int GTuple1D2D[], GFits::cdouble value) {
  98 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
100 throw GException::out_of_range("__setitem__()", "Row index", 99 throw GException::out_of_range("__setitem__()", "Row index",
101 - GFitsTableColInx[1], self->nrows()); 100 + GTuple1D2D[1], self->nrows());
102 } 101 }
103 - if (GFitsTableColInx[0] == 1) {  
104 - (*self)(GFitsTableColInx[1]) = value; 102 + if (GTuple1D2D[0] == 1) {
  103 + (*self)(GTuple1D2D[1]) = value;
105 } 104 }
106 else { 105 else {
107 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
108 - self->elements(GFitsTableColInx[1])) {  
109 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 106 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] <
  107 + self->elements(GTuple1D2D[1])) {
  108 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
110 } 109 }
111 else { 110 else {
112 throw GException::out_of_range("__setitem__()", "Column index", 111 throw GException::out_of_range("__setitem__()", "Column index",
113 - GFitsTableColInx[2],  
114 - self->elements(GFitsTableColInx[1])); 112 + GTuple1D2D[2],
  113 + self->elements(GTuple1D2D[1]));
115 } 114 }
116 } 115 }
117 } 116 }
pyext/GFitsTableCFloatCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableCFloatCol.i - FITS table single precision complex column * 2 * GFitsTableCFloatCol.i - FITS table single precision complex column *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2017 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -74,44 +74,42 @@ public: @@ -74,44 +74,42 @@ public:
74 ***************************************************************************/ 74 ***************************************************************************/
75 %extend GFitsTableCFloatCol { 75 %extend GFitsTableCFloatCol {
76 /* 76 /*
77 - GFits::cfloat __getitem__(int GFitsTableColInx[]) {  
78 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 77 + GFits::cfloat __getitem__(int GTuple1D2D[]) {
  78 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
79 throw GException::out_of_range("__getitem__()", "Row index", 79 throw GException::out_of_range("__getitem__()", "Row index",
80 - GFitsTableColInx[1], self->nrows()); 80 + GTuple1D2D[1], self->nrows());
81 } 81 }
82 - if (GFitsTableColInx[0] == 1) {  
83 - return (*self)(GFitsTableColInx[1]); 82 + if (GTuple1D2D[0] == 1) {
  83 + return (*self)(GTuple1D2D[1]);
84 } 84 }
85 else { 85 else {
86 - if (GFitsTableColInx[2] >= 0 &&  
87 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
88 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 86 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  87 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
89 } 88 }
90 else { 89 else {
91 throw GException::out_of_range("__getitem__()", "Column index", 90 throw GException::out_of_range("__getitem__()", "Column index",
92 - GFitsTableColInx[2],  
93 - self->elements(GFitsTableColInx[1])); 91 + GTuple1D2D[2],
  92 + self->elements(GTuple1D2D[1]));
94 } 93 }
95 } 94 }
96 } 95 }
97 */ 96 */
98 - void __setitem__(int GFitsTableColInx[], GFits::cfloat value) {  
99 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 97 + void __setitem__(int GTuple1D2D[], GFits::cfloat value) {
  98 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
100 throw GException::out_of_range("__setitem__()", "Row index", 99 throw GException::out_of_range("__setitem__()", "Row index",
101 - GFitsTableColInx[1], self->nrows()); 100 + GTuple1D2D[1], self->nrows());
102 } 101 }
103 - if (GFitsTableColInx[0] == 1) {  
104 - (*self)(GFitsTableColInx[1]) = value; 102 + if (GTuple1D2D[0] == 1) {
  103 + (*self)(GTuple1D2D[1]) = value;
105 } 104 }
106 else { 105 else {
107 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
108 - self->elements(GFitsTableColInx[1])) {  
109 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 106 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  107 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
110 } 108 }
111 else { 109 else {
112 throw GException::out_of_range("__setitem__()", "Column index", 110 throw GException::out_of_range("__setitem__()", "Column index",
113 - GFitsTableColInx[2],  
114 - self->elements(GFitsTableColInx[1])); 111 + GTuple1D2D[2],
  112 + self->elements(GTuple1D2D[1]));
115 } 113 }
116 } 114 }
117 } 115 }
pyext/GFitsTableCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableCol.i - FITS abstract table column base class * 2 * GFitsTableCol.i - FITS abstract table column base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -42,27 +42,6 @@ @@ -42,27 +42,6 @@
42 %} 42 %}
43 %include "std_vector.i" 43 %include "std_vector.i"
44 44
45 -// This typecheck verifies that all arguments are integers. The typecheck  
46 -// is needed for using "int GFitsTableColInx" in overloaded methods.  
47 -%typemap(typecheck, precedence=SWIG_TYPECHECK_INTEGER) int GFitsTableColInx[ANY] {  
48 - $1 = 1;  
49 - if (PySequence_Check($input)) {  
50 - int size = PyObject_Length($input);  
51 - for (int i = 0; i < size; i++) {  
52 - PyObject *o = PySequence_GetItem($input,i);  
53 - if (!PyInt_Check(o)) {  
54 - $1 = 0;  
55 - break;  
56 - }  
57 - }  
58 - }  
59 - else {  
60 - if (!PyInt_Check($input)) {  
61 - $1 = 0;  
62 - }  
63 - }  
64 -}  
65 -  
66 45
67 /***********************************************************************//** 46 /***********************************************************************//**
68 * @class GFitsTableCol 47 * @class GFitsTableCol
@@ -141,120 +120,120 @@ public: @@ -141,120 +120,120 @@ public:
141 * @todo Add range checking for type casting 120 * @todo Add range checking for type casting
142 ***************************************************************************/ 121 ***************************************************************************/
143 %extend GFitsTableCol { 122 %extend GFitsTableCol {
144 - 123 +
145 // String setting 124 // String setting
146 - void __setitem__(int GFitsTableColInx[], std::string value) { 125 + void __setitem__(int GTuple1D2D[], std::string value) {
147 if (dynamic_cast<GFitsTableStringCol*>(self) != NULL) { 126 if (dynamic_cast<GFitsTableStringCol*>(self) != NULL) {
148 GFitsTableStringCol* col = dynamic_cast<GFitsTableStringCol*>(self); 127 GFitsTableStringCol* col = dynamic_cast<GFitsTableStringCol*>(self);
149 - if (GFitsTableColInx[0] == 1)  
150 - (*col)(GFitsTableColInx[1]) = value; 128 + if (GTuple1D2D[0] == 1)
  129 + (*col)(GTuple1D2D[1]) = value;
151 else 130 else
152 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 131 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = value;
153 } 132 }
154 else { 133 else {
155 throw GException::bad_type("GFitsTableCol::__setitem__", 134 throw GException::bad_type("GFitsTableCol::__setitem__",
156 - "Column type does not support string setting."); 135 + "Column type does not support string setting.");
157 } 136 }
158 } 137 }
159 - 138 +
160 // Integer setting 139 // Integer setting
161 - void __setitem__(int GFitsTableColInx[], int value) { 140 + void __setitem__(int GTuple1D2D[], int value) {
162 if (dynamic_cast<GFitsTableBitCol*>(self) != NULL) { 141 if (dynamic_cast<GFitsTableBitCol*>(self) != NULL) {
163 GFitsTableBitCol* col = dynamic_cast<GFitsTableBitCol*>(self); 142 GFitsTableBitCol* col = dynamic_cast<GFitsTableBitCol*>(self);
164 - if (GFitsTableColInx[0] == 1)  
165 - (*col)(GFitsTableColInx[1]) = (bool)value; 143 + if (GTuple1D2D[0] == 1)
  144 + (*col)(GTuple1D2D[1]) = (bool)value;
166 else 145 else
167 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (bool)value; 146 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (bool)value;
168 } 147 }
169 else if (dynamic_cast<GFitsTableBoolCol*>(self) != NULL) { 148 else if (dynamic_cast<GFitsTableBoolCol*>(self) != NULL) {
170 GFitsTableBoolCol* col = dynamic_cast<GFitsTableBoolCol*>(self); 149 GFitsTableBoolCol* col = dynamic_cast<GFitsTableBoolCol*>(self);
171 - if (GFitsTableColInx[0] == 1)  
172 - (*col)(GFitsTableColInx[1]) = (bool)value; 150 + if (GTuple1D2D[0] == 1)
  151 + (*col)(GTuple1D2D[1]) = (bool)value;
173 else 152 else
174 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (bool)value; 153 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (bool)value;
175 } 154 }
176 else if (dynamic_cast<GFitsTableByteCol*>(self) != NULL) { 155 else if (dynamic_cast<GFitsTableByteCol*>(self) != NULL) {
177 GFitsTableByteCol* col = dynamic_cast<GFitsTableByteCol*>(self); 156 GFitsTableByteCol* col = dynamic_cast<GFitsTableByteCol*>(self);
178 - if (GFitsTableColInx[0] == 1)  
179 - (*col)(GFitsTableColInx[1]) = (unsigned char)value; 157 + if (GTuple1D2D[0] == 1)
  158 + (*col)(GTuple1D2D[1]) = (unsigned char)value;
180 else 159 else
181 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (unsigned char)value; 160 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (unsigned char)value;
182 } 161 }
183 else if (dynamic_cast<GFitsTableLongCol*>(self) != NULL) { 162 else if (dynamic_cast<GFitsTableLongCol*>(self) != NULL) {
184 GFitsTableLongCol* col = dynamic_cast<GFitsTableLongCol*>(self); 163 GFitsTableLongCol* col = dynamic_cast<GFitsTableLongCol*>(self);
185 - if (GFitsTableColInx[0] == 1)  
186 - (*col)(GFitsTableColInx[1]) = (long)value; 164 + if (GTuple1D2D[0] == 1)
  165 + (*col)(GTuple1D2D[1]) = (long)value;
187 else 166 else
188 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (long)value; 167 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (long)value;
189 } 168 }
190 else if (dynamic_cast<GFitsTableLongLongCol*>(self) != NULL) { 169 else if (dynamic_cast<GFitsTableLongLongCol*>(self) != NULL) {
191 GFitsTableLongLongCol* col = dynamic_cast<GFitsTableLongLongCol*>(self); 170 GFitsTableLongLongCol* col = dynamic_cast<GFitsTableLongLongCol*>(self);
192 - if (GFitsTableColInx[0] == 1)  
193 - (*col)(GFitsTableColInx[1]) = (long long)value; 171 + if (GTuple1D2D[0] == 1)
  172 + (*col)(GTuple1D2D[1]) = (long long)value;
194 else 173 else
195 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (long long)value; 174 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (long long)value;
196 } 175 }
197 else if (dynamic_cast<GFitsTableShortCol*>(self) != NULL) { 176 else if (dynamic_cast<GFitsTableShortCol*>(self) != NULL) {
198 GFitsTableShortCol* col = dynamic_cast<GFitsTableShortCol*>(self); 177 GFitsTableShortCol* col = dynamic_cast<GFitsTableShortCol*>(self);
199 - if (GFitsTableColInx[0] == 1)  
200 - (*col)(GFitsTableColInx[1]) = (short)value; 178 + if (GTuple1D2D[0] == 1)
  179 + (*col)(GTuple1D2D[1]) = (short)value;
201 else 180 else
202 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (short)value; 181 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (short)value;
203 } 182 }
204 else if (dynamic_cast<GFitsTableULongCol*>(self) != NULL) { 183 else if (dynamic_cast<GFitsTableULongCol*>(self) != NULL) {
205 GFitsTableULongCol* col = dynamic_cast<GFitsTableULongCol*>(self); 184 GFitsTableULongCol* col = dynamic_cast<GFitsTableULongCol*>(self);
206 - if (GFitsTableColInx[0] == 1)  
207 - (*col)(GFitsTableColInx[1]) = (unsigned long)value; 185 + if (GTuple1D2D[0] == 1)
  186 + (*col)(GTuple1D2D[1]) = (unsigned long)value;
208 else 187 else
209 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (unsigned long)value; 188 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (unsigned long)value;
210 } 189 }
211 else if (dynamic_cast<GFitsTableUShortCol*>(self) != NULL) { 190 else if (dynamic_cast<GFitsTableUShortCol*>(self) != NULL) {
212 GFitsTableUShortCol* col = dynamic_cast<GFitsTableUShortCol*>(self); 191 GFitsTableUShortCol* col = dynamic_cast<GFitsTableUShortCol*>(self);
213 - if (GFitsTableColInx[0] == 1)  
214 - (*col)(GFitsTableColInx[1]) = (unsigned short)value; 192 + if (GTuple1D2D[0] == 1)
  193 + (*col)(GTuple1D2D[1]) = (unsigned short)value;
215 else 194 else
216 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (unsigned short)value; 195 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (unsigned short)value;
217 } 196 }
218 else if (dynamic_cast<GFitsTableDoubleCol*>(self) != NULL) { 197 else if (dynamic_cast<GFitsTableDoubleCol*>(self) != NULL) {
219 GFitsTableDoubleCol* col = dynamic_cast<GFitsTableDoubleCol*>(self); 198 GFitsTableDoubleCol* col = dynamic_cast<GFitsTableDoubleCol*>(self);
220 - if (GFitsTableColInx[0] == 1)  
221 - (*col)(GFitsTableColInx[1]) = (double)value; 199 + if (GTuple1D2D[0] == 1)
  200 + (*col)(GTuple1D2D[1]) = (double)value;
222 else 201 else
223 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (double)value; 202 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (double)value;
224 } 203 }
225 else if (dynamic_cast<GFitsTableFloatCol*>(self) != NULL) { 204 else if (dynamic_cast<GFitsTableFloatCol*>(self) != NULL) {
226 GFitsTableFloatCol* col = dynamic_cast<GFitsTableFloatCol*>(self); 205 GFitsTableFloatCol* col = dynamic_cast<GFitsTableFloatCol*>(self);
227 - if (GFitsTableColInx[0] == 1)  
228 - (*col)(GFitsTableColInx[1]) = (float)value; 206 + if (GTuple1D2D[0] == 1)
  207 + (*col)(GTuple1D2D[1]) = (float)value;
229 else 208 else
230 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (float)value; 209 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (float)value;
231 } 210 }
232 else { 211 else {
233 throw GException::bad_type("GFitsTableCol::__setitem__", 212 throw GException::bad_type("GFitsTableCol::__setitem__",
234 - "Column type does not support integer setting."); 213 + "Column type does not support integer setting.");
235 } 214 }
236 } 215 }
237 - 216 +
238 // Floating point setting 217 // Floating point setting
239 - void __setitem__(int GFitsTableColInx[], double value) { 218 + void __setitem__(int GTuple1D2D[], double value) {
240 if (dynamic_cast<GFitsTableDoubleCol*>(self) != NULL) { 219 if (dynamic_cast<GFitsTableDoubleCol*>(self) != NULL) {
241 GFitsTableDoubleCol* col = dynamic_cast<GFitsTableDoubleCol*>(self); 220 GFitsTableDoubleCol* col = dynamic_cast<GFitsTableDoubleCol*>(self);
242 - if (GFitsTableColInx[0] == 1)  
243 - (*col)(GFitsTableColInx[1]) = value; 221 + if (GTuple1D2D[0] == 1)
  222 + (*col)(GTuple1D2D[1]) = value;
244 else 223 else
245 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 224 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = value;
246 } 225 }
247 else if (dynamic_cast<GFitsTableFloatCol*>(self) != NULL) { 226 else if (dynamic_cast<GFitsTableFloatCol*>(self) != NULL) {
248 GFitsTableFloatCol* col = dynamic_cast<GFitsTableFloatCol*>(self); 227 GFitsTableFloatCol* col = dynamic_cast<GFitsTableFloatCol*>(self);
249 - if (GFitsTableColInx[0] == 1)  
250 - (*col)(GFitsTableColInx[1]) = (float)value; 228 + if (GTuple1D2D[0] == 1)
  229 + (*col)(GTuple1D2D[1]) = (float)value;
251 else 230 else
252 - (*col)(GFitsTableColInx[1], GFitsTableColInx[2]) = (float)value; 231 + (*col)(GTuple1D2D[1], GTuple1D2D[2]) = (float)value;
253 } 232 }
254 233
255 else { 234 else {
256 throw GException::bad_type("GFitsTableCol::__setitem__", 235 throw GException::bad_type("GFitsTableCol::__setitem__",
257 - "Column type does not support floating point setting."); 236 + "Column type does not support floating point setting.");
258 } 237 }
259 } 238 }
260 }; 239 };
pyext/GFitsTableDoubleCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableDoubleCol.i - FITS table double precision column class * 2 * GFitsTableDoubleCol.i - FITS table double precision column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,41 @@ public: @@ -70,43 +70,41 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableDoubleCol { 72 %extend GFitsTableDoubleCol {
73 - double __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + double __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  83 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 84 }
86 else { 85 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 86 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 87 + GTuple1D2D[2],
  88 + self->elements(GTuple1D2D[1]));
90 } 89 }
91 } 90 }
92 } 91 }
93 - void __setitem__(int GFitsTableColInx[], double value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 92 + void __setitem__(int GTuple1D2D[], double value) {
  93 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 94 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 95 + GTuple1D2D[1], self->nrows());
97 } 96 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 97 + if (GTuple1D2D[0] == 1) {
  98 + (*self)(GTuple1D2D[1]) = value;
100 } 99 }
101 else { 100 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 101 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  102 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 103 }
106 else { 104 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 105 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 106 + GTuple1D2D[2],
  107 + self->elements(GTuple1D2D[1]));
110 } 108 }
111 } 109 }
112 } 110 }
pyext/GFitsTableFloatCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableFloatCol.i - FITS table single precision column class * 2 * GFitsTableFloatCol.i - FITS table single precision column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,41 @@ public: @@ -70,43 +70,41 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableFloatCol { 72 %extend GFitsTableFloatCol {
73 - float __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + float __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  83 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 84 }
86 else { 85 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 86 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 87 + GTuple1D2D[2],
  88 + self->elements(GTuple1D2D[1]));
90 } 89 }
91 } 90 }
92 } 91 }
93 - void __setitem__(int GFitsTableColInx[], float value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 92 + void __setitem__(int GTuple1D2D[], float value) {
  93 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 94 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 95 + GTuple1D2D[1], self->nrows());
97 } 96 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 97 + if (GTuple1D2D[0] == 1) {
  98 + (*self)(GTuple1D2D[1]) = value;
100 } 99 }
101 else { 100 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 101 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  102 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 103 }
106 else { 104 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 105 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 106 + GTuple1D2D[2],
  107 + self->elements(GTuple1D2D[1]));
110 } 108 }
111 } 109 }
112 } 110 }
pyext/GFitsTableLongCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableLongCol.i - FITS table long integer column class * 2 * GFitsTableLongCol.i - FITS table long integer column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,41 @@ public: @@ -70,43 +70,41 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableLongCol { 72 %extend GFitsTableLongCol {
73 - long __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + long __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  83 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 84 }
86 else { 85 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 86 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 87 + GTuple1D2D[2],
  88 + self->elements(GTuple1D2D[1]));
90 } 89 }
91 } 90 }
92 } 91 }
93 - void __setitem__(int GFitsTableColInx[], long value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 92 + void __setitem__(int GTuple1D2D[], long value) {
  93 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 94 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 95 + GTuple1D2D[1], self->nrows());
97 } 96 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 97 + if (GTuple1D2D[0] == 1) {
  98 + (*self)(GTuple1D2D[1]) = value;
100 } 99 }
101 else { 100 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 101 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  102 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 103 }
106 else { 104 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 105 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 106 + GTuple1D2D[2],
  107 + self->elements(GTuple1D2D[1]));
110 } 108 }
111 } 109 }
112 } 110 }
pyext/GFitsTableLongLongCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableLongLongCol.i - FITS table long long integer column class * 2 * GFitsTableLongLongCol.i - FITS table long long integer column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,41 @@ public: @@ -70,43 +70,41 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableLongLongCol { 72 %extend GFitsTableLongLongCol {
73 - long long __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + long long __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  83 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 84 }
86 else { 85 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 86 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 87 + GTuple1D2D[2],
  88 + self->elements(GTuple1D2D[1]));
90 } 89 }
91 } 90 }
92 } 91 }
93 - void __setitem__(int GFitsTableColInx[], long long value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 92 + void __setitem__(int GTuple1D2D[], long long value) {
  93 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 94 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 95 + GTuple1D2D[1], self->nrows());
97 } 96 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 97 + if (GTuple1D2D[0] == 1) {
  98 + (*self)(GTuple1D2D[1]) = value;
100 } 99 }
101 else { 100 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 101 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  102 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 103 }
106 else { 104 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 105 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 106 + GTuple1D2D[2],
  107 + self->elements(GTuple1D2D[1]));
110 } 108 }
111 } 109 }
112 } 110 }
pyext/GFitsTableShortCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableShortCol.i - FITS table short integer column class * 2 * GFitsTableShortCol.i - FITS table short integer column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,41 @@ public: @@ -70,43 +70,41 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableShortCol { 72 %extend GFitsTableShortCol {
73 - short __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + short __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  83 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 84 }
86 else { 85 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 86 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 87 + GTuple1D2D[2],
  88 + self->elements(GTuple1D2D[1]));
90 } 89 }
91 } 90 }
92 } 91 }
93 - void __setitem__(int GFitsTableColInx[], short value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 92 + void __setitem__(int GTuple1D2D[], short value) {
  93 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 94 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 95 + GTuple1D2D[1], self->nrows());
97 } 96 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 97 + if (GTuple1D2D[0] == 1) {
  98 + (*self)(GTuple1D2D[1]) = value;
100 } 99 }
101 else { 100 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 101 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  102 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 103 }
106 else { 104 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 105 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 106 + GTuple1D2D[2],
  107 + self->elements(GTuple1D2D[1]));
110 } 108 }
111 } 109 }
112 } 110 }
pyext/GFitsTableStringCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableStringCol.i - FITS table string column class * 2 * GFitsTableStringCol.i - FITS table string column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -71,63 +71,60 @@ public: @@ -71,63 +71,60 @@ public:
71 * find out how to implement this (e.g. via typemaps). 71 * find out how to implement this (e.g. via typemaps).
72 ***************************************************************************/ 72 ***************************************************************************/
73 %extend GFitsTableStringCol { 73 %extend GFitsTableStringCol {
74 - std::string __getitem__(int GFitsTableColInx[]) {  
75 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 74 + std::string __getitem__(int GTuple1D2D[]) {
  75 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
76 throw GException::out_of_range("__getitem__()", "Row index", 76 throw GException::out_of_range("__getitem__()", "Row index",
77 - GFitsTableColInx[1], self->nrows()); 77 + GTuple1D2D[1], self->nrows());
78 } 78 }
79 - if (GFitsTableColInx[0] == 1) {  
80 - return (*self)(GFitsTableColInx[1]); 79 + if (GTuple1D2D[0] == 1) {
  80 + return (*self)(GTuple1D2D[1]);
81 } 81 }
82 else { 82 else {
83 - if (GFitsTableColInx[2] >= 0 &&  
84 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
85 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 83 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  84 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
86 } 85 }
87 else { 86 else {
88 throw GException::out_of_range("__getitem__()", "Column index", 87 throw GException::out_of_range("__getitem__()", "Column index",
89 - GFitsTableColInx[2],  
90 - self->elements(GFitsTableColInx[1])); 88 + GTuple1D2D[2],
  89 + self->elements(GTuple1D2D[1]));
91 } 90 }
92 } 91 }
93 } 92 }
94 - void __setitem__(int GFitsTableColInx[], std::string value) {  
95 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 93 + void __setitem__(int GTuple1D2D[], std::string value) {
  94 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
96 throw GException::out_of_range("__setitem__()", "Row index", 95 throw GException::out_of_range("__setitem__()", "Row index",
97 - GFitsTableColInx[1], self->nrows()); 96 + GTuple1D2D[1], self->nrows());
98 } 97 }
99 - if (GFitsTableColInx[0] == 1) {  
100 - (*self)(GFitsTableColInx[1]) = value; 98 + if (GTuple1D2D[0] == 1) {
  99 + (*self)(GTuple1D2D[1]) = value;
101 } 100 }
102 else { 101 else {
103 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
104 - self->elements(GFitsTableColInx[1])) {  
105 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 102 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  103 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
106 } 104 }
107 else { 105 else {
108 throw GException::out_of_range("__setitem__()", "Column index", 106 throw GException::out_of_range("__setitem__()", "Column index",
109 - GFitsTableColInx[2],  
110 - self->elements(GFitsTableColInx[1])); 107 + GTuple1D2D[2],
  108 + self->elements(GTuple1D2D[1]));
111 } 109 }
112 } 110 }
113 } 111 }
114 - void __setitem__(int GFitsTableColInx[], GFilename value) {  
115 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 112 + void __setitem__(int GTuple1D2D[], GFilename value) {
  113 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
116 throw GException::out_of_range("__setitem__()", "Row index", 114 throw GException::out_of_range("__setitem__()", "Row index",
117 - GFitsTableColInx[1], self->nrows()); 115 + GTuple1D2D[1], self->nrows());
118 } 116 }
119 - if (GFitsTableColInx[0] == 1) {  
120 - (*self)(GFitsTableColInx[1]) = std::string(value); 117 + if (GTuple1D2D[0] == 1) {
  118 + (*self)(GTuple1D2D[1]) = std::string(value);
121 } 119 }
122 else { 120 else {
123 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
124 - self->elements(GFitsTableColInx[1])) {  
125 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = std::string(value); 121 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  122 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = std::string(value);
126 } 123 }
127 else { 124 else {
128 throw GException::out_of_range("__setitem__()", "Column index", 125 throw GException::out_of_range("__setitem__()", "Column index",
129 - GFitsTableColInx[2],  
130 - self->elements(GFitsTableColInx[1])); 126 + GTuple1D2D[2],
  127 + self->elements(GTuple1D2D[1]));
131 } 128 }
132 } 129 }
133 } 130 }
pyext/GFitsTableULongCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableULongCol.i - FITS table unsigned long integer column class * 2 * GFitsTableULongCol.i - FITS table unsigned long integer column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,42 @@ public: @@ -70,43 +70,42 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableULongCol { 72 %extend GFitsTableULongCol {
73 - unsigned long __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + unsigned long __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 &&
  83 + GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  84 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 85 }
86 else { 86 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 87 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 88 + GTuple1D2D[2],
  89 + self->elements(GTuple1D2D[1]));
90 } 90 }
91 } 91 }
92 } 92 }
93 - void __setitem__(int GFitsTableColInx[], unsigned long value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 93 + void __setitem__(int GTuple1D2D[], unsigned long value) {
  94 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 95 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 96 + GTuple1D2D[1], self->nrows());
97 } 97 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 98 + if (GTuple1D2D[0] == 1) {
  99 + (*self)(GTuple1D2D[1]) = value;
100 } 100 }
101 else { 101 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 102 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  103 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 104 }
106 else { 105 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 106 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 107 + GTuple1D2D[2],
  108 + self->elements(GTuple1D2D[1]));
110 } 109 }
111 } 110 }
112 } 111 }
pyext/GFitsTableUShortCol.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GFitsTableUShortCol.i - FITS table unsigned short integer column class * 2 * GFitsTableUShortCol.i - FITS table unsigned short integer column class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -70,43 +70,42 @@ public: @@ -70,43 +70,42 @@ public:
70 * find out how to implement this (e.g. via typemaps). 70 * find out how to implement this (e.g. via typemaps).
71 ***************************************************************************/ 71 ***************************************************************************/
72 %extend GFitsTableUShortCol { 72 %extend GFitsTableUShortCol {
73 - unsigned short __getitem__(int GFitsTableColInx[]) {  
74 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 73 + unsigned short __getitem__(int GTuple1D2D[]) {
  74 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
75 throw GException::out_of_range("__getitem__()", "Row index", 75 throw GException::out_of_range("__getitem__()", "Row index",
76 - GFitsTableColInx[1], self->nrows()); 76 + GTuple1D2D[1], self->nrows());
77 } 77 }
78 - if (GFitsTableColInx[0] == 1) {  
79 - return (*self)(GFitsTableColInx[1]); 78 + if (GTuple1D2D[0] == 1) {
  79 + return (*self)(GTuple1D2D[1]);
80 } 80 }
81 else { 81 else {
82 - if (GFitsTableColInx[2] >= 0 &&  
83 - GFitsTableColInx[2] < self->elements(GFitsTableColInx[1])) {  
84 - return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); 82 + if (GTuple1D2D[2] >= 0 &&
  83 + GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  84 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
85 } 85 }
86 else { 86 else {
87 throw GException::out_of_range("__getitem__()", "Column index", 87 throw GException::out_of_range("__getitem__()", "Column index",
88 - GFitsTableColInx[2],  
89 - self->elements(GFitsTableColInx[1])); 88 + GTuple1D2D[2],
  89 + self->elements(GTuple1D2D[1]));
90 } 90 }
91 } 91 }
92 } 92 }
93 - void __setitem__(int GFitsTableColInx[], unsigned short value) {  
94 - if (GFitsTableColInx[1] < 0 || GFitsTableColInx[1] >= self->nrows()) { 93 + void __setitem__(int GTuple1D2D[], unsigned short value) {
  94 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->nrows()) {
95 throw GException::out_of_range("__setitem__()", "Row index", 95 throw GException::out_of_range("__setitem__()", "Row index",
96 - GFitsTableColInx[1], self->nrows()); 96 + GTuple1D2D[1], self->nrows());
97 } 97 }
98 - if (GFitsTableColInx[0] == 1) {  
99 - (*self)(GFitsTableColInx[1]) = value; 98 + if (GTuple1D2D[0] == 1) {
  99 + (*self)(GTuple1D2D[1]) = value;
100 } 100 }
101 else { 101 else {
102 - if (GFitsTableColInx[2] >= 0 && GFitsTableColInx[2] <  
103 - self->elements(GFitsTableColInx[1])) {  
104 - (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; 102 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->elements(GTuple1D2D[1])) {
  103 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
105 } 104 }
106 else { 105 else {
107 throw GException::out_of_range("__setitem__()", "Column index", 106 throw GException::out_of_range("__setitem__()", "Column index",
108 - GFitsTableColInx[2],  
109 - self->elements(GFitsTableColInx[1])); 107 + GTuple1D2D[2],
  108 + self->elements(GTuple1D2D[1]));
110 } 109 }
111 } 110 }
112 } 111 }
pyext/GMatrix.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GMatrix.i - General Matrix class * 2 * GMatrix.i - General Matrix class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -94,11 +94,11 @@ public: @@ -94,11 +94,11 @@ public:
94 * @brief GMatrix class extension 94 * @brief GMatrix class extension
95 ***************************************************************************/ 95 ***************************************************************************/
96 %extend GMatrix { 96 %extend GMatrix {
97 - double __getitem__(int GTuple[2]) {  
98 - return (*self)(GTuple[0], GTuple[1]); 97 + double __getitem__(int GTuple2D[]) {
  98 + return (*self)(GTuple2D[0], GTuple2D[1]);
99 } 99 }
100 - void __setitem__(int GTuple[2], double value) {  
101 - (*self)(GTuple[0], GTuple[1]) = value; 100 + void __setitem__(int GTuple2D[], double value) {
  101 + (*self)(GTuple2D[0], GTuple2D[1]) = value;
102 } 102 }
103 GVector __mul__(const GVector& vector) { 103 GVector __mul__(const GVector& vector) {
104 return ((*self) * vector); 104 return ((*self) * vector);
pyext/GMatrixSparse.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GMatrixSparse.i - Sparse matrix class * 2 * GMatrixSparse.i - Sparse matrix class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -108,11 +108,11 @@ public: @@ -108,11 +108,11 @@ public:
108 * @brief GMatrixSparse class extension 108 * @brief GMatrixSparse class extension
109 ***************************************************************************/ 109 ***************************************************************************/
110 %extend GMatrixSparse { 110 %extend GMatrixSparse {
111 - double __getitem__(int GTuple[2]) {  
112 - return (*self)(GTuple[0], GTuple[1]); 111 + double __getitem__(int GTuple2D[]) {
  112 + return (*self)(GTuple2D[0], GTuple2D[1]);
113 } 113 }
114 - void __setitem__(int GTuple[2], double value) {  
115 - (*self)(GTuple[0], GTuple[1]) = value; 114 + void __setitem__(int GTuple2D[], double value) {
  115 + (*self)(GTuple2D[0], GTuple2D[1]) = value;
116 } 116 }
117 GVector __mul__(const GVector& vector) { 117 GVector __mul__(const GVector& vector) {
118 return ((*self) * vector); 118 return ((*self) * vector);
pyext/GMatrixSymmetric.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GMatrixSymmetric.i - Symmetric matrix class * 2 * GMatrixSymmetric.i - Symmetric matrix class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2008-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -93,11 +93,11 @@ public: @@ -93,11 +93,11 @@ public:
93 * @brief GMatrixSymmetric class extension 93 * @brief GMatrixSymmetric class extension
94 ***************************************************************************/ 94 ***************************************************************************/
95 %extend GMatrixSymmetric { 95 %extend GMatrixSymmetric {
96 - double __getitem__(int GTuple[2]) {  
97 - return (*self)(GTuple[0], GTuple[1]); 96 + double __getitem__(int GTuple2D[]) {
  97 + return (*self)(GTuple2D[0], GTuple2D[1]);
98 } 98 }
99 - void __setitem__(int GTuple[2], double value) {  
100 - (*self)(GTuple[0], GTuple[1]) = value; 99 + void __setitem__(int GTuple2D[], double value) {
  100 + (*self)(GTuple2D[0], GTuple2D[1]) = value;
101 } 101 }
102 GVector __mul__(const GVector& vector) { 102 GVector __mul__(const GVector& vector) {
103 return ((*self) * vector); 103 return ((*self) * vector);
pyext/GResponseVectorCache.i
@@ -38,8 +38,9 @@ @@ -38,8 +38,9 @@
38 * 38 *
39 */ 39 */
40 %include "typemaps.i" 40 %include "typemaps.i"
41 -%apply GVector *OUTPUT { GVector* value };  
42 - 41 +%typemap(argout) GVector *OUTPUT {
  42 + $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_GVector, 0 | 0);
  43 +}
43 44
44 /***********************************************************************//** 45 /***********************************************************************//**
45 * @class GResponseVectorCache 46 * @class GResponseVectorCache
pyext/GRmf.i
@@ -85,11 +85,11 @@ public: @@ -85,11 +85,11 @@ public:
85 * @brief GRmf class extension 85 * @brief GRmf class extension
86 ***************************************************************************/ 86 ***************************************************************************/
87 %extend GRmf { 87 %extend GRmf {
88 - double __getitem__(int GTuple[2]) {  
89 - return self->at(GTuple[0], GTuple[1]); 88 + double __getitem__(int GTuple2D[]) {
  89 + return self->at(GTuple2D[0], GTuple2D[1]);
90 } 90 }
91 - void __setitem__(int GTuple[2], const double& value) {  
92 - self->at(GTuple[0], GTuple[1]) = value; 91 + void __setitem__(int GTuple2D[], const double& value) {
  92 + self->at(GTuple2D[0], GTuple2D[1]) = value;
93 } 93 }
94 int __len__() { 94 int __len__() {
95 return (self->size()); 95 return (self->size());
pyext/GSkyMap.i
@@ -31,76 +31,6 @@ @@ -31,76 +31,6 @@
31 31
32 32
33 /***********************************************************************//** 33 /***********************************************************************//**
34 - * @brief Tuple to index conversion to provide pixel access.  
35 - *  
36 - * The following function provides conversion between a Python tuple and  
37 - * an integer array. This allows skymap pixel access via tuples, such as in  
38 - * a[3,5,10] = 10.0 or c = a[2,9].  
39 - ***************************************************************************/  
40 -%{  
41 -static int skymap_tuple(PyObject *input, int *ptr) {  
42 - if (PySequence_Check(input)) {  
43 - int size = PyObject_Length(input);  
44 - if (size > 2) {  
45 - PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple");  
46 - return 0;  
47 - }  
48 - ptr[0] = size;  
49 - for (int i = 0; i < size; i++) {  
50 - PyObject *o = PySequence_GetItem(input,i);  
51 - if (!PyInt_Check(o)) {  
52 - Py_XDECREF(o);  
53 - PyErr_SetString(PyExc_ValueError,"Expecting a tuple of integers");  
54 - return 0;  
55 - }  
56 - ptr[i+1] = (int)PyInt_AsLong(o);  
57 - Py_DECREF(o);  
58 - }  
59 - return 1;  
60 - }  
61 - else {  
62 - ptr[0] = 1;  
63 - if (!PyInt_Check(input)) {  
64 - PyErr_SetString(PyExc_ValueError,"Expecting an integer");  
65 - return 0;  
66 - }  
67 - ptr[1] = (int)PyInt_AsLong(input);  
68 - return 1;  
69 - }  
70 -}  
71 -%}  
72 -  
73 -// This is the typemap that makes use of the function defined above  
74 -%typemap(in) int GSkyMapInx[ANY](int temp[3]) {  
75 - if (!skymap_tuple($input,temp)) {  
76 - return NULL;  
77 - }  
78 - $1 = &temp[0];  
79 -}  
80 -  
81 -// This typecheck verifies that all arguments are integers. The typecheck  
82 -// is needed for using "int GSkyMapInx" in overloaded methods.  
83 -%typemap(typecheck) int GSkyMapInx[ANY] {  
84 - $1 = 1;  
85 - if (PySequence_Check($input)) {  
86 - int size = PyObject_Length($input);  
87 - for (int i = 0; i < size; i++) {  
88 - PyObject *o = PySequence_GetItem($input,i);  
89 - if (!PyInt_Check(o)) {  
90 - $1 = 0;  
91 - break;  
92 - }  
93 - }  
94 - }  
95 - else {  
96 - if (!PyInt_Check($input)) {  
97 - $1 = 0;  
98 - }  
99 - }  
100 -}  
101 -  
102 -  
103 -/***********************************************************************//**  
104 * @class GSkyMap 34 * @class GSkyMap
105 * 35 *
106 * @brief GSkyMap class interface definition 36 * @brief GSkyMap class interface definition
@@ -200,23 +130,23 @@ public: @@ -200,23 +130,23 @@ public:
200 * GSkyDir 130 * GSkyDir
201 ***************************************************************************/ 131 ***************************************************************************/
202 %extend GSkyMap { 132 %extend GSkyMap {
203 - double __getitem__(int GSkyMapInx[]) {  
204 - if (GSkyMapInx[1] < 0 || GSkyMapInx[1] >= self->npix()) { 133 + double __getitem__(int GTuple1D2D[]) {
  134 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->npix()) {
205 throw GException::out_of_range("GSkyMap::__getitem__(int*)", 135 throw GException::out_of_range("GSkyMap::__getitem__(int*)",
206 "Sky map index", 136 "Sky map index",
207 - GSkyMapInx[1], self->npix()); 137 + GTuple1D2D[1], self->npix());
208 } 138 }
209 - if (GSkyMapInx[0] == 1) {  
210 - return (*self)(GSkyMapInx[1]); 139 + if (GTuple1D2D[0] == 1) {
  140 + return (*self)(GTuple1D2D[1]);
211 } 141 }
212 else { 142 else {
213 - if (GSkyMapInx[2] >= 0 && GSkyMapInx[2] < self->nmaps()) {  
214 - return (*self)(GSkyMapInx[1], GSkyMapInx[2]); 143 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->nmaps()) {
  144 + return (*self)(GTuple1D2D[1], GTuple1D2D[2]);
215 } 145 }
216 else { 146 else {
217 throw GException::out_of_range("GSkyMap::__getitem__(int*)", 147 throw GException::out_of_range("GSkyMap::__getitem__(int*)",
218 "Sky map number", 148 "Sky map number",
219 - GSkyMapInx[2], self->nmaps()); 149 + GTuple1D2D[2], self->nmaps());
220 } 150 }
221 } 151 }
222 } 152 }
@@ -225,23 +155,23 @@ public: @@ -225,23 +155,23 @@ public:
225 return (*self)(pixel); 155 return (*self)(pixel);
226 } 156 }
227 */ 157 */
228 - void __setitem__(int GSkyMapInx[], double value) {  
229 - if (GSkyMapInx[1] < 0 || GSkyMapInx[1] >= self->npix()) { 158 + void __setitem__(int GTuple1D2D[], double value) {
  159 + if (GTuple1D2D[1] < 0 || GTuple1D2D[1] >= self->npix()) {
230 throw GException::out_of_range("GSkyMap::__setitem__(int*,double&)", 160 throw GException::out_of_range("GSkyMap::__setitem__(int*,double&)",
231 "Sky map index", 161 "Sky map index",
232 - GSkyMapInx[1], self->npix()); 162 + GTuple1D2D[1], self->npix());
233 } 163 }
234 - if (GSkyMapInx[0] == 1) {  
235 - (*self)(GSkyMapInx[1]) = value; 164 + if (GTuple1D2D[0] == 1) {
  165 + (*self)(GTuple1D2D[1]) = value;
236 } 166 }
237 else { 167 else {
238 - if (GSkyMapInx[2] >= 0 && GSkyMapInx[2] < self->nmaps()) {  
239 - (*self)(GSkyMapInx[1], GSkyMapInx[2]) = value; 168 + if (GTuple1D2D[2] >= 0 && GTuple1D2D[2] < self->nmaps()) {
  169 + (*self)(GTuple1D2D[1], GTuple1D2D[2]) = value;
240 } 170 }
241 else { 171 else {
242 throw GException::out_of_range("GSkyMap::__setitem__(int*,double&)", 172 throw GException::out_of_range("GSkyMap::__setitem__(int*,double&)",
243 "Sky map number", 173 "Sky map number",
244 - GSkyMapInx[2], self->nmaps()); 174 + GTuple1D2D[2], self->nmaps());
245 } 175 }
246 } 176 }
247 } 177 }
pyext/gammalib/fits.i
@@ -47,6 +47,7 @@ namespace std { @@ -47,6 +47,7 @@ namespace std {
47 /* __ Include GammaLib typemaps __________________________________________ */ 47 /* __ Include GammaLib typemaps __________________________________________ */
48 %include typemap_GChatter.i 48 %include typemap_GChatter.i
49 %include typemap_GFilename.i 49 %include typemap_GFilename.i
  50 +%include typemap_GTuple.i
50 %include typemap_slices.i 51 %include typemap_slices.i
51 52
52 /* __ Include interface classes __________________________________________ */ 53 /* __ Include interface classes __________________________________________ */
pyext/gammalib/obs.i
@@ -216,22 +216,6 @@ @@ -216,22 +216,6 @@
216 $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), myinfo, 0 | 0); 216 $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), myinfo, 0 | 0);
217 } 217 }
218 } 218 }
219 -%typemap(out) GVector* {  
220 - char classname[80];  
221 - strcpy(classname, "_p_");  
222 - strcat(classname, result->classname().c_str());  
223 - swig_type_info *myinfo = SWIGTYPE_p_GVector;  
224 - swig_cast_info *mycast = 0;  
225 - mycast = myinfo->cast;  
226 - while (mycast != 0) {  
227 - if (strcmp(classname, mycast->type->name) == 0) {  
228 - myinfo = mycast->type;  
229 - break;  
230 - }  
231 - mycast = mycast->next;  
232 - }  
233 - $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), myinfo, 0 | 0);  
234 -}  
235 219
236 /* __ Observation handling _______________________________________________ */ 220 /* __ Observation handling _______________________________________________ */
237 %include "GEnergy.i" 221 %include "GEnergy.i"
pyext/gammalib/sky.i
@@ -49,6 +49,7 @@ namespace std { @@ -49,6 +49,7 @@ namespace std {
49 /* __ Include GammaLib typemaps __________________________________________ */ 49 /* __ Include GammaLib typemaps __________________________________________ */
50 %include typemap_GChatter.i 50 %include typemap_GChatter.i
51 %include typemap_GFilename.i 51 %include typemap_GFilename.i
  52 +%include typemap_GTuple.i
52 %include typemap_slices.i 53 %include typemap_slices.i
53 54
54 /* __ Include interface classes __________________________________________ */ 55 /* __ Include interface classes __________________________________________ */
pyext/gammalib/support.i
@@ -46,6 +46,7 @@ @@ -46,6 +46,7 @@
46 /* __ Include GammaLib typemaps __________________________________________ */ 46 /* __ Include GammaLib typemaps __________________________________________ */
47 %include typemap_GChatter.i 47 %include typemap_GChatter.i
48 %include typemap_GFilename.i 48 %include typemap_GFilename.i
  49 +%include typemap_GTuple.i
49 %include typemap_slices.i 50 %include typemap_slices.i
50 51
51 /* __ Include interface classes __________________________________________ */ 52 /* __ Include interface classes __________________________________________ */
pyext/typemap_GTuple.i
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 * in a[3,5] = 10.0 or c = a[2,9]. A typecheck typemap is provided to allow 36 * in a[3,5] = 10.0 or c = a[2,9]. A typecheck typemap is provided to allow
37 * overloading. 37 * overloading.
38 ***************************************************************************/ 38 ***************************************************************************/
39 -%typemap(in) int GTuple[2] (int temp[2]) { 39 +%typemap(in) int GTuple2D[] (int temp[2]) {
40 if (!PySequence_Check($input)) { 40 if (!PySequence_Check($input)) {
41 PyErr_SetString(PyExc_ValueError,"Expected a sequence"); 41 PyErr_SetString(PyExc_ValueError,"Expected a sequence");
42 return NULL; 42 return NULL;
@@ -57,13 +57,70 @@ @@ -57,13 +57,70 @@
57 } 57 }
58 $1 = temp; 58 $1 = temp;
59 } 59 }
60 -%typemap(typecheck) int GTuple[2] { 60 +%typemap(typecheck) int GTuple2D[] {
61 $1 = 1; 61 $1 = 1;
62 if (PySequence_Check($input)) { 62 if (PySequence_Check($input)) {
63 - int size = PyObject_Length($input); 63 + Py_ssize_t size = PyObject_Length($input);
  64 + for (int i = 0; i < size; ++i) {
  65 + PyObject *o = PySequence_GetItem($input,i);
  66 + if (!PyInt_Check(o)) {
  67 + $1 = 0;
  68 + break;
  69 + }
  70 + }
  71 + }
  72 + else {
  73 + if (!PyInt_Check($input)) {
  74 + $1 = 0;
  75 + }
  76 + }
  77 +}
  78 +
  79 +
  80 +/***********************************************************************//**
  81 + * @brief 1D or 2D tuple to index conversion
  82 + *
  83 + * The following typemap provides conversion between a 1-dimensional or
  84 + * or 2-dimensional Python tuple and an integer array. This allows index
  85 + * access via tuples, such as in a[3] = 10.0 or c = a[2,9]. A typecheck
  86 + * typemap is provided to allow overloading.
  87 + ***************************************************************************/
  88 +%typemap(in) int GTuple1D2D[] (int temp[3]) {
  89 + if (PySequence_Check($input)) {
  90 + Py_ssize_t size = PyObject_Length($input);
  91 + if (size > 2) {
  92 + PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple");
  93 + return NULL;
  94 + }
  95 + temp[0] = size;
64 for (int i = 0; i < size; i++) { 96 for (int i = 0; i < size; i++) {
65 PyObject *o = PySequence_GetItem($input,i); 97 PyObject *o = PySequence_GetItem($input,i);
66 if (!PyInt_Check(o)) { 98 if (!PyInt_Check(o)) {
  99 + Py_XDECREF(o);
  100 + PyErr_SetString(PyExc_ValueError,"Expecting a tuple of integers");
  101 + return NULL;
  102 + }
  103 + temp[i+1] = (int)PyInt_AsLong(o);
  104 + Py_DECREF(o);
  105 + }
  106 + }
  107 + else {
  108 + temp[0] = 1;
  109 + if (!PyInt_Check($input)) {
  110 + PyErr_SetString(PyExc_ValueError,"Expecting an integer");
  111 + return NULL;
  112 + }
  113 + temp[1] = (int)PyInt_AsLong($input);
  114 + }
  115 + $1 = temp;
  116 +}
  117 +%typemap(typecheck, precedence=SWIG_TYPECHECK_INTEGER) int GTuple1D2D[] {
  118 + $1 = 1;
  119 + if (PySequence_Check($input)) {
  120 + Py_ssize_t size = PyObject_Length($input);
  121 + for (int i = 0; i < size; ++i) {
  122 + PyObject *o = PySequence_GetItem($input,i);
  123 + if (!PyInt_Check(o)) {
67 $1 = 0; 124 $1 = 0;
68 break; 125 break;
69 } 126 }
@@ -86,13 +143,13 @@ @@ -86,13 +143,13 @@
86 ***************************************************************************/ 143 ***************************************************************************/
87 %typemap(in) int GTuple[ANY] (int temp[11]) { 144 %typemap(in) int GTuple[ANY] (int temp[11]) {
88 if (PySequence_Check($input)) { 145 if (PySequence_Check($input)) {
89 - int size = PyObject_Length($input); 146 + Py_ssize_t size = PyObject_Length($input);
90 if (size > 10) { 147 if (size > 10) {
91 PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple"); 148 PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple");
92 return NULL; 149 return NULL;
93 } 150 }
94 temp[0] = size; 151 temp[0] = size;
95 - for (int i = 0; i < size; i++) { 152 + for (int i = 0; i < size; ++i) {
96 PyObject *o = PySequence_GetItem($input,i); 153 PyObject *o = PySequence_GetItem($input,i);
97 if (!PyInt_Check(o)) { 154 if (!PyInt_Check(o)) {
98 Py_XDECREF(o); 155 Py_XDECREF(o);
@@ -102,7 +159,6 @@ @@ -102,7 +159,6 @@
102 temp[i+1] = (int)PyInt_AsLong(o); 159 temp[i+1] = (int)PyInt_AsLong(o);
103 Py_DECREF(o); 160 Py_DECREF(o);
104 } 161 }
105 - $1 = &temp[0];  
106 } 162 }
107 else { 163 else {
108 temp[0] = 1; 164 temp[0] = 1;
@@ -111,14 +167,14 @@ @@ -111,14 +167,14 @@
111 return NULL; 167 return NULL;
112 } 168 }
113 temp[1] = (int)PyInt_AsLong($input); 169 temp[1] = (int)PyInt_AsLong($input);
114 - $1 = &temp[0];  
115 } 170 }
  171 + $1 = temp;
116 } 172 }
117 %typemap(typecheck) int GTuple[ANY] { 173 %typemap(typecheck) int GTuple[ANY] {
118 $1 = 1; 174 $1 = 1;
119 if (PySequence_Check($input)) { 175 if (PySequence_Check($input)) {
120 - int size = PyObject_Length($input);  
121 - for (int i = 0; i < size; i++) { 176 + Py_ssize_t size = PyObject_Length($input);
  177 + for (int i = 0; i < size; ++i) {
122 PyObject *o = PySequence_GetItem($input,i); 178 PyObject *o = PySequence_GetItem($input,i);
123 if (!PyInt_Check(o)) { 179 if (!PyInt_Check(o)) {
124 $1 = 0; 180 $1 = 0;