diff --git a/.gitignore b/.gitignore index ba45fe0..a18f081 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.o -__pycache__ \ No newline at end of file +__pycache__ +*.pyc +*.vscode diff --git a/NIRS.py b/NIRS.py index 99d2dbb..9536464 100644 --- a/NIRS.py +++ b/NIRS.py @@ -1,6 +1,7 @@ # NIRScanner Python Wrapper # Created by Weiwei Jiang -# +# Fix by Jintao Yang on 2020/11/24 +#!/usr/bin/python3.8 import os, sys sys.path.append(os.path.join(os.path.dirname(__file__), "./")) @@ -83,9 +84,9 @@ def set_hibernate(self, new_value: bool): return NIRScanner_setHibernate(self.nirs_obj, new_value) def set_config(self, scanConfigIndex=8, scan_type=1, num_patterns=228, num_repeats=6, - wavelength_start_nm=900, wavelength_end_nm=1700, width_px=7): + wavelength_start_nm=900, wavelength_end_nm=1700, width_px=7, exposure_time = 0, ScanConfig_serial_number = "", config_name = "cfg8"): return NIRScanner_setConfig(self.nirs_obj, scanConfigIndex, scan_type, num_patterns, num_repeats, - wavelength_start_nm, wavelength_end_nm, width_px) + wavelength_start_nm, wavelength_end_nm, width_px, exposure_time, config_name) def set_pga_gain(self, new_value): return NIRScanner_setPGAGain(self.nirs_obj, new_value) @@ -96,6 +97,8 @@ def set_lamp_on_off(self, new_value): def clear_error_status(self): return NIRScanner_resetErrorStatus(self.nirs_obj) + def sync_device_date_time(self, year = 1970, month = 1, day = 1, wday = 0, hour = 0, min = 0, sec = 0): + return NIRScanner_syncDeviceDateTime(self.nirs_obj, year, month, day, wday, hour, min, sec) if __name__ == "__main__": import time @@ -107,7 +110,7 @@ def clear_error_status(self): nirs.set_config(8, NIRS.TYPES.HADAMARD_TYPE, 228, 6, 900, 1700, 7) # Turn on the lamp. - nirs.set_lamp_on_off(True) + nirs.set_lamp_on_off(1) time.sleep(3) # Scan. @@ -117,6 +120,6 @@ def clear_error_status(self): results = nirs.get_scan_results() # Turn lamp off. - nirs.set_lamp_on_off(False) + nirs.set_lamp_on_off(-1) pass diff --git a/README.md b/README.md index 9f17fd4..65cdcde 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,12 @@ $ cd NIRScanner-Python ``` For compiling Python 2 library: ```console +NIRScanner-Python$ chmod +x ./src/scripts/compile_py2.sh NIRScanner-Python$ ./src/scripts/compile_py2.sh ``` For compiling Python 3 library: ```console +NIRScanner-Python$ chmod +x ./src/scripts/compile_py3.sh NIRScanner-Python$ ./src/scripts/compile_py3.sh ``` ## Deploy diff --git a/_NIRScanner.so b/_NIRScanner.so index a2f98f0..eb07d02 100644 Binary files a/_NIRScanner.so and b/_NIRScanner.so differ diff --git a/lib/_NIRScanner.so.3.8 b/lib/_NIRScanner.so.3.8 new file mode 100755 index 0000000..eb07d02 Binary files /dev/null and b/lib/_NIRScanner.so.3.8 differ diff --git a/src/NIRScanner.cpp b/src/NIRScanner.cpp index 9030286..9e52350 100644 --- a/src/NIRScanner.cpp +++ b/src/NIRScanner.cpp @@ -196,15 +196,41 @@ void NIRScanner::setConfig(uint16_t scanConfigIndex, // < Unique ID per spectro uint16_t num_repeats, // Number of times to repeat the scan on the spectromter before averaging the scans together and returning the results. This can be used to increase integration time. uint16_t wavelength_start_nm, // Minimum wavelength to start the scan from, in nm. uint16_t wavelength_end_nm, // Maximum wavelength to end the scan at, in nm. - uint8_t width_px // Pixel width of the patterns. Increasing this will increase SNR, but reduce resolution. - ) { - this->mConfig.scanCfg.scanConfigIndex = scanConfigIndex; - this->mConfig.scanCfg.scan_type = scan_type; - this->mConfig.scanCfg.num_patterns = num_patterns; - this->mConfig.scanCfg.num_repeats = num_repeats; - this->mConfig.scanCfg.wavelength_start_nm = wavelength_start_nm; - this->mConfig.scanCfg.wavelength_end_nm = wavelength_end_nm; - this->mConfig.scanCfg.width_px = width_px; + uint8_t width_px ,// Pixel width of the patterns. Increasing this will increase SNR, but reduce resolution. + uint16_t exposure_time, //Time for for which each pattern in this section will be exposed. Values should be as per EXP_TIME enum above + const char* config_name//User friendly scan configuration name for display + ) +{ + if(scan_type != SLEW_TYPE) + { + this->mConfig.scanCfg.scanConfigIndex = scanConfigIndex; + this->mConfig.scanCfg.scan_type = scan_type; + this->mConfig.scanCfg.num_patterns = num_patterns; + this->mConfig.scanCfg.num_repeats = num_repeats; + this->mConfig.scanCfg.wavelength_start_nm = wavelength_start_nm; + this->mConfig.scanCfg.wavelength_end_nm = wavelength_end_nm; + this->mConfig.scanCfg.width_px = width_px; + + char ser_num[NANO_SER_NUM_LEN] = ""; + NNO_GetSerialNumber(ser_num); + memcpy(this->mConfig.scanCfg.ScanConfig_serial_number, ser_num, NANO_SER_NUM_LEN); + + memcpy(this->mConfig.scanCfg.config_name, config_name, SCAN_CFG_FILENAME_LEN); + } + else + { + this->mConfig.slewScanCfg.head.num_sections; + this->mConfig.slewScanCfg.head.num_repeats; + for(uint8_t i=0; i < this->mConfig.slewScanCfg.head.num_sections; i++) + { + this->mConfig.slewScanCfg.section[i].section_scan_type; + this->mConfig.slewScanCfg.section[i].wavelength_start_nm; + this->mConfig.slewScanCfg.section[i].wavelength_end_nm; + this->mConfig.slewScanCfg.section[i].width_px; + this->mConfig.slewScanCfg.section[i].num_patterns; + this->mConfig.slewScanCfg.section[i].exposure_time; + } + } this->configEVM(); } @@ -233,6 +259,21 @@ void NIRScanner::setPGAGain(int32_t newValue) } } +void NIRScanner::syncDeviceDateTime(uint16_t year, uint8_t month, uint8_t day, uint8_t wday, uint8_t hour, uint8_t min, uint8_t sec) +{ + NNO_SetDateTime(uint8_t(year - 2000), uint8_t(month), uint8_t(day), uint8_t(wday), uint8_t(hour), uint8_t(min), uint8_t(sec)); + + uint8_t yearR = 0; + uint8_t monthR = 0; + uint8_t dayR = 0; + uint8_t wdayR = 0; + uint8_t hourR = 0; + uint8_t minR = 0; + uint8_t secR = 0; + NNO_GetDateTime(&yearR, &monthR, &dayR, &wdayR, &hourR, &minR, &secR); + printf("synchronized date time %d.%d.%d-%d:%d:%d\n", yearR + 2000, monthR, dayR, hourR, minR, secR); +} + void NIRScanner::setLampOnOff(int32_t newValue) /* * Set the lamp always on or off. diff --git a/src/NIRScanner.h b/src/NIRScanner.h index 7bf8b35..f3d9af3 100644 --- a/src/NIRScanner.h +++ b/src/NIRScanner.h @@ -38,10 +38,19 @@ class NIRScanner { int readVersion(); void resetErrorStatus(); void setLampOnOff(int32_t newValue); - void setConfig(uint16_t scanConfigIndex, uint8_t scan_type, uint16_t num_patterns, uint16_t num_repeats, - uint16_t wavelength_start_nm, uint16_t wavelength_end_nm, uint8_t width_px); + void setConfig(uint16_t scanConfigIndex, // < Unique ID per spectrometer which is modified when the config is changed. Can be used to determine whether a cached version of the config is valid per spectrometer SN. + uint8_t scan_type, // 0: COLUMN_TYPE, 1: HADAMARD_TYPE, 2: SLEW_TYPE. + uint16_t num_patterns, // Number of desired points in the spectrum. + uint16_t num_repeats, // Number of times to repeat the scan on the spectromter before averaging the scans together and returning the results. This can be used to increase integration time. + uint16_t wavelength_start_nm, // Minimum wavelength to start the scan from, in nm. + uint16_t wavelength_end_nm, // Maximum wavelength to end the scan at, in nm. + uint8_t width_px ,// Pixel width of the patterns. Increasing this will increase SNR, but reduce resolution. + uint16_t exposure_time, //Time for for which each pattern in this section will be exposed. Values should be as per EXP_TIME enum above + const char* config_name//User friendly scan configuration name for display + ); void configEVM(uScanConfig* pConfig = nullptr); void setPGAGain(int32_t newValue); + void syncDeviceDateTime(uint16_t year, uint8_t month, uint8_t day, uint8_t wday, uint8_t hour, uint8_t min, uint8_t sec); string scanSNR(bool isHadamard=true); void scan(bool saveDataFlag=false, int numRepeats=1); diff --git a/src/NIRScanner.i b/src/NIRScanner.i index e34038c..0066901 100644 --- a/src/NIRScanner.i +++ b/src/NIRScanner.i @@ -23,10 +23,19 @@ public: int readVersion(); void resetErrorStatus(); void setLampOnOff(int32_t newValue); - void setConfig(uint16_t scanConfigIndex, uint8_t scan_type, uint16_t num_patterns, uint16_t num_repeats, - uint16_t wavelength_start_nm, uint16_t wavelength_end_nm, uint8_t width_px); + void setConfig(uint16_t scanConfigIndex, // < Unique ID per spectrometer which is modified when the config is changed. Can be used to determine whether a cached version of the config is valid per spectrometer SN. + uint8_t scan_type, // 0: COLUMN_TYPE, 1: HADAMARD_TYPE, 2: SLEW_TYPE. + uint16_t num_patterns, // Number of desired points in the spectrum. + uint16_t num_repeats, // Number of times to repeat the scan on the spectromter before averaging the scans together and returning the results. This can be used to increase integration time. + uint16_t wavelength_start_nm, // Minimum wavelength to start the scan from, in nm. + uint16_t wavelength_end_nm, // Maximum wavelength to end the scan at, in nm. + uint8_t width_px ,// Pixel width of the patterns. Increasing this will increase SNR, but reduce resolution. + uint16_t exposure_time, //Time for for which each pattern in this section will be exposed. Values should be as per EXP_TIME enum above + const char* config_name//User friendly scan configuration name for display + ); void configEVM(uScanConfig* pConfig = nullptr); void setPGAGain(int32_t newValue); + void syncDeviceDateTime(uint16_t year, uint8_t month, uint8_t day, uint8_t wday, uint8_t hour, uint8_t min, uint8_t sec); string scanSNR(bool isHadamard=true); void scan(bool saveDataFlag=false, int numRepeats=1); diff --git a/src/NIRScanner.py b/src/NIRScanner.py index c937f05..4cc53c1 100644 --- a/src/NIRScanner.py +++ b/src/NIRScanner.py @@ -1,115 +1,73 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 3.0.12 +# Version 4.0.1 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. from sys import version_info as _swig_python_version_info -if _swig_python_version_info >= (2, 7, 0): - def swig_import_helper(): - import importlib - pkg = __name__.rpartition('.')[0] - mname = '.'.join((pkg, '_NIRScanner')).lstrip('.') - try: - return importlib.import_module(mname) - except ImportError: - return importlib.import_module('_NIRScanner') - _NIRScanner = swig_import_helper() - del swig_import_helper -elif _swig_python_version_info >= (2, 6, 0): - def swig_import_helper(): - from os.path import dirname - import imp - fp = None - try: - fp, pathname, description = imp.find_module('_NIRScanner', [dirname(__file__)]) - except ImportError: - import _NIRScanner - return _NIRScanner - try: - _mod = imp.load_module('_NIRScanner', fp, pathname, description) - finally: - if fp is not None: - fp.close() - return _mod - _NIRScanner = swig_import_helper() - del swig_import_helper +if _swig_python_version_info < (2, 7, 0): + raise RuntimeError("Python 2.7 or later required") + +# Import the low-level C/C++ module +if __package__ or "." in __name__: + from . import _NIRScanner else: import _NIRScanner -del _swig_python_version_info - -try: - _swig_property = property -except NameError: - pass # Python < 2.2 doesn't have 'property'. try: import builtins as __builtin__ except ImportError: import __builtin__ -def _swig_setattr_nondynamic(self, class_type, name, value, static=1): - if (name == "thisown"): - return self.this.own(value) - if (name == "this"): - if type(value).__name__ == 'SwigPyObject': - self.__dict__[name] = value - return - method = class_type.__swig_setmethods__.get(name, None) - if method: - return method(self, value) - if (not static): - if _newclass: - object.__setattr__(self, name, value) +def _swig_repr(self): + try: + strthis = "proxy of " + self.this.__repr__() + except __builtin__.Exception: + strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + + +def _swig_setattr_nondynamic_instance_variable(set): + def set_instance_attr(self, name, value): + if name == "thisown": + self.this.own(value) + elif name == "this": + set(self, name, value) + elif hasattr(self, name) and isinstance(getattr(type(self), name), property): + set(self, name, value) else: - self.__dict__[name] = value - else: - raise AttributeError("You cannot add attributes to %s" % self) + raise AttributeError("You cannot add instance attributes to %s" % self) + return set_instance_attr -def _swig_setattr(self, class_type, name, value): - return _swig_setattr_nondynamic(self, class_type, name, value, 0) +def _swig_setattr_nondynamic_class_variable(set): + def set_class_attr(cls, name, value): + if hasattr(cls, name) and not isinstance(getattr(cls, name), property): + set(cls, name, value) + else: + raise AttributeError("You cannot add class attributes to %s" % cls) + return set_class_attr -def _swig_getattr(self, class_type, name): - if (name == "thisown"): - return self.this.own() - method = class_type.__swig_getmethods__.get(name, None) - if method: - return method(self) - raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name)) +def _swig_add_metaclass(metaclass): + """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" + def wrapper(cls): + return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) + return wrapper -def _swig_repr(self): - try: - strthis = "proxy of " + self.this.__repr__() - except __builtin__.Exception: - strthis = "" - return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) +class _SwigNonDynamicMeta(type): + """Meta class to enforce nondynamic attributes (no new attributes) for a class""" + __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) -try: - _object = object - _newclass = 1 -except __builtin__.Exception: - class _object: - pass - _newclass = 0 - -class NIRScanner(_object): - __swig_setmethods__ = {} - __setattr__ = lambda self, name, value: _swig_setattr(self, NIRScanner, name, value) - __swig_getmethods__ = {} - __getattr__ = lambda self, name: _swig_getattr(self, NIRScanner, name) + +class NIRScanner(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr def __init__(self, pConfig=None): - this = _NIRScanner.new_NIRScanner(pConfig) - try: - self.this.append(this) - except __builtin__.Exception: - self.this = this + _NIRScanner.NIRScanner_swiginit(self, _NIRScanner.new_NIRScanner(pConfig)) __swig_destroy__ = _NIRScanner.delete_NIRScanner - __del__ = lambda self: None def readVersion(self): return _NIRScanner.NIRScanner_readVersion(self) @@ -120,8 +78,8 @@ def resetErrorStatus(self): def setLampOnOff(self, newValue): return _NIRScanner.NIRScanner_setLampOnOff(self, newValue) - def setConfig(self, scanConfigIndex, scan_type, num_patterns, num_repeats, wavelength_start_nm, wavelength_end_nm, width_px): - return _NIRScanner.NIRScanner_setConfig(self, scanConfigIndex, scan_type, num_patterns, num_repeats, wavelength_start_nm, wavelength_end_nm, width_px) + def setConfig(self, scanConfigIndex, scan_type, num_patterns, num_repeats, wavelength_start_nm, wavelength_end_nm, width_px, exposure_time, config_name): + return _NIRScanner.NIRScanner_setConfig(self, scanConfigIndex, scan_type, num_patterns, num_repeats, wavelength_start_nm, wavelength_end_nm, width_px, exposure_time, config_name) def configEVM(self, pConfig=None): return _NIRScanner.NIRScanner_configEVM(self, pConfig) @@ -129,6 +87,9 @@ def configEVM(self, pConfig=None): def setPGAGain(self, newValue): return _NIRScanner.NIRScanner_setPGAGain(self, newValue) + def syncDeviceDateTime(self, year, month, day, wday, hour, min, sec): + return _NIRScanner.NIRScanner_syncDeviceDateTime(self, year, month, day, wday, hour, min, sec) + def scanSNR(self, isHadamard=True): return _NIRScanner.NIRScanner_scanSNR(self, isHadamard) @@ -140,9 +101,9 @@ def getScanData(self): def setHibernate(self, newValue): return _NIRScanner.NIRScanner_setHibernate(self, newValue) -NIRScanner_swigregister = _NIRScanner.NIRScanner_swigregister -NIRScanner_swigregister(NIRScanner) -# This file is compatible with both classic and new-style classes. +# Register NIRScanner in _NIRScanner: +_NIRScanner.NIRScanner_swigregister(NIRScanner) + diff --git a/src/NIRScanner_wrap.cxx b/src/NIRScanner_wrap.cxx index 047d924..1ac5529 100644 --- a/src/NIRScanner_wrap.cxx +++ b/src/NIRScanner_wrap.cxx @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.12 + * Version 4.0.1 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -164,11 +164,16 @@ template T SwigValueInit() { #endif +#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) +/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ +# include +#endif + #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ # undef _DEBUG # include -# define _DEBUG +# define _DEBUG 1 #else # include #endif @@ -218,6 +223,7 @@ template T SwigValueInit() { /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -803,14 +809,16 @@ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 - char *cstr; - char *newstr; - Py_ssize_t len; + char *newstr = 0; str = PyUnicode_AsUTF8String(str); - PyBytes_AsStringAndSize(str, &cstr, &len); - newstr = (char *) malloc(len+1); - memcpy(newstr, cstr, len+1); - Py_XDECREF(str); + if (str) { + char *cstr; + Py_ssize_t len; + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + } return newstr; #else return PyString_AsString(str); @@ -834,144 +842,14 @@ SWIG_Python_str_FromChar(const char *c) #endif } -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif - -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -typedef inquiry lenfunc; -typedef intargfunc ssizeargfunc; -typedef intintargfunc ssizessizeargfunc; -typedef intobjargproc ssizeobjargproc; -typedef intintobjargproc ssizessizeobjargproc; -typedef getreadbufferproc readbufferproc; -typedef getwritebufferproc writebufferproc; -typedef getsegcountproc segcountproc; -typedef getcharbufferproc charbufferproc; -static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) -{ - long result = 0; - PyObject *i = PyNumber_Int(x); - if (i) { - result = PyInt_AsLong(i); - Py_DECREF(i); - } - return result; -} -#endif - -#if PY_VERSION_HEX < 0x02050000 -#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) -#endif - -#if PY_VERSION_HEX < 0x02040000 -#define Py_VISIT(op) \ - do { \ - if (op) { \ - int vret = visit((op), arg); \ - if (vret) \ - return vret; \ - } \ - } while (0) -#endif - -#if PY_VERSION_HEX < 0x02030000 -typedef struct { - PyTypeObject type; - PyNumberMethods as_number; - PyMappingMethods as_mapping; - PySequenceMethods as_sequence; - PyBufferProcs as_buffer; - PyObject *name, *slots; -} PyHeapTypeObject; -#endif - -#if PY_VERSION_HEX < 0x02030000 -typedef destructor freefunc; -#endif - -#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ - (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ - (PY_MAJOR_VERSION > 3)) +// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user +// interface files check for it. # define SWIGPY_USE_CAPSULE -# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) -#endif +# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) @@ -1034,14 +912,17 @@ SWIG_Python_AddErrorMsg(const char* mesg) PyObject *value = 0; PyObject *traceback = 0; - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (PyErr_Occurred()) + PyErr_Fetch(&type, &value, &traceback); if (value) { - char *tmp; PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); PyErr_Clear(); Py_XINCREF(type); - - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + if (tmp) + PyErr_Format(type, "%s %s", tmp, mesg); + else + PyErr_Format(type, "%s", mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); @@ -1050,6 +931,37 @@ SWIG_Python_AddErrorMsg(const char* mesg) } } +SWIGRUNTIME int +SWIG_Python_TypeErrorOccurred(PyObject *obj) +{ + PyObject *error; + if (obj) + return 0; + error = PyErr_Occurred(); + return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); +} + +SWIGRUNTIME void +SWIG_Python_RaiseOrModifyTypeError(const char *message) +{ + if (SWIG_Python_TypeErrorOccurred(NULL)) { + /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *newvalue; + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); +#if PY_VERSION_HEX >= 0x03000000 + newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); +#else + newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); +#endif + Py_XDECREF(value); + PyErr_Restore(type, newvalue, traceback); + } else { + /* Raise TypeError using given message */ + PyErr_SetString(PyExc_TypeError, message); + } +} + #if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS @@ -1057,9 +969,7 @@ SWIG_Python_AddErrorMsg(const char* mesg) #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif +# define SWIG_PYTHON_USE_GIL # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS @@ -1136,30 +1046,13 @@ extern "C" { /* Constant information structure */ typedef struct swig_const_info { int type; - char *name; + const char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -#if PY_VERSION_HEX >= 0x03000000 -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) -{ - return PyInstanceMethod_New(func); -} -#else -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) -{ - return NULL; -} -#endif - #ifdef __cplusplus } #endif @@ -1174,6 +1067,14 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), * * ----------------------------------------------------------------------------- */ +#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ +# error "This version of SWIG only supports Python >= 2.7" +#endif + +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 +# error "This version of SWIG only supports Python 3 >= 3.2" +#endif + /* Common SWIG API */ /* for raw pointers */ @@ -1257,11 +1158,7 @@ SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { -#if PY_VERSION_HEX < 0x02030000 - PyDict_SetItemString(d, (char *)name, obj); -#else PyDict_SetItemString(d, name, obj); -#endif Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); @@ -1271,11 +1168,7 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { -#if PY_VERSION_HEX < 0x02030000 - PyDict_SetItemString(d, (char *)name, obj); -#else PyDict_SetItemString(d, name, obj); -#endif Py_DECREF(obj); } @@ -1285,7 +1178,6 @@ SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { @@ -1301,29 +1193,6 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { Py_DECREF(obj); } return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif } /* Unpack the argument tuple */ @@ -1375,11 +1244,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } /* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif /* Helper for static pointer initialization for both C and C++ code, for example @@ -1408,35 +1273,6 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi extern "C" { #endif -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue((char*)""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - /* The python void return value */ SWIGRUNTIMEINLINE PyObject * @@ -1463,7 +1299,10 @@ SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - return data ? data->implicitconv : 0; + int fail = data ? data->implicitconv : 0; + if (fail) + PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); + return fail; } SWIGRUNTIMEINLINE PyObject * @@ -1490,11 +1329,7 @@ SwigPyClientData_New(PyObject* obj) data->newargs = obj; Py_INCREF(obj); } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif + data->newraw = PyObject_GetAttrString(data->klass, "__new__"); if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); @@ -1505,7 +1340,7 @@ SwigPyClientData_New(PyObject* obj) Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; @@ -1514,11 +1349,7 @@ SwigPyClientData_New(PyObject* obj) int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif } else { data->delargs = 0; } @@ -1606,20 +1437,12 @@ SwigPyObject_hex(SwigPyObject *v) } SWIGRUNTIME PyObject * -#ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) -#else -SwigPyObject_repr(SwigPyObject *v, PyObject *args) -#endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (v->next) { -# ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); -# else - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); -# endif # if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); @@ -1632,6 +1455,14 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) return repr; } +/* We need a version taking two PyObject* parameters so it's a valid + * PyCFunction to use in swigobject_methods[]. */ +SWIGRUNTIME PyObject * +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + return SwigPyObject_repr((SwigPyObject*)v); +} + SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { @@ -1705,14 +1536,14 @@ SwigPyObject_dealloc(PyObject *v) PyObject *res; /* PyObject_CallFunction() has the potential to silently drop - the active active exception. In cases of unnamed temporary + the active exception. In cases of unnamed temporary variable or where we just finished iterating over a generator StopIteration will be active right now, and this needs to remain true upon return from SwigPyObject_dealloc. So save and restore. */ - PyObject *val = NULL, *type = NULL, *tb = NULL; - PyErr_Fetch(&val, &type, &tb); + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ @@ -1727,7 +1558,7 @@ SwigPyObject_dealloc(PyObject *v) if (!res) PyErr_WriteUnraisable(destroy); - PyErr_Restore(val, type, tb); + PyErr_Restore(type, value, traceback); Py_XDECREF(res); } @@ -1746,11 +1577,6 @@ SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif if (!SwigPyObject_Check(next)) { PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); return NULL; @@ -1761,11 +1587,7 @@ SwigPyObject_append(PyObject* v, PyObject* next) } SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -SwigPyObject_next(PyObject* v) -#else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { @@ -1777,11 +1599,7 @@ SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) } SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_disown(PyObject *v) -#else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; @@ -1789,11 +1607,7 @@ SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) } SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_acquire(PyObject *v) -#else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; @@ -1804,70 +1618,32 @@ SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#elif (PY_VERSION_HEX < 0x02050000) - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#else - if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) -#endif - { - return NULL; + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { + return NULL; + } else { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } } - else - { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); - } else { - SwigPyObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } -#endif - } - return obj; - } + return obj; + } } -#ifdef METH_O static PyMethodDef swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, {0, 0, 0, 0} }; -#else -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -SwigPyObject_getattr(SwigPyObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { @@ -1912,12 +1688,8 @@ SwigPyObject_TypeOnce(void) { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ #elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ +#else 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; @@ -1931,16 +1703,12 @@ SwigPyObject_TypeOnce(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"SwigPyObject", /* tp_name */ + "SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 0, /* tp_print */ -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ -#else (getattrfunc)0, /* tp_getattr */ -#endif (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX >= 0x03000000 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ @@ -1963,7 +1731,6 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ @@ -1984,13 +1751,8 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ -#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -1998,20 +1760,14 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ -#endif 0 /* tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - swigpyobject_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&swigpyobject_type) < 0) return NULL; -#endif } return &swigpyobject_type; } @@ -2040,20 +1796,6 @@ typedef struct { size_t size; } SwigPyPacked; -SWIGRUNTIME int -SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { @@ -2082,7 +1824,7 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); + return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); @@ -2122,11 +1864,11 @@ SwigPyPacked_TypeOnce(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"SwigPyPacked", /* tp_name */ + "SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ - (printfunc)SwigPyPacked_print, /* tp_print */ + 0, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 @@ -2150,7 +1892,6 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ @@ -2171,13 +1912,8 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ -#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -2185,20 +1921,14 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ -#endif 0 /* tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - swigpypacked_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&swigpypacked_type) < 0) return NULL; -#endif } return &swigpypacked_type; } @@ -2239,20 +1969,14 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) * pointers/data manipulation * ----------------------------------------------------------------------------- */ -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return SWIG_Python_str_FromChar("this"); -} - -static PyObject *swig_this = NULL; +static PyObject *Swig_This_global = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { - if (swig_this == NULL) - swig_this = _SWIG_This(); - return swig_this; + if (Swig_This_global == NULL) + Swig_This_global = SWIG_Python_str_FromChar("this"); + return Swig_This_global; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ @@ -2284,7 +2008,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { @@ -2354,7 +2078,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } res = SWIG_ERROR; @@ -2434,13 +2158,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } } - } - if (!SWIG_IsOK(res) && obj == Py_None) { - if (ptr) - *ptr = 0; - if (PyErr_Occurred()) - PyErr_Clear(); - res = SWIG_OK; + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } } } return res; @@ -2454,31 +2178,28 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; - + swig_cast_info *tc; + /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) + if (!desc) return SWIG_ERROR; - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } + tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ } else { - *ptr = vptr; + return SWIG_ERROR; } return SWIG_OK; } } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { @@ -2506,7 +2227,6 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { -#if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { @@ -2529,10 +2249,18 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } else { #if PY_VERSION_HEX >= 0x03000000 - inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - if (inst) { - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + PyObject *empty_args = PyTuple_New(0); + if (empty_args) { + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } + } + Py_DECREF(empty_args); } #else PyObject *dict = PyDict_New(); @@ -2544,45 +2272,13 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) #endif } return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst = 0; - PyObject *dict = PyDict_New(); - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; @@ -2594,7 +2290,7 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) return; } #endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + dict = PyObject_GetAttrString(inst, "__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } @@ -2693,12 +2389,7 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else -# ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); -# else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); -# endif if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; @@ -2708,48 +2399,10 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { return (swig_module_info *) type_pointer; } -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - SWIGRUNTIME void -#ifdef SWIGPY_USE_CAPSULE SWIG_Python_DestroyModule(PyObject *obj) -#else -SWIG_Python_DestroyModule(void *vptr) -#endif { -#ifdef SWIGPY_USE_CAPSULE swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); -#else - swig_module_info *swig_module = (swig_module_info *) vptr; -#endif swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { @@ -2760,33 +2413,24 @@ SWIG_Python_DestroyModule(void *vptr) } } Py_DECREF(SWIG_This()); - swig_this = NULL; + Swig_This_global = NULL; } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { #if PY_VERSION_HEX >= 0x03000000 /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); + PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); #else static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); + PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif -#ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -#else - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } -#endif } /* The python cached type query */ @@ -2804,20 +2448,12 @@ SWIG_Python_TypeQuery(const char *type) PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { -#ifdef SWIGPY_USE_CAPSULE descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); -#else - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); -#endif } else { swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { -#ifdef SWIGPY_USE_CAPSULE obj = PyCapsule_New((void*) descriptor, NULL, NULL); -#else - obj = PyCObject_FromVoidPtr(descriptor, NULL); -#endif PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } @@ -2842,14 +2478,15 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront) PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { - char *tmp; PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + const char *errmesg = tmp ? tmp : "Invalid error message"; Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); + PyErr_Format(type, "%s %s", mesg, errmesg); } else { - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + PyErr_Format(type, "%s %s", errmesg, mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); @@ -2975,6 +2612,8 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { Py_INCREF(name); } else { encoded_name = PyUnicode_AsUTF8String(name); + if (!encoded_name) + return -1; } PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); Py_DECREF(encoded_name); @@ -3001,6 +2640,21 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { +#ifdef __cplusplus +extern "C" { +#endif + +/* Method creation and docstring support functions */ + +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); + +#ifdef __cplusplus +} +#endif + + /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_NIRScanner swig_types[0] @@ -3021,11 +2675,10 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; /* -------- TYPES TABLE (END) -------- */ -#if (PY_VERSION_HEX <= 0x02000000) -# if !defined(SWIG_PYTHON_CLASSIC) -# error "This python version requires swig to be run with the '-classic' option" -# endif +#ifdef SWIG_TypeQuery +# undef SWIG_TypeQuery #endif +#define SWIG_TypeQuery SWIG_Python_TypeQuery /*----------------------------------------------- @(target):= _NIRScanner.so @@ -3039,7 +2692,7 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; #endif #define SWIG_name "_NIRScanner" -#define SWIGVERSION 0x030012 +#define SWIGVERSION 0x040001 #define SWIG_VERSION SWIGVERSION @@ -3367,6 +3020,129 @@ SWIG_AsVal_unsigned_SS_char (PyObject * obj, unsigned char *val) } +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (PyBytes_Check(obj)) +#else + if (PyUnicode_Check(obj)) +#endif +#else + if (PyString_Check(obj)) +#endif + { + char *cstr; Py_ssize_t len; + int ret = SWIG_OK; +#if PY_VERSION_HEX>=0x03000000 +#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (alloc) + *alloc = SWIG_NEWOBJ; +#endif + PyBytes_AsStringAndSize(obj, &cstr, &len); +#else + PyString_AsStringAndSize(obj, &cstr, &len); +#endif + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1))); + *alloc = SWIG_NEWOBJ; + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + *cptr = PyBytes_AsString(obj); +#else + assert(0); /* Should never reach here with Unicode strings in Python 3 */ +#endif +#else + *cptr = SWIG_Python_str_AsChar(obj); + if (!*cptr) + ret = SWIG_TypeError; +#endif + } + } + if (psize) *psize = len + 1; +#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + Py_XDECREF(obj); +#endif + return ret; + } else { +#if defined(SWIG_PYTHON_2_UNICODE) +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) +#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" +#endif +#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1))); + } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } +#endif +#endif + + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + SWIGINTERN int SWIG_AsVal_bool (PyObject *obj, bool *val) { @@ -3381,19 +3157,6 @@ SWIG_AsVal_bool (PyObject *obj, bool *val) } -SWIGINTERN swig_type_info* -SWIG_pchar_descriptor(void) -{ - static int init = 0; - static swig_type_info* info = 0; - if (!init) { - info = SWIG_TypeQuery("_p_char"); - init = 1; - } - return info; -} - - SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { @@ -3407,11 +3170,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) #if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) return PyBytes_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); #else -#if PY_VERSION_HEX >= 0x03010000 return PyUnicode_DecodeUTF8(carray, static_cast< Py_ssize_t >(size), "surrogateescape"); -#else - return PyUnicode_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); -#endif #endif #else return PyString_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); @@ -3432,16 +3191,15 @@ SWIG_From_std_string (const std::string& s) #ifdef __cplusplus extern "C" { #endif -SWIGINTERN PyObject *_wrap_new_NIRScanner__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_NIRScanner__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; uScanConfig *arg1 = (uScanConfig *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; NIRScanner *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:new_NIRScanner",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uScanConfig, 0 | 0 ); + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_uScanConfig, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_NIRScanner" "', argument " "1"" of type '" "uScanConfig *""'"); } @@ -3454,11 +3212,11 @@ SWIGINTERN PyObject *_wrap_new_NIRScanner__SWIG_0(PyObject *SWIGUNUSEDPARM(self) } -SWIGINTERN PyObject *_wrap_new_NIRScanner__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_new_NIRScanner__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) { PyObject *resultobj = 0; NIRScanner *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)":new_NIRScanner")) SWIG_fail; + if ((nobjs < 0) || (nobjs > 0)) SWIG_fail; result = (NIRScanner *)new NIRScanner(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_NIRScanner, SWIG_POINTER_NEW | 0 ); return resultobj; @@ -3472,15 +3230,11 @@ SWIGINTERN PyObject *_wrap_new_NIRScanner(PyObject *self, PyObject *args) { PyObject *argv[2] = { 0 }; - Py_ssize_t ii; - if (!PyTuple_Check(args)) SWIG_fail; - argc = args ? PyObject_Length(args) : 0; - for (ii = 0; (ii < 1) && (ii < argc); ii++) { - argv[ii] = PyTuple_GET_ITEM(args,ii); - } + if (!(argc = SWIG_Python_UnpackTuple(args, "new_NIRScanner", 0, 1, argv))) SWIG_fail; + --argc; if (argc == 0) { - return _wrap_new_NIRScanner__SWIG_1(self, args); + return _wrap_new_NIRScanner__SWIG_1(self, argc, argv); } if (argc == 1) { int _v; @@ -3488,12 +3242,12 @@ SWIGINTERN PyObject *_wrap_new_NIRScanner(PyObject *self, PyObject *args) { int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_uScanConfig, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_NIRScanner__SWIG_0(self, args); + return _wrap_new_NIRScanner__SWIG_0(self, argc, argv); } } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_NIRScanner'.\n" + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_NIRScanner'.\n" " Possible C/C++ prototypes are:\n" " NIRScanner::NIRScanner(uScanConfig *)\n" " NIRScanner::NIRScanner()\n"); @@ -3506,10 +3260,11 @@ SWIGINTERN PyObject *_wrap_delete_NIRScanner(PyObject *SWIGUNUSEDPARM(self), PyO NIRScanner *arg1 = (NIRScanner *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; - if (!PyArg_ParseTuple(args,(char *)"O:delete_NIRScanner",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, SWIG_POINTER_DISOWN | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, SWIG_POINTER_DISOWN | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_NIRScanner" "', argument " "1"" of type '" "NIRScanner *""'"); } @@ -3527,11 +3282,12 @@ SWIGINTERN PyObject *_wrap_NIRScanner_readVersion(PyObject *SWIGUNUSEDPARM(self) NIRScanner *arg1 = (NIRScanner *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; int result; - if (!PyArg_ParseTuple(args,(char *)"O:NIRScanner_readVersion",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_readVersion" "', argument " "1"" of type '" "NIRScanner *""'"); } @@ -3549,10 +3305,11 @@ SWIGINTERN PyObject *_wrap_NIRScanner_resetErrorStatus(PyObject *SWIGUNUSEDPARM( NIRScanner *arg1 = (NIRScanner *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; - if (!PyArg_ParseTuple(args,(char *)"O:NIRScanner_resetErrorStatus",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_resetErrorStatus" "', argument " "1"" of type '" "NIRScanner *""'"); } @@ -3573,16 +3330,15 @@ SWIGINTERN PyObject *_wrap_NIRScanner_setLampOnOff(PyObject *SWIGUNUSEDPARM(self int res1 = 0 ; int val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; - if (!PyArg_ParseTuple(args,(char *)"OO:NIRScanner_setLampOnOff",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "NIRScanner_setLampOnOff", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_setLampOnOff" "', argument " "1"" of type '" "NIRScanner *""'"); } arg1 = reinterpret_cast< NIRScanner * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NIRScanner_setLampOnOff" "', argument " "2"" of type '" "int32_t""'"); } @@ -3605,6 +3361,8 @@ SWIGINTERN PyObject *_wrap_NIRScanner_setConfig(PyObject *SWIGUNUSEDPARM(self), uint16_t arg6 ; uint16_t arg7 ; uint8_t arg8 ; + uint16_t arg9 ; + char *arg10 = (char *) 0 ; void *argp1 = 0 ; int res1 = 0 ; unsigned short val2 ; @@ -3621,65 +3379,75 @@ SWIGINTERN PyObject *_wrap_NIRScanner_setConfig(PyObject *SWIGUNUSEDPARM(self), int ecode7 = 0 ; unsigned char val8 ; int ecode8 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - PyObject * obj3 = 0 ; - PyObject * obj4 = 0 ; - PyObject * obj5 = 0 ; - PyObject * obj6 = 0 ; - PyObject * obj7 = 0 ; + unsigned short val9 ; + int ecode9 = 0 ; + int res10 ; + char *buf10 = 0 ; + int alloc10 = 0 ; + PyObject *swig_obj[10] ; - if (!PyArg_ParseTuple(args,(char *)"OOOOOOOO:NIRScanner_setConfig",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "NIRScanner_setConfig", 10, 10, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_setConfig" "', argument " "1"" of type '" "NIRScanner *""'"); } arg1 = reinterpret_cast< NIRScanner * >(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_short(obj1, &val2); + ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NIRScanner_setConfig" "', argument " "2"" of type '" "uint16_t""'"); } arg2 = static_cast< uint16_t >(val2); - ecode3 = SWIG_AsVal_unsigned_SS_char(obj2, &val3); + ecode3 = SWIG_AsVal_unsigned_SS_char(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "NIRScanner_setConfig" "', argument " "3"" of type '" "uint8_t""'"); } arg3 = static_cast< uint8_t >(val3); - ecode4 = SWIG_AsVal_unsigned_SS_short(obj3, &val4); + ecode4 = SWIG_AsVal_unsigned_SS_short(swig_obj[3], &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "NIRScanner_setConfig" "', argument " "4"" of type '" "uint16_t""'"); } arg4 = static_cast< uint16_t >(val4); - ecode5 = SWIG_AsVal_unsigned_SS_short(obj4, &val5); + ecode5 = SWIG_AsVal_unsigned_SS_short(swig_obj[4], &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "NIRScanner_setConfig" "', argument " "5"" of type '" "uint16_t""'"); } arg5 = static_cast< uint16_t >(val5); - ecode6 = SWIG_AsVal_unsigned_SS_short(obj5, &val6); + ecode6 = SWIG_AsVal_unsigned_SS_short(swig_obj[5], &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "NIRScanner_setConfig" "', argument " "6"" of type '" "uint16_t""'"); } arg6 = static_cast< uint16_t >(val6); - ecode7 = SWIG_AsVal_unsigned_SS_short(obj6, &val7); + ecode7 = SWIG_AsVal_unsigned_SS_short(swig_obj[6], &val7); if (!SWIG_IsOK(ecode7)) { SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "NIRScanner_setConfig" "', argument " "7"" of type '" "uint16_t""'"); } arg7 = static_cast< uint16_t >(val7); - ecode8 = SWIG_AsVal_unsigned_SS_char(obj7, &val8); + ecode8 = SWIG_AsVal_unsigned_SS_char(swig_obj[7], &val8); if (!SWIG_IsOK(ecode8)) { SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "NIRScanner_setConfig" "', argument " "8"" of type '" "uint8_t""'"); } arg8 = static_cast< uint8_t >(val8); - (arg1)->setConfig(arg2,arg3,arg4,arg5,arg6,arg7,arg8); + ecode9 = SWIG_AsVal_unsigned_SS_short(swig_obj[8], &val9); + if (!SWIG_IsOK(ecode9)) { + SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "NIRScanner_setConfig" "', argument " "9"" of type '" "uint16_t""'"); + } + arg9 = static_cast< uint16_t >(val9); + res10 = SWIG_AsCharPtrAndSize(swig_obj[9], &buf10, NULL, &alloc10); + if (!SWIG_IsOK(res10)) { + SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "NIRScanner_setConfig" "', argument " "10"" of type '" "char const *""'"); + } + arg10 = reinterpret_cast< char * >(buf10); + (arg1)->setConfig(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10); resultobj = SWIG_Py_Void(); + if (alloc10 == SWIG_NEWOBJ) delete[] buf10; return resultobj; fail: + if (alloc10 == SWIG_NEWOBJ) delete[] buf10; return NULL; } -SWIGINTERN PyObject *_wrap_NIRScanner_configEVM__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_NIRScanner_configEVM__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; NIRScanner *arg1 = (NIRScanner *) 0 ; uScanConfig *arg2 = (uScanConfig *) 0 ; @@ -3687,16 +3455,14 @@ SWIGINTERN PyObject *_wrap_NIRScanner_configEVM__SWIG_0(PyObject *SWIGUNUSEDPARM int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:NIRScanner_configEVM",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_configEVM" "', argument " "1"" of type '" "NIRScanner *""'"); } arg1 = reinterpret_cast< NIRScanner * >(argp1); - res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_uScanConfig, 0 | 0 ); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_uScanConfig, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "NIRScanner_configEVM" "', argument " "2"" of type '" "uScanConfig *""'"); } @@ -3709,15 +3475,14 @@ SWIGINTERN PyObject *_wrap_NIRScanner_configEVM__SWIG_0(PyObject *SWIGUNUSEDPARM } -SWIGINTERN PyObject *_wrap_NIRScanner_configEVM__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_NIRScanner_configEVM__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; NIRScanner *arg1 = (NIRScanner *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:NIRScanner_configEVM",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_configEVM" "', argument " "1"" of type '" "NIRScanner *""'"); } @@ -3735,20 +3500,16 @@ SWIGINTERN PyObject *_wrap_NIRScanner_configEVM(PyObject *self, PyObject *args) PyObject *argv[3] = { 0 }; - Py_ssize_t ii; - if (!PyTuple_Check(args)) SWIG_fail; - argc = args ? PyObject_Length(args) : 0; - for (ii = 0; (ii < 2) && (ii < argc); ii++) { - argv[ii] = PyTuple_GET_ITEM(args,ii); - } + if (!(argc = SWIG_Python_UnpackTuple(args, "NIRScanner_configEVM", 0, 2, argv))) SWIG_fail; + --argc; if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_NIRScanner, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_NIRScanner_configEVM__SWIG_1(self, args); + return _wrap_NIRScanner_configEVM__SWIG_1(self, argc, argv); } } if (argc == 2) { @@ -3761,13 +3522,13 @@ SWIGINTERN PyObject *_wrap_NIRScanner_configEVM(PyObject *self, PyObject *args) int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_uScanConfig, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_NIRScanner_configEVM__SWIG_0(self, args); + return _wrap_NIRScanner_configEVM__SWIG_0(self, argc, argv); } } } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'NIRScanner_configEVM'.\n" + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'NIRScanner_configEVM'.\n" " Possible C/C++ prototypes are:\n" " NIRScanner::configEVM(uScanConfig *)\n" " NIRScanner::configEVM()\n"); @@ -3783,16 +3544,15 @@ SWIGINTERN PyObject *_wrap_NIRScanner_setPGAGain(PyObject *SWIGUNUSEDPARM(self), int res1 = 0 ; int val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; - if (!PyArg_ParseTuple(args,(char *)"OO:NIRScanner_setPGAGain",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "NIRScanner_setPGAGain", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_setPGAGain" "', argument " "1"" of type '" "NIRScanner *""'"); } arg1 = reinterpret_cast< NIRScanner * >(argp1); - ecode2 = SWIG_AsVal_int(obj1, &val2); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NIRScanner_setPGAGain" "', argument " "2"" of type '" "int32_t""'"); } @@ -3805,7 +3565,84 @@ SWIGINTERN PyObject *_wrap_NIRScanner_setPGAGain(PyObject *SWIGUNUSEDPARM(self), } -SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_NIRScanner_syncDeviceDateTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + NIRScanner *arg1 = (NIRScanner *) 0 ; + uint16_t arg2 ; + uint8_t arg3 ; + uint8_t arg4 ; + uint8_t arg5 ; + uint8_t arg6 ; + uint8_t arg7 ; + uint8_t arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned short val2 ; + int ecode2 = 0 ; + unsigned char val3 ; + int ecode3 = 0 ; + unsigned char val4 ; + int ecode4 = 0 ; + unsigned char val5 ; + int ecode5 = 0 ; + unsigned char val6 ; + int ecode6 = 0 ; + unsigned char val7 ; + int ecode7 = 0 ; + unsigned char val8 ; + int ecode8 = 0 ; + PyObject *swig_obj[8] ; + + if (!SWIG_Python_UnpackTuple(args, "NIRScanner_syncDeviceDateTime", 8, 8, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_syncDeviceDateTime" "', argument " "1"" of type '" "NIRScanner *""'"); + } + arg1 = reinterpret_cast< NIRScanner * >(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_short(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NIRScanner_syncDeviceDateTime" "', argument " "2"" of type '" "uint16_t""'"); + } + arg2 = static_cast< uint16_t >(val2); + ecode3 = SWIG_AsVal_unsigned_SS_char(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "NIRScanner_syncDeviceDateTime" "', argument " "3"" of type '" "uint8_t""'"); + } + arg3 = static_cast< uint8_t >(val3); + ecode4 = SWIG_AsVal_unsigned_SS_char(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "NIRScanner_syncDeviceDateTime" "', argument " "4"" of type '" "uint8_t""'"); + } + arg4 = static_cast< uint8_t >(val4); + ecode5 = SWIG_AsVal_unsigned_SS_char(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "NIRScanner_syncDeviceDateTime" "', argument " "5"" of type '" "uint8_t""'"); + } + arg5 = static_cast< uint8_t >(val5); + ecode6 = SWIG_AsVal_unsigned_SS_char(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "NIRScanner_syncDeviceDateTime" "', argument " "6"" of type '" "uint8_t""'"); + } + arg6 = static_cast< uint8_t >(val6); + ecode7 = SWIG_AsVal_unsigned_SS_char(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "NIRScanner_syncDeviceDateTime" "', argument " "7"" of type '" "uint8_t""'"); + } + arg7 = static_cast< uint8_t >(val7); + ecode8 = SWIG_AsVal_unsigned_SS_char(swig_obj[7], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "NIRScanner_syncDeviceDateTime" "', argument " "8"" of type '" "uint8_t""'"); + } + arg8 = static_cast< uint8_t >(val8); + (arg1)->syncDeviceDateTime(arg2,arg3,arg4,arg5,arg6,arg7,arg8); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; NIRScanner *arg1 = (NIRScanner *) 0 ; bool arg2 ; @@ -3813,17 +3650,15 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR__SWIG_0(PyObject *SWIGUNUSEDPARM(s int res1 = 0 ; bool val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; std::string result; - if (!PyArg_ParseTuple(args,(char *)"OO:NIRScanner_scanSNR",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_scanSNR" "', argument " "1"" of type '" "NIRScanner *""'"); } arg1 = reinterpret_cast< NIRScanner * >(argp1); - ecode2 = SWIG_AsVal_bool(obj1, &val2); + ecode2 = SWIG_AsVal_bool(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NIRScanner_scanSNR" "', argument " "2"" of type '" "bool""'"); } @@ -3836,16 +3671,15 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR__SWIG_0(PyObject *SWIGUNUSEDPARM(s } -SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; NIRScanner *arg1 = (NIRScanner *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; std::string result; - if (!PyArg_ParseTuple(args,(char *)"O:NIRScanner_scanSNR",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_scanSNR" "', argument " "1"" of type '" "NIRScanner *""'"); } @@ -3863,20 +3697,16 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR(PyObject *self, PyObject *args) { PyObject *argv[3] = { 0 }; - Py_ssize_t ii; - if (!PyTuple_Check(args)) SWIG_fail; - argc = args ? PyObject_Length(args) : 0; - for (ii = 0; (ii < 2) && (ii < argc); ii++) { - argv[ii] = PyTuple_GET_ITEM(args,ii); - } + if (!(argc = SWIG_Python_UnpackTuple(args, "NIRScanner_scanSNR", 0, 2, argv))) SWIG_fail; + --argc; if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_NIRScanner, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_NIRScanner_scanSNR__SWIG_1(self, args); + return _wrap_NIRScanner_scanSNR__SWIG_1(self, argc, argv); } } if (argc == 2) { @@ -3890,13 +3720,13 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); } if (_v) { - return _wrap_NIRScanner_scanSNR__SWIG_0(self, args); + return _wrap_NIRScanner_scanSNR__SWIG_0(self, argc, argv); } } } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'NIRScanner_scanSNR'.\n" + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'NIRScanner_scanSNR'.\n" " Possible C/C++ prototypes are:\n" " NIRScanner::scanSNR(bool)\n" " NIRScanner::scanSNR()\n"); @@ -3904,7 +3734,7 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scanSNR(PyObject *self, PyObject *args) { } -SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; NIRScanner *arg1 = (NIRScanner *) 0 ; bool arg2 ; @@ -3915,22 +3745,19 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_0(PyObject *SWIGUNUSEDPARM(self int ecode2 = 0 ; int val3 ; int ecode3 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - PyObject * obj2 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OOO:NIRScanner_scan",&obj0,&obj1,&obj2)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_scan" "', argument " "1"" of type '" "NIRScanner *""'"); } arg1 = reinterpret_cast< NIRScanner * >(argp1); - ecode2 = SWIG_AsVal_bool(obj1, &val2); + ecode2 = SWIG_AsVal_bool(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NIRScanner_scan" "', argument " "2"" of type '" "bool""'"); } arg2 = static_cast< bool >(val2); - ecode3 = SWIG_AsVal_int(obj2, &val3); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "NIRScanner_scan" "', argument " "3"" of type '" "int""'"); } @@ -3943,7 +3770,7 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_0(PyObject *SWIGUNUSEDPARM(self } -SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; NIRScanner *arg1 = (NIRScanner *) 0 ; bool arg2 ; @@ -3951,16 +3778,14 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_1(PyObject *SWIGUNUSEDPARM(self int res1 = 0 ; bool val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"OO:NIRScanner_scan",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_scan" "', argument " "1"" of type '" "NIRScanner *""'"); } arg1 = reinterpret_cast< NIRScanner * >(argp1); - ecode2 = SWIG_AsVal_bool(obj1, &val2); + ecode2 = SWIG_AsVal_bool(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NIRScanner_scan" "', argument " "2"" of type '" "bool""'"); } @@ -3973,15 +3798,14 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_1(PyObject *SWIGUNUSEDPARM(self } -SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_NIRScanner_scan__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; NIRScanner *arg1 = (NIRScanner *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; - if (!PyArg_ParseTuple(args,(char *)"O:NIRScanner_scan",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if ((nobjs < 1) || (nobjs > 1)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_scan" "', argument " "1"" of type '" "NIRScanner *""'"); } @@ -3999,20 +3823,16 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scan(PyObject *self, PyObject *args) { PyObject *argv[4] = { 0 }; - Py_ssize_t ii; - if (!PyTuple_Check(args)) SWIG_fail; - argc = args ? PyObject_Length(args) : 0; - for (ii = 0; (ii < 3) && (ii < argc); ii++) { - argv[ii] = PyTuple_GET_ITEM(args,ii); - } + if (!(argc = SWIG_Python_UnpackTuple(args, "NIRScanner_scan", 0, 3, argv))) SWIG_fail; + --argc; if (argc == 1) { int _v; void *vptr = 0; int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_NIRScanner, 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_NIRScanner_scan__SWIG_2(self, args); + return _wrap_NIRScanner_scan__SWIG_2(self, argc, argv); } } if (argc == 2) { @@ -4026,7 +3846,7 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scan(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); } if (_v) { - return _wrap_NIRScanner_scan__SWIG_1(self, args); + return _wrap_NIRScanner_scan__SWIG_1(self, argc, argv); } } } @@ -4046,14 +3866,14 @@ SWIGINTERN PyObject *_wrap_NIRScanner_scan(PyObject *self, PyObject *args) { _v = SWIG_CheckState(res); } if (_v) { - return _wrap_NIRScanner_scan__SWIG_0(self, args); + return _wrap_NIRScanner_scan__SWIG_0(self, argc, argv); } } } } fail: - SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'NIRScanner_scan'.\n" + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'NIRScanner_scan'.\n" " Possible C/C++ prototypes are:\n" " NIRScanner::scan(bool,int)\n" " NIRScanner::scan(bool)\n" @@ -4067,11 +3887,12 @@ SWIGINTERN PyObject *_wrap_NIRScanner_getScanData(PyObject *SWIGUNUSEDPARM(self) NIRScanner *arg1 = (NIRScanner *) 0 ; void *argp1 = 0 ; int res1 = 0 ; - PyObject * obj0 = 0 ; + PyObject *swig_obj[1] ; std::string result; - if (!PyArg_ParseTuple(args,(char *)"O:NIRScanner_getScanData",&obj0)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_getScanData" "', argument " "1"" of type '" "NIRScanner *""'"); } @@ -4092,17 +3913,16 @@ SWIGINTERN PyObject *_wrap_NIRScanner_setHibernate(PyObject *SWIGUNUSEDPARM(self int res1 = 0 ; bool val2 ; int ecode2 = 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; + PyObject *swig_obj[2] ; int result; - if (!PyArg_ParseTuple(args,(char *)"OO:NIRScanner_setHibernate",&obj0,&obj1)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); + if (!SWIG_Python_UnpackTuple(args, "NIRScanner_setHibernate", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_NIRScanner, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "NIRScanner_setHibernate" "', argument " "1"" of type '" "NIRScanner *""'"); } arg1 = reinterpret_cast< NIRScanner * >(argp1); - ecode2 = SWIG_AsVal_bool(obj1, &val2); + ecode2 = SWIG_AsVal_bool(swig_obj[1], &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "NIRScanner_setHibernate" "', argument " "2"" of type '" "bool""'"); } @@ -4117,26 +3937,36 @@ SWIGINTERN PyObject *_wrap_NIRScanner_setHibernate(PyObject *SWIGUNUSEDPARM(self SWIGINTERN PyObject *NIRScanner_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; - if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; + if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_NIRScanner, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } +SWIGINTERN PyObject *NIRScanner_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + static PyMethodDef SwigMethods[] = { - { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, - { (char *)"new_NIRScanner", _wrap_new_NIRScanner, METH_VARARGS, NULL}, - { (char *)"delete_NIRScanner", _wrap_delete_NIRScanner, METH_VARARGS, NULL}, - { (char *)"NIRScanner_readVersion", _wrap_NIRScanner_readVersion, METH_VARARGS, NULL}, - { (char *)"NIRScanner_resetErrorStatus", _wrap_NIRScanner_resetErrorStatus, METH_VARARGS, NULL}, - { (char *)"NIRScanner_setLampOnOff", _wrap_NIRScanner_setLampOnOff, METH_VARARGS, NULL}, - { (char *)"NIRScanner_setConfig", _wrap_NIRScanner_setConfig, METH_VARARGS, NULL}, - { (char *)"NIRScanner_configEVM", _wrap_NIRScanner_configEVM, METH_VARARGS, NULL}, - { (char *)"NIRScanner_setPGAGain", _wrap_NIRScanner_setPGAGain, METH_VARARGS, NULL}, - { (char *)"NIRScanner_scanSNR", _wrap_NIRScanner_scanSNR, METH_VARARGS, NULL}, - { (char *)"NIRScanner_scan", _wrap_NIRScanner_scan, METH_VARARGS, NULL}, - { (char *)"NIRScanner_getScanData", _wrap_NIRScanner_getScanData, METH_VARARGS, NULL}, - { (char *)"NIRScanner_setHibernate", _wrap_NIRScanner_setHibernate, METH_VARARGS, NULL}, - { (char *)"NIRScanner_swigregister", NIRScanner_swigregister, METH_VARARGS, NULL}, + { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL}, + { "new_NIRScanner", _wrap_new_NIRScanner, METH_VARARGS, NULL}, + { "delete_NIRScanner", _wrap_delete_NIRScanner, METH_O, NULL}, + { "NIRScanner_readVersion", _wrap_NIRScanner_readVersion, METH_O, NULL}, + { "NIRScanner_resetErrorStatus", _wrap_NIRScanner_resetErrorStatus, METH_O, NULL}, + { "NIRScanner_setLampOnOff", _wrap_NIRScanner_setLampOnOff, METH_VARARGS, NULL}, + { "NIRScanner_setConfig", _wrap_NIRScanner_setConfig, METH_VARARGS, NULL}, + { "NIRScanner_configEVM", _wrap_NIRScanner_configEVM, METH_VARARGS, NULL}, + { "NIRScanner_setPGAGain", _wrap_NIRScanner_setPGAGain, METH_VARARGS, NULL}, + { "NIRScanner_syncDeviceDateTime", _wrap_NIRScanner_syncDeviceDateTime, METH_VARARGS, NULL}, + { "NIRScanner_scanSNR", _wrap_NIRScanner_scanSNR, METH_VARARGS, NULL}, + { "NIRScanner_scan", _wrap_NIRScanner_scan, METH_VARARGS, NULL}, + { "NIRScanner_getScanData", _wrap_NIRScanner_getScanData, METH_O, NULL}, + { "NIRScanner_setHibernate", _wrap_NIRScanner_setHibernate, METH_VARARGS, NULL}, + { "NIRScanner_swigregister", NIRScanner_swigregister, METH_O, NULL}, + { "NIRScanner_swiginit", NIRScanner_swiginit, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + +static PyMethodDef SwigMethods_proxydocs[] = { { NULL, NULL, 0, NULL } }; @@ -4304,7 +4134,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -4312,7 +4142,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -4387,7 +4217,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; @@ -4509,17 +4339,6 @@ extern "C" { return str; } - SWIGINTERN int - swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - char *tmp; - PyObject *str = swig_varlink_str(v); - fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(str); - return 0; - } - SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; @@ -4578,11 +4397,11 @@ extern "C" { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"swigvarlink", /* tp_name */ + "swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ - (printfunc) swig_varlink_print, /* tp_print */ + 0, /* tp_print */ (getattrfunc) swig_varlink_getattr, /* tp_getattr */ (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 0, /* tp_compare */ @@ -4602,15 +4421,9 @@ extern "C" { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ -#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -4618,20 +4431,14 @@ extern "C" { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ -#endif 0 /* tp_next */ #endif }; varlink_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - varlink_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&varlink_type) < 0) return NULL; -#endif } return &varlink_type; } @@ -4647,14 +4454,14 @@ extern "C" { } SWIGINTERN void - SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { - strncpy(gv->name,name,size); + memcpy(gv->name, name, size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; @@ -4665,9 +4472,11 @@ extern "C" { SWIGINTERN PyObject * SWIG_globals(void) { - static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); - return _SWIG_globals; + static PyObject *globals = 0; + if (!globals) { + globals = SWIG_newvarlink(); + } + return globals; } /* ----------------------------------------------------------------------------- @@ -4733,9 +4542,9 @@ extern "C" { char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; - strncpy(buff, methods[i].ml_doc, ldoc); + memcpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; - strncpy(buff, "swig_ptr: ", 10); + memcpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; @@ -4746,6 +4555,64 @@ extern "C" { } } + /* ----------------------------------------------------------------------------- + * Method creation and docstring support functions + * ----------------------------------------------------------------------------- */ + + /* ----------------------------------------------------------------------------- + * Function to find the method definition with the correct docstring for the + * proxy module as opposed to the low-level API + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { + /* Find the function in the modified method table */ + size_t offset = 0; + int found = 0; + while (SwigMethods_proxydocs[offset].ml_meth != NULL) { + if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { + found = 1; + break; + } + offset++; + } + /* Use the copy with the modified docstring if available */ + return found ? &SwigMethods_proxydocs[offset] : NULL; + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } +#if PY_VERSION_HEX >= 0x03000000 + return PyInstanceMethod_New(func); +#else + return PyMethod_New(func, NULL, NULL); +#endif + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyStaticMethod_New() + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } + return PyStaticMethod_New(func); + } + #ifdef __cplusplus } #endif @@ -4765,20 +4632,12 @@ PyObject* void #endif SWIG_init(void) { - PyObject *m, *d, *md; + PyObject *m, *d, *md, *globals; + #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { -# if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, -# else - { - PyObject_HEAD_INIT(NULL) - NULL, /* m_init */ - 0, /* m_index */ - NULL, /* m_copy */ - }, -# endif - (char *) SWIG_name, + SWIG_name, NULL, -1, SwigMethods, @@ -4797,8 +4656,8 @@ SWIG_init(void) { (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL }; static SwigPyGetSet thisown_getset_closure = { - (PyCFunction) SwigPyObject_own, - (PyCFunction) SwigPyObject_own + SwigPyObject_own, + SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure @@ -4829,13 +4688,23 @@ SWIG_init(void) { assert(metatype); #endif + (void)globals; + + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); +#ifndef SWIGPYTHON_BUILTIN + SwigPyObject_type(); +#endif + /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); #if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else - m = Py_InitModule((char *) SWIG_name, SwigMethods); + m = Py_InitModule(SWIG_name, SwigMethods); #endif md = d = PyModule_GetDict(m); diff --git a/src/build/_NIRScanner.so.3.8 b/src/build/_NIRScanner.so.3.8 new file mode 100755 index 0000000..eb07d02 Binary files /dev/null and b/src/build/_NIRScanner.so.3.8 differ diff --git a/src/scripts/compile_py3.8.sh b/src/scripts/compile_py3.8.sh new file mode 100755 index 0000000..c9100fb --- /dev/null +++ b/src/scripts/compile_py3.8.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Get script directory. +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +echo $DIR + +if swig_loc="$(type -p "swig")" || [[ -z $swig_loc ]]; +then + swig -c++ -python $DIR/../NIRScanner.i +else + echo "Did not detect swig, using generated Python Interface." +fi + +# Find Python version & set library path. +PYTHON3_VERSION=$(/usr/bin/python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') + +# Compile. +gcc -fpic -c $DIR/../*.c +g++ -fpic -c $DIR/../*.cpp +g++ -fpic -c $DIR/../*.cxx -I/usr/include/python${PYTHON3_VERSION} +mv ./*.o $DIR/../build +# g++ -o ../build/main ../build/*.o -ludev +g++ -shared $DIR/../build/*.o -ludev -o $DIR/../build/_NIRScanner.so.3.8 +cp $DIR/../build/_NIRScanner.so.3.8 $DIR/../../lib/ +cp $DIR/../../lib/_NIRScanner.so.3.8 $DIR/../../_NIRScanner.so + +# Clean .o files. +rm $DIR/../build/*.o diff --git a/testplot.py b/testplot.py new file mode 100644 index 0000000..758a936 --- /dev/null +++ b/testplot.py @@ -0,0 +1,64 @@ +# NIRScanner Nano Python wrapper. +# Created by Jintao Yang on 2020/11/23 +#!/usr/bin/python3.8 + +import os +import sys +import math +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd +from NIRS import NIRS +from time import sleep +import time + +def main(): + nirs = NIRS() + nirs.display_version() + + # Set config. + localtime = time.localtime(time.time()) + nirs.sync_device_date_time(localtime.tm_year, localtime.tm_mon, localtime.tm_mday, localtime.tm_wday, localtime.tm_hour, localtime.tm_min, localtime.tm_sec); + nirs.set_config(8, NIRS.TYPES.COLUMN_TYPE, 220, 10, 900, 1700, 15, 1, "my_cfg8") + nirs.set_hibernate(False) + nirs.clear_error_status() + nirs.set_lamp_on_off(0) + nirs.set_lamp_on_off(1) + nirs.set_pga_gain(0) + print("Scanning...") + sleep(1) + nirs.scan(6) + sleep(1) + nirs.set_lamp_on_off(-1) + results = nirs.get_scan_results() + print(results) + df = pd.DataFrame(results) + #print(df) + df.to_csv("./"+results["scan_time"]+".csv") + + my_reference = [1033, 1184, 1308, 1443, 1621, 1886, 2131, 2403, 2684, 3046, 3319, 3564, 3823, 4147, 4411, 4679, 4917, 5272, 5504, 5717, 5924, 6153, 6302, 6398, 6493, 6596, 6654, 6691, 6729, 6758, 6764, 6787, 6782, 6789, 6776, 6749, 6727, 6697, 6685, 6652, 6640, 6606, 6574, 6536, 6504, 6455, 6415, 6371, 6314, 6253, 6224, 6171, 6098, 6041, 5985, 5945, 5862, 5815, 5769, 5716, 5672, 5638, 5605, 5577, 5557, 5553, 5536, 5541, 5545, 5534, 5560, 5569, 5614, 5658, 5694, 5735, 5784, 5850, 5904, 5973, 6017, 6094, 6143, 6197, 6276, 6361, 6426, 6506, 6561, 6629, 6685, 6715, 6761, 6781, 6804, 6830, 6832, 6834, 6836, 6819, 6827, 6800, 6785, 6764, 6751, 6716, 6685, 6658, 6637, 6595, 6550, 6510, 6471, 6407, 6369, 6319, 6271, 6181, 6116, 6024, 5898, 5664, 5460, 5263, 5193, 5156, 5208, 5253, 5304, 5367, 5400, 5429, 5435, 5447, 5417, 5416, 5395, 5359, 5344, 5311, 5287, 5281, 5219, 5208, 5143, 5119, 5063, 5009, 4961, 4903, 4863, 4802, 4758, 4687, 4633, 4578, 4534, 4459, 4386, 4322, 4048, 4188, 4130, 4070, 3995, 3925, 3846, 3779, 3715, 3626, 3560, 3493, 3421, 3332, 3265, 3195, 3130, 3040, 2970, 2909, 2859, 2776, 2699, 2632, 2578, 2498, 2433, 2376, 2310, 2238, 2163, 2115, 2039, 1968, 1898, 1843, 1798, 1723, 1668, 1597, 1566, 1489, 1429, 1381, 1306, 1225, 1141, 1060, 976, 838, 739, 621, 540, 426, 357, 296, 262, 219, 186, 150] + #my_reference = results["reference"] + reformat_intensity = [] + reformat_reference = [] + reformat_wavelength = [] + for i in range(results["valid_length"]): + if my_reference[i] != 0 and results["intensity"][i] != 0: + reformat_intensity.append(results["intensity"][i]) + reformat_reference.append(my_reference[i]) + reformat_wavelength.append(results["wavelength"][i]) + + reflectance = np.array(reformat_intensity) / np.array(reformat_reference) + absorption = -1 * np.log10(reflectance) + + #plt.plot(reformat_wavelength, reformat_intensity, '-r', label='intensity') + #plt.plot(reformat_wavelength, reflectance, '-g', label='reflectance') + plt.plot(reformat_wavelength, absorption, '-b', label='absorption') + + plt.xlabel("wavelength") + plt.ylabel("intensity-ratio") + plt.title("NIR Scan Spectrum") + plt.legend(loc='upper right', fontsize=7) # label position + plt.show() + +if __name__ == "__main__": + main()