Merge branch 'master' into 1611-enum-class

This commit is contained in:
Hong Chen 2023-11-16 11:10:33 -06:00
commit 52998e5002
2 changed files with 25 additions and 6 deletions

View File

@ -4,6 +4,7 @@
PURPOSE: ( Event Class )
*/
#include <string>
#include <iostream>
#include "trick/mm_macros.hh"
#include "trick/exec_proto.h"
@ -203,12 +204,16 @@ class Event {
#ifndef SWIG
struct CompareEventPtrs : public std::binary_function<Trick::Event *, Trick::Event *, bool> {
bool operator()(const Trick::Event * lhs, const Trick::Event * rhs) const {
return lhs->get_next_tics() < rhs->get_next_tics();
}
};
// No need to inherit from binary_function for c++11 or later
#if __cplusplus >= 201103L
struct CompareEventPtrs {
#else
struct CompareEventPtrs : public std::binary_function<Trick::Event *, Trick::Event *, bool> {
#endif
bool operator()(const Trick::Event * lhs, const Trick::Event * rhs) const {
return lhs->get_next_tics() < rhs->get_next_tics();
}
};
#endif
}

View File

@ -64,9 +64,15 @@ template<typename T > static int typemap_in_scalar( T & output , PyObject *input
output = (T)PyFloat_AsDouble(input) ;
} else if ( PyInt_Check(input) ) {
output = (T)PyInt_AsLong(input) ;
// PyUnicode_GET_SIZE: deprecated since Python 3.3 and removed in Python 3.12
// PyUnicode_GET_LENGTH: new in Python 3.3
#if PY_VERSION_HEX >= 0x03000000
} else if ( PyUnicode_Check(input) ) {
#if defined(PyUnicode_GET_LENGTH)
if ( PyUnicode_GET_LENGTH(input) == 1 ) {
#else
if ( PyUnicode_GET_SIZE(input) == 1 ) {
#endif
PyObject * temp = PyUnicode_AsEncodedString(input, "utf-8", "Error ~");
char * temp_str = PyBytes_AS_STRING(temp) ;
output = (T)temp_str[0] ;
@ -142,7 +148,11 @@ template<typename T > static T * typemap_in_1d( PyObject *input , unsigned int o
}
#if PY_VERSION_HEX >= 0x03000000
} else if ( PyUnicode_Check(input) ) {
#if defined(PyUnicode_GET_LENGTH)
unsigned int size = PyUnicode_GET_LENGTH(input) ;
#else
unsigned int size = PyUnicode_GET_SIZE(input) ;
#endif
PyObject * temp = PyUnicode_AsEncodedString(input, "utf-8", "Error ~");
char * temp_str = PyBytes_AS_STRING(temp) ;
#else
@ -330,7 +340,11 @@ template<typename T, typename baseT > static void * typemap_in_2d( PyObject *inp
}
#if PY_VERSION_HEX >= 0x03000000
} else if ( PyUnicode_Check(o) ) {
#if defined(PyUnicode_GET_LENGTH)
unsigned int size = PyUnicode_GET_LENGTH(o) ;
#else
unsigned int size = PyUnicode_GET_SIZE(o) ;
#endif
PyObject * temp = PyUnicode_AsEncodedString(o, "utf-8", "Error ~");
char * temp_str = PyBytes_AS_STRING(temp) ;
#else