Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Interface SWIGLALAlpha.i

SWIG code which must appear before the LAL headers.

Author
Karl Wette

Standard output/error redirection

The swig_redirect_standard_output_error() function turns on/off standard output/error redirection for all LAL libraries. It returns whether redirection was previously turned on/off. The swig_lal_do_redirect_stdouterr variable is defined in SWIGSharedVars.c. See SWIGCommon.i for further information.

%inline %{
BOOLEAN swig_redirect_standard_output_error(BOOLEAN redirect) {
BOOLEAN old_swig_lal_do_redirect_stdouterr = swig_lal_do_redirect_stdouterr;
swig_lal_do_redirect_stdouterr = redirect ? 1 : 0;
return old_swig_lal_do_redirect_stdouterr;
}
%}
unsigned char BOOLEAN
Boolean logical type, see Headers LAL(Atomic)Datatypes.h for more details.
int swig_lal_do_redirect_stdouterr
The swig_lal_do_redirect_stdouterr variable turns on standard output/error redirection for all LAL li...

Error handling

Custom LAL/GSL error handlers which raise XLAL errors, so that they will be caught by the SWIG %exception handler (instead of aborting, which will crash the user's scripting language session).

%header %{
%}

Use nice custom error handlers by default.

%header %{
static int swig_set_error_handler_messages = 0;
%}
%init %{
swig_set_nice_error_handlers();
swig_set_error_handler_messages = 1;
%}

Set nice custom error handlers: replace default XLAL/LAL/GSL error handler with nice custom handlers, and ensure default XLAL error handler is used.

%inline %{
void swig_set_nice_error_handlers(void) {
if (swig_set_error_handler_messages) {
fprintf(stderr, "*** WARNING: XLAL/LAL/GSL functions will now raise XLAL errors ***\n");
}
gsl_set_error_handler(swig_lal_gsl_error_handler);
lalRaiseHook = swig_lal_raise_hook;
lalAbortHook = swig_lal_abort_hook;
}
%}
int(* lalRaiseHook)(int, const char *,...)
Definition: LALError.c:57
void(* lalAbortHook)(const char *,...)
Definition: LALError.c:75
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
Sets the error handler to a new handler and returns the old handler.
Definition: XLALError.c:372
void XLALDefaultErrorHandler(const char *func, const char *file, int line, int errnum)
The default XLAL error handler.
Definition: XLALError.c:561

Set nasty custom error handlers: use abort() error handlers in XLAL/LAL/GSL, which can be useful when running scripting language interpreter under a debugger.

%inline %{
void swig_set_nasty_error_handlers(void) {
if (swig_set_error_handler_messages) {
fprintf(stderr, "*** WARNING: XLAL/LAL/GSL functions will now abort() on error ***\n");
}
gsl_set_error_handler(NULL);
}
%}
int LALRaise(int sig, const char *fmt,...)
Definition: LALError.c:58
void LALAbort(const char *fmt,...)
Definition: LALError.c:76
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
The XLAL error handler that raises SIGABRT.
Definition: XLALError.c:599

GSL vectors and matrices

This macro create wrapping structs for GSL vectors and matrices.

%define %swig_lal_gsl_vector_matrix(BASETYPE, TYPE, NAME)
#define TYPE
#define BASETYPE
%enddef

GSL integer vectors and matrices.

%swig_lal_gsl_vector_matrix(short, short, _short);
%swig_lal_gsl_vector_matrix(unsigned short, unsigned short, _ushort);
%swig_lal_gsl_vector_matrix(int, int, _int);
%swig_lal_gsl_vector_matrix(unsigned int, unsigned int, _uint);
%swig_lal_gsl_vector_matrix(long, long, _long);
%swig_lal_gsl_vector_matrix(unsigned long, unsigned long, _ulong);

GSL real and complex vectors and matrices.

%swig_lal_gsl_vector_matrix(float, float, _float);
%swig_lal_gsl_vector_matrix(double, double, ); // GSL double vector/matrix has no typename suffix.
%swig_lal_gsl_vector_matrix(float, gsl_complex_float, _complex_float);
%swig_lal_gsl_vector_matrix(double, gsl_complex, _complex);

Specialised typemaps for <tt>LIGOTimeGPS</tt>

Allow arbitrary attributes to be attached to the LIGOTimeGPS class in Python.

#if defined(SWIGPYTHON)
%pythondynamic tagLIGOTimeGPS;
#endif

Specialised input typemaps for LIGOTimeGPS structs. Accepts a SWIG-wrapped LIGOTimeGPS or a double as input; in Python, also accepts any object with .gpsSeconds and .gpsNanoSeconds attributes.

%fragment("swiglal_specialised_tagLIGOTimeGPS", "header", fragment=SWIG_AsVal_frag(double), fragment=SWIG_AsVal_frag(int32_t)) {
int swiglal_specialised_tagLIGOTimeGPS(SWIG_Object in, LIGOTimeGPS *out) {
double val = 0;
int res = SWIG_AsVal(double)(in, &val);
if (!SWIG_IsOK(res)) {
#ifdef SWIGPYTHON
if (PyObject_HasAttrString(in, "gpsSeconds") && PyObject_HasAttrString(in, "gpsNanoSeconds")) {
int32_t gpsSeconds = 0, gpsNanoSeconds = 0;
res = SWIG_AsVal(int32_t)(PyObject_GetAttrString(in, "gpsSeconds"), &gpsSeconds);
if (!SWIG_IsOK(res)) {
return res;
}
res = SWIG_AsVal(int32_t)(PyObject_GetAttrString(in, "gpsNanoSeconds"), &gpsNanoSeconds);
if (!SWIG_IsOK(res)) {
return res;
}
return SWIG_OK;
}
#endif
return res;
}
XLALGPSSetREAL8(out, val);
return SWIG_OK;
}
}
%swiglal_specialised_typemaps(tagLIGOTimeGPS, "swiglal_specialised_tagLIGOTimeGPS");
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
Sets GPS time given GPS seconds as a REAL8.
Definition: XLALTime.c:73
LIGOTimeGPS * XLALGPSSet(LIGOTimeGPS *epoch, INT4 gpssec, INT8 gpsnan)
Sets GPS time given GPS integer seconds and residual nanoseconds.
Definition: XLALTime.c:63
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
Definition: LALDatatypes.h:458

Specialised typemaps for <tt>LALUnit</tt>

Specialised input typemaps for LALUnit structs. Accepts a SWIG-wrapped LALUnit, a unit string, or a dimensionless power-of-10 double as input.

%fragment("swiglal_specialised_tagLALUnit", "header",
fragment="SWIG_AsCharPtr",
fragment=SWIG_AsVal_frag(double)
)
{
int swiglal_specialised_tagLALUnit(SWIG_Object in, LALUnit *out) {
char *str = 0;
int alloc = 0;
int res = SWIG_AsCharPtr(in, &str, &alloc);
if (SWIG_IsOK(res)) {
if (XLALParseUnitString(out, str) == NULL) {
res = SWIG_ValueError;
}
}
if (alloc == SWIG_NEWOBJ) {
%delete_array(str);
}
if (SWIG_IsOK(res)) {
return res;
}
double val = 0;
res = SWIG_AsVal(double)(in, &val);
if (!SWIG_IsOK(res)) {
return res;
}
if (val <= 0) {
return SWIG_ValueError;
}
double pow10 = 0;
if (modf(log10(val), &pow10) != 0) {
return SWIG_ValueError;
}
if (pow10 < INT16_MIN || INT16_MAX < pow10) {
return SWIG_ValueError;
}
out->powerOfTen = (INT2)pow10;
return SWIG_OK;
}
}
%swiglal_specialised_typemaps(tagLALUnit, "swiglal_specialised_tagLALUnit");
int16_t INT2
Two-byte signed integer.
LALUnit * XLALParseUnitString(LALUnit *output, const char *string)
Returns the pointer output upon return or a pointer to newly allocated memory if output was NULL; on ...
Definition: UnitDefs.c:354
const LALUnit lalDimensionlessUnit
dimensionless units
Definition: UnitDefs.c:156
This structure stores units in the mksA system (plus Kelvin, Strain, and ADC Count).
Definition: LALDatatypes.h:498
INT2 powerOfTen
Overall power-of-ten scaling is 10^powerOfTen.
Definition: LALDatatypes.h:499

Specialised typemaps for <tt>LALDict</tt>

Specialised input typemaps for LALDict. Accepts a SWIG-wrapped LALDict, or:

%fragment("swiglal_specialised_ptr_tagLALDict", "header",
fragment="SWIG_AsCharPtr",
fragment=SWIG_AsVal_frag(uint16_t),
fragment=SWIG_AsVal_frag(int16_t),
fragment=SWIG_AsVal_frag(uint32_t),
fragment=SWIG_AsVal_frag(int32_t),
fragment=SWIG_AsVal_frag(uint64_t),
fragment=SWIG_AsVal_frag(int64_t),
fragment=SWIG_AsVal_frag(float),
fragment=SWIG_AsVal_frag(double),
fragment=SWIG_AsVal_frag(COMPLEX8),
fragment=SWIG_AsVal_frag(COMPLEX16)
)
{
int swiglal_specialised_ptr_tagLALDict(SWIG_Object in, LALDict **out) {
int res = SWIG_ValueError;
char *keyname, *valuestr = 0;
int keyalloc, valuealloc = 0;
*out = XLALCreateDict();
if (*out == NULL) {
goto fail;
}
#ifdef SWIGPYTHON
if (!PyDict_Check(in)) {
return SWIG_ValueError;
}
PyObject *key, *value;
Py_ssize_t pos = 0;
while (PyDict_Next(in, &pos, &key, &value)) {
if (!SWIG_IsOK(SWIG_AsCharPtr(key, &keyname, &keyalloc))) {
break;
}
char *keytype = strrchr(keyname, ':');
if (keytype == NULL) {
keytype = keyname + strlen(keyname);
} else {
*keytype = 0;
++keytype;
}
do {
#define SWIGLAL_LALDICT_HANDLE_TYPE(LALTYPESTR, LALTYPE, CTYPE, FMT, ...) \
if (XLALStringCaseCompare(keytype, LALTYPESTR) == 0) { \
CTYPE v = 0; \
if (SWIG_IsOK(SWIG_AsVal(CTYPE)(value, &v))) { \
if (XLALDictInsert##LALTYPE##Value(*out, keyname, v) != XLAL_SUCCESS) { \
goto fail; \
} \
XLALPrintInfo("%s: dict=%p, key=%s, type=%s, value=" FMT "\n", __func__, in, keyname, keytype, __VA_ARGS__); \
break; \
} \
}
SWIGLAL_LALDICT_HANDLE_TYPE("UINT2", UINT2, uint16_t, "%" LAL_UINT2_FORMAT, v);
SWIGLAL_LALDICT_HANDLE_TYPE("INT2", INT2, int16_t, "%" LAL_INT2_FORMAT, v);
SWIGLAL_LALDICT_HANDLE_TYPE("UINT4", UINT4, uint32_t, "%" LAL_UINT4_FORMAT, v);
SWIGLAL_LALDICT_HANDLE_TYPE("INT4", INT4, int32_t, "%" LAL_INT4_FORMAT, v);
SWIGLAL_LALDICT_HANDLE_TYPE("UINT8", UINT8, uint64_t, "%" LAL_UINT8_FORMAT, v);
SWIGLAL_LALDICT_HANDLE_TYPE("INT8", INT8, int64_t, "%" LAL_INT8_FORMAT, v);
SWIGLAL_LALDICT_HANDLE_TYPE("REAL4", REAL4, float, "%" LAL_REAL4_FORMAT, v);
SWIGLAL_LALDICT_HANDLE_TYPE("REAL8", REAL8, double, "%" LAL_REAL8_FORMAT, v);
SWIGLAL_LALDICT_HANDLE_TYPE("COMPLEX8", COMPLEX8, COMPLEX8, "(%" LAL_REAL4_FORMAT ",%" LAL_REAL4_FORMAT ")", crealf(v), cimagf(v));
SWIGLAL_LALDICT_HANDLE_TYPE("COMPLEX16", COMPLEX16, COMPLEX16, "(%" LAL_REAL8_FORMAT ",%" LAL_REAL8_FORMAT ")", creal (v), cimag (v));
#undef SWIGLAL_LALDICT_GIVEN_TYPE
if (SWIG_IsOK(SWIG_AsCharPtr(value, &valuestr, &valuealloc))) {
if (XLALDictInsertStringValue(*out, keyname, valuestr) != XLAL_SUCCESS) {
goto fail;
}
XLALPrintInfo("%s: dict=%p, key=%s, type=string, value='%s'\n", __func__, in, keyname, valuestr);
if (valuealloc == SWIG_NEWOBJ) {
%delete_array(valuestr);
valuealloc = 0;
}
} else {
XLALPrintInfo("%s: dict=%p, key=%s, type=unknown\n", __func__, in, keyname);
goto fail;
}
} while(0);
if (keyalloc == SWIG_NEWOBJ) {
%delete_array(keyname);
keyalloc = 0;
}
}
res = SWIG_OK;
#endif
fail:
if (!SWIG_IsOK(res)) {
*out = NULL;
}
if (keyalloc == SWIG_NEWOBJ) {
%delete_array(keyname);
}
if (valuealloc == SWIG_NEWOBJ) {
%delete_array(valuestr);
}
return res;
}
void swiglal_specialised_ptr_tagLALDict_destroy(LALDict *tmp) {
}
}
%swiglal_specialised_ptr_typemaps(tagLALDict, "swiglal_specialised_ptr_tagLALDict");
void XLALDestroyDict(LALDict *dict)
Definition: LALDict.c:137
LALDict * XLALCreateDict(void)
Definition: LALDict.c:148
int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string)
Definition: LALDict.c:411
int XLALPrintInfo(const char *fmt,...)
Definition: XLALError.c:90
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
double complex COMPLEX16
Double-precision floating-point complex number (16 bytes total)
double REAL8
Double precision real floating-point number (8 bytes).
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
uint16_t UINT2
Two-byte unsigned integer.
uint32_t UINT4
Four-byte unsigned integer.
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
#define LAL_REAL8_FORMAT
Definition: LALStdio.h:133
#define LAL_INT2_FORMAT
Definition: LALStdio.h:126
#define LAL_INT8_FORMAT
Definition: LALStdio.h:128
#define LAL_INT4_FORMAT
Definition: LALStdio.h:127
#define LAL_REAL4_FORMAT
Definition: LALStdio.h:132
#define LAL_UINT8_FORMAT
Definition: LALStdio.h:131
#define LAL_UINT4_FORMAT
Definition: LALStdio.h:130
#define LAL_UINT2_FORMAT
Definition: LALStdio.h:129
@ XLAL_SUCCESS
Success return value (not an error number)
Definition: XLALError.h:401