Changeset: fa8269d15912 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fa8269d15912
Added Files:
sql/backends/monet5/UDF/pyapi/pyheader.h
Modified Files:
sql/backends/monet5/UDF/pyapi/Makefile.ag
Branch: default
Log Message:
Add missing header.
diffs (119 lines):
diff --git a/sql/backends/monet5/UDF/pyapi/Makefile.ag
b/sql/backends/monet5/UDF/pyapi/Makefile.ag
--- a/sql/backends/monet5/UDF/pyapi/Makefile.ag
+++ b/sql/backends/monet5/UDF/pyapi/Makefile.ag
@@ -24,7 +24,7 @@ MTSAFE
lib__pyapi = {
MODULE
DIR = libdir/monetdb5
- SOURCES = pyapi.c pyapi.h unicode.c unicode.h pytypes.c pytypes.h
type_conversion.c type_conversion.h formatinput.c formatinput.h connection.c
connection.h undef.h pyloader.c emit.h emit.c conversion.c conversion.h
convert_loops.h
+ SOURCES = pyapi.c pyapi.h unicode.c unicode.h pytypes.c pytypes.h
type_conversion.c type_conversion.h formatinput.c formatinput.h connection.c
connection.h undef.h pyloader.c emit.h emit.c conversion.c conversion.h
convert_loops.h pyheader.h
XDEPS = $(libpy_LIBDEP)
LIBS = ../../../../../monetdb5/tools/libmonetdb5 \
../../../../../gdk/libbat \
diff --git a/sql/backends/monet5/UDF/pyapi/pyheader.h
b/sql/backends/monet5/UDF/pyapi/pyheader.h
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/UDF/pyapi/pyheader.h
@@ -0,0 +1,102 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 2008-2015 MonetDB B.V.
+ */
+
+/*
+ * M. Raasveldt
+ * This file simply includes standard MonetDB and Python headers
+ * Because this needs to be done in a specific order, and this needs to happen
in multiple places
+ * We simplify our lives by only having to include this header.
+ */
+
+#ifndef _PYHEADER_H_
+#define _PYHEADER_H_
+
+#include "monetdb_config.h"
+#include "mal.h"
+#include "mal_stack.h"
+#include "mal_linker.h"
+#include "gdk_atoms.h"
+#include "gdk_utils.h"
+#include "gdk_posix.h"
+#include "gdk.h"
+#include "sql_catalog.h"
+#include "sql_scenario.h"
+#include "sql_cast.h"
+#include "sql_execute.h"
+#include "sql_storage.h"
+
+#include "undef.h"
+
+// Python library
+#undef _GNU_SOURCE
+#undef _XOPEN_SOURCE
+#undef _POSIX_C_SOURCE
+#ifdef _DEBUG
+ #undef _DEBUG
+ #include <Python.h>
+ #define _DEBUG
+#else
+ #include <Python.h>
+#endif
+
+// Numpy Library
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#ifdef __INTEL_COMPILER
+// Intel compiler complains about trailing comma's in numpy source code,
+#pragma warning(disable:271)
+#endif
+#include <numpy/arrayobject.h>
+#include <numpy/npy_common.h>
+
+// DLL Export Flags
+#ifdef WIN32
+#ifndef LIBPYAPI
+#define pyapi_export extern __declspec(dllimport)
+#else
+#define pyapi_export extern __declspec(dllexport)
+#endif
+#else
+#define pyapi_export extern
+#endif
+
+// Fixes for Python 2 <> Python 3
+#if PY_MAJOR_VERSION >= 3
+#define IS_PY3K
+#define PyString_FromString PyUnicode_FromString
+#define PyString_Check PyUnicode_Check
+#define PyString_CheckExact PyUnicode_CheckExact
+#define PyString_AsString PyUnicode_AsUTF8
+#define PyString_AS_STRING PyUnicode_AsUTF8
+#define PyInt_FromLong PyLong_FromLong
+#define PyInt_Check PyLong_Check
+#define PythonUnicodeType char
+#else
+#define PythonUnicodeType Py_UNICODE
+#endif
+
+#if defined(WIN32) && !defined(HAVE_EMBEDDED)
+// On Windows we need to dynamically load any SQL functions we use
+// For embedded, this is not necessary because we create one large shared
object
+#define CREATE_SQL_FUNCTION_PTR(retval, fcnname) \
+ typedef retval (*fcnname##_ptr_tpe)(); \
+ fcnname##_ptr_tpe fcnname##_ptr = NULL;
+
+#define LOAD_SQL_FUNCTION_PTR(fcnname)
\
+ fcnname##_ptr = (fcnname##_ptr_tpe) getAddress(NULL, "lib_sql.dll",
#fcnname, 0); \
+ if (fcnname##_ptr == NULL) {
\
+ msg = createException(MAL, "pyapi.eval", "Failed to load function %s",
#fcnname); \
+ }
+#else
+#define CREATE_SQL_FUNCTION_PTR(retval, fcnname) \
+ typedef retval (*fcnname##_ptr_tpe)(); \
+ fcnname##_ptr_tpe fcnname##_ptr = (fcnname##_ptr_tpe)fcnname;
+
+#define LOAD_SQL_FUNCTION_PTR(fcnname) (void) fcnname
+#endif
+
+#endif /* _PYHEADER_H_ */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list