Commit 32ccd8a8 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Minor tweaks to the CAPI support

parent c2877853
// Copyright (c) 2014 Dropbox, Inc. // Copyright (c) 2014 Dropbox, Inc.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...@@ -22,10 +22,11 @@ ...@@ -22,10 +22,11 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
//struct PyObject { #include "object.h"
//};
//typedef struct PyObject PyObject; #ifdef __cplusplus
typedef void PyObject; extern "C" {
#endif
bool PyArg_ParseTuple(PyObject*, const char*, ...); bool PyArg_ParseTuple(PyObject*, const char*, ...);
PyObject* Py_BuildValue(const char*, ...); PyObject* Py_BuildValue(const char*, ...);
...@@ -76,4 +77,7 @@ PyObject* Py_InitModule4(const char *arg0, PyMethodDef *arg1, const char *arg2, ...@@ -76,4 +77,7 @@ PyObject* Py_InitModule4(const char *arg0, PyMethodDef *arg1, const char *arg2,
Py_InitModule4(name, methods, doc, (PyObject *)NULL, \ Py_InitModule4(name, methods, doc, (PyObject *)NULL, \
PYTHON_API_VERSION) PYTHON_API_VERSION)
#ifdef __cplusplus
}
#endif
#endif #endif
// Copyright (c) 2014 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Portions of this file are based on CPython's Include/object.h file
#ifndef PYSTON_EXTINCLUDE_OBJECT_H
#define PYSTON_EXTINCLUDE_OBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void PyObject;
#ifdef __cplusplus
}
#endif
#endif
...@@ -871,6 +871,6 @@ ext: ../test/test_extension/test.so ...@@ -871,6 +871,6 @@ ext: ../test/test_extension/test.so
../test/test_extension/test.o: ../test/test_extension/test.c $(wildcard ../include/*.h) $(BUILD_SYSTEM_DEPS) ../test/test_extension/test.o: ../test/test_extension/test.c $(wildcard ../include/*.h) $(BUILD_SYSTEM_DEPS)
$(CLANG_EXE) -O2 -fPIC -Wimplicit -I../include -c $< -o $@ -g $(CLANG_EXE) -O2 -fPIC -Wimplicit -I../include -c $< -o $@ -g
../lib_python/2.7_Modules/%.o: ../lib_python/2.7_Modules/%.c $(wildcard ../include/*.h) $(BUILD_SYSTEM_DEPS) ../lib_python/2.7_Modules/%.o: ../lib_python/2.7_Modules/%.c $(BUILD_SYSTEM_DEPS)
$(ECHO) Compiling extension file $@ $(ECHO) Compiling extension file $@
$(VERB) $(CLANG_EXE) $(EXT_CFLAGS) -c $< -o $@ -g -ferror-limit=$(ERROR_LIMIT) -MMD -MP -MF $<.d $(VERB) $(CLANG_EXE) $(EXT_CFLAGS) -c $< -o $@ -g -ferror-limit=$(ERROR_LIMIT) -MMD -MP -MF $<.d
...@@ -120,7 +120,8 @@ public: ...@@ -120,7 +120,8 @@ public:
} }
}; };
extern "C" void* Py_InitModule4(const char* name, PyMethodDef* methods, const char* doc, PyObject* self, int apiver) { extern "C" PyObject* Py_InitModule4(const char* name, PyMethodDef* methods, const char* doc, PyObject* self,
int apiver) {
BoxedModule* module = createModule(name, "__builtin__"); BoxedModule* module = createModule(name, "__builtin__");
Box* passthrough = static_cast<Box*>(self); Box* passthrough = static_cast<Box*>(self);
...@@ -144,12 +145,12 @@ extern "C" void* Py_InitModule4(const char* name, PyMethodDef* methods, const ch ...@@ -144,12 +145,12 @@ extern "C" void* Py_InitModule4(const char* name, PyMethodDef* methods, const ch
return module; return module;
} }
extern "C" void* Py_BuildValue(const char* arg0) { extern "C" PyObject* Py_BuildValue(const char* arg0, ...) {
assert(*arg0 == '\0'); assert(*arg0 == '\0');
return None; return None;
} }
extern "C" bool PyArg_ParseTuple(void* tuple, const char* fmt, ...) { extern "C" bool PyArg_ParseTuple(PyObject* tuple, const char* fmt, ...) {
if (strcmp("", fmt) == 0) if (strcmp("", fmt) == 0)
return true; return true;
......
...@@ -81,7 +81,7 @@ def verify_include_order(_, dir, files): ...@@ -81,7 +81,7 @@ def verify_include_order(_, dir, files):
for incl in section: for incl in section:
if incl.startswith('#include "llvm/'): if incl.startswith('#include "llvm/'):
continue continue
if '"opagent.h"' in incl or '"Python.h"' in incl: if '"opagent.h"' in incl or '"Python.h"' in incl or '"object.h"' in incl:
continue continue
return False return False
return True return True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment