├── README.md ├── bin ├── avmdbg.pyd └── demo.py ├── doc ├── AVMDBG说明.docx └── 安卓调试器原理与实现.docx ├── src ├── AdbHelper.cpp ├── AdbHelper.h ├── AvmDebugger.cpp ├── AvmDebugger.h ├── Jdwp.h ├── JdwpPacket.cpp ├── JdwpPacket.h ├── JdwpProtocol.h ├── JdwpRepObject.h ├── JdwpSerializer.h ├── JdwpSocket.h ├── JdwpValue.cpp ├── JdwpValue.h ├── Log.h ├── avmdbg.cpp ├── avmdbg.sln ├── avmdbg.vcxproj ├── dllmain.cpp ├── pybind11 │ ├── attr.h │ ├── cast.h │ ├── common.h │ ├── complex.h │ ├── descr.h │ ├── eigen.h │ ├── eval.h │ ├── functional.h │ ├── numpy.h │ ├── operators.h │ ├── pybind11.h │ ├── python27 │ │ ├── include │ │ │ ├── Python-ast.h │ │ │ ├── Python.h │ │ │ ├── abstract.h │ │ │ ├── asdl.h │ │ │ ├── ast.h │ │ │ ├── bitset.h │ │ │ ├── boolobject.h │ │ │ ├── bufferobject.h │ │ │ ├── bytearrayobject.h │ │ │ ├── bytes_methods.h │ │ │ ├── bytesobject.h │ │ │ ├── cStringIO.h │ │ │ ├── cellobject.h │ │ │ ├── ceval.h │ │ │ ├── classobject.h │ │ │ ├── cobject.h │ │ │ ├── code.h │ │ │ ├── codecs.h │ │ │ ├── compile.h │ │ │ ├── complexobject.h │ │ │ ├── datetime.h │ │ │ ├── descrobject.h │ │ │ ├── dictobject.h │ │ │ ├── dtoa.h │ │ │ ├── enumobject.h │ │ │ ├── errcode.h │ │ │ ├── eval.h │ │ │ ├── fileobject.h │ │ │ ├── floatobject.h │ │ │ ├── frameobject.h │ │ │ ├── funcobject.h │ │ │ ├── genobject.h │ │ │ ├── graminit.h │ │ │ ├── grammar.h │ │ │ ├── import.h │ │ │ ├── intobject.h │ │ │ ├── intrcheck.h │ │ │ ├── iterobject.h │ │ │ ├── listobject.h │ │ │ ├── longintrepr.h │ │ │ ├── longobject.h │ │ │ ├── marshal.h │ │ │ ├── memoryobject.h │ │ │ ├── metagrammar.h │ │ │ ├── methodobject.h │ │ │ ├── modsupport.h │ │ │ ├── moduleobject.h │ │ │ ├── node.h │ │ │ ├── object.h │ │ │ ├── objimpl.h │ │ │ ├── opcode.h │ │ │ ├── osdefs.h │ │ │ ├── parsetok.h │ │ │ ├── patchlevel.h │ │ │ ├── pgen.h │ │ │ ├── pgenheaders.h │ │ │ ├── py_curses.h │ │ │ ├── pyarena.h │ │ │ ├── pycapsule.h │ │ │ ├── pyconfig.h │ │ │ ├── pyctype.h │ │ │ ├── pydebug.h │ │ │ ├── pyerrors.h │ │ │ ├── pyexpat.h │ │ │ ├── pyfpe.h │ │ │ ├── pygetopt.h │ │ │ ├── pymacconfig.h │ │ │ ├── pymactoolbox.h │ │ │ ├── pymath.h │ │ │ ├── pymem.h │ │ │ ├── pyport.h │ │ │ ├── pystate.h │ │ │ ├── pystrcmp.h │ │ │ ├── pystrtod.h │ │ │ ├── pythonrun.h │ │ │ ├── pythread.h │ │ │ ├── rangeobject.h │ │ │ ├── setobject.h │ │ │ ├── sliceobject.h │ │ │ ├── stringobject.h │ │ │ ├── structmember.h │ │ │ ├── structseq.h │ │ │ ├── symtable.h │ │ │ ├── sysmodule.h │ │ │ ├── timefuncs.h │ │ │ ├── token.h │ │ │ ├── traceback.h │ │ │ ├── tupleobject.h │ │ │ ├── ucnhash.h │ │ │ ├── unicodeobject.h │ │ │ ├── warnings.h │ │ │ └── weakrefobject.h │ │ └── libs │ │ │ ├── _bsddb.lib │ │ │ ├── _ctypes.lib │ │ │ ├── _ctypes_test.lib │ │ │ ├── _elementtree.lib │ │ │ ├── _hashlib.lib │ │ │ ├── _msi.lib │ │ │ ├── _multiprocessing.lib │ │ │ ├── _socket.lib │ │ │ ├── _sqlite3.lib │ │ │ ├── _ssl.lib │ │ │ ├── _testcapi.lib │ │ │ ├── _tkinter.lib │ │ │ ├── bz2.lib │ │ │ ├── libpython27.a │ │ │ ├── pyexpat.lib │ │ │ ├── python27.lib │ │ │ ├── select.lib │ │ │ ├── unicodedata.lib │ │ │ └── winsound.lib │ ├── pytypes.h │ ├── stl.h │ ├── stl_bind.h │ └── typeid.h ├── stdafx.cpp ├── stdafx.h └── targetver.h └── test ├── LoginActivity.smali ├── app-debug.apk └── demo.py /README.md: -------------------------------------------------------------------------------- 1 | # avmdbg 2 | a lightweight debugger for android virtual machine. 3 | -------------------------------------------------------------------------------- /bin/avmdbg.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/bin/avmdbg.pyd -------------------------------------------------------------------------------- /bin/demo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | #coding=utf-8 4 | 5 | from avmdbg import * 6 | 7 | 8 | class JdwpTag: 9 | def __init__(self): 10 | pass 11 | BYTE = 66 12 | CHAR = 67 13 | DOUBLE = 68 14 | FLOAT = 70 15 | INT = 73 16 | LONG = 74 17 | OBJECT = 76 18 | SHORT = 83 19 | BOOLEAN = 90 20 | ARRAY = 91 21 | 22 | 23 | def breakPointCallback0(context): 24 | print "### breakPointCallback0 ###" 25 | # 线程、堆栈 26 | print "[threadId]:%d" % context["threadId"] 27 | print "[threadName]:%s" % context["threadName"] 28 | print "[frameId]:%d" % context["frameId"] 29 | 30 | # 输出参数 31 | print "[param]:" 32 | for k, v in context["param"].items(): 33 | print k + ":" + str(v) 34 | 35 | # This指针 36 | thisObjectId = context["param"]["p0"]["id"] 37 | print "[this]:" 38 | objectFields = debugger.getObjectFieldValues(thisObjectId) 39 | for item in objectFields: 40 | print str(item) 41 | 42 | # 附加信息 43 | print "[reqExt]:" 44 | for k, v in context["reqExt"].items(): 45 | print k + ":" + str(v) 46 | 47 | # 堆栈回溯 48 | print "[stackFrames]:" 49 | stackFrames = debugger.getStackFrames(context["threadId"]) 50 | for frame in stackFrames: 51 | print frame["class"] + " -> " + \ 52 | frame["method"] + frame["sign"] + " [+]" + \ 53 | hex(frame["index"]) 54 | 55 | 56 | def breakPointCallback1(context): 57 | print "### breakPointCallback1 ###" 58 | strArray = debugger.getRegisterValue(context, "p3", JdwpTag.ARRAY) 59 | print "[p3]:" + str(strArray) 60 | print " [0]:" + str(debugger.getStringValue(strArray["value"]["data"][0])) 61 | print " [1]:" + str(debugger.getStringValue(strArray["value"]["data"][1])) 62 | 63 | print "[v0]:" + str(debugger.getRegisterValue(context, "v0", JdwpTag.OBJECT)) 64 | print "[v1]:" + str(debugger.getRegisterValue(context, "v1", JdwpTag.INT)) 65 | 66 | 67 | if __name__ == '__main__': 68 | 69 | debugger = AvmDebugger() 70 | 71 | if not debugger.attach("com.example.x0r.demo"): 72 | print "[err]: process attach fail!" 73 | exit(-1) 74 | 75 | # .method private 76 | # test0(B, [I, J, String) V 77 | # .registers 9 78 | # .param p1, "a0" 79 | # .param p2, "a1" 80 | # .param p3, "a2" 81 | # .param p5, "a3" 82 | # .prologue 83 | bp0 = { 84 | "class": "Lcom/example/x0r/demo/LoginActivity;", 85 | "method": "test0", 86 | "sign": "(B[IJLjava/lang/String;)V", 87 | "index": 0, 88 | "registers": 9, 89 | "callback": breakPointCallback0 90 | } 91 | 92 | if not debugger.setBreakPoint(bp0): 93 | print "[err]: set breakpoint0 fail!" 94 | exit(-1) 95 | 96 | # @a const-string v0, "test1" 97 | # @c aget v1, p1, v2 98 | # @e add-int/lit8 v1, v1, 0xb 99 | # @10 invoke-static {v1}, Ljava/lang/Integer;->toString(I)Ljava/lang/String; 100 | bp1 = { 101 | "class": "Lcom/example/x0r/demo/LoginActivity;", 102 | "method": "test1", 103 | "sign": "(B[IC[Ljava/lang/String;)V", 104 | "index": 0x10, 105 | "registers": 7, 106 | "callback": breakPointCallback1 107 | } 108 | 109 | if not debugger.setBreakPoint(bp0): 110 | print "[err]: set breakpoint1 fail!" 111 | exit(-1) 112 | 113 | debugger.waitLoop() 114 | -------------------------------------------------------------------------------- /doc/AVMDBG说明.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/doc/AVMDBG说明.docx -------------------------------------------------------------------------------- /doc/安卓调试器原理与实现.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/doc/安卓调试器原理与实现.docx -------------------------------------------------------------------------------- /src/AdbHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "AdbHelper.h" 3 | 4 | 5 | AdbHelper::AdbHelper() 6 | { 7 | } 8 | 9 | 10 | AdbHelper::~AdbHelper() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /src/AdbHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | 11 | class AdbHelper 12 | { 13 | public: 14 | AdbHelper(); 15 | ~AdbHelper(); 16 | public: 17 | bool AdbHelper::getDebugableApps(map* result) { 18 | vector jdwpPids; 19 | cmd_jdwp(&jdwpPids); 20 | 21 | vector psLines; 22 | cmd_shell_ps(&psLines); 23 | 24 | vector::iterator it = psLines.begin(); 25 | for (; it != psLines.end(); it++) { 26 | vector info; 27 | split(*it, " ", &info); 28 | vector::iterator it = find(jdwpPids.begin(), jdwpPids.end(), info[1]); 29 | if (it != jdwpPids.end()) 30 | result->insert(make_pair(info[8], info[1])); 31 | } 32 | 33 | return result->size() > 0; 34 | } 35 | 36 | bool AdbHelper::cmd_jdwp(vector* jdwpPids) { 37 | std::string outStr; 38 | if (execute(string("adb jdwp"), &outStr)) { 39 | split(outStr, "\r\n", jdwpPids); 40 | return jdwpPids->size() > 0; 41 | } 42 | return false; 43 | } 44 | 45 | bool AdbHelper::cmd_shell_ps(vector* retLines) { 46 | std::string outStr; 47 | if (execute(string("adb shell ps"), &outStr)) { 48 | split(outStr, "\r\r\n", retLines); 49 | if (retLines->size() > 1) 50 | retLines->erase(retLines->begin()); 51 | return retLines->size() > 0; 52 | } 53 | return false; 54 | } 55 | 56 | bool AdbHelper::cmd_forword_jdwp(string port, string pid) { 57 | return execute(string("adb forward tcp:") + port + string(" jdwp:") + pid, NULL); 58 | } 59 | 60 | bool AdbHelper::execute(std::string cmdStr, std::string* pOutStr) { 61 | bool bRet = false; 62 | HANDLE hPipeRead = NULL; 63 | HANDLE hPipeWrite = NULL; 64 | DWORD dwRead = 0; 65 | DWORD dwFileSize = 0; 66 | CHAR* pszBuffer = NULL; 67 | PROCESS_INFORMATION pi = { 0 }; 68 | STARTUPINFO si = { 0 }; 69 | SECURITY_ATTRIBUTES sa = { 0 }; 70 | 71 | sa.bInheritHandle = TRUE; 72 | sa.nLength = sizeof(SECURITY_ATTRIBUTES); 73 | 74 | if (!::CreatePipe(&hPipeRead, &hPipeWrite, &sa, 1024*64)) 75 | return false; 76 | ::SetHandleInformation(hPipeRead, HANDLE_FLAG_INHERIT, 0); 77 | 78 | si.cb = sizeof(STARTUPINFO); 79 | si.hStdOutput = hPipeWrite; 80 | si.hStdError = hPipeWrite; 81 | si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; 82 | si.wShowWindow = SW_HIDE; 83 | 84 | wchar_t cmdLine[MAX_PATH] = { 0 }; 85 | std::wstring wCmdStr(cmdStr.length(), L' '); 86 | std::copy(cmdStr.begin(), cmdStr.end(), wCmdStr.begin()); 87 | wcscpy_s(cmdLine, MAX_PATH, wCmdStr.c_str()); 88 | 89 | if (::CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { 90 | ::WaitForSingleObject(pi.hProcess, 3000); 91 | ::CloseHandle(pi.hProcess); 92 | ::CloseHandle(pi.hThread); 93 | 94 | if (pOutStr != NULL) { 95 | dwFileSize = ::GetFileSize(hPipeRead, NULL); 96 | pszBuffer = new CHAR[dwFileSize + sizeof(CHAR)]; 97 | if (NULL != pszBuffer) { 98 | memset(pszBuffer, 0, dwFileSize + sizeof(CHAR)); 99 | ::ReadFile(hPipeRead, pszBuffer, dwFileSize, &dwRead, NULL); 100 | pOutStr->append(pszBuffer); 101 | delete[] pszBuffer; 102 | bRet = true; 103 | } 104 | } 105 | } 106 | 107 | ::CloseHandle(hPipeRead); 108 | ::CloseHandle(hPipeWrite); 109 | return bRet; 110 | } 111 | 112 | private: 113 | static void split(const string str, const string delim, vector* ret) { 114 | size_t last = 0; 115 | size_t index = str.find_first_of(delim, last); 116 | while (index != -1) { 117 | string tmp = str.substr(last, index - last); 118 | if (tmp.length() > 0) 119 | ret->push_back(tmp); 120 | last = index + delim.length(); 121 | index = str.find_first_of(delim, last); 122 | } 123 | if (str.length() > last) 124 | ret->push_back(str.substr(last)); 125 | } 126 | 127 | private: 128 | std::string m_adbPath; 129 | HANDLE m_pipe; 130 | HANDLE m_hRead; 131 | HANDLE m_hWrite; 132 | }; -------------------------------------------------------------------------------- /src/AvmDebugger.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/AvmDebugger.cpp -------------------------------------------------------------------------------- /src/AvmDebugger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "JdwpProtocol.h" 4 | 5 | #include "pybind11/pybind11.h" 6 | namespace py = pybind11; 7 | 8 | typedef std::function EventCallBack; 9 | 10 | struct EventContext 11 | { 12 | EventCallBack mCallBack; 13 | py::dict mReqExt; 14 | }; 15 | 16 | class AvmDebugger : public JdwpProtocol 17 | { 18 | public: 19 | AvmDebugger(); 20 | ~AvmDebugger(); 21 | 22 | public: 23 | bool attach(string& processName); 24 | 25 | void waitLoop(); 26 | 27 | bool setBreakPoint(py::dict& bp); 28 | 29 | py::list getStackFrames(ObjectId threadId); 30 | 31 | py::str getStringValue(ObjectId objectId); 32 | 33 | py::list getObjectFieldValues(ObjectId objectId); 34 | 35 | py::dict getArrayObjectValue(ObjectId objectId); 36 | 37 | py::dict getRegisterValue(py::dict& Context, string& regName, u1 varType); 38 | 39 | private: 40 | 41 | py::list getAllClasses(); 42 | 43 | py::list getClassesBySignature(string& classSign); 44 | 45 | virtual void handleEventNotify(JdwpRep_Event_Composite& eventNotify); 46 | 47 | void registerEventNotify(u4 uRequestId, EventContext eventContext); 48 | 49 | bool getEventContext(u4 uRequestId, EventContext& eventContext); 50 | 51 | void formatJdwpValue(JdwpValue& val, py::dict& item); 52 | 53 | private: 54 | std::map mEventNotifyMap; 55 | std::mutex mEventMutex; 56 | }; 57 | -------------------------------------------------------------------------------- /src/JdwpPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "JdwpPacket.h" 3 | 4 | #include 5 | 6 | u4 JdwpPacket::stPacketId = 1; 7 | 8 | JdwpPacket::JdwpPacket(JdwpPacketHeader* Header) { 9 | u4 uSize = Tranverse32(Header->length); 10 | mBuffer.resize(uSize); 11 | memset(mBuffer.data(), 0, uSize); 12 | memcpy(mBuffer.data(), Header, sizeof(JdwpPacketHeader)); 13 | } 14 | 15 | JdwpPacket::JdwpPacket() { 16 | mBuffer.resize(sizeof(JdwpPacketHeader)); 17 | memset(mBuffer.data(), 0, sizeof(JdwpPacketHeader)); 18 | } 19 | 20 | JdwpPacket::~JdwpPacket() { 21 | 22 | } 23 | 24 | void JdwpPacket::setCommand(eJdwpCommandSet cmdSet, eJdwpCommandId cmdId) { 25 | JdwpPacketHeader* header = (JdwpPacketHeader*)mBuffer.data(); 26 | u4 Length = sizeof(JdwpPacketHeader); 27 | u4 packetId = JdwpPacket::makePacketId(); 28 | header->length = Tranverse32(Length); 29 | header->id = Tranverse32(packetId); 30 | header->flags = 0x00; 31 | header->cmdSet = cmdSet; 32 | header->cmdId = cmdId; 33 | } 34 | 35 | void JdwpPacket::appendBody(const u1* Data, u4 Size) { 36 | vector Temp(Data, Data + Size); 37 | if (Size == 2 || Size == 4 || Size == 8) 38 | std::reverse(Temp.begin(), Temp.end()); 39 | mBuffer.insert(mBuffer.end(), Temp.begin(), Temp.end()); 40 | JdwpPacketHeader* Header = (JdwpPacketHeader*)mBuffer.data(); 41 | Header->length = Tranverse32(mBuffer.size()); 42 | } 43 | 44 | JdwpPacketHeader* JdwpPacket::getHeader() { 45 | if (mBuffer.size() >= sizeof(JdwpPacketHeader)) { 46 | return (JdwpPacketHeader*)mBuffer.data(); 47 | } 48 | return 0; 49 | } 50 | 51 | u1* JdwpPacket::getBody() { 52 | if (mBuffer.size() > sizeof(JdwpPacketHeader)) 53 | return (unsigned char*)mBuffer.data() + sizeof(JdwpPacketHeader); 54 | return 0; 55 | } 56 | 57 | size_t JdwpPacket::getBodySize() { 58 | if (mBuffer.size() > sizeof(JdwpPacketHeader)) 59 | return mBuffer.size() - sizeof(JdwpPacketHeader); 60 | return 0; 61 | } 62 | 63 | u1* JdwpPacket::getBuffer() { 64 | return mBuffer.data(); 65 | } 66 | 67 | size_t JdwpPacket::getBufferSize() { 68 | return mBuffer.size(); 69 | } 70 | 71 | u4 JdwpPacket::getId() { 72 | if (mBuffer.size() >= sizeof(JdwpPacketHeader)) { 73 | JdwpPacketHeader* Header = (JdwpPacketHeader*)mBuffer.data(); 74 | return Tranverse32(Header->id); 75 | } 76 | return 0; 77 | } 78 | 79 | eJdwpPacketType JdwpPacket::getType() { 80 | if (mBuffer.size() >= sizeof(JdwpPacketHeader)) { 81 | JdwpPacketHeader* header = (JdwpPacketHeader*)mBuffer.data(); 82 | if (header->flags == 0x80) 83 | return PACKET_TYPE_REPLY; 84 | if (header->flags == 0x00) 85 | return PACKET_TYPE_COMMAND; 86 | } 87 | return PACKET_TYPE_UNKNOWN; 88 | } 89 | 90 | u4 JdwpPacket::makePacketId() { 91 | return JdwpPacket::stPacketId++; 92 | } 93 | 94 | string JdwpPacket::toString() { 95 | std::stringstream stream; 96 | if (mBuffer.size() >= sizeof(JdwpPacketHeader)) { 97 | JdwpPacketHeader* Header = (JdwpPacketHeader*)mBuffer.data(); 98 | u4 Length = Tranverse32(Header->length); 99 | u4 Id = Tranverse32(Header->id); 100 | u1 cmdset = Header->cmdSet; 101 | u1 cmdid = Header->cmdId; 102 | u2 errCode = Tranverse16(Header->errorCode); 103 | if (Header->flags == 0x80) 104 | stream << "[JdwpPacket] ==> type=REPLY | len=" << Length << " | id=" << Id 105 | << " | err=" << errCode << endl; 106 | if (Header->flags == 0x00) 107 | stream << "[JdwpPacket] ==> type=COMMAND | len=" << Length << " | id=" << Id 108 | << " | cmdset=" << cmdset << " |cmdid=" << cmdid << endl; 109 | return stream.str(); 110 | } 111 | return string(""); 112 | } 113 | -------------------------------------------------------------------------------- /src/JdwpPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | using namespace std; 5 | 6 | #include "Jdwp.h" 7 | 8 | /* 9 | * JDWP message header 10 | */ 11 | #pragma pack (1) 12 | typedef struct JdwpPacketHeader { 13 | u4 length; 14 | u4 id; 15 | u1 flags; 16 | union { 17 | u2 errorCode; 18 | struct { 19 | u1 cmdSet; 20 | u1 cmdId; 21 | }; 22 | }; 23 | } JdwpPacketHeader; 24 | #pragma pack () 25 | 26 | class JdwpPacket 27 | { 28 | static u4 stPacketId; 29 | public: 30 | JdwpPacket(JdwpPacketHeader* Header); 31 | JdwpPacket(); 32 | ~JdwpPacket(); 33 | public: 34 | 35 | void setCommand(eJdwpCommandSet cmdSet, eJdwpCommandId cmdId); 36 | 37 | void appendBody(const u1* Data, u4 Size); 38 | 39 | JdwpPacketHeader* getHeader(); 40 | 41 | unsigned char* getBody(); 42 | 43 | u4 getBodySize(); 44 | 45 | u1* getBuffer(); 46 | 47 | u4 getBufferSize(); 48 | 49 | u4 getId(); 50 | 51 | eJdwpPacketType getType(); 52 | 53 | static u4 makePacketId(); 54 | 55 | string toString(); 56 | 57 | private: 58 | std::vector mBuffer; 59 | }; 60 | 61 | -------------------------------------------------------------------------------- /src/JdwpRepObject.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/JdwpRepObject.h -------------------------------------------------------------------------------- /src/JdwpSerializer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | using namespace std; 5 | 6 | 7 | class JdwpSerializer 8 | { 9 | public: 10 | JdwpSerializer() {}; 11 | JdwpSerializer(u1* buffer, u4 size) { 12 | mBuffer = buffer; 13 | mSize = size; 14 | mPos = mBuffer; 15 | } 16 | ~JdwpSerializer() { } 17 | 18 | bool read(u1& v) { 19 | if (mPos + sizeof(u1) > mBuffer + mSize) 20 | return false; 21 | v = *(u1*)mPos;; 22 | mPos += sizeof(u1); 23 | return true; 24 | } 25 | 26 | bool read(u2& v) { 27 | if (mPos + sizeof(u2) > mBuffer + mSize) 28 | return false; 29 | u2* _cur = (u2*)mPos; 30 | v = Tranverse16(*_cur); 31 | mPos += sizeof(u2); 32 | return true; 33 | } 34 | 35 | bool read(u4& v) { 36 | if (mPos + sizeof(u4) > mBuffer + mSize) 37 | return false; 38 | u4* _cur = (u4*)mPos; 39 | v = Tranverse32(*_cur); 40 | mPos += sizeof(u4); 41 | return true; 42 | } 43 | 44 | bool read(u8& v) { 45 | if (mPos + sizeof(u8) > mBuffer + mSize) 46 | return false; 47 | v = Tranverse64(*(u8*)mPos); 48 | mPos += sizeof(u8); 49 | return true; 50 | } 51 | 52 | bool read(std::string &v) { 53 | u4* _cur = (u4*)mPos; 54 | u4 len = Tranverse32(_cur[0]); 55 | if (mPos + sizeof(u4) + len > mBuffer + mSize) 56 | return false; 57 | mPos += sizeof(u4); 58 | v.append((char*)mPos, len); 59 | mPos += len; 60 | return true; 61 | } 62 | public: 63 | u1* mBuffer; 64 | u4 mSize; 65 | u1* mPos; 66 | }; -------------------------------------------------------------------------------- /src/JdwpSocket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define _WINSOCK_DEPRECATED_NO_WARNINGS 4 | #include 5 | #pragma comment(lib, "ws2_32.lib") 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | using namespace std; 13 | 14 | #include "JdwpPacket.h" 15 | 16 | class jdwpSocket { 17 | public: 18 | void Init() { 19 | WSADATA wsa; 20 | if (::WSAStartup(514, &wsa) != 0) { 21 | throw std::runtime_error("WSAStartup failed."); 22 | } 23 | } 24 | 25 | jdwpSocket() { 26 | Init(); 27 | if ((mSocket = ::socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { 28 | throw std::runtime_error("Failed to create socket."); 29 | } 30 | } 31 | 32 | bool Connect(const char* address, int port) { 33 | sockaddr_in addr; 34 | addr.sin_addr.s_addr = inet_addr(address); 35 | addr.sin_family = AF_INET; 36 | addr.sin_port = ::htons(port); 37 | if (::connect(mSocket, (struct sockaddr *)&addr, sizeof(addr)) < 0) { 38 | throw std::runtime_error("Failed to connect."); 39 | } 40 | return true; 41 | } 42 | 43 | bool Send(const char* buffer, int size) { 44 | return ::send(mSocket, buffer, size, 0) > 0; 45 | } 46 | 47 | bool Recv(char* buffer, int size) { 48 | return ::recv(mSocket, buffer, size, 0) > 0; 49 | } 50 | 51 | void runRecvWorker() { 52 | std::thread recvThread(&jdwpSocket::recvPacket, this); 53 | recvThread.detach(); 54 | } 55 | 56 | JdwpPacket* getNextPacket() { 57 | std::lock_guard lk(mQueueMutex); 58 | if (mPacketQueue.size()) 59 | { 60 | JdwpPacket* packet = mPacketQueue.front(); 61 | //std::cout << "mPacketQueue Pop PacketID:" << packet->getPacketId() << endl; 62 | mPacketQueue.pop_front(); 63 | return packet; 64 | } 65 | return 0; 66 | } 67 | 68 | bool RecvN(char* buffer, int size) { 69 | int idx = 0; 70 | while (true) 71 | { 72 | int ret = recv(mSocket, buffer + idx, size - idx, 0); 73 | if (ret <= 0) { 74 | std::cout << "recv packet fail. LastError:" << WSAGetLastError() << endl; 75 | return false; 76 | } 77 | idx += ret; 78 | if (idx == size) 79 | return true; 80 | } 81 | } 82 | 83 | void recvPacket() 84 | { 85 | while (true) 86 | { 87 | JdwpPacketHeader packetHeader; 88 | memset(&packetHeader, 0, sizeof(packetHeader)); 89 | 90 | if (!RecvN((char*)&packetHeader, sizeof(JdwpPacketHeader))) 91 | break; 92 | 93 | if (Tranverse32(packetHeader.length) == sizeof(JdwpPacketHeader)) 94 | continue; 95 | 96 | JdwpPacket* jdwpPacket = new JdwpPacket(&packetHeader); 97 | size_t bodySize = jdwpPacket->getBodySize(); 98 | char* bodyBuffer = (char*)jdwpPacket->getBody(); 99 | if (bodyBuffer && bodySize) 100 | RecvN(bodyBuffer, bodySize); 101 | 102 | std::lock_guard lk(mQueueMutex); 103 | mPacketQueue.push_back(jdwpPacket); 104 | } 105 | } 106 | 107 | ~jdwpSocket() { 108 | ::closesocket(mSocket); 109 | mSocket = INVALID_SOCKET; 110 | mPacketQueue.clear(); 111 | } 112 | private: 113 | SOCKET mSocket; 114 | std::mutex mQueueMutex; 115 | std::list mPacketQueue; 116 | }; -------------------------------------------------------------------------------- /src/JdwpValue.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/JdwpValue.cpp -------------------------------------------------------------------------------- /src/JdwpValue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "jdwp.h" 4 | 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | 10 | /* 11 | ARRAY 91 '[' - an array object(objectID size). 12 | BYTE 66 'B' - a byte value(1 byte). 13 | CHAR 67 'C' - a character value(2 bytes). 14 | OBJECT 76 'L' - an object(objectID size). 15 | FLOAT 70 'F' - a float value(4 bytes). 16 | DOUBLE 68 'D' - a double value(8 bytes). 17 | INT 73 'I' - an int value(4 bytes). 18 | LONG 74 'J' - a long value(8 bytes). 19 | SHORT 83 'S' - a short value(2 bytes). 20 | VOID 86 'V' - a void value(no bytes). 21 | BOOLEAN 90 'Z' - a boolean value(1 byte). 22 | STRING 115 's' - a String object(objectID size). 23 | THREAD 116 't' - a Thread object(objectID size). 24 | THREAD_GROUP 103 'g' - a ThreadGroup object(objectID size). 25 | CLASS_LOADER 108 'l' - a ClassLoader object(objectID size). 26 | CLASS_OBJECT 99 'c' - a class object object(objectID size) 27 | */ 28 | 29 | union JdwpValue 30 | { 31 | u1 mType; 32 | struct JValueArry { 33 | eJdwpType _t; 34 | ObjectId val; 35 | } _arry; 36 | 37 | struct JValueByte { 38 | eJdwpType _t; 39 | u1 val; 40 | } _byte; 41 | 42 | struct JValueChar { 43 | eJdwpType _t; 44 | u2 val; 45 | } _char; 46 | 47 | struct JValueObject { 48 | eJdwpType _t; 49 | ObjectId val; 50 | } _object; 51 | 52 | struct JValueFloat{ 53 | eJdwpType _t; 54 | float val; 55 | } _float; 56 | 57 | struct JValueDouble{ 58 | eJdwpType _t; 59 | double val; 60 | } _double; 61 | 62 | struct JValueInt{ 63 | eJdwpType _t; 64 | u4 val; 65 | } _int; 66 | 67 | struct JValueLong{ 68 | eJdwpType _t; 69 | u8 val; 70 | } _long; 71 | 72 | struct JValueShort{ 73 | eJdwpType _t; 74 | u2 val; 75 | } _short; 76 | 77 | struct JValueVoid{ 78 | eJdwpType _t; 79 | } _void; 80 | 81 | struct JValueBoolean{ 82 | eJdwpType _t; 83 | bool val; 84 | } _boolean; 85 | 86 | struct JValueString{ 87 | eJdwpType _t; 88 | ObjectId val; 89 | } _string; 90 | 91 | struct JValueThread{ 92 | eJdwpType _t; 93 | ObjectId val; 94 | } _thread; 95 | 96 | struct JValueThreadGroup{ 97 | eJdwpType _t; 98 | ObjectId val; 99 | } _threadgroup; 100 | 101 | struct JValueClassLoader{ 102 | eJdwpType _t; 103 | ObjectId val; 104 | } _classloader; 105 | 106 | struct JValueClassObject { 107 | eJdwpType _t; 108 | ObjectId val; 109 | } _classobject; 110 | 111 | public: 112 | JdwpValue() {} 113 | JdwpValue(u1 type) { 114 | mType = type; 115 | } 116 | u4 getValueSize() { 117 | switch (mType) { 118 | case JT_VOID: 119 | return 0; 120 | case JT_BYTE: 121 | case JT_BOOLEAN: 122 | return 1; 123 | case JT_CHAR: 124 | case JT_SHORT: 125 | return 2; 126 | case JT_FLOAT: 127 | case JT_INT: 128 | return 4; 129 | case JT_DOUBLE: 130 | case JT_LONG: 131 | return 8; 132 | case JT_OBJECT: 133 | case JT_ARRAY: 134 | case JT_STRING: 135 | case JT_THREAD: 136 | case JT_THREAD_GROUP: 137 | case JT_CLASS_LOADER: 138 | case JT_CLASS_OBJECT: 139 | return sizeof(ObjectId); 140 | default: 141 | return -1; 142 | } 143 | } 144 | const char* getTypeName() { 145 | switch (mType) { 146 | case JT_VOID: 147 | return "void"; 148 | case JT_BYTE: 149 | return "byte"; 150 | case JT_BOOLEAN: 151 | return "boolean"; 152 | case JT_CHAR: 153 | return "char"; 154 | case JT_SHORT: 155 | return "short"; 156 | case JT_FLOAT: 157 | return "float"; 158 | case JT_INT: 159 | return "int"; 160 | case JT_DOUBLE: 161 | return "double"; 162 | case JT_LONG: 163 | return "long"; 164 | case JT_OBJECT: 165 | return "object"; 166 | case JT_ARRAY: 167 | return "array"; 168 | case JT_STRING: 169 | return "string"; 170 | case JT_THREAD: 171 | return "thread"; 172 | case JT_THREAD_GROUP: 173 | return "threadGroup"; 174 | case JT_CLASS_LOADER: 175 | return "classLoader"; 176 | case JT_CLASS_OBJECT: 177 | return "classObject"; 178 | default: 179 | return "unknown"; 180 | } 181 | } 182 | }; 183 | 184 | struct JdwpVariable 185 | { 186 | string mName; 187 | size_t mSlot; 188 | string mSign; 189 | JdwpValue mValue; 190 | }; 191 | 192 | string getParamSign(const string& funcSign); 193 | eJdwpType getParamType(const string& param); 194 | size_t getRegisterWide(u1 type); 195 | size_t findTypeEnd(const string& param, size_t index); 196 | bool splitsParam(const string& paramStr, vector& paramVec); 197 | bool analysisParam(const string& paramStr, size_t registerCount, bool bStatic, vector& result); 198 | -------------------------------------------------------------------------------- /src/avmdbg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/avmdbg.cpp -------------------------------------------------------------------------------- /src/avmdbg.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "avmdbg", "avmdbg.vcxproj", "{7B79F420-1DCE-410F-B071-8E3D43078E2C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7B79F420-1DCE-410F-B071-8E3D43078E2C}.Debug|x64.ActiveCfg = Debug|x64 17 | {7B79F420-1DCE-410F-B071-8E3D43078E2C}.Debug|x64.Build.0 = Debug|x64 18 | {7B79F420-1DCE-410F-B071-8E3D43078E2C}.Debug|x86.ActiveCfg = Debug|Win32 19 | {7B79F420-1DCE-410F-B071-8E3D43078E2C}.Debug|x86.Build.0 = Debug|Win32 20 | {7B79F420-1DCE-410F-B071-8E3D43078E2C}.Release|x64.ActiveCfg = Release|x64 21 | {7B79F420-1DCE-410F-B071-8E3D43078E2C}.Release|x64.Build.0 = Release|x64 22 | {7B79F420-1DCE-410F-B071-8E3D43078E2C}.Release|x86.ActiveCfg = Release|Win32 23 | {7B79F420-1DCE-410F-B071-8E3D43078E2C}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /src/dllmain.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/dllmain.cpp -------------------------------------------------------------------------------- /src/pybind11/complex.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/complex.h: Complex number support 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "pybind11.h" 13 | #include 14 | 15 | /// glibc defines I as a macro which breaks things, e.g., boost template names 16 | #ifdef I 17 | # undef I 18 | #endif 19 | 20 | NAMESPACE_BEGIN(pybind11) 21 | 22 | PYBIND11_DECL_FMT(std::complex, "Zf"); 23 | PYBIND11_DECL_FMT(std::complex, "Zd"); 24 | 25 | NAMESPACE_BEGIN(detail) 26 | template class type_caster> { 27 | public: 28 | bool load(handle src, bool) { 29 | if (!src) 30 | return false; 31 | Py_complex result = PyComplex_AsCComplex(src.ptr()); 32 | if (result.real == -1.0 && PyErr_Occurred()) { 33 | PyErr_Clear(); 34 | return false; 35 | } 36 | value = std::complex((T) result.real, (T) result.imag); 37 | return true; 38 | } 39 | 40 | static handle cast(const std::complex &src, return_value_policy /* policy */, handle /* parent */) { 41 | return PyComplex_FromDoubles((double) src.real(), (double) src.imag()); 42 | } 43 | 44 | PYBIND11_TYPE_CASTER(std::complex, _("complex")); 45 | }; 46 | NAMESPACE_END(detail) 47 | NAMESPACE_END(pybind11) 48 | -------------------------------------------------------------------------------- /src/pybind11/eval.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/exec.h: Support for evaluating Python expressions and statements 3 | from strings and files 4 | 5 | Copyright (c) 2016 Klemens Morgenstern and 6 | Wenzel Jakob 7 | 8 | All rights reserved. Use of this source code is governed by a 9 | BSD-style license that can be found in the LICENSE file. 10 | */ 11 | 12 | #pragma once 13 | 14 | #pragma once 15 | 16 | #include "pybind11.h" 17 | 18 | NAMESPACE_BEGIN(pybind11) 19 | 20 | enum eval_mode { 21 | /// Evaluate a string containing an isolated expression 22 | eval_expr, 23 | 24 | /// Evaluate a string containing a single statement. Returns \c none 25 | eval_single_statement, 26 | 27 | /// Evaluate a string containing a sequence of statement. Returns \c none 28 | eval_statements 29 | }; 30 | 31 | template 32 | object eval(str expr, object global = object(), object local = object()) { 33 | if (!global) { 34 | global = object(PyEval_GetGlobals(), true); 35 | if (!global) 36 | global = dict(); 37 | } 38 | if (!local) 39 | local = global; 40 | 41 | /* PyRun_String does not accept a PyObject / encoding specifier, 42 | this seems to be the only alternative */ 43 | std::string buffer = "# -*- coding: utf-8 -*-\n" + (std::string) expr; 44 | 45 | int start; 46 | switch (mode) { 47 | case eval_expr: start = Py_eval_input; break; 48 | case eval_single_statement: start = Py_single_input; break; 49 | case eval_statements: start = Py_file_input; break; 50 | default: pybind11_fail("invalid evaluation mode"); 51 | } 52 | 53 | object result(PyRun_String(buffer.c_str(), start, global.ptr(), local.ptr()), false); 54 | 55 | if (!result) 56 | throw error_already_set(); 57 | return result; 58 | } 59 | 60 | template 61 | object eval_file(str fname, object global = object(), object local = object()) { 62 | if (!global) { 63 | global = object(PyEval_GetGlobals(), true); 64 | if (!global) 65 | global = dict(); 66 | } 67 | if (!local) 68 | local = global; 69 | 70 | int start; 71 | switch (mode) { 72 | case eval_expr: start = Py_eval_input; break; 73 | case eval_single_statement: start = Py_single_input; break; 74 | case eval_statements: start = Py_file_input; break; 75 | default: pybind11_fail("invalid evaluation mode"); 76 | } 77 | 78 | int closeFile = 1; 79 | std::string fname_str = (std::string) fname; 80 | #if PY_VERSION_HEX >= 0x03040000 81 | FILE *f = _Py_fopen_obj(fname.ptr(), "r"); 82 | #elif PY_VERSION_HEX >= 0x03000000 83 | FILE *f = _Py_fopen(fname.ptr(), "r"); 84 | #else 85 | /* No unicode support in open() :( */ 86 | object fobj(PyFile_FromString( 87 | const_cast(fname_str.c_str()), 88 | const_cast("r")), false); 89 | FILE *f = nullptr; 90 | if (fobj) 91 | f = PyFile_AsFile(fobj.ptr()); 92 | closeFile = 0; 93 | #endif 94 | if (!f) { 95 | PyErr_Clear(); 96 | pybind11_fail("File \"" + fname_str + "\" could not be opened!"); 97 | } 98 | 99 | object result(PyRun_FileEx(f, fname_str.c_str(), start, global.ptr(), 100 | local.ptr(), closeFile), 101 | false); 102 | 103 | if (!result) 104 | throw error_already_set(); 105 | 106 | return result; 107 | } 108 | 109 | NAMESPACE_END(pybind11) 110 | -------------------------------------------------------------------------------- /src/pybind11/functional.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/functional.h: std::function<> support 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "pybind11.h" 13 | #include 14 | 15 | NAMESPACE_BEGIN(pybind11) 16 | NAMESPACE_BEGIN(detail) 17 | 18 | template struct type_caster> { 19 | typedef std::function type; 20 | typedef typename std::conditional::value, void_type, Return>::type retval_type; 21 | public: 22 | bool load(handle src_, bool) { 23 | if (src_.ptr() == Py_None) 24 | return true; 25 | 26 | src_ = detail::get_function(src_); 27 | if (!src_ || !PyCallable_Check(src_.ptr())) 28 | return false; 29 | 30 | { 31 | /* 32 | When passing a C++ function as an argument to another C++ 33 | function via Python, every function call would normally involve 34 | a full C++ -> Python -> C++ roundtrip, which can be prohibitive. 35 | Here, we try to at least detect the case where the function is 36 | stateless (i.e. function pointer or lambda function without 37 | captured variables), in which case the roundtrip can be avoided. 38 | */ 39 | if (PyCFunction_Check(src_.ptr())) { 40 | capsule c(PyCFunction_GetSelf(src_.ptr()), true); 41 | auto rec = (function_record *) c; 42 | using FunctionType = Return (*) (Args...); 43 | 44 | if (rec && rec->is_stateless && rec->data[1] == &typeid(FunctionType)) { 45 | struct capture { FunctionType f; }; 46 | value = ((capture *) &rec->data)->f; 47 | return true; 48 | } 49 | } 50 | } 51 | 52 | object src(src_, true); 53 | value = [src](Args... args) -> Return { 54 | gil_scoped_acquire acq; 55 | object retval(src(std::move(args)...)); 56 | /* Visual studio 2015 parser issue: need parentheses around this expression */ 57 | return (retval.template cast()); 58 | }; 59 | return true; 60 | } 61 | 62 | template 63 | static handle cast(Func &&f_, return_value_policy policy, handle /* parent */) { 64 | if (!f_) 65 | return handle(Py_None).inc_ref(); 66 | 67 | auto result = f_.template target(); 68 | if (result) 69 | return cpp_function(*result, policy).release(); 70 | else 71 | return cpp_function(std::forward(f_), policy).release(); 72 | } 73 | 74 | PYBIND11_TYPE_CASTER(type, _("Callable[[") + 75 | type_caster>::element_names() + _("], ") + 76 | type_caster::name() + 77 | _("]")); 78 | }; 79 | 80 | NAMESPACE_END(detail) 81 | NAMESPACE_END(pybind11) 82 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/Python.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_PYTHON_H 2 | #define Py_PYTHON_H 3 | /* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ 4 | 5 | /* Include nearly all Python header files */ 6 | 7 | #include "patchlevel.h" 8 | #include "pyconfig.h" 9 | #include "pymacconfig.h" 10 | 11 | /* Cyclic gc is always enabled, starting with release 2.3a1. Supply the 12 | * old symbol for the benefit of extension modules written before then 13 | * that may be conditionalizing on it. The core doesn't use it anymore. 14 | */ 15 | #ifndef WITH_CYCLE_GC 16 | #define WITH_CYCLE_GC 1 17 | #endif 18 | 19 | #include 20 | 21 | #ifndef UCHAR_MAX 22 | #error "Something's broken. UCHAR_MAX should be defined in limits.h." 23 | #endif 24 | 25 | #if UCHAR_MAX != 255 26 | #error "Python's source code assumes C's unsigned char is an 8-bit type." 27 | #endif 28 | 29 | #if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) 30 | #define _SGI_MP_SOURCE 31 | #endif 32 | 33 | #include 34 | #ifndef NULL 35 | # error "Python.h requires that stdio.h define NULL." 36 | #endif 37 | 38 | #include 39 | #ifdef HAVE_ERRNO_H 40 | #include 41 | #endif 42 | #include 43 | #ifdef HAVE_UNISTD_H 44 | #include 45 | #endif 46 | 47 | /* For size_t? */ 48 | #ifdef HAVE_STDDEF_H 49 | #include 50 | #endif 51 | 52 | /* CAUTION: Build setups should ensure that NDEBUG is defined on the 53 | * compiler command line when building Python in release mode; else 54 | * assert() calls won't be removed. 55 | */ 56 | #include 57 | 58 | #include "pyport.h" 59 | 60 | /* pyconfig.h or pyport.h may or may not define DL_IMPORT */ 61 | #ifndef DL_IMPORT /* declarations for DLL import/export */ 62 | #define DL_IMPORT(RTYPE) RTYPE 63 | #endif 64 | #ifndef DL_EXPORT /* declarations for DLL import/export */ 65 | #define DL_EXPORT(RTYPE) RTYPE 66 | #endif 67 | 68 | /* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. 69 | * PYMALLOC_DEBUG is in error if pymalloc is not in use. 70 | */ 71 | #if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG) 72 | #define PYMALLOC_DEBUG 73 | #endif 74 | #if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC) 75 | #error "PYMALLOC_DEBUG requires WITH_PYMALLOC" 76 | #endif 77 | #include "pymath.h" 78 | #include "pymem.h" 79 | 80 | #include "object.h" 81 | #include "objimpl.h" 82 | 83 | #include "pydebug.h" 84 | 85 | #include "unicodeobject.h" 86 | #include "intobject.h" 87 | #include "boolobject.h" 88 | #include "longobject.h" 89 | #include "floatobject.h" 90 | #ifndef WITHOUT_COMPLEX 91 | #include "complexobject.h" 92 | #endif 93 | #include "rangeobject.h" 94 | #include "stringobject.h" 95 | #include "memoryobject.h" 96 | #include "bufferobject.h" 97 | #include "bytesobject.h" 98 | #include "bytearrayobject.h" 99 | #include "tupleobject.h" 100 | #include "listobject.h" 101 | #include "dictobject.h" 102 | #include "enumobject.h" 103 | #include "setobject.h" 104 | #include "methodobject.h" 105 | #include "moduleobject.h" 106 | #include "funcobject.h" 107 | #include "classobject.h" 108 | #include "fileobject.h" 109 | #include "cobject.h" 110 | #include "pycapsule.h" 111 | #include "traceback.h" 112 | #include "sliceobject.h" 113 | #include "cellobject.h" 114 | #include "iterobject.h" 115 | #include "genobject.h" 116 | #include "descrobject.h" 117 | #include "warnings.h" 118 | #include "weakrefobject.h" 119 | 120 | #include "codecs.h" 121 | #include "pyerrors.h" 122 | 123 | #include "pystate.h" 124 | 125 | #include "pyarena.h" 126 | #include "modsupport.h" 127 | #include "pythonrun.h" 128 | #include "ceval.h" 129 | #include "sysmodule.h" 130 | #include "intrcheck.h" 131 | #include "import.h" 132 | 133 | #include "abstract.h" 134 | 135 | #include "compile.h" 136 | #include "eval.h" 137 | 138 | #include "pyctype.h" 139 | #include "pystrtod.h" 140 | #include "pystrcmp.h" 141 | #include "dtoa.h" 142 | 143 | /* _Py_Mangle is defined in compile.c */ 144 | PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); 145 | 146 | /* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */ 147 | #define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a)) 148 | 149 | /* PyArg_NoArgs should not be necessary. 150 | Set ml_flags in the PyMethodDef to METH_NOARGS. */ 151 | #define PyArg_NoArgs(v) PyArg_Parse(v, "") 152 | 153 | /* Argument must be a char or an int in [-128, 127] or [0, 255]. */ 154 | #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) 155 | 156 | #include "pyfpe.h" 157 | 158 | /* These definitions must match corresponding definitions in graminit.h. 159 | There's code in compile.c that checks that they are the same. */ 160 | #define Py_single_input 256 161 | #define Py_file_input 257 162 | #define Py_eval_input 258 163 | 164 | #ifdef HAVE_PTH 165 | /* GNU pth user-space thread support */ 166 | #include 167 | #endif 168 | 169 | /* Define macros for inline documentation. */ 170 | #define PyDoc_VAR(name) static char name[] 171 | #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) 172 | #ifdef WITH_DOC_STRINGS 173 | #define PyDoc_STR(str) str 174 | #else 175 | #define PyDoc_STR(str) "" 176 | #endif 177 | 178 | #endif /* !Py_PYTHON_H */ 179 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/asdl.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_ASDL_H 2 | #define Py_ASDL_H 3 | 4 | typedef PyObject * identifier; 5 | typedef PyObject * string; 6 | typedef PyObject * object; 7 | 8 | #ifndef __cplusplus 9 | typedef enum {false, true} bool; 10 | #endif 11 | 12 | /* It would be nice if the code generated by asdl_c.py was completely 13 | independent of Python, but it is a goal the requires too much work 14 | at this stage. So, for example, I'll represent identifiers as 15 | interned Python strings. 16 | */ 17 | 18 | /* XXX A sequence should be typed so that its use can be typechecked. */ 19 | 20 | typedef struct { 21 | int size; 22 | void *elements[1]; 23 | } asdl_seq; 24 | 25 | typedef struct { 26 | int size; 27 | int elements[1]; 28 | } asdl_int_seq; 29 | 30 | asdl_seq *asdl_seq_new(int size, PyArena *arena); 31 | asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena); 32 | 33 | #define asdl_seq_GET(S, I) (S)->elements[(I)] 34 | #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size) 35 | #ifdef Py_DEBUG 36 | #define asdl_seq_SET(S, I, V) { \ 37 | int _asdl_i = (I); \ 38 | assert((S) && _asdl_i < (S)->size); \ 39 | (S)->elements[_asdl_i] = (V); \ 40 | } 41 | #else 42 | #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V) 43 | #endif 44 | 45 | #endif /* !Py_ASDL_H */ 46 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/ast.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_AST_H 2 | #define Py_AST_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags, 8 | const char *, PyArena *); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | #endif /* !Py_AST_H */ 14 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/bitset.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_BITSET_H 3 | #define Py_BITSET_H 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* Bitset interface */ 9 | 10 | #define BYTE char 11 | 12 | typedef BYTE *bitset; 13 | 14 | bitset newbitset(int nbits); 15 | void delbitset(bitset bs); 16 | #define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0) 17 | int addbit(bitset bs, int ibit); /* Returns 0 if already set */ 18 | int samebitset(bitset bs1, bitset bs2, int nbits); 19 | void mergebitset(bitset bs1, bitset bs2, int nbits); 20 | 21 | #define BITSPERBYTE (8*sizeof(BYTE)) 22 | #define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE) 23 | 24 | #define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE) 25 | #define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE) 26 | #define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit)) 27 | #define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE) 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | #endif /* !Py_BITSET_H */ 33 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/boolobject.h: -------------------------------------------------------------------------------- 1 | /* Boolean object interface */ 2 | 3 | #ifndef Py_BOOLOBJECT_H 4 | #define Py_BOOLOBJECT_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | 10 | typedef PyIntObject PyBoolObject; 11 | 12 | PyAPI_DATA(PyTypeObject) PyBool_Type; 13 | 14 | #define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type) 15 | 16 | /* Py_False and Py_True are the only two bools in existence. 17 | Don't forget to apply Py_INCREF() when returning either!!! */ 18 | 19 | /* Don't use these directly */ 20 | PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; 21 | 22 | /* Use these macros */ 23 | #define Py_False ((PyObject *) &_Py_ZeroStruct) 24 | #define Py_True ((PyObject *) &_Py_TrueStruct) 25 | 26 | /* Macros for returning Py_True or Py_False, respectively */ 27 | #define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True 28 | #define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False 29 | 30 | /* Function to return a bool from a C long */ 31 | PyAPI_FUNC(PyObject *) PyBool_FromLong(long); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | #endif /* !Py_BOOLOBJECT_H */ 37 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/bufferobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Buffer object interface */ 3 | 4 | /* Note: the object's structure is private */ 5 | 6 | #ifndef Py_BUFFEROBJECT_H 7 | #define Py_BUFFEROBJECT_H 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | 13 | PyAPI_DATA(PyTypeObject) PyBuffer_Type; 14 | 15 | #define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type) 16 | 17 | #define Py_END_OF_BUFFER (-1) 18 | 19 | PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base, 20 | Py_ssize_t offset, Py_ssize_t size); 21 | PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base, 22 | Py_ssize_t offset, 23 | Py_ssize_t size); 24 | 25 | PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size); 26 | PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size); 27 | 28 | PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | #endif /* !Py_BUFFEROBJECT_H */ 34 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/bytearrayobject.h: -------------------------------------------------------------------------------- 1 | /* ByteArray object interface */ 2 | 3 | #ifndef Py_BYTEARRAYOBJECT_H 4 | #define Py_BYTEARRAYOBJECT_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include 10 | 11 | /* Type PyByteArrayObject represents a mutable array of bytes. 12 | * The Python API is that of a sequence; 13 | * the bytes are mapped to ints in [0, 256). 14 | * Bytes are not characters; they may be used to encode characters. 15 | * The only way to go between bytes and str/unicode is via encoding 16 | * and decoding. 17 | * For the convenience of C programmers, the bytes type is considered 18 | * to contain a char pointer, not an unsigned char pointer. 19 | */ 20 | 21 | /* Object layout */ 22 | typedef struct { 23 | PyObject_VAR_HEAD 24 | /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ 25 | int ob_exports; /* how many buffer exports */ 26 | Py_ssize_t ob_alloc; /* How many bytes allocated */ 27 | char *ob_bytes; 28 | } PyByteArrayObject; 29 | 30 | /* Type object */ 31 | PyAPI_DATA(PyTypeObject) PyByteArray_Type; 32 | PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type; 33 | 34 | /* Type check macros */ 35 | #define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type) 36 | #define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type) 37 | 38 | /* Direct API functions */ 39 | PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *); 40 | PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *); 41 | PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t); 42 | PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *); 43 | PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *); 44 | PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); 45 | 46 | /* Macros, trading safety for speed */ 47 | #define PyByteArray_AS_STRING(self) \ 48 | (assert(PyByteArray_Check(self)), \ 49 | Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string) 50 | #define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self)) 51 | 52 | PyAPI_DATA(char) _PyByteArray_empty_string[]; 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | #endif /* !Py_BYTEARRAYOBJECT_H */ 58 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/bytes_methods.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_BYTES_CTYPE_H 2 | #define Py_BYTES_CTYPE_H 3 | 4 | /* 5 | * The internal implementation behind PyString (bytes) and PyBytes (buffer) 6 | * methods of the given names, they operate on ASCII byte strings. 7 | */ 8 | extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len); 9 | extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len); 10 | extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len); 11 | extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len); 12 | extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len); 13 | extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len); 14 | extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len); 15 | 16 | /* These store their len sized answer in the given preallocated *result arg. */ 17 | extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len); 18 | extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len); 19 | extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len); 20 | extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len); 21 | extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len); 22 | 23 | /* Shared __doc__ strings. */ 24 | extern const char _Py_isspace__doc__[]; 25 | extern const char _Py_isalpha__doc__[]; 26 | extern const char _Py_isalnum__doc__[]; 27 | extern const char _Py_isdigit__doc__[]; 28 | extern const char _Py_islower__doc__[]; 29 | extern const char _Py_isupper__doc__[]; 30 | extern const char _Py_istitle__doc__[]; 31 | extern const char _Py_lower__doc__[]; 32 | extern const char _Py_upper__doc__[]; 33 | extern const char _Py_title__doc__[]; 34 | extern const char _Py_capitalize__doc__[]; 35 | extern const char _Py_swapcase__doc__[]; 36 | 37 | /* These are left in for backward compatibility and will be removed 38 | in 2.8/3.2 */ 39 | #define ISLOWER(c) Py_ISLOWER(c) 40 | #define ISUPPER(c) Py_ISUPPER(c) 41 | #define ISALPHA(c) Py_ISALPHA(c) 42 | #define ISDIGIT(c) Py_ISDIGIT(c) 43 | #define ISXDIGIT(c) Py_ISXDIGIT(c) 44 | #define ISALNUM(c) Py_ISALNUM(c) 45 | #define ISSPACE(c) Py_ISSPACE(c) 46 | 47 | #undef islower 48 | #define islower(c) undefined_islower(c) 49 | #undef isupper 50 | #define isupper(c) undefined_isupper(c) 51 | #undef isalpha 52 | #define isalpha(c) undefined_isalpha(c) 53 | #undef isdigit 54 | #define isdigit(c) undefined_isdigit(c) 55 | #undef isxdigit 56 | #define isxdigit(c) undefined_isxdigit(c) 57 | #undef isalnum 58 | #define isalnum(c) undefined_isalnum(c) 59 | #undef isspace 60 | #define isspace(c) undefined_isspace(c) 61 | 62 | /* These are left in for backward compatibility and will be removed 63 | in 2.8/3.2 */ 64 | #define TOLOWER(c) Py_TOLOWER(c) 65 | #define TOUPPER(c) Py_TOUPPER(c) 66 | 67 | #undef tolower 68 | #define tolower(c) undefined_tolower(c) 69 | #undef toupper 70 | #define toupper(c) undefined_toupper(c) 71 | 72 | /* this is needed because some docs are shared from the .o, not static */ 73 | #define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str) 74 | 75 | #endif /* !Py_BYTES_CTYPE_H */ 76 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/bytesobject.h: -------------------------------------------------------------------------------- 1 | #define PyBytesObject PyStringObject 2 | #define PyBytes_Type PyString_Type 3 | 4 | #define PyBytes_Check PyString_Check 5 | #define PyBytes_CheckExact PyString_CheckExact 6 | #define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED 7 | #define PyBytes_AS_STRING PyString_AS_STRING 8 | #define PyBytes_GET_SIZE PyString_GET_SIZE 9 | #define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS 10 | 11 | #define PyBytes_FromStringAndSize PyString_FromStringAndSize 12 | #define PyBytes_FromString PyString_FromString 13 | #define PyBytes_FromFormatV PyString_FromFormatV 14 | #define PyBytes_FromFormat PyString_FromFormat 15 | #define PyBytes_Size PyString_Size 16 | #define PyBytes_AsString PyString_AsString 17 | #define PyBytes_Repr PyString_Repr 18 | #define PyBytes_Concat PyString_Concat 19 | #define PyBytes_ConcatAndDel PyString_ConcatAndDel 20 | #define _PyBytes_Resize _PyString_Resize 21 | #define _PyBytes_Eq _PyString_Eq 22 | #define PyBytes_Format PyString_Format 23 | #define _PyBytes_FormatLong _PyString_FormatLong 24 | #define PyBytes_DecodeEscape PyString_DecodeEscape 25 | #define _PyBytes_Join _PyString_Join 26 | #define PyBytes_AsStringAndSize PyString_AsStringAndSize 27 | #define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping 28 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/cStringIO.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_CSTRINGIO_H 2 | #define Py_CSTRINGIO_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | /* 7 | 8 | This header provides access to cStringIO objects from C. 9 | Functions are provided for calling cStringIO objects and 10 | macros are provided for testing whether you have cStringIO 11 | objects. 12 | 13 | Before calling any of the functions or macros, you must initialize 14 | the routines with: 15 | 16 | PycString_IMPORT 17 | 18 | This would typically be done in your init function. 19 | 20 | */ 21 | 22 | #define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI" 23 | 24 | #define PycString_IMPORT \ 25 | PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\ 26 | PycStringIO_CAPSULE_NAME, 0)) 27 | 28 | /* Basic functions to manipulate cStringIO objects from C */ 29 | 30 | static struct PycStringIO_CAPI { 31 | 32 | /* Read a string from an input object. If the last argument 33 | is -1, the remainder will be read. 34 | */ 35 | int(*cread)(PyObject *, char **, Py_ssize_t); 36 | 37 | /* Read a line from an input object. Returns the length of the read 38 | line as an int and a pointer inside the object buffer as char** (so 39 | the caller doesn't have to provide its own buffer as destination). 40 | */ 41 | int(*creadline)(PyObject *, char **); 42 | 43 | /* Write a string to an output object*/ 44 | int(*cwrite)(PyObject *, const char *, Py_ssize_t); 45 | 46 | /* Get the output object as a Python string (returns new reference). */ 47 | PyObject *(*cgetvalue)(PyObject *); 48 | 49 | /* Create a new output object */ 50 | PyObject *(*NewOutput)(int); 51 | 52 | /* Create an input object from a Python string 53 | (copies the Python string reference). 54 | */ 55 | PyObject *(*NewInput)(PyObject *); 56 | 57 | /* The Python types for cStringIO input and output objects. 58 | Note that you can do input on an output object. 59 | */ 60 | PyTypeObject *InputType, *OutputType; 61 | 62 | } *PycStringIO; 63 | 64 | /* These can be used to test if you have one */ 65 | #define PycStringIO_InputCheck(O) \ 66 | (Py_TYPE(O)==PycStringIO->InputType) 67 | #define PycStringIO_OutputCheck(O) \ 68 | (Py_TYPE(O)==PycStringIO->OutputType) 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | #endif /* !Py_CSTRINGIO_H */ 74 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/cellobject.h: -------------------------------------------------------------------------------- 1 | /* Cell object interface */ 2 | 3 | #ifndef Py_CELLOBJECT_H 4 | #define Py_CELLOBJECT_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | PyObject_HEAD 11 | PyObject *ob_ref; /* Content of the cell or NULL when empty */ 12 | } PyCellObject; 13 | 14 | PyAPI_DATA(PyTypeObject) PyCell_Type; 15 | 16 | #define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type) 17 | 18 | PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); 19 | PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); 20 | PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); 21 | 22 | #define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref) 23 | #define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v) 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | #endif /* !Py_TUPLEOBJECT_H */ 29 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/ceval.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_CEVAL_H 2 | #define Py_CEVAL_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* Interface to random parts in ceval.c */ 9 | 10 | PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords( 11 | PyObject *, PyObject *, PyObject *); 12 | 13 | /* Inline this */ 14 | #define PyEval_CallObject(func,arg) \ 15 | PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL) 16 | 17 | PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, 18 | const char *format, ...); 19 | PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, 20 | const char *methodname, 21 | const char *format, ...); 22 | 23 | PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); 24 | PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); 25 | 26 | struct _frame; /* Avoid including frameobject.h */ 27 | 28 | PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void); 29 | PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); 30 | PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); 31 | PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void); 32 | PyAPI_FUNC(int) PyEval_GetRestricted(void); 33 | 34 | /* Look at the current frame's (if any) code's co_flags, and turn on 35 | the corresponding compiler flags in cf->cf_flags. Return 1 if any 36 | flag was set, else return 0. */ 37 | PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); 38 | 39 | PyAPI_FUNC(int) Py_FlushLine(void); 40 | 41 | PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg); 42 | PyAPI_FUNC(int) Py_MakePendingCalls(void); 43 | 44 | /* Protection against deeply nested recursive calls */ 45 | PyAPI_FUNC(void) Py_SetRecursionLimit(int); 46 | PyAPI_FUNC(int) Py_GetRecursionLimit(void); 47 | 48 | #define Py_EnterRecursiveCall(where) \ 49 | (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \ 50 | _Py_CheckRecursiveCall(where)) 51 | #define Py_LeaveRecursiveCall() \ 52 | (--PyThreadState_GET()->recursion_depth) 53 | PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where); 54 | PyAPI_DATA(int) _Py_CheckRecursionLimit; 55 | #ifdef USE_STACKCHECK 56 | # define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit) 57 | #else 58 | # define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) 59 | #endif 60 | 61 | PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *); 62 | PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *); 63 | 64 | PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *); 65 | PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *); 66 | PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc); 67 | 68 | /* this used to be handled on a per-thread basis - now just two globals */ 69 | PyAPI_DATA(volatile int) _Py_Ticker; 70 | PyAPI_DATA(int) _Py_CheckInterval; 71 | 72 | /* Interface for threads. 73 | 74 | A module that plans to do a blocking system call (or something else 75 | that lasts a long time and doesn't touch Python data) can allow other 76 | threads to run as follows: 77 | 78 | ...preparations here... 79 | Py_BEGIN_ALLOW_THREADS 80 | ...blocking system call here... 81 | Py_END_ALLOW_THREADS 82 | ...interpret result here... 83 | 84 | The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a 85 | {}-surrounded block. 86 | To leave the block in the middle (e.g., with return), you must insert 87 | a line containing Py_BLOCK_THREADS before the return, e.g. 88 | 89 | if (...premature_exit...) { 90 | Py_BLOCK_THREADS 91 | PyErr_SetFromErrno(PyExc_IOError); 92 | return NULL; 93 | } 94 | 95 | An alternative is: 96 | 97 | Py_BLOCK_THREADS 98 | if (...premature_exit...) { 99 | PyErr_SetFromErrno(PyExc_IOError); 100 | return NULL; 101 | } 102 | Py_UNBLOCK_THREADS 103 | 104 | For convenience, that the value of 'errno' is restored across 105 | Py_END_ALLOW_THREADS and Py_BLOCK_THREADS. 106 | 107 | WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND 108 | Py_END_ALLOW_THREADS!!! 109 | 110 | The function PyEval_InitThreads() should be called only from 111 | initthread() in "threadmodule.c". 112 | 113 | Note that not yet all candidates have been converted to use this 114 | mechanism! 115 | */ 116 | 117 | PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void); 118 | PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *); 119 | 120 | #ifdef WITH_THREAD 121 | 122 | PyAPI_FUNC(int) PyEval_ThreadsInitialized(void); 123 | PyAPI_FUNC(void) PyEval_InitThreads(void); 124 | PyAPI_FUNC(void) PyEval_AcquireLock(void); 125 | PyAPI_FUNC(void) PyEval_ReleaseLock(void); 126 | PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); 127 | PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); 128 | PyAPI_FUNC(void) PyEval_ReInitThreads(void); 129 | 130 | #define Py_BEGIN_ALLOW_THREADS { \ 131 | PyThreadState *_save; \ 132 | _save = PyEval_SaveThread(); 133 | #define Py_BLOCK_THREADS PyEval_RestoreThread(_save); 134 | #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); 135 | #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ 136 | } 137 | 138 | #else /* !WITH_THREAD */ 139 | 140 | #define Py_BEGIN_ALLOW_THREADS { 141 | #define Py_BLOCK_THREADS 142 | #define Py_UNBLOCK_THREADS 143 | #define Py_END_ALLOW_THREADS } 144 | 145 | #endif /* !WITH_THREAD */ 146 | 147 | PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *); 148 | 149 | 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | #endif /* !Py_CEVAL_H */ 154 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/classobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Class object interface */ 3 | 4 | /* Revealing some structures (not for general use) */ 5 | 6 | #ifndef Py_CLASSOBJECT_H 7 | #define Py_CLASSOBJECT_H 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef struct { 13 | PyObject_HEAD 14 | PyObject *cl_bases; /* A tuple of class objects */ 15 | PyObject *cl_dict; /* A dictionary */ 16 | PyObject *cl_name; /* A string */ 17 | /* The following three are functions or NULL */ 18 | PyObject *cl_getattr; 19 | PyObject *cl_setattr; 20 | PyObject *cl_delattr; 21 | PyObject *cl_weakreflist; /* List of weak references */ 22 | } PyClassObject; 23 | 24 | typedef struct { 25 | PyObject_HEAD 26 | PyClassObject *in_class; /* The class object */ 27 | PyObject *in_dict; /* A dictionary */ 28 | PyObject *in_weakreflist; /* List of weak references */ 29 | } PyInstanceObject; 30 | 31 | typedef struct { 32 | PyObject_HEAD 33 | PyObject *im_func; /* The callable object implementing the method */ 34 | PyObject *im_self; /* The instance it is bound to, or NULL */ 35 | PyObject *im_class; /* The class that asked for the method */ 36 | PyObject *im_weakreflist; /* List of weak references */ 37 | } PyMethodObject; 38 | 39 | PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type; 40 | 41 | #define PyClass_Check(op) ((op)->ob_type == &PyClass_Type) 42 | #define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type) 43 | #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) 44 | 45 | PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *); 46 | PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *, 47 | PyObject *); 48 | PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *); 49 | PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *); 50 | 51 | PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); 52 | PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); 53 | PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *); 54 | 55 | /* Look up attribute with name (a string) on instance object pinst, using 56 | * only the instance and base class dicts. If a descriptor is found in 57 | * a class dict, the descriptor is returned without calling it. 58 | * Returns NULL if nothing found, else a borrowed reference to the 59 | * value associated with name in the dict in which name was found. 60 | * The point of this routine is that it never calls arbitrary Python 61 | * code, so is always "safe": all it does is dict lookups. The function 62 | * can't fail, never sets an exception, and NULL is not an error (it just 63 | * means "not found"). 64 | */ 65 | PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name); 66 | 67 | /* Macros for direct access to these values. Type checks are *not* 68 | done, so use with care. */ 69 | #define PyMethod_GET_FUNCTION(meth) \ 70 | (((PyMethodObject *)meth) -> im_func) 71 | #define PyMethod_GET_SELF(meth) \ 72 | (((PyMethodObject *)meth) -> im_self) 73 | #define PyMethod_GET_CLASS(meth) \ 74 | (((PyMethodObject *)meth) -> im_class) 75 | 76 | PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *); 77 | 78 | PyAPI_FUNC(int) PyMethod_ClearFreeList(void); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #endif /* !Py_CLASSOBJECT_H */ 84 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/cobject.h: -------------------------------------------------------------------------------- 1 | /* 2 | CObjects are marked Pending Deprecation as of Python 2.7. 3 | The full schedule for 2.x is as follows: 4 | - CObjects are marked Pending Deprecation in Python 2.7. 5 | - CObjects will be marked Deprecated in Python 2.8 6 | (if there is one). 7 | - CObjects will be removed in Python 2.9 (if there is one). 8 | 9 | Additionally, for the Python 3.x series: 10 | - CObjects were marked Deprecated in Python 3.1. 11 | - CObjects will be removed in Python 3.2. 12 | 13 | You should switch all use of CObjects to capsules. Capsules 14 | have a safer and more consistent API. For more information, 15 | see Include/pycapsule.h, or read the "Capsules" topic in 16 | the "Python/C API Reference Manual". 17 | 18 | Python 2.7 no longer uses CObjects itself; all objects which 19 | were formerly CObjects are now capsules. Note that this change 20 | does not by itself break binary compatibility with extensions 21 | built for previous versions of Python--PyCObject_AsVoidPtr() 22 | has been changed to also understand capsules. 23 | 24 | */ 25 | 26 | /* original file header comment follows: */ 27 | 28 | /* C objects to be exported from one extension module to another. 29 | 30 | C objects are used for communication between extension modules. 31 | They provide a way for an extension module to export a C interface 32 | to other extension modules, so that extension modules can use the 33 | Python import mechanism to link to one another. 34 | 35 | */ 36 | 37 | #ifndef Py_COBJECT_H 38 | #define Py_COBJECT_H 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | PyAPI_DATA(PyTypeObject) PyCObject_Type; 44 | 45 | #define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type) 46 | 47 | /* Create a PyCObject from a pointer to a C object and an optional 48 | destructor function. If the second argument is non-null, then it 49 | will be called with the first argument if and when the PyCObject is 50 | destroyed. 51 | 52 | */ 53 | PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( 54 | void *cobj, void (*destruct)(void*)); 55 | 56 | 57 | /* Create a PyCObject from a pointer to a C object, a description object, 58 | and an optional destructor function. If the third argument is non-null, 59 | then it will be called with the first and second arguments if and when 60 | the PyCObject is destroyed. 61 | */ 62 | PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( 63 | void *cobj, void *desc, void (*destruct)(void*,void*)); 64 | 65 | /* Retrieve a pointer to a C object from a PyCObject. */ 66 | PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); 67 | 68 | /* Retrieve a pointer to a description object from a PyCObject. */ 69 | PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *); 70 | 71 | /* Import a pointer to a C object from a module using a PyCObject. */ 72 | PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name); 73 | 74 | /* Modify a C object. Fails (==0) if object has a destructor. */ 75 | PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj); 76 | 77 | 78 | typedef struct { 79 | PyObject_HEAD 80 | void *cobject; 81 | void *desc; 82 | void (*destructor)(void *); 83 | } PyCObject; 84 | 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif /* !Py_COBJECT_H */ 90 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/code.h: -------------------------------------------------------------------------------- 1 | /* Definitions for bytecode */ 2 | 3 | #ifndef Py_CODE_H 4 | #define Py_CODE_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /* Bytecode object */ 10 | typedef struct { 11 | PyObject_HEAD 12 | int co_argcount; /* #arguments, except *args */ 13 | int co_nlocals; /* #local variables */ 14 | int co_stacksize; /* #entries needed for evaluation stack */ 15 | int co_flags; /* CO_..., see below */ 16 | PyObject *co_code; /* instruction opcodes */ 17 | PyObject *co_consts; /* list (constants used) */ 18 | PyObject *co_names; /* list of strings (names used) */ 19 | PyObject *co_varnames; /* tuple of strings (local variable names) */ 20 | PyObject *co_freevars; /* tuple of strings (free variable names) */ 21 | PyObject *co_cellvars; /* tuple of strings (cell variable names) */ 22 | /* The rest doesn't count for hash/cmp */ 23 | PyObject *co_filename; /* string (where it was loaded from) */ 24 | PyObject *co_name; /* string (name, for reference) */ 25 | int co_firstlineno; /* first source line number */ 26 | PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See 27 | Objects/lnotab_notes.txt for details. */ 28 | void *co_zombieframe; /* for optimization only (see frameobject.c) */ 29 | PyObject *co_weakreflist; /* to support weakrefs to code objects */ 30 | } PyCodeObject; 31 | 32 | /* Masks for co_flags above */ 33 | #define CO_OPTIMIZED 0x0001 34 | #define CO_NEWLOCALS 0x0002 35 | #define CO_VARARGS 0x0004 36 | #define CO_VARKEYWORDS 0x0008 37 | #define CO_NESTED 0x0010 38 | #define CO_GENERATOR 0x0020 39 | /* The CO_NOFREE flag is set if there are no free or cell variables. 40 | This information is redundant, but it allows a single flag test 41 | to determine whether there is any extra work to be done when the 42 | call frame it setup. 43 | */ 44 | #define CO_NOFREE 0x0040 45 | 46 | #if 0 47 | /* This is no longer used. Stopped defining in 2.5, do not re-use. */ 48 | #define CO_GENERATOR_ALLOWED 0x1000 49 | #endif 50 | #define CO_FUTURE_DIVISION 0x2000 51 | #define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */ 52 | #define CO_FUTURE_WITH_STATEMENT 0x8000 53 | #define CO_FUTURE_PRINT_FUNCTION 0x10000 54 | #define CO_FUTURE_UNICODE_LITERALS 0x20000 55 | 56 | /* This should be defined if a future statement modifies the syntax. 57 | For example, when a keyword is added. 58 | */ 59 | #if 1 60 | #define PY_PARSER_REQUIRES_FUTURE_KEYWORD 61 | #endif 62 | 63 | #define CO_MAXBLOCKS 20 /* Max static block nesting within a function */ 64 | 65 | PyAPI_DATA(PyTypeObject) PyCode_Type; 66 | 67 | #define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type) 68 | #define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) 69 | 70 | /* Public interface */ 71 | PyAPI_FUNC(PyCodeObject *) PyCode_New( 72 | int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, 73 | PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); 74 | /* same as struct above */ 75 | 76 | /* Creates a new empty code object with the specified source location. */ 77 | PyAPI_FUNC(PyCodeObject *) 78 | PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); 79 | 80 | /* Return the line number associated with the specified bytecode index 81 | in this code object. If you just need the line number of a frame, 82 | use PyFrame_GetLineNumber() instead. */ 83 | PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); 84 | 85 | /* for internal use only */ 86 | #define _PyCode_GETCODEPTR(co, pp) \ 87 | ((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \ 88 | ((co)->co_code, 0, (void **)(pp))) 89 | 90 | typedef struct _addr_pair { 91 | int ap_lower; 92 | int ap_upper; 93 | } PyAddrPair; 94 | 95 | /* Update *bounds to describe the first and one-past-the-last instructions in the 96 | same line as lasti. Return the number of that line. 97 | */ 98 | PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co, 99 | int lasti, PyAddrPair *bounds); 100 | 101 | PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, 102 | PyObject *names, PyObject *lineno_obj); 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | #endif /* !Py_CODE_H */ 108 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/codecs.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_CODECREGISTRY_H 2 | #define Py_CODECREGISTRY_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | /* ------------------------------------------------------------------------ 8 | 9 | Python Codec Registry and support functions 10 | 11 | 12 | Written by Marc-Andre Lemburg (mal@lemburg.com). 13 | 14 | Copyright (c) Corporation for National Research Initiatives. 15 | 16 | ------------------------------------------------------------------------ */ 17 | 18 | /* Register a new codec search function. 19 | 20 | As side effect, this tries to load the encodings package, if not 21 | yet done, to make sure that it is always first in the list of 22 | search functions. 23 | 24 | The search_function's refcount is incremented by this function. */ 25 | 26 | PyAPI_FUNC(int) PyCodec_Register( 27 | PyObject *search_function 28 | ); 29 | 30 | /* Codec register lookup API. 31 | 32 | Looks up the given encoding and returns a CodecInfo object with 33 | function attributes which implement the different aspects of 34 | processing the encoding. 35 | 36 | The encoding string is looked up converted to all lower-case 37 | characters. This makes encodings looked up through this mechanism 38 | effectively case-insensitive. 39 | 40 | If no codec is found, a KeyError is set and NULL returned. 41 | 42 | As side effect, this tries to load the encodings package, if not 43 | yet done. This is part of the lazy load strategy for the encodings 44 | package. 45 | 46 | */ 47 | 48 | PyAPI_FUNC(PyObject *) _PyCodec_Lookup( 49 | const char *encoding 50 | ); 51 | 52 | /* Generic codec based encoding API. 53 | 54 | object is passed through the encoder function found for the given 55 | encoding using the error handling method defined by errors. errors 56 | may be NULL to use the default method defined for the codec. 57 | 58 | Raises a LookupError in case no encoder can be found. 59 | 60 | */ 61 | 62 | PyAPI_FUNC(PyObject *) PyCodec_Encode( 63 | PyObject *object, 64 | const char *encoding, 65 | const char *errors 66 | ); 67 | 68 | /* Generic codec based decoding API. 69 | 70 | object is passed through the decoder function found for the given 71 | encoding using the error handling method defined by errors. errors 72 | may be NULL to use the default method defined for the codec. 73 | 74 | Raises a LookupError in case no encoder can be found. 75 | 76 | */ 77 | 78 | PyAPI_FUNC(PyObject *) PyCodec_Decode( 79 | PyObject *object, 80 | const char *encoding, 81 | const char *errors 82 | ); 83 | 84 | /* --- Codec Lookup APIs -------------------------------------------------- 85 | 86 | All APIs return a codec object with incremented refcount and are 87 | based on _PyCodec_Lookup(). The same comments w/r to the encoding 88 | name also apply to these APIs. 89 | 90 | */ 91 | 92 | /* Get an encoder function for the given encoding. */ 93 | 94 | PyAPI_FUNC(PyObject *) PyCodec_Encoder( 95 | const char *encoding 96 | ); 97 | 98 | /* Get a decoder function for the given encoding. */ 99 | 100 | PyAPI_FUNC(PyObject *) PyCodec_Decoder( 101 | const char *encoding 102 | ); 103 | 104 | /* Get a IncrementalEncoder object for the given encoding. */ 105 | 106 | PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder( 107 | const char *encoding, 108 | const char *errors 109 | ); 110 | 111 | /* Get a IncrementalDecoder object function for the given encoding. */ 112 | 113 | PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder( 114 | const char *encoding, 115 | const char *errors 116 | ); 117 | 118 | /* Get a StreamReader factory function for the given encoding. */ 119 | 120 | PyAPI_FUNC(PyObject *) PyCodec_StreamReader( 121 | const char *encoding, 122 | PyObject *stream, 123 | const char *errors 124 | ); 125 | 126 | /* Get a StreamWriter factory function for the given encoding. */ 127 | 128 | PyAPI_FUNC(PyObject *) PyCodec_StreamWriter( 129 | const char *encoding, 130 | PyObject *stream, 131 | const char *errors 132 | ); 133 | 134 | /* Unicode encoding error handling callback registry API */ 135 | 136 | /* Register the error handling callback function error under the given 137 | name. This function will be called by the codec when it encounters 138 | unencodable characters/undecodable bytes and doesn't know the 139 | callback name, when name is specified as the error parameter 140 | in the call to the encode/decode function. 141 | Return 0 on success, -1 on error */ 142 | PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error); 143 | 144 | /* Lookup the error handling callback function registered under the given 145 | name. As a special case NULL can be passed, in which case 146 | the error handling callback for "strict" will be returned. */ 147 | PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name); 148 | 149 | /* raise exc as an exception */ 150 | PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc); 151 | 152 | /* ignore the unicode error, skipping the faulty input */ 153 | PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc); 154 | 155 | /* replace the unicode encode error with ? or U+FFFD */ 156 | PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc); 157 | 158 | /* replace the unicode encode error with XML character references */ 159 | PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc); 160 | 161 | /* replace the unicode encode error with backslash escapes (\x, \u and \U) */ 162 | PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc); 163 | 164 | #ifdef __cplusplus 165 | } 166 | #endif 167 | #endif /* !Py_CODECREGISTRY_H */ 168 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/compile.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_COMPILE_H 3 | #define Py_COMPILE_H 4 | 5 | #include "code.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | /* Public interface */ 12 | struct _node; /* Declare the existence of this type */ 13 | PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *); 14 | 15 | /* Future feature support */ 16 | 17 | typedef struct { 18 | int ff_features; /* flags set by future statements */ 19 | int ff_lineno; /* line number of last future statement */ 20 | } PyFutureFeatures; 21 | 22 | #define FUTURE_NESTED_SCOPES "nested_scopes" 23 | #define FUTURE_GENERATORS "generators" 24 | #define FUTURE_DIVISION "division" 25 | #define FUTURE_ABSOLUTE_IMPORT "absolute_import" 26 | #define FUTURE_WITH_STATEMENT "with_statement" 27 | #define FUTURE_PRINT_FUNCTION "print_function" 28 | #define FUTURE_UNICODE_LITERALS "unicode_literals" 29 | 30 | 31 | struct _mod; /* Declare the existence of this type */ 32 | PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *, 33 | PyCompilerFlags *, PyArena *); 34 | PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *); 35 | 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif /* !Py_COMPILE_H */ 41 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/complexobject.h: -------------------------------------------------------------------------------- 1 | /* Complex number structure */ 2 | 3 | #ifndef Py_COMPLEXOBJECT_H 4 | #define Py_COMPLEXOBJECT_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct { 10 | double real; 11 | double imag; 12 | } Py_complex; 13 | 14 | /* Operations on complex numbers from complexmodule.c */ 15 | 16 | #define c_sum _Py_c_sum 17 | #define c_diff _Py_c_diff 18 | #define c_neg _Py_c_neg 19 | #define c_prod _Py_c_prod 20 | #define c_quot _Py_c_quot 21 | #define c_pow _Py_c_pow 22 | #define c_abs _Py_c_abs 23 | 24 | PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex); 25 | PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex); 26 | PyAPI_FUNC(Py_complex) c_neg(Py_complex); 27 | PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex); 28 | PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex); 29 | PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex); 30 | PyAPI_FUNC(double) c_abs(Py_complex); 31 | 32 | 33 | /* Complex object interface */ 34 | 35 | /* 36 | PyComplexObject represents a complex number with double-precision 37 | real and imaginary parts. 38 | */ 39 | 40 | typedef struct { 41 | PyObject_HEAD 42 | Py_complex cval; 43 | } PyComplexObject; 44 | 45 | PyAPI_DATA(PyTypeObject) PyComplex_Type; 46 | 47 | #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) 48 | #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type) 49 | 50 | PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); 51 | PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); 52 | 53 | PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); 54 | PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); 55 | PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); 56 | 57 | /* Format the object based on the format_spec, as defined in PEP 3101 58 | (Advanced String Formatting). */ 59 | PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj, 60 | char *format_spec, 61 | Py_ssize_t format_spec_len); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | #endif /* !Py_COMPLEXOBJECT_H */ 67 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/descrobject.h: -------------------------------------------------------------------------------- 1 | /* Descriptors */ 2 | #ifndef Py_DESCROBJECT_H 3 | #define Py_DESCROBJECT_H 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef PyObject *(*getter)(PyObject *, void *); 9 | typedef int (*setter)(PyObject *, PyObject *, void *); 10 | 11 | typedef struct PyGetSetDef { 12 | char *name; 13 | getter get; 14 | setter set; 15 | char *doc; 16 | void *closure; 17 | } PyGetSetDef; 18 | 19 | typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, 20 | void *wrapped); 21 | 22 | typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, 23 | void *wrapped, PyObject *kwds); 24 | 25 | struct wrapperbase { 26 | char *name; 27 | int offset; 28 | void *function; 29 | wrapperfunc wrapper; 30 | char *doc; 31 | int flags; 32 | PyObject *name_strobj; 33 | }; 34 | 35 | /* Flags for above struct */ 36 | #define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ 37 | 38 | /* Various kinds of descriptor objects */ 39 | 40 | #define PyDescr_COMMON \ 41 | PyObject_HEAD \ 42 | PyTypeObject *d_type; \ 43 | PyObject *d_name 44 | 45 | typedef struct { 46 | PyDescr_COMMON; 47 | } PyDescrObject; 48 | 49 | typedef struct { 50 | PyDescr_COMMON; 51 | PyMethodDef *d_method; 52 | } PyMethodDescrObject; 53 | 54 | typedef struct { 55 | PyDescr_COMMON; 56 | struct PyMemberDef *d_member; 57 | } PyMemberDescrObject; 58 | 59 | typedef struct { 60 | PyDescr_COMMON; 61 | PyGetSetDef *d_getset; 62 | } PyGetSetDescrObject; 63 | 64 | typedef struct { 65 | PyDescr_COMMON; 66 | struct wrapperbase *d_base; 67 | void *d_wrapped; /* This can be any function pointer */ 68 | } PyWrapperDescrObject; 69 | 70 | PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; 71 | PyAPI_DATA(PyTypeObject) PyDictProxy_Type; 72 | PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; 73 | PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; 74 | 75 | PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); 76 | PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); 77 | PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, 78 | struct PyMemberDef *); 79 | PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, 80 | struct PyGetSetDef *); 81 | PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, 82 | struct wrapperbase *, void *); 83 | #define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) 84 | 85 | PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); 86 | PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); 87 | 88 | 89 | PyAPI_DATA(PyTypeObject) PyProperty_Type; 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif /* !Py_DESCROBJECT_H */ 94 | 95 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/dtoa.h: -------------------------------------------------------------------------------- 1 | #ifndef PY_NO_SHORT_FLOAT_REPR 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr); 7 | PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits, 8 | int *decpt, int *sign, char **rve); 9 | PyAPI_FUNC(void) _Py_dg_freedtoa(char *s); 10 | 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/enumobject.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_ENUMOBJECT_H 2 | #define Py_ENUMOBJECT_H 3 | 4 | /* Enumerate Object */ 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | PyAPI_DATA(PyTypeObject) PyEnum_Type; 11 | PyAPI_DATA(PyTypeObject) PyReversed_Type; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif /* !Py_ENUMOBJECT_H */ 18 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/errcode.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_ERRCODE_H 2 | #define Py_ERRCODE_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* Error codes passed around between file input, tokenizer, parser and 9 | interpreter. This is necessary so we can turn them into Python 10 | exceptions at a higher level. Note that some errors have a 11 | slightly different meaning when passed from the tokenizer to the 12 | parser than when passed from the parser to the interpreter; e.g. 13 | the parser only returns E_EOF when it hits EOF immediately, and it 14 | never returns E_OK. */ 15 | 16 | #define E_OK 10 /* No error */ 17 | #define E_EOF 11 /* End Of File */ 18 | #define E_INTR 12 /* Interrupted */ 19 | #define E_TOKEN 13 /* Bad token */ 20 | #define E_SYNTAX 14 /* Syntax error */ 21 | #define E_NOMEM 15 /* Ran out of memory */ 22 | #define E_DONE 16 /* Parsing complete */ 23 | #define E_ERROR 17 /* Execution error */ 24 | #define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */ 25 | #define E_OVERFLOW 19 /* Node had too many children */ 26 | #define E_TOODEEP 20 /* Too many indentation levels */ 27 | #define E_DEDENT 21 /* No matching outer block for dedent */ 28 | #define E_DECODE 22 /* Error in decoding into Unicode */ 29 | #define E_EOFS 23 /* EOF in triple-quoted string */ 30 | #define E_EOLS 24 /* EOL in single-quoted string */ 31 | #define E_LINECONT 25 /* Unexpected characters after a line continuation */ 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | #endif /* !Py_ERRCODE_H */ 37 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/eval.h: -------------------------------------------------------------------------------- 1 | 2 | /* Interface to execute compiled code */ 3 | 4 | #ifndef Py_EVAL_H 5 | #define Py_EVAL_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *); 11 | 12 | PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co, 13 | PyObject *globals, 14 | PyObject *locals, 15 | PyObject **args, int argc, 16 | PyObject **kwds, int kwdc, 17 | PyObject **defs, int defc, 18 | PyObject *closure); 19 | 20 | PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | #endif /* !Py_EVAL_H */ 26 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/fileobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* File object interface */ 3 | 4 | #ifndef Py_FILEOBJECT_H 5 | #define Py_FILEOBJECT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | PyObject_HEAD 12 | FILE *f_fp; 13 | PyObject *f_name; 14 | PyObject *f_mode; 15 | int (*f_close)(FILE *); 16 | int f_softspace; /* Flag used by 'print' command */ 17 | int f_binary; /* Flag which indicates whether the file is 18 | open in binary (1) or text (0) mode */ 19 | char* f_buf; /* Allocated readahead buffer */ 20 | char* f_bufend; /* Points after last occupied position */ 21 | char* f_bufptr; /* Current buffer position */ 22 | char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */ 23 | int f_univ_newline; /* Handle any newline convention */ 24 | int f_newlinetypes; /* Types of newlines seen */ 25 | int f_skipnextlf; /* Skip next \n */ 26 | PyObject *f_encoding; 27 | PyObject *f_errors; 28 | PyObject *weakreflist; /* List of weak references */ 29 | int unlocked_count; /* Num. currently running sections of code 30 | using f_fp with the GIL released. */ 31 | int readable; 32 | int writable; 33 | } PyFileObject; 34 | 35 | PyAPI_DATA(PyTypeObject) PyFile_Type; 36 | 37 | #define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type) 38 | #define PyFile_CheckExact(op) (Py_TYPE(op) == &PyFile_Type) 39 | 40 | PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *); 41 | PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int); 42 | PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *); 43 | PyAPI_FUNC(int) PyFile_SetEncodingAndErrors(PyObject *, const char *, char *errors); 44 | PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, 45 | int (*)(FILE *)); 46 | PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *); 47 | PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *); 48 | PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *); 49 | PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *); 50 | PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); 51 | PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); 52 | PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int); 53 | PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); 54 | PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); 55 | 56 | /* The default encoding used by the platform file system APIs 57 | If non-NULL, this is different than the default encoding for strings 58 | */ 59 | PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; 60 | 61 | /* Routines to replace fread() and fgets() which accept any of \r, \n 62 | or \r\n as line terminators. 63 | */ 64 | #define PY_STDIOTEXTMODE "b" 65 | char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); 66 | size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *); 67 | 68 | /* A routine to do sanity checking on the file mode string. returns 69 | non-zero on if an exception occurred 70 | */ 71 | int _PyFile_SanitizeMode(char *mode); 72 | 73 | #if defined _MSC_VER && _MSC_VER >= 1400 74 | /* A routine to check if a file descriptor is valid on Windows. Returns 0 75 | * and sets errno to EBADF if it isn't. This is to avoid Assertions 76 | * from various functions in the Windows CRT beginning with 77 | * Visual Studio 2005 78 | */ 79 | int _PyVerify_fd(int fd); 80 | #elif defined _MSC_VER && _MSC_VER >= 1200 81 | /* fdopen doesn't set errno EBADF and crashes for large fd on debug build */ 82 | #define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0) 83 | #else 84 | #define _PyVerify_fd(A) (1) /* dummy */ 85 | #endif 86 | 87 | /* A routine to check if a file descriptor can be select()-ed. */ 88 | #ifdef HAVE_SELECT 89 | #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE)) 90 | #else 91 | #define _PyIsSelectable_fd(FD) (1) 92 | #endif /* HAVE_SELECT */ 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | #endif /* !Py_FILEOBJECT_H */ 98 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/floatobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Float object interface */ 3 | 4 | /* 5 | PyFloatObject represents a (double precision) floating point number. 6 | */ 7 | 8 | #ifndef Py_FLOATOBJECT_H 9 | #define Py_FLOATOBJECT_H 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | typedef struct { 15 | PyObject_HEAD 16 | double ob_fval; 17 | } PyFloatObject; 18 | 19 | PyAPI_DATA(PyTypeObject) PyFloat_Type; 20 | 21 | #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) 22 | #define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type) 23 | 24 | /* The str() precision PyFloat_STR_PRECISION is chosen so that in most cases, 25 | the rounding noise created by various operations is suppressed, while 26 | giving plenty of precision for practical use. */ 27 | 28 | #define PyFloat_STR_PRECISION 12 29 | 30 | #ifdef Py_NAN 31 | #define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN) 32 | #endif 33 | 34 | #define Py_RETURN_INF(sign) do \ 35 | if (copysign(1., sign) == 1.) { \ 36 | return PyFloat_FromDouble(Py_HUGE_VAL); \ 37 | } else { \ 38 | return PyFloat_FromDouble(-Py_HUGE_VAL); \ 39 | } while(0) 40 | 41 | PyAPI_FUNC(double) PyFloat_GetMax(void); 42 | PyAPI_FUNC(double) PyFloat_GetMin(void); 43 | PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void); 44 | 45 | /* Return Python float from string PyObject. Second argument ignored on 46 | input, and, if non-NULL, NULL is stored into *junk (this tried to serve a 47 | purpose once but can't be made to work as intended). */ 48 | PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*, char** junk); 49 | 50 | /* Return Python float from C double. */ 51 | PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double); 52 | 53 | /* Extract C double from Python float. The macro version trades safety for 54 | speed. */ 55 | PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *); 56 | #define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval) 57 | 58 | /* Write repr(v) into the char buffer argument, followed by null byte. The 59 | buffer must be "big enough"; >= 100 is very safe. 60 | PyFloat_AsReprString(buf, x) strives to print enough digits so that 61 | PyFloat_FromString(buf) then reproduces x exactly. */ 62 | PyAPI_FUNC(void) PyFloat_AsReprString(char*, PyFloatObject *v); 63 | 64 | /* Write str(v) into the char buffer argument, followed by null byte. The 65 | buffer must be "big enough"; >= 100 is very safe. Note that it's 66 | unusual to be able to get back the float you started with from 67 | PyFloat_AsString's result -- use PyFloat_AsReprString() if you want to 68 | preserve precision across conversions. */ 69 | PyAPI_FUNC(void) PyFloat_AsString(char*, PyFloatObject *v); 70 | 71 | /* _PyFloat_{Pack,Unpack}{4,8} 72 | * 73 | * The struct and pickle (at least) modules need an efficient platform- 74 | * independent way to store floating-point values as byte strings. 75 | * The Pack routines produce a string from a C double, and the Unpack 76 | * routines produce a C double from such a string. The suffix (4 or 8) 77 | * specifies the number of bytes in the string. 78 | * 79 | * On platforms that appear to use (see _PyFloat_Init()) IEEE-754 formats 80 | * these functions work by copying bits. On other platforms, the formats the 81 | * 4- byte format is identical to the IEEE-754 single precision format, and 82 | * the 8-byte format to the IEEE-754 double precision format, although the 83 | * packing of INFs and NaNs (if such things exist on the platform) isn't 84 | * handled correctly, and attempting to unpack a string containing an IEEE 85 | * INF or NaN will raise an exception. 86 | * 87 | * On non-IEEE platforms with more precision, or larger dynamic range, than 88 | * 754 supports, not all values can be packed; on non-IEEE platforms with less 89 | * precision, or smaller dynamic range, not all values can be unpacked. What 90 | * happens in such cases is partly accidental (alas). 91 | */ 92 | 93 | /* The pack routines write 4 or 8 bytes, starting at p. le is a bool 94 | * argument, true if you want the string in little-endian format (exponent 95 | * last, at p+3 or p+7), false if you want big-endian format (exponent 96 | * first, at p). 97 | * Return value: 0 if all is OK, -1 if error (and an exception is 98 | * set, most likely OverflowError). 99 | * There are two problems on non-IEEE platforms: 100 | * 1): What this does is undefined if x is a NaN or infinity. 101 | * 2): -0.0 and +0.0 produce the same string. 102 | */ 103 | PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le); 104 | PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le); 105 | 106 | /* Used to get the important decimal digits of a double */ 107 | PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum); 108 | PyAPI_FUNC(void) _PyFloat_DigitsInit(void); 109 | 110 | /* The unpack routines read 4 or 8 bytes, starting at p. le is a bool 111 | * argument, true if the string is in little-endian format (exponent 112 | * last, at p+3 or p+7), false if big-endian (exponent first, at p). 113 | * Return value: The unpacked double. On error, this is -1.0 and 114 | * PyErr_Occurred() is true (and an exception is set, most likely 115 | * OverflowError). Note that on a non-IEEE platform this will refuse 116 | * to unpack a string that represents a NaN or infinity. 117 | */ 118 | PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le); 119 | PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le); 120 | 121 | /* free list api */ 122 | PyAPI_FUNC(int) PyFloat_ClearFreeList(void); 123 | 124 | /* Format the object based on the format_spec, as defined in PEP 3101 125 | (Advanced String Formatting). */ 126 | PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj, 127 | char *format_spec, 128 | Py_ssize_t format_spec_len); 129 | 130 | /* Round a C double x to the closest multiple of 10**-ndigits. Returns a 131 | Python float on success, or NULL (with an appropriate exception set) on 132 | failure. Used in builtin_round in bltinmodule.c. */ 133 | PyAPI_FUNC(PyObject *) _Py_double_round(double x, int ndigits); 134 | 135 | 136 | 137 | #ifdef __cplusplus 138 | } 139 | #endif 140 | #endif /* !Py_FLOATOBJECT_H */ 141 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/frameobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Frame object interface */ 3 | 4 | #ifndef Py_FRAMEOBJECT_H 5 | #define Py_FRAMEOBJECT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | int b_type; /* what kind of block this is */ 12 | int b_handler; /* where to jump to find handler */ 13 | int b_level; /* value stack level to pop to */ 14 | } PyTryBlock; 15 | 16 | typedef struct _frame { 17 | PyObject_VAR_HEAD 18 | struct _frame *f_back; /* previous frame, or NULL */ 19 | PyCodeObject *f_code; /* code segment */ 20 | PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ 21 | PyObject *f_globals; /* global symbol table (PyDictObject) */ 22 | PyObject *f_locals; /* local symbol table (any mapping) */ 23 | PyObject **f_valuestack; /* points after the last local */ 24 | /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. 25 | Frame evaluation usually NULLs it, but a frame that yields sets it 26 | to the current stack top. */ 27 | PyObject **f_stacktop; 28 | PyObject *f_trace; /* Trace function */ 29 | 30 | /* If an exception is raised in this frame, the next three are used to 31 | * record the exception info (if any) originally in the thread state. See 32 | * comments before set_exc_info() -- it's not obvious. 33 | * Invariant: if _type is NULL, then so are _value and _traceback. 34 | * Desired invariant: all three are NULL, or all three are non-NULL. That 35 | * one isn't currently true, but "should be". 36 | */ 37 | PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; 38 | 39 | PyThreadState *f_tstate; 40 | int f_lasti; /* Last instruction if called */ 41 | /* Call PyFrame_GetLineNumber() instead of reading this field 42 | directly. As of 2.3 f_lineno is only valid when tracing is 43 | active (i.e. when f_trace is set). At other times we use 44 | PyCode_Addr2Line to calculate the line from the current 45 | bytecode index. */ 46 | int f_lineno; /* Current line number */ 47 | int f_iblock; /* index in f_blockstack */ 48 | PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ 49 | PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ 50 | } PyFrameObject; 51 | 52 | 53 | /* Standard object interface */ 54 | 55 | PyAPI_DATA(PyTypeObject) PyFrame_Type; 56 | 57 | #define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) 58 | #define PyFrame_IsRestricted(f) \ 59 | ((f)->f_builtins != (f)->f_tstate->interp->builtins) 60 | 61 | PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, 62 | PyObject *, PyObject *); 63 | 64 | 65 | /* The rest of the interface is specific for frame objects */ 66 | 67 | /* Block management functions */ 68 | 69 | PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); 70 | PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); 71 | 72 | /* Extend the value stack */ 73 | 74 | PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); 75 | 76 | /* Conversions between "fast locals" and locals in dictionary */ 77 | 78 | PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); 79 | PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); 80 | 81 | PyAPI_FUNC(int) PyFrame_ClearFreeList(void); 82 | 83 | /* Return the line of code the frame is currently executing. */ 84 | PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif /* !Py_FRAMEOBJECT_H */ 90 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/funcobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Function object interface */ 3 | 4 | #ifndef Py_FUNCOBJECT_H 5 | #define Py_FUNCOBJECT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /* Function objects and code objects should not be confused with each other: 11 | * 12 | * Function objects are created by the execution of the 'def' statement. 13 | * They reference a code object in their func_code attribute, which is a 14 | * purely syntactic object, i.e. nothing more than a compiled version of some 15 | * source code lines. There is one code object per source code "fragment", 16 | * but each code object can be referenced by zero or many function objects 17 | * depending only on how many times the 'def' statement in the source was 18 | * executed so far. 19 | */ 20 | 21 | typedef struct { 22 | PyObject_HEAD 23 | PyObject *func_code; /* A code object */ 24 | PyObject *func_globals; /* A dictionary (other mappings won't do) */ 25 | PyObject *func_defaults; /* NULL or a tuple */ 26 | PyObject *func_closure; /* NULL or a tuple of cell objects */ 27 | PyObject *func_doc; /* The __doc__ attribute, can be anything */ 28 | PyObject *func_name; /* The __name__ attribute, a string object */ 29 | PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */ 30 | PyObject *func_weakreflist; /* List of weak references */ 31 | PyObject *func_module; /* The __module__ attribute, can be anything */ 32 | 33 | /* Invariant: 34 | * func_closure contains the bindings for func_code->co_freevars, so 35 | * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code) 36 | * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0). 37 | */ 38 | } PyFunctionObject; 39 | 40 | PyAPI_DATA(PyTypeObject) PyFunction_Type; 41 | 42 | #define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type) 43 | 44 | PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); 45 | PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); 46 | PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); 47 | PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); 48 | PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); 49 | PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); 50 | PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); 51 | PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); 52 | 53 | /* Macros for direct access to these values. Type checks are *not* 54 | done, so use with care. */ 55 | #define PyFunction_GET_CODE(func) \ 56 | (((PyFunctionObject *)func) -> func_code) 57 | #define PyFunction_GET_GLOBALS(func) \ 58 | (((PyFunctionObject *)func) -> func_globals) 59 | #define PyFunction_GET_MODULE(func) \ 60 | (((PyFunctionObject *)func) -> func_module) 61 | #define PyFunction_GET_DEFAULTS(func) \ 62 | (((PyFunctionObject *)func) -> func_defaults) 63 | #define PyFunction_GET_CLOSURE(func) \ 64 | (((PyFunctionObject *)func) -> func_closure) 65 | 66 | /* The classmethod and staticmethod types lives here, too */ 67 | PyAPI_DATA(PyTypeObject) PyClassMethod_Type; 68 | PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; 69 | 70 | PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); 71 | PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | #endif /* !Py_FUNCOBJECT_H */ 77 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/genobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Generator object interface */ 3 | 4 | #ifndef Py_GENOBJECT_H 5 | #define Py_GENOBJECT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | struct _frame; /* Avoid including frameobject.h */ 11 | 12 | typedef struct { 13 | PyObject_HEAD 14 | /* The gi_ prefix is intended to remind of generator-iterator. */ 15 | 16 | /* Note: gi_frame can be NULL if the generator is "finished" */ 17 | struct _frame *gi_frame; 18 | 19 | /* True if generator is being executed. */ 20 | int gi_running; 21 | 22 | /* The code object backing the generator */ 23 | PyObject *gi_code; 24 | 25 | /* List of weak reference. */ 26 | PyObject *gi_weakreflist; 27 | } PyGenObject; 28 | 29 | PyAPI_DATA(PyTypeObject) PyGen_Type; 30 | 31 | #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) 32 | #define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) 33 | 34 | PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); 35 | PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif /* !Py_GENOBJECT_H */ 41 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/graminit.h: -------------------------------------------------------------------------------- 1 | /* Generated by Parser/pgen */ 2 | 3 | #define single_input 256 4 | #define file_input 257 5 | #define eval_input 258 6 | #define decorator 259 7 | #define decorators 260 8 | #define decorated 261 9 | #define funcdef 262 10 | #define parameters 263 11 | #define varargslist 264 12 | #define fpdef 265 13 | #define fplist 266 14 | #define stmt 267 15 | #define simple_stmt 268 16 | #define small_stmt 269 17 | #define expr_stmt 270 18 | #define augassign 271 19 | #define print_stmt 272 20 | #define del_stmt 273 21 | #define pass_stmt 274 22 | #define flow_stmt 275 23 | #define break_stmt 276 24 | #define continue_stmt 277 25 | #define return_stmt 278 26 | #define yield_stmt 279 27 | #define raise_stmt 280 28 | #define import_stmt 281 29 | #define import_name 282 30 | #define import_from 283 31 | #define import_as_name 284 32 | #define dotted_as_name 285 33 | #define import_as_names 286 34 | #define dotted_as_names 287 35 | #define dotted_name 288 36 | #define global_stmt 289 37 | #define exec_stmt 290 38 | #define assert_stmt 291 39 | #define compound_stmt 292 40 | #define if_stmt 293 41 | #define while_stmt 294 42 | #define for_stmt 295 43 | #define try_stmt 296 44 | #define with_stmt 297 45 | #define with_item 298 46 | #define except_clause 299 47 | #define suite 300 48 | #define testlist_safe 301 49 | #define old_test 302 50 | #define old_lambdef 303 51 | #define test 304 52 | #define or_test 305 53 | #define and_test 306 54 | #define not_test 307 55 | #define comparison 308 56 | #define comp_op 309 57 | #define expr 310 58 | #define xor_expr 311 59 | #define and_expr 312 60 | #define shift_expr 313 61 | #define arith_expr 314 62 | #define term 315 63 | #define factor 316 64 | #define power 317 65 | #define atom 318 66 | #define listmaker 319 67 | #define testlist_comp 320 68 | #define lambdef 321 69 | #define trailer 322 70 | #define subscriptlist 323 71 | #define subscript 324 72 | #define sliceop 325 73 | #define exprlist 326 74 | #define testlist 327 75 | #define dictorsetmaker 328 76 | #define classdef 329 77 | #define arglist 330 78 | #define argument 331 79 | #define list_iter 332 80 | #define list_for 333 81 | #define list_if 334 82 | #define comp_iter 335 83 | #define comp_for 336 84 | #define comp_if 337 85 | #define testlist1 338 86 | #define encoding_decl 339 87 | #define yield_expr 340 88 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/grammar.h: -------------------------------------------------------------------------------- 1 | 2 | /* Grammar interface */ 3 | 4 | #ifndef Py_GRAMMAR_H 5 | #define Py_GRAMMAR_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #include "bitset.h" /* Sigh... */ 11 | 12 | /* A label of an arc */ 13 | 14 | typedef struct { 15 | int lb_type; 16 | char *lb_str; 17 | } label; 18 | 19 | #define EMPTY 0 /* Label number 0 is by definition the empty label */ 20 | 21 | /* A list of labels */ 22 | 23 | typedef struct { 24 | int ll_nlabels; 25 | label *ll_label; 26 | } labellist; 27 | 28 | /* An arc from one state to another */ 29 | 30 | typedef struct { 31 | short a_lbl; /* Label of this arc */ 32 | short a_arrow; /* State where this arc goes to */ 33 | } arc; 34 | 35 | /* A state in a DFA */ 36 | 37 | typedef struct { 38 | int s_narcs; 39 | arc *s_arc; /* Array of arcs */ 40 | 41 | /* Optional accelerators */ 42 | int s_lower; /* Lowest label index */ 43 | int s_upper; /* Highest label index */ 44 | int *s_accel; /* Accelerator */ 45 | int s_accept; /* Nonzero for accepting state */ 46 | } state; 47 | 48 | /* A DFA */ 49 | 50 | typedef struct { 51 | int d_type; /* Non-terminal this represents */ 52 | char *d_name; /* For printing */ 53 | int d_initial; /* Initial state */ 54 | int d_nstates; 55 | state *d_state; /* Array of states */ 56 | bitset d_first; 57 | } dfa; 58 | 59 | /* A grammar */ 60 | 61 | typedef struct { 62 | int g_ndfas; 63 | dfa *g_dfa; /* Array of DFAs */ 64 | labellist g_ll; 65 | int g_start; /* Start symbol of the grammar */ 66 | int g_accel; /* Set if accelerators present */ 67 | } grammar; 68 | 69 | /* FUNCTIONS */ 70 | 71 | grammar *newgrammar(int start); 72 | dfa *adddfa(grammar *g, int type, char *name); 73 | int addstate(dfa *d); 74 | void addarc(dfa *d, int from, int to, int lbl); 75 | dfa *PyGrammar_FindDFA(grammar *g, int type); 76 | 77 | int addlabel(labellist *ll, int type, char *str); 78 | int findlabel(labellist *ll, int type, char *str); 79 | char *PyGrammar_LabelRepr(label *lb); 80 | void translatelabels(grammar *g); 81 | 82 | void addfirstsets(grammar *g); 83 | 84 | void PyGrammar_AddAccelerators(grammar *g); 85 | void PyGrammar_RemoveAccelerators(grammar *); 86 | 87 | void printgrammar(grammar *g, FILE *fp); 88 | void printnonterminals(grammar *g, FILE *fp); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif /* !Py_GRAMMAR_H */ 94 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/import.h: -------------------------------------------------------------------------------- 1 | 2 | /* Module definition and import interface */ 3 | 4 | #ifndef Py_IMPORT_H 5 | #define Py_IMPORT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | PyAPI_FUNC(long) PyImport_GetMagicNumber(void); 11 | PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co); 12 | PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( 13 | char *name, PyObject *co, char *pathname); 14 | PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); 15 | PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name); 16 | PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name); 17 | PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *); 18 | PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name, 19 | PyObject *globals, PyObject *locals, PyObject *fromlist, int level); 20 | 21 | #define PyImport_ImportModuleEx(n, g, l, f) \ 22 | PyImport_ImportModuleLevel(n, g, l, f, -1) 23 | 24 | PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path); 25 | PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); 26 | PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); 27 | PyAPI_FUNC(void) PyImport_Cleanup(void); 28 | PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *); 29 | 30 | #ifdef WITH_THREAD 31 | PyAPI_FUNC(void) _PyImport_AcquireLock(void); 32 | PyAPI_FUNC(int) _PyImport_ReleaseLock(void); 33 | #else 34 | #define _PyImport_AcquireLock() 35 | #define _PyImport_ReleaseLock() 1 36 | #endif 37 | 38 | PyAPI_FUNC(struct filedescr *) _PyImport_FindModule( 39 | const char *, PyObject *, char *, size_t, FILE **, PyObject **); 40 | PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *); 41 | PyAPI_FUNC(void) _PyImport_ReInitLock(void); 42 | 43 | PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *); 44 | PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *); 45 | 46 | struct _inittab { 47 | char *name; 48 | void (*initfunc)(void); 49 | }; 50 | 51 | PyAPI_DATA(PyTypeObject) PyNullImporter_Type; 52 | PyAPI_DATA(struct _inittab *) PyImport_Inittab; 53 | 54 | PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, void (*initfunc)(void)); 55 | PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); 56 | 57 | struct _frozen { 58 | char *name; 59 | unsigned char *code; 60 | int size; 61 | }; 62 | 63 | /* Embedding apps may change this pointer to point to their favorite 64 | collection of frozen modules: */ 65 | 66 | PyAPI_DATA(struct _frozen *) PyImport_FrozenModules; 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | #endif /* !Py_IMPORT_H */ 72 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/intobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Integer object interface */ 3 | 4 | /* 5 | PyIntObject represents a (long) integer. This is an immutable object; 6 | an integer cannot change its value after creation. 7 | 8 | There are functions to create new integer objects, to test an object 9 | for integer-ness, and to get the integer value. The latter functions 10 | returns -1 and sets errno to EBADF if the object is not an PyIntObject. 11 | None of the functions should be applied to nil objects. 12 | 13 | The type PyIntObject is (unfortunately) exposed here so we can declare 14 | _Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this. 15 | */ 16 | 17 | #ifndef Py_INTOBJECT_H 18 | #define Py_INTOBJECT_H 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct { 24 | PyObject_HEAD 25 | long ob_ival; 26 | } PyIntObject; 27 | 28 | PyAPI_DATA(PyTypeObject) PyInt_Type; 29 | 30 | #define PyInt_Check(op) \ 31 | PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS) 32 | #define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type) 33 | 34 | PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int); 35 | #ifdef Py_USING_UNICODE 36 | PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int); 37 | #endif 38 | PyAPI_FUNC(PyObject *) PyInt_FromLong(long); 39 | PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t); 40 | PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t); 41 | PyAPI_FUNC(long) PyInt_AsLong(PyObject *); 42 | PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *); 43 | PyAPI_FUNC(int) _PyInt_AsInt(PyObject *); 44 | PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *); 45 | #ifdef HAVE_LONG_LONG 46 | PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *); 47 | #endif 48 | 49 | PyAPI_FUNC(long) PyInt_GetMax(void); 50 | 51 | /* Macro, trading safety for speed */ 52 | #define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival) 53 | 54 | /* These aren't really part of the Int object, but they're handy; the protos 55 | * are necessary for systems that need the magic of PyAPI_FUNC and that want 56 | * to have stropmodule as a dynamically loaded module instead of building it 57 | * into the main Python shared library/DLL. Guido thinks I'm weird for 58 | * building it this way. :-) [cjh] 59 | */ 60 | PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int); 61 | PyAPI_FUNC(long) PyOS_strtol(char *, char **, int); 62 | 63 | /* free list api */ 64 | PyAPI_FUNC(int) PyInt_ClearFreeList(void); 65 | 66 | /* Convert an integer to the given base. Returns a string. 67 | If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. 68 | If newstyle is zero, then use the pre-2.6 behavior of octal having 69 | a leading "0" */ 70 | PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int newstyle); 71 | 72 | /* Format the object based on the format_spec, as defined in PEP 3101 73 | (Advanced String Formatting). */ 74 | PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj, 75 | char *format_spec, 76 | Py_ssize_t format_spec_len); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | #endif /* !Py_INTOBJECT_H */ 82 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/intrcheck.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_INTRCHECK_H 3 | #define Py_INTRCHECK_H 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | PyAPI_FUNC(int) PyOS_InterruptOccurred(void); 9 | PyAPI_FUNC(void) PyOS_InitInterrupts(void); 10 | PyAPI_FUNC(void) PyOS_AfterFork(void); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | #endif /* !Py_INTRCHECK_H */ 16 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/iterobject.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_ITEROBJECT_H 2 | #define Py_ITEROBJECT_H 3 | /* Iterators (the basic kind, over a sequence) */ 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | PyAPI_DATA(PyTypeObject) PySeqIter_Type; 9 | 10 | #define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type) 11 | 12 | PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); 13 | 14 | PyAPI_DATA(PyTypeObject) PyCallIter_Type; 15 | 16 | #define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type) 17 | 18 | PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif /* !Py_ITEROBJECT_H */ 23 | 24 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/listobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* List object interface */ 3 | 4 | /* 5 | Another generally useful object type is an list of object pointers. 6 | This is a mutable type: the list items can be changed, and items can be 7 | added or removed. Out-of-range indices or non-list objects are ignored. 8 | 9 | *** WARNING *** PyList_SetItem does not increment the new item's reference 10 | count, but does decrement the reference count of the item it replaces, 11 | if not nil. It does *decrement* the reference count if it is *not* 12 | inserted in the list. Similarly, PyList_GetItem does not increment the 13 | returned item's reference count. 14 | */ 15 | 16 | #ifndef Py_LISTOBJECT_H 17 | #define Py_LISTOBJECT_H 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | typedef struct { 23 | PyObject_VAR_HEAD 24 | /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ 25 | PyObject **ob_item; 26 | 27 | /* ob_item contains space for 'allocated' elements. The number 28 | * currently in use is ob_size. 29 | * Invariants: 30 | * 0 <= ob_size <= allocated 31 | * len(list) == ob_size 32 | * ob_item == NULL implies ob_size == allocated == 0 33 | * list.sort() temporarily sets allocated to -1 to detect mutations. 34 | * 35 | * Items must normally not be NULL, except during construction when 36 | * the list is not yet visible outside the function that builds it. 37 | */ 38 | Py_ssize_t allocated; 39 | } PyListObject; 40 | 41 | PyAPI_DATA(PyTypeObject) PyList_Type; 42 | 43 | #define PyList_Check(op) \ 44 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) 45 | #define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type) 46 | 47 | PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); 48 | PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); 49 | PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t); 50 | PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); 51 | PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *); 52 | PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); 53 | PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); 54 | PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); 55 | PyAPI_FUNC(int) PyList_Sort(PyObject *); 56 | PyAPI_FUNC(int) PyList_Reverse(PyObject *); 57 | PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); 58 | PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *); 59 | 60 | /* Macro, trading safety for speed */ 61 | #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i]) 62 | #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) 63 | #define PyList_GET_SIZE(op) Py_SIZE(op) 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | #endif /* !Py_LISTOBJECT_H */ 69 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/longintrepr.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_LONGINTREPR_H 2 | #define Py_LONGINTREPR_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* This is published for the benefit of "friend" marshal.c only. */ 9 | 10 | /* Parameters of the long integer representation. There are two different 11 | sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit 12 | integer type, and one set for 15-bit digits with each digit stored in an 13 | unsigned short. The value of PYLONG_BITS_IN_DIGIT, defined either at 14 | configure time or in pyport.h, is used to decide which digit size to use. 15 | 16 | Type 'digit' should be able to hold 2*PyLong_BASE-1, and type 'twodigits' 17 | should be an unsigned integer type able to hold all integers up to 18 | PyLong_BASE*PyLong_BASE-1. x_sub assumes that 'digit' is an unsigned type, 19 | and that overflow is handled by taking the result modulo 2**N for some N > 20 | PyLong_SHIFT. The majority of the code doesn't care about the precise 21 | value of PyLong_SHIFT, but there are some notable exceptions: 22 | 23 | - long_pow() requires that PyLong_SHIFT be divisible by 5 24 | 25 | - PyLong_{As,From}ByteArray require that PyLong_SHIFT be at least 8 26 | 27 | - long_hash() requires that PyLong_SHIFT is *strictly* less than the number 28 | of bits in an unsigned long, as do the PyLong <-> long (or unsigned long) 29 | conversion functions 30 | 31 | - the long <-> size_t/Py_ssize_t conversion functions expect that 32 | PyLong_SHIFT is strictly less than the number of bits in a size_t 33 | 34 | - the marshal code currently expects that PyLong_SHIFT is a multiple of 15 35 | 36 | The values 15 and 30 should fit all of the above requirements, on any 37 | platform. 38 | */ 39 | 40 | #if PYLONG_BITS_IN_DIGIT == 30 41 | #if !(defined HAVE_UINT64_T && defined HAVE_UINT32_T && \ 42 | defined HAVE_INT64_T && defined HAVE_INT32_T) 43 | #error "30-bit long digits requested, but the necessary types are not available on this platform" 44 | #endif 45 | typedef PY_UINT32_T digit; 46 | typedef PY_INT32_T sdigit; /* signed variant of digit */ 47 | typedef PY_UINT64_T twodigits; 48 | typedef PY_INT64_T stwodigits; /* signed variant of twodigits */ 49 | #define PyLong_SHIFT 30 50 | #define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */ 51 | #define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */ 52 | #elif PYLONG_BITS_IN_DIGIT == 15 53 | typedef unsigned short digit; 54 | typedef short sdigit; /* signed variant of digit */ 55 | typedef unsigned long twodigits; 56 | typedef long stwodigits; /* signed variant of twodigits */ 57 | #define PyLong_SHIFT 15 58 | #define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */ 59 | #define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */ 60 | #else 61 | #error "PYLONG_BITS_IN_DIGIT should be 15 or 30" 62 | #endif 63 | #define PyLong_BASE ((digit)1 << PyLong_SHIFT) 64 | #define PyLong_MASK ((digit)(PyLong_BASE - 1)) 65 | 66 | /* b/w compatibility with Python 2.5 */ 67 | #define SHIFT PyLong_SHIFT 68 | #define BASE PyLong_BASE 69 | #define MASK PyLong_MASK 70 | 71 | #if PyLong_SHIFT % 5 != 0 72 | #error "longobject.c requires that PyLong_SHIFT be divisible by 5" 73 | #endif 74 | 75 | /* Long integer representation. 76 | The absolute value of a number is equal to 77 | SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) 78 | Negative numbers are represented with ob_size < 0; 79 | zero is represented by ob_size == 0. 80 | In a normalized number, ob_digit[abs(ob_size)-1] (the most significant 81 | digit) is never zero. Also, in all cases, for all valid i, 82 | 0 <= ob_digit[i] <= MASK. 83 | The allocation function takes care of allocating extra memory 84 | so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. 85 | 86 | CAUTION: Generic code manipulating subtypes of PyVarObject has to 87 | aware that longs abuse ob_size's sign bit. 88 | */ 89 | 90 | struct _longobject { 91 | PyObject_VAR_HEAD 92 | digit ob_digit[1]; 93 | }; 94 | 95 | PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t); 96 | 97 | /* Return a copy of src. */ 98 | PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src); 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | #endif /* !Py_LONGINTREPR_H */ 104 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/longobject.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_LONGOBJECT_H 2 | #define Py_LONGOBJECT_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* Long (arbitrary precision) integer object interface */ 9 | 10 | typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */ 11 | 12 | PyAPI_DATA(PyTypeObject) PyLong_Type; 13 | 14 | #define PyLong_Check(op) \ 15 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) 16 | #define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type) 17 | 18 | PyAPI_FUNC(PyObject *) PyLong_FromLong(long); 19 | PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); 20 | PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); 21 | PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t); 22 | PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t); 23 | PyAPI_FUNC(long) PyLong_AsLong(PyObject *); 24 | PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *); 25 | PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); 26 | PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); 27 | PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); 28 | PyAPI_FUNC(int) _PyLong_AsInt(PyObject *); 29 | PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); 30 | 31 | /* For use by intobject.c only */ 32 | #define _PyLong_AsSsize_t PyLong_AsSsize_t 33 | #define _PyLong_FromSize_t PyLong_FromSize_t 34 | #define _PyLong_FromSsize_t PyLong_FromSsize_t 35 | PyAPI_DATA(int) _PyLong_DigitValue[256]; 36 | 37 | /* _PyLong_Frexp returns a double x and an exponent e such that the 38 | true value is approximately equal to x * 2**e. e is >= 0. x is 39 | 0.0 if and only if the input is 0 (in which case, e and x are both 40 | zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is 41 | possible if the number of bits doesn't fit into a Py_ssize_t, sets 42 | OverflowError and returns -1.0 for x, 0 for e. */ 43 | PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e); 44 | 45 | PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); 46 | PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); 47 | PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); 48 | 49 | #ifdef HAVE_LONG_LONG 50 | PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG); 51 | PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG); 52 | PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *); 53 | PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *); 54 | PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *); 55 | PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *); 56 | #endif /* HAVE_LONG_LONG */ 57 | 58 | PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int); 59 | #ifdef Py_USING_UNICODE 60 | PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int); 61 | #endif 62 | 63 | /* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0. 64 | v must not be NULL, and must be a normalized long. 65 | There are no error cases. 66 | */ 67 | PyAPI_FUNC(int) _PyLong_Sign(PyObject *v); 68 | 69 | 70 | /* _PyLong_NumBits. Return the number of bits needed to represent the 71 | absolute value of a long. For example, this returns 1 for 1 and -1, 2 72 | for 2 and -2, and 2 for 3 and -3. It returns 0 for 0. 73 | v must not be NULL, and must be a normalized long. 74 | (size_t)-1 is returned and OverflowError set if the true result doesn't 75 | fit in a size_t. 76 | */ 77 | PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); 78 | 79 | /* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in 80 | base 256, and return a Python long with the same numeric value. 81 | If n is 0, the integer is 0. Else: 82 | If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB; 83 | else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the 84 | LSB. 85 | If is_signed is 0/false, view the bytes as a non-negative integer. 86 | If is_signed is 1/true, view the bytes as a 2's-complement integer, 87 | non-negative if bit 0x80 of the MSB is clear, negative if set. 88 | Error returns: 89 | + Return NULL with the appropriate exception set if there's not 90 | enough memory to create the Python long. 91 | */ 92 | PyAPI_FUNC(PyObject *) _PyLong_FromByteArray( 93 | const unsigned char* bytes, size_t n, 94 | int little_endian, int is_signed); 95 | 96 | /* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long 97 | v to a base-256 integer, stored in array bytes. Normally return 0, 98 | return -1 on error. 99 | If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at 100 | bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and 101 | the LSB at bytes[n-1]. 102 | If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes 103 | are filled and there's nothing special about bit 0x80 of the MSB. 104 | If is_signed is 1/true, bytes is filled with the 2's-complement 105 | representation of v's value. Bit 0x80 of the MSB is the sign bit. 106 | Error returns (-1): 107 | + is_signed is 0 and v < 0. TypeError is set in this case, and bytes 108 | isn't altered. 109 | + n isn't big enough to hold the full mathematical value of v. For 110 | example, if is_signed is 0 and there are more digits in the v than 111 | fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of 112 | being large enough to hold a sign bit. OverflowError is set in this 113 | case, but bytes holds the least-signficant n bytes of the true value. 114 | */ 115 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, 116 | unsigned char* bytes, size_t n, 117 | int little_endian, int is_signed); 118 | 119 | /* _PyLong_Format: Convert the long to a string object with given base, 120 | appending a base prefix of 0[box] if base is 2, 8 or 16. 121 | Add a trailing "L" if addL is non-zero. 122 | If newstyle is zero, then use the pre-2.6 behavior of octal having 123 | a leading "0", instead of the prefix "0o" */ 124 | PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base, int addL, int newstyle); 125 | 126 | /* Format the object based on the format_spec, as defined in PEP 3101 127 | (Advanced String Formatting). */ 128 | PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj, 129 | char *format_spec, 130 | Py_ssize_t format_spec_len); 131 | 132 | #ifdef __cplusplus 133 | } 134 | #endif 135 | #endif /* !Py_LONGOBJECT_H */ 136 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/marshal.h: -------------------------------------------------------------------------------- 1 | 2 | /* Interface for marshal.c */ 3 | 4 | #ifndef Py_MARSHAL_H 5 | #define Py_MARSHAL_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define Py_MARSHAL_VERSION 2 11 | 12 | PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int); 13 | PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int); 14 | PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int); 15 | 16 | PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *); 17 | PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *); 18 | PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *); 19 | PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *); 20 | PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | #endif /* !Py_MARSHAL_H */ 26 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/memoryobject.h: -------------------------------------------------------------------------------- 1 | /* Memory view object. In Python this is available as "memoryview". */ 2 | 3 | #ifndef Py_MEMORYOBJECT_H 4 | #define Py_MEMORYOBJECT_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | PyAPI_DATA(PyTypeObject) PyMemoryView_Type; 10 | 11 | #define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type) 12 | 13 | /* Get a pointer to the underlying Py_buffer of a memoryview object. */ 14 | #define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view) 15 | /* Get a pointer to the PyObject from which originates a memoryview object. */ 16 | #define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj) 17 | 18 | 19 | PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, 20 | int buffertype, 21 | char fort); 22 | 23 | /* Return a contiguous chunk of memory representing the buffer 24 | from an object in a memory view object. If a copy is made then the 25 | base object for the memory view will be a *new* bytes object. 26 | 27 | Otherwise, the base-object will be the object itself and no 28 | data-copying will be done. 29 | 30 | The buffertype argument can be PyBUF_READ, PyBUF_WRITE, 31 | PyBUF_SHADOW to determine whether the returned buffer 32 | should be READONLY, WRITABLE, or set to update the 33 | original buffer if a copy must be made. If buffertype is 34 | PyBUF_WRITE and the buffer is not contiguous an error will 35 | be raised. In this circumstance, the user can use 36 | PyBUF_SHADOW to ensure that a a writable temporary 37 | contiguous buffer is returned. The contents of this 38 | contiguous buffer will be copied back into the original 39 | object after the memoryview object is deleted as long as 40 | the original object is writable and allows setting an 41 | exclusive write lock. If this is not allowed by the 42 | original object, then a BufferError is raised. 43 | 44 | If the object is multi-dimensional and if fortran is 'F', 45 | the first dimension of the underlying array will vary the 46 | fastest in the buffer. If fortran is 'C', then the last 47 | dimension will vary the fastest (C-style contiguous). If 48 | fortran is 'A', then it does not matter and you will get 49 | whatever the object decides is more efficient. 50 | 51 | A new reference is returned that must be DECREF'd when finished. 52 | */ 53 | 54 | PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base); 55 | 56 | PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info); 57 | /* create new if bufptr is NULL 58 | will be a new bytesobject in base */ 59 | 60 | 61 | /* The struct is declared here so that macros can work, but it shouldn't 62 | be considered public. Don't access those fields directly, use the macros 63 | and functions instead! */ 64 | typedef struct { 65 | PyObject_HEAD 66 | PyObject *base; 67 | Py_buffer view; 68 | } PyMemoryViewObject; 69 | 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #endif /* !Py_MEMORYOBJECT_H */ 75 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/metagrammar.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_METAGRAMMAR_H 2 | #define Py_METAGRAMMAR_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | #define MSTART 256 9 | #define RULE 257 10 | #define RHS 258 11 | #define ALT 259 12 | #define ITEM 260 13 | #define ATOM 261 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | #endif /* !Py_METAGRAMMAR_H */ 19 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/methodobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Method object interface */ 3 | 4 | #ifndef Py_METHODOBJECT_H 5 | #define Py_METHODOBJECT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /* This is about the type 'builtin_function_or_method', 11 | not Python methods in user-defined classes. See classobject.h 12 | for the latter. */ 13 | 14 | PyAPI_DATA(PyTypeObject) PyCFunction_Type; 15 | 16 | #define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type) 17 | 18 | typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); 19 | typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, 20 | PyObject *); 21 | typedef PyObject *(*PyNoArgsFunction)(PyObject *); 22 | 23 | PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); 24 | PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); 25 | PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); 26 | 27 | /* Macros for direct access to these values. Type checks are *not* 28 | done, so use with care. */ 29 | #define PyCFunction_GET_FUNCTION(func) \ 30 | (((PyCFunctionObject *)func) -> m_ml -> ml_meth) 31 | #define PyCFunction_GET_SELF(func) \ 32 | (((PyCFunctionObject *)func) -> m_self) 33 | #define PyCFunction_GET_FLAGS(func) \ 34 | (((PyCFunctionObject *)func) -> m_ml -> ml_flags) 35 | PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); 36 | 37 | struct PyMethodDef { 38 | const char *ml_name; /* The name of the built-in function/method */ 39 | PyCFunction ml_meth; /* The C function that implements it */ 40 | int ml_flags; /* Combination of METH_xxx flags, which mostly 41 | describe the args expected by the C func */ 42 | const char *ml_doc; /* The __doc__ attribute, or NULL */ 43 | }; 44 | typedef struct PyMethodDef PyMethodDef; 45 | 46 | PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, const char *); 47 | 48 | #define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL) 49 | PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, 50 | PyObject *); 51 | 52 | /* Flag passed to newmethodobject */ 53 | #define METH_OLDARGS 0x0000 54 | #define METH_VARARGS 0x0001 55 | #define METH_KEYWORDS 0x0002 56 | /* METH_NOARGS and METH_O must not be combined with the flags above. */ 57 | #define METH_NOARGS 0x0004 58 | #define METH_O 0x0008 59 | 60 | /* METH_CLASS and METH_STATIC are a little different; these control 61 | the construction of methods for a class. These cannot be used for 62 | functions in modules. */ 63 | #define METH_CLASS 0x0010 64 | #define METH_STATIC 0x0020 65 | 66 | /* METH_COEXIST allows a method to be entered eventhough a slot has 67 | already filled the entry. When defined, the flag allows a separate 68 | method, "__contains__" for example, to coexist with a defined 69 | slot like sq_contains. */ 70 | 71 | #define METH_COEXIST 0x0040 72 | 73 | typedef struct PyMethodChain { 74 | PyMethodDef *methods; /* Methods of this type */ 75 | struct PyMethodChain *link; /* NULL or base type */ 76 | } PyMethodChain; 77 | 78 | PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *, 79 | const char *); 80 | 81 | typedef struct { 82 | PyObject_HEAD 83 | PyMethodDef *m_ml; /* Description of the C function to call */ 84 | PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ 85 | PyObject *m_module; /* The __module__ attribute, can be anything */ 86 | } PyCFunctionObject; 87 | 88 | PyAPI_FUNC(int) PyCFunction_ClearFreeList(void); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #endif /* !Py_METHODOBJECT_H */ 94 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/modsupport.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_MODSUPPORT_H 3 | #define Py_MODSUPPORT_H 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* Module support interface */ 9 | 10 | #include 11 | 12 | /* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier 13 | to mean Py_ssize_t */ 14 | #ifdef PY_SSIZE_T_CLEAN 15 | #define PyArg_Parse _PyArg_Parse_SizeT 16 | #define PyArg_ParseTuple _PyArg_ParseTuple_SizeT 17 | #define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT 18 | #define PyArg_VaParse _PyArg_VaParse_SizeT 19 | #define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT 20 | #define Py_BuildValue _Py_BuildValue_SizeT 21 | #define Py_VaBuildValue _Py_VaBuildValue_SizeT 22 | #else 23 | PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list); 24 | #endif 25 | 26 | PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); 27 | PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3); 28 | PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, 29 | const char *, char **, ...); 30 | PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); 31 | PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); 32 | PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); 33 | PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw); 34 | 35 | PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); 36 | PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, 37 | const char *, char **, va_list); 38 | PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); 39 | 40 | PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *); 41 | PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); 42 | PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); 43 | #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c) 44 | #define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c) 45 | 46 | #define PYTHON_API_VERSION 1013 47 | #define PYTHON_API_STRING "1013" 48 | /* The API version is maintained (independently from the Python version) 49 | so we can detect mismatches between the interpreter and dynamically 50 | loaded modules. These are diagnosed by an error message but 51 | the module is still loaded (because the mismatch can only be tested 52 | after loading the module). The error message is intended to 53 | explain the core dump a few seconds later. 54 | 55 | The symbol PYTHON_API_STRING defines the same value as a string 56 | literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** 57 | 58 | Please add a line or two to the top of this log for each API 59 | version change: 60 | 61 | 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths 62 | 63 | 19-Aug-2002 GvR 1012 Changes to string object struct for 64 | interning changes, saving 3 bytes. 65 | 66 | 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side 67 | 68 | 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and 69 | PyFrame_New(); Python 2.1a2 70 | 71 | 14-Mar-2000 GvR 1009 Unicode API added 72 | 73 | 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) 74 | 75 | 3-Dec-1998 GvR 1008 Python 1.5.2b1 76 | 77 | 18-Jan-1997 GvR 1007 string interning and other speedups 78 | 79 | 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( 80 | 81 | 30-Jul-1996 GvR Slice and ellipses syntax added 82 | 83 | 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) 84 | 85 | 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) 86 | 87 | 10-Jan-1995 GvR Renamed globals to new naming scheme 88 | 89 | 9-Jan-1995 GvR Initial version (incompatible with older API) 90 | */ 91 | 92 | #ifdef MS_WINDOWS 93 | /* Special defines for Windows versions used to live here. Things 94 | have changed, and the "Version" is now in a global string variable. 95 | Reason for this is that this for easier branding of a "custom DLL" 96 | without actually needing a recompile. */ 97 | #endif /* MS_WINDOWS */ 98 | 99 | #if SIZEOF_SIZE_T != SIZEOF_INT 100 | /* On a 64-bit system, rename the Py_InitModule4 so that 2.4 101 | modules cannot get loaded into a 2.5 interpreter */ 102 | #define Py_InitModule4 Py_InitModule4_64 103 | #endif 104 | 105 | #ifdef Py_TRACE_REFS 106 | /* When we are tracing reference counts, rename Py_InitModule4 so 107 | modules compiled with incompatible settings will generate a 108 | link-time error. */ 109 | #if SIZEOF_SIZE_T != SIZEOF_INT 110 | #undef Py_InitModule4 111 | #define Py_InitModule4 Py_InitModule4TraceRefs_64 112 | #else 113 | #define Py_InitModule4 Py_InitModule4TraceRefs 114 | #endif 115 | #endif 116 | 117 | PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods, 118 | const char *doc, PyObject *self, 119 | int apiver); 120 | 121 | #define Py_InitModule(name, methods) \ 122 | Py_InitModule4(name, methods, (char *)NULL, (PyObject *)NULL, \ 123 | PYTHON_API_VERSION) 124 | 125 | #define Py_InitModule3(name, methods, doc) \ 126 | Py_InitModule4(name, methods, doc, (PyObject *)NULL, \ 127 | PYTHON_API_VERSION) 128 | 129 | PyAPI_DATA(char *) _Py_PackageContext; 130 | 131 | #ifdef __cplusplus 132 | } 133 | #endif 134 | #endif /* !Py_MODSUPPORT_H */ 135 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/moduleobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Module object interface */ 3 | 4 | #ifndef Py_MODULEOBJECT_H 5 | #define Py_MODULEOBJECT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | PyAPI_DATA(PyTypeObject) PyModule_Type; 11 | 12 | #define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) 13 | #define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type) 14 | 15 | PyAPI_FUNC(PyObject *) PyModule_New(const char *); 16 | PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); 17 | PyAPI_FUNC(char *) PyModule_GetName(PyObject *); 18 | PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *); 19 | PyAPI_FUNC(void) _PyModule_Clear(PyObject *); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | #endif /* !Py_MODULEOBJECT_H */ 25 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/node.h: -------------------------------------------------------------------------------- 1 | 2 | /* Parse tree node interface */ 3 | 4 | #ifndef Py_NODE_H 5 | #define Py_NODE_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct _node { 11 | short n_type; 12 | char *n_str; 13 | int n_lineno; 14 | int n_col_offset; 15 | int n_nchildren; 16 | struct _node *n_child; 17 | } node; 18 | 19 | PyAPI_FUNC(node *) PyNode_New(int type); 20 | PyAPI_FUNC(int) PyNode_AddChild(node *n, int type, 21 | char *str, int lineno, int col_offset); 22 | PyAPI_FUNC(void) PyNode_Free(node *n); 23 | #ifndef Py_LIMITED_API 24 | Py_ssize_t _PyNode_SizeOf(node *n); 25 | #endif 26 | 27 | /* Node access functions */ 28 | #define NCH(n) ((n)->n_nchildren) 29 | 30 | #define CHILD(n, i) (&(n)->n_child[i]) 31 | #define RCHILD(n, i) (CHILD(n, NCH(n) + i)) 32 | #define TYPE(n) ((n)->n_type) 33 | #define STR(n) ((n)->n_str) 34 | 35 | /* Assert that the type of a node is what we expect */ 36 | #define REQ(n, type) assert(TYPE(n) == (type)) 37 | 38 | PyAPI_FUNC(void) PyNode_ListTree(node *); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | #endif /* !Py_NODE_H */ 44 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/opcode.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_OPCODE_H 2 | #define Py_OPCODE_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* Instruction opcodes for compiled code */ 9 | 10 | #define STOP_CODE 0 11 | #define POP_TOP 1 12 | #define ROT_TWO 2 13 | #define ROT_THREE 3 14 | #define DUP_TOP 4 15 | #define ROT_FOUR 5 16 | #define NOP 9 17 | 18 | #define UNARY_POSITIVE 10 19 | #define UNARY_NEGATIVE 11 20 | #define UNARY_NOT 12 21 | #define UNARY_CONVERT 13 22 | 23 | #define UNARY_INVERT 15 24 | 25 | #define BINARY_POWER 19 26 | 27 | #define BINARY_MULTIPLY 20 28 | #define BINARY_DIVIDE 21 29 | #define BINARY_MODULO 22 30 | #define BINARY_ADD 23 31 | #define BINARY_SUBTRACT 24 32 | #define BINARY_SUBSCR 25 33 | #define BINARY_FLOOR_DIVIDE 26 34 | #define BINARY_TRUE_DIVIDE 27 35 | #define INPLACE_FLOOR_DIVIDE 28 36 | #define INPLACE_TRUE_DIVIDE 29 37 | 38 | #define SLICE 30 39 | /* Also uses 31-33 */ 40 | 41 | #define STORE_SLICE 40 42 | /* Also uses 41-43 */ 43 | 44 | #define DELETE_SLICE 50 45 | /* Also uses 51-53 */ 46 | 47 | #define STORE_MAP 54 48 | #define INPLACE_ADD 55 49 | #define INPLACE_SUBTRACT 56 50 | #define INPLACE_MULTIPLY 57 51 | #define INPLACE_DIVIDE 58 52 | #define INPLACE_MODULO 59 53 | #define STORE_SUBSCR 60 54 | #define DELETE_SUBSCR 61 55 | 56 | #define BINARY_LSHIFT 62 57 | #define BINARY_RSHIFT 63 58 | #define BINARY_AND 64 59 | #define BINARY_XOR 65 60 | #define BINARY_OR 66 61 | #define INPLACE_POWER 67 62 | #define GET_ITER 68 63 | 64 | #define PRINT_EXPR 70 65 | #define PRINT_ITEM 71 66 | #define PRINT_NEWLINE 72 67 | #define PRINT_ITEM_TO 73 68 | #define PRINT_NEWLINE_TO 74 69 | #define INPLACE_LSHIFT 75 70 | #define INPLACE_RSHIFT 76 71 | #define INPLACE_AND 77 72 | #define INPLACE_XOR 78 73 | #define INPLACE_OR 79 74 | #define BREAK_LOOP 80 75 | #define WITH_CLEANUP 81 76 | #define LOAD_LOCALS 82 77 | #define RETURN_VALUE 83 78 | #define IMPORT_STAR 84 79 | #define EXEC_STMT 85 80 | #define YIELD_VALUE 86 81 | #define POP_BLOCK 87 82 | #define END_FINALLY 88 83 | #define BUILD_CLASS 89 84 | 85 | #define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ 86 | 87 | #define STORE_NAME 90 /* Index in name list */ 88 | #define DELETE_NAME 91 /* "" */ 89 | #define UNPACK_SEQUENCE 92 /* Number of sequence items */ 90 | #define FOR_ITER 93 91 | #define LIST_APPEND 94 92 | 93 | #define STORE_ATTR 95 /* Index in name list */ 94 | #define DELETE_ATTR 96 /* "" */ 95 | #define STORE_GLOBAL 97 /* "" */ 96 | #define DELETE_GLOBAL 98 /* "" */ 97 | #define DUP_TOPX 99 /* number of items to duplicate */ 98 | #define LOAD_CONST 100 /* Index in const list */ 99 | #define LOAD_NAME 101 /* Index in name list */ 100 | #define BUILD_TUPLE 102 /* Number of tuple items */ 101 | #define BUILD_LIST 103 /* Number of list items */ 102 | #define BUILD_SET 104 /* Number of set items */ 103 | #define BUILD_MAP 105 /* Always zero for now */ 104 | #define LOAD_ATTR 106 /* Index in name list */ 105 | #define COMPARE_OP 107 /* Comparison operator */ 106 | #define IMPORT_NAME 108 /* Index in name list */ 107 | #define IMPORT_FROM 109 /* Index in name list */ 108 | #define JUMP_FORWARD 110 /* Number of bytes to skip */ 109 | 110 | #define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning 111 | of code */ 112 | #define JUMP_IF_TRUE_OR_POP 112 /* "" */ 113 | #define JUMP_ABSOLUTE 113 /* "" */ 114 | #define POP_JUMP_IF_FALSE 114 /* "" */ 115 | #define POP_JUMP_IF_TRUE 115 /* "" */ 116 | 117 | #define LOAD_GLOBAL 116 /* Index in name list */ 118 | 119 | #define CONTINUE_LOOP 119 /* Start of loop (absolute) */ 120 | #define SETUP_LOOP 120 /* Target address (relative) */ 121 | #define SETUP_EXCEPT 121 /* "" */ 122 | #define SETUP_FINALLY 122 /* "" */ 123 | 124 | #define LOAD_FAST 124 /* Local variable number */ 125 | #define STORE_FAST 125 /* Local variable number */ 126 | #define DELETE_FAST 126 /* Local variable number */ 127 | 128 | #define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */ 129 | /* CALL_FUNCTION_XXX opcodes defined below depend on this definition */ 130 | #define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */ 131 | #define MAKE_FUNCTION 132 /* #defaults */ 132 | #define BUILD_SLICE 133 /* Number of items */ 133 | 134 | #define MAKE_CLOSURE 134 /* #free vars */ 135 | #define LOAD_CLOSURE 135 /* Load free variable from closure */ 136 | #define LOAD_DEREF 136 /* Load and dereference from closure cell */ 137 | #define STORE_DEREF 137 /* Store into cell */ 138 | 139 | /* The next 3 opcodes must be contiguous and satisfy 140 | (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */ 141 | #define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */ 142 | #define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */ 143 | #define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */ 144 | 145 | #define SETUP_WITH 143 146 | 147 | /* Support for opargs more than 16 bits long */ 148 | #define EXTENDED_ARG 145 149 | 150 | #define SET_ADD 146 151 | #define MAP_ADD 147 152 | 153 | 154 | enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, 155 | PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; 156 | 157 | #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) 158 | 159 | #ifdef __cplusplus 160 | } 161 | #endif 162 | #endif /* !Py_OPCODE_H */ 163 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/osdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_OSDEFS_H 2 | #define Py_OSDEFS_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* Operating system dependencies */ 9 | 10 | /* Mod by chrish: QNX has WATCOM, but isn't DOS */ 11 | #if !defined(__QNX__) 12 | #if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) 13 | #if defined(PYOS_OS2) && defined(PYCC_GCC) 14 | #define MAXPATHLEN 260 15 | #define SEP '/' 16 | #define ALTSEP '\\' 17 | #else 18 | #define SEP '\\' 19 | #define ALTSEP '/' 20 | #define MAXPATHLEN 256 21 | #endif 22 | #define DELIM ';' 23 | #endif 24 | #endif 25 | 26 | #ifdef RISCOS 27 | #define SEP '.' 28 | #define MAXPATHLEN 256 29 | #define DELIM ',' 30 | #endif 31 | 32 | 33 | /* Filename separator */ 34 | #ifndef SEP 35 | #define SEP '/' 36 | #endif 37 | 38 | /* Max pathname length */ 39 | #ifdef __hpux 40 | #include 41 | #include 42 | #ifndef PATH_MAX 43 | #define PATH_MAX MAXPATHLEN 44 | #endif 45 | #endif 46 | 47 | #ifndef MAXPATHLEN 48 | #if defined(PATH_MAX) && PATH_MAX > 1024 49 | #define MAXPATHLEN PATH_MAX 50 | #else 51 | #define MAXPATHLEN 1024 52 | #endif 53 | #endif 54 | 55 | /* Search path entry delimiter */ 56 | #ifndef DELIM 57 | #define DELIM ':' 58 | #endif 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #endif /* !Py_OSDEFS_H */ 64 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/parsetok.h: -------------------------------------------------------------------------------- 1 | 2 | /* Parser-tokenizer link interface */ 3 | 4 | #ifndef Py_PARSETOK_H 5 | #define Py_PARSETOK_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | int error; 12 | const char *filename; 13 | int lineno; 14 | int offset; 15 | char *text; 16 | int token; 17 | int expected; 18 | } perrdetail; 19 | 20 | #if 0 21 | #define PyPARSE_YIELD_IS_KEYWORD 0x0001 22 | #endif 23 | 24 | #define PyPARSE_DONT_IMPLY_DEDENT 0x0002 25 | 26 | #if 0 27 | #define PyPARSE_WITH_IS_KEYWORD 0x0003 28 | #endif 29 | 30 | #define PyPARSE_PRINT_IS_FUNCTION 0x0004 31 | #define PyPARSE_UNICODE_LITERALS 0x0008 32 | 33 | 34 | 35 | PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, 36 | perrdetail *); 37 | PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int, 38 | char *, char *, perrdetail *); 39 | 40 | PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int, 41 | perrdetail *, int); 42 | PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *, 43 | int, char *, char *, 44 | perrdetail *, int); 45 | PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *, grammar *, 46 | int, char *, char *, 47 | perrdetail *, int *); 48 | 49 | PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *, 50 | const char *, 51 | grammar *, int, 52 | perrdetail *, int); 53 | PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *, 54 | const char *, 55 | grammar *, int, 56 | perrdetail *, int *); 57 | 58 | /* Note that he following function is defined in pythonrun.c not parsetok.c. */ 59 | PyAPI_FUNC(void) PyParser_SetError(perrdetail *); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #endif /* !Py_PARSETOK_H */ 65 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/patchlevel.h: -------------------------------------------------------------------------------- 1 | 2 | /* Newfangled version identification scheme. 3 | 4 | This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL 5 | was available. To test for presence of the scheme, test for 6 | defined(PY_MAJOR_VERSION). 7 | 8 | When the major or minor version changes, the VERSION variable in 9 | configure.ac must also be changed. 10 | 11 | There is also (independent) API version information in modsupport.h. 12 | */ 13 | 14 | /* Values for PY_RELEASE_LEVEL */ 15 | #define PY_RELEASE_LEVEL_ALPHA 0xA 16 | #define PY_RELEASE_LEVEL_BETA 0xB 17 | #define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */ 18 | #define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */ 19 | /* Higher for patch releases */ 20 | 21 | /* Version parsed out into numeric values */ 22 | /*--start constants--*/ 23 | #define PY_MAJOR_VERSION 2 24 | #define PY_MINOR_VERSION 7 25 | #define PY_MICRO_VERSION 6 26 | #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL 27 | #define PY_RELEASE_SERIAL 0 28 | 29 | /* Version as a string */ 30 | #define PY_VERSION "2.7.6" 31 | /*--end constants--*/ 32 | 33 | /* Subversion Revision number of this file (not of the repository). Empty 34 | since Mercurial migration. */ 35 | #define PY_PATCHLEVEL_REVISION "" 36 | 37 | /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. 38 | Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ 39 | #define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ 40 | (PY_MINOR_VERSION << 16) | \ 41 | (PY_MICRO_VERSION << 8) | \ 42 | (PY_RELEASE_LEVEL << 4) | \ 43 | (PY_RELEASE_SERIAL << 0)) 44 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pgen.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_PGEN_H 2 | #define Py_PGEN_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* Parser generator interface */ 9 | 10 | extern grammar *meta_grammar(void); 11 | 12 | struct _node; 13 | extern grammar *pgen(struct _node *); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | #endif /* !Py_PGEN_H */ 19 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pgenheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_PGENHEADERS_H 2 | #define Py_PGENHEADERS_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* Include files and extern declarations used by most of the parser. */ 9 | 10 | #include "Python.h" 11 | 12 | PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) 13 | Py_GCC_ATTRIBUTE((format(printf, 1, 2))); 14 | PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) 15 | Py_GCC_ATTRIBUTE((format(printf, 1, 2))); 16 | 17 | #define addarc _Py_addarc 18 | #define addbit _Py_addbit 19 | #define adddfa _Py_adddfa 20 | #define addfirstsets _Py_addfirstsets 21 | #define addlabel _Py_addlabel 22 | #define addstate _Py_addstate 23 | #define delbitset _Py_delbitset 24 | #define dumptree _Py_dumptree 25 | #define findlabel _Py_findlabel 26 | #define mergebitset _Py_mergebitset 27 | #define meta_grammar _Py_meta_grammar 28 | #define newbitset _Py_newbitset 29 | #define newgrammar _Py_newgrammar 30 | #define pgen _Py_pgen 31 | #define printgrammar _Py_printgrammar 32 | #define printnonterminals _Py_printnonterminals 33 | #define printtree _Py_printtree 34 | #define samebitset _Py_samebitset 35 | #define showtree _Py_showtree 36 | #define tok_dump _Py_tok_dump 37 | #define translatelabels _Py_translatelabels 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | #endif /* !Py_PGENHEADERS_H */ 43 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/py_curses.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_CURSES_H 3 | #define Py_CURSES_H 4 | 5 | #ifdef __APPLE__ 6 | /* 7 | ** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards 8 | ** against multiple definition of wchar_t. 9 | */ 10 | #ifdef _BSD_WCHAR_T_DEFINED_ 11 | #define _WCHAR_T 12 | #endif 13 | 14 | /* the following define is necessary for OS X 10.6; without it, the 15 | Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python 16 | can't get at the WINDOW flags field. */ 17 | #define NCURSES_OPAQUE 0 18 | #endif /* __APPLE__ */ 19 | 20 | #ifdef __FreeBSD__ 21 | /* 22 | ** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards 23 | ** against multiple definition of wchar_t and wint_t. 24 | */ 25 | #ifdef _XOPEN_SOURCE_EXTENDED 26 | #ifndef __FreeBSD_version 27 | #include 28 | #endif 29 | #if __FreeBSD_version >= 500000 30 | #ifndef __wchar_t 31 | #define __wchar_t 32 | #endif 33 | #ifndef __wint_t 34 | #define __wint_t 35 | #endif 36 | #else 37 | #ifndef _WCHAR_T 38 | #define _WCHAR_T 39 | #endif 40 | #ifndef _WINT_T 41 | #define _WINT_T 42 | #endif 43 | #endif 44 | #endif 45 | #endif 46 | 47 | #ifdef HAVE_NCURSES_H 48 | #include 49 | #else 50 | #include 51 | #ifdef HAVE_TERM_H 52 | /* for tigetstr, which is not declared in SysV curses */ 53 | #include 54 | #endif 55 | #endif 56 | 57 | #ifdef HAVE_NCURSES_H 58 | /* configure was checking , but we will 59 | use , which has all these features. */ 60 | #ifndef WINDOW_HAS_FLAGS 61 | #define WINDOW_HAS_FLAGS 1 62 | #endif 63 | #ifndef MVWDELCH_IS_EXPRESSION 64 | #define MVWDELCH_IS_EXPRESSION 1 65 | #endif 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | extern "C" { 70 | #endif 71 | 72 | #define PyCurses_API_pointers 4 73 | 74 | /* Type declarations */ 75 | 76 | typedef struct { 77 | PyObject_HEAD 78 | WINDOW *win; 79 | } PyCursesWindowObject; 80 | 81 | #define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) 82 | 83 | #define PyCurses_CAPSULE_NAME "_curses._C_API" 84 | 85 | 86 | #ifdef CURSES_MODULE 87 | /* This section is used when compiling _cursesmodule.c */ 88 | 89 | #else 90 | /* This section is used in modules that use the _cursesmodule API */ 91 | 92 | static void **PyCurses_API; 93 | 94 | #define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0]) 95 | #define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} 96 | #define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} 97 | #define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} 98 | 99 | #define import_curses() \ 100 | PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1); 101 | 102 | #endif 103 | 104 | /* general error messages */ 105 | static char *catchall_ERR = "curses function returned ERR"; 106 | static char *catchall_NULL = "curses function returned NULL"; 107 | 108 | /* Function Prototype Macros - They are ugly but very, very useful. ;-) 109 | 110 | X - function name 111 | TYPE - parameter Type 112 | ERGSTR - format string for construction of the return value 113 | PARSESTR - format string for argument parsing 114 | */ 115 | 116 | #define NoArgNoReturnFunction(X) \ 117 | static PyObject *PyCurses_ ## X (PyObject *self) \ 118 | { \ 119 | PyCursesInitialised \ 120 | return PyCursesCheckERR(X(), # X); } 121 | 122 | #define NoArgOrFlagNoReturnFunction(X) \ 123 | static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ 124 | { \ 125 | int flag = 0; \ 126 | PyCursesInitialised \ 127 | switch(PyTuple_Size(args)) { \ 128 | case 0: \ 129 | return PyCursesCheckERR(X(), # X); \ 130 | case 1: \ 131 | if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \ 132 | if (flag) return PyCursesCheckERR(X(), # X); \ 133 | else return PyCursesCheckERR(no ## X (), # X); \ 134 | default: \ 135 | PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ 136 | return NULL; } } 137 | 138 | #define NoArgReturnIntFunction(X) \ 139 | static PyObject *PyCurses_ ## X (PyObject *self) \ 140 | { \ 141 | PyCursesInitialised \ 142 | return PyInt_FromLong((long) X()); } 143 | 144 | 145 | #define NoArgReturnStringFunction(X) \ 146 | static PyObject *PyCurses_ ## X (PyObject *self) \ 147 | { \ 148 | PyCursesInitialised \ 149 | return PyString_FromString(X()); } 150 | 151 | #define NoArgTrueFalseFunction(X) \ 152 | static PyObject *PyCurses_ ## X (PyObject *self) \ 153 | { \ 154 | PyCursesInitialised \ 155 | if (X () == FALSE) { \ 156 | Py_INCREF(Py_False); \ 157 | return Py_False; \ 158 | } \ 159 | Py_INCREF(Py_True); \ 160 | return Py_True; } 161 | 162 | #define NoArgNoReturnVoidFunction(X) \ 163 | static PyObject *PyCurses_ ## X (PyObject *self) \ 164 | { \ 165 | PyCursesInitialised \ 166 | X(); \ 167 | Py_INCREF(Py_None); \ 168 | return Py_None; } 169 | 170 | #ifdef __cplusplus 171 | } 172 | #endif 173 | 174 | #endif /* !defined(Py_CURSES_H) */ 175 | 176 | 177 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pyarena.h: -------------------------------------------------------------------------------- 1 | /* An arena-like memory interface for the compiler. 2 | */ 3 | 4 | #ifndef Py_PYARENA_H 5 | #define Py_PYARENA_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct _arena PyArena; 12 | 13 | /* PyArena_New() and PyArena_Free() create a new arena and free it, 14 | respectively. Once an arena has been created, it can be used 15 | to allocate memory via PyArena_Malloc(). Pointers to PyObject can 16 | also be registered with the arena via PyArena_AddPyObject(), and the 17 | arena will ensure that the PyObjects stay alive at least until 18 | PyArena_Free() is called. When an arena is freed, all the memory it 19 | allocated is freed, the arena releases internal references to registered 20 | PyObject*, and none of its pointers are valid. 21 | XXX (tim) What does "none of its pointers are valid" mean? Does it 22 | XXX mean that pointers previously obtained via PyArena_Malloc() are 23 | XXX no longer valid? (That's clearly true, but not sure that's what 24 | XXX the text is trying to say.) 25 | 26 | PyArena_New() returns an arena pointer. On error, it 27 | returns a negative number and sets an exception. 28 | XXX (tim): Not true. On error, PyArena_New() actually returns NULL, 29 | XXX and looks like it may or may not set an exception (e.g., if the 30 | XXX internal PyList_New(0) returns NULL, PyArena_New() passes that on 31 | XXX and an exception is set; OTOH, if the internal 32 | XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but 33 | XXX an exception is not set in that case). 34 | */ 35 | PyAPI_FUNC(PyArena *) PyArena_New(void); 36 | PyAPI_FUNC(void) PyArena_Free(PyArena *); 37 | 38 | /* Mostly like malloc(), return the address of a block of memory spanning 39 | * `size` bytes, or return NULL (without setting an exception) if enough 40 | * new memory can't be obtained. Unlike malloc(0), PyArena_Malloc() with 41 | * size=0 does not guarantee to return a unique pointer (the pointer 42 | * returned may equal one or more other pointers obtained from 43 | * PyArena_Malloc()). 44 | * Note that pointers obtained via PyArena_Malloc() must never be passed to 45 | * the system free() or realloc(), or to any of Python's similar memory- 46 | * management functions. PyArena_Malloc()-obtained pointers remain valid 47 | * until PyArena_Free(ar) is called, at which point all pointers obtained 48 | * from the arena `ar` become invalid simultaneously. 49 | */ 50 | PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size); 51 | 52 | /* This routine isn't a proper arena allocation routine. It takes 53 | * a PyObject* and records it so that it can be DECREFed when the 54 | * arena is freed. 55 | */ 56 | PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* !Py_PYARENA_H */ 63 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pycapsule.h: -------------------------------------------------------------------------------- 1 | 2 | /* Capsule objects let you wrap a C "void *" pointer in a Python 3 | object. They're a way of passing data through the Python interpreter 4 | without creating your own custom type. 5 | 6 | Capsules are used for communication between extension modules. 7 | They provide a way for an extension module to export a C interface 8 | to other extension modules, so that extension modules can use the 9 | Python import mechanism to link to one another. 10 | 11 | For more information, please see "c-api/capsule.html" in the 12 | documentation. 13 | */ 14 | 15 | #ifndef Py_CAPSULE_H 16 | #define Py_CAPSULE_H 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | PyAPI_DATA(PyTypeObject) PyCapsule_Type; 22 | 23 | typedef void (*PyCapsule_Destructor)(PyObject *); 24 | 25 | #define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type) 26 | 27 | 28 | PyAPI_FUNC(PyObject *) PyCapsule_New( 29 | void *pointer, 30 | const char *name, 31 | PyCapsule_Destructor destructor); 32 | 33 | PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name); 34 | 35 | PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule); 36 | 37 | PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule); 38 | 39 | PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule); 40 | 41 | PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name); 42 | 43 | PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer); 44 | 45 | PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor); 46 | 47 | PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name); 48 | 49 | PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context); 50 | 51 | PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif /* !Py_CAPSULE_H */ 57 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pyctype.h: -------------------------------------------------------------------------------- 1 | #ifndef PYCTYPE_H 2 | #define PYCTYPE_H 3 | 4 | #define PY_CTF_LOWER 0x01 5 | #define PY_CTF_UPPER 0x02 6 | #define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER) 7 | #define PY_CTF_DIGIT 0x04 8 | #define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT) 9 | #define PY_CTF_SPACE 0x08 10 | #define PY_CTF_XDIGIT 0x10 11 | 12 | PyAPI_DATA(const unsigned int) _Py_ctype_table[256]; 13 | 14 | /* Unlike their C counterparts, the following macros are not meant to 15 | * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument 16 | * must be a signed/unsigned char. */ 17 | #define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER) 18 | #define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER) 19 | #define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA) 20 | #define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT) 21 | #define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT) 22 | #define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM) 23 | #define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE) 24 | 25 | PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256]; 26 | PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256]; 27 | 28 | #define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) 29 | #define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) 30 | 31 | #endif /* !PYCTYPE_H */ 32 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pydebug.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_PYDEBUG_H 3 | #define Py_PYDEBUG_H 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | PyAPI_DATA(int) Py_DebugFlag; 9 | PyAPI_DATA(int) Py_VerboseFlag; 10 | PyAPI_DATA(int) Py_InteractiveFlag; 11 | PyAPI_DATA(int) Py_InspectFlag; 12 | PyAPI_DATA(int) Py_OptimizeFlag; 13 | PyAPI_DATA(int) Py_NoSiteFlag; 14 | PyAPI_DATA(int) Py_BytesWarningFlag; 15 | PyAPI_DATA(int) Py_UseClassExceptionsFlag; 16 | PyAPI_DATA(int) Py_FrozenFlag; 17 | PyAPI_DATA(int) Py_TabcheckFlag; 18 | PyAPI_DATA(int) Py_UnicodeFlag; 19 | PyAPI_DATA(int) Py_IgnoreEnvironmentFlag; 20 | PyAPI_DATA(int) Py_DivisionWarningFlag; 21 | PyAPI_DATA(int) Py_DontWriteBytecodeFlag; 22 | PyAPI_DATA(int) Py_NoUserSiteDirectory; 23 | /* _XXX Py_QnewFlag should go away in 3.0. It's true iff -Qnew is passed, 24 | on the command line, and is used in 2.2 by ceval.c to make all "/" divisions 25 | true divisions (which they will be in 3.0). */ 26 | PyAPI_DATA(int) _Py_QnewFlag; 27 | /* Warn about 3.x issues */ 28 | PyAPI_DATA(int) Py_Py3kWarningFlag; 29 | PyAPI_DATA(int) Py_HashRandomizationFlag; 30 | 31 | /* this is a wrapper around getenv() that pays attention to 32 | Py_IgnoreEnvironmentFlag. It should be used for getting variables like 33 | PYTHONPATH and PYTHONHOME from the environment */ 34 | #define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s)) 35 | 36 | PyAPI_FUNC(void) Py_FatalError(const char *message); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif /* !Py_PYDEBUG_H */ 42 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pyexpat.h: -------------------------------------------------------------------------------- 1 | /* Stuff to export relevant 'expat' entry points from pyexpat to other 2 | * parser modules, such as cElementTree. */ 3 | 4 | /* note: you must import expat.h before importing this module! */ 5 | 6 | #define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0" 7 | #define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI" 8 | 9 | struct PyExpat_CAPI 10 | { 11 | char* magic; /* set to PyExpat_CAPI_MAGIC */ 12 | int size; /* set to sizeof(struct PyExpat_CAPI) */ 13 | int MAJOR_VERSION; 14 | int MINOR_VERSION; 15 | int MICRO_VERSION; 16 | /* pointers to selected expat functions. add new functions at 17 | the end, if needed */ 18 | const XML_LChar * (*ErrorString)(enum XML_Error code); 19 | enum XML_Error (*GetErrorCode)(XML_Parser parser); 20 | XML_Size (*GetErrorColumnNumber)(XML_Parser parser); 21 | XML_Size (*GetErrorLineNumber)(XML_Parser parser); 22 | enum XML_Status (*Parse)( 23 | XML_Parser parser, const char *s, int len, int isFinal); 24 | XML_Parser (*ParserCreate_MM)( 25 | const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, 26 | const XML_Char *namespaceSeparator); 27 | void (*ParserFree)(XML_Parser parser); 28 | void (*SetCharacterDataHandler)( 29 | XML_Parser parser, XML_CharacterDataHandler handler); 30 | void (*SetCommentHandler)( 31 | XML_Parser parser, XML_CommentHandler handler); 32 | void (*SetDefaultHandlerExpand)( 33 | XML_Parser parser, XML_DefaultHandler handler); 34 | void (*SetElementHandler)( 35 | XML_Parser parser, XML_StartElementHandler start, 36 | XML_EndElementHandler end); 37 | void (*SetNamespaceDeclHandler)( 38 | XML_Parser parser, XML_StartNamespaceDeclHandler start, 39 | XML_EndNamespaceDeclHandler end); 40 | void (*SetProcessingInstructionHandler)( 41 | XML_Parser parser, XML_ProcessingInstructionHandler handler); 42 | void (*SetUnknownEncodingHandler)( 43 | XML_Parser parser, XML_UnknownEncodingHandler handler, 44 | void *encodingHandlerData); 45 | void (*SetUserData)(XML_Parser parser, void *userData); 46 | /* always add new stuff to the end! */ 47 | }; 48 | 49 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pygetopt.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_PYGETOPT_H 3 | #define Py_PYGETOPT_H 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | PyAPI_DATA(int) _PyOS_opterr; 9 | PyAPI_DATA(int) _PyOS_optind; 10 | PyAPI_DATA(char *) _PyOS_optarg; 11 | 12 | PyAPI_FUNC(void) _PyOS_ResetGetOpt(void); 13 | PyAPI_FUNC(int) _PyOS_GetOpt(int argc, char **argv, char *optstring); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | #endif /* !Py_PYGETOPT_H */ 19 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pymacconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef PYMACCONFIG_H 2 | #define PYMACCONFIG_H 3 | /* 4 | * This file moves some of the autoconf magic to compile-time 5 | * when building on MacOSX. This is needed for building 4-way 6 | * universal binaries and for 64-bit universal binaries because 7 | * the values redefined below aren't configure-time constant but 8 | * only compile-time constant in these scenarios. 9 | */ 10 | 11 | #if defined(__APPLE__) 12 | 13 | # undef SIZEOF_LONG 14 | # undef SIZEOF_PTHREAD_T 15 | # undef SIZEOF_SIZE_T 16 | # undef SIZEOF_TIME_T 17 | # undef SIZEOF_VOID_P 18 | # undef SIZEOF__BOOL 19 | # undef SIZEOF_UINTPTR_T 20 | # undef SIZEOF_PTHREAD_T 21 | # undef WORDS_BIGENDIAN 22 | # undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 23 | # undef DOUBLE_IS_BIG_ENDIAN_IEEE754 24 | # undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 25 | # undef HAVE_GCC_ASM_FOR_X87 26 | 27 | # undef VA_LIST_IS_ARRAY 28 | # if defined(__LP64__) && defined(__x86_64__) 29 | # define VA_LIST_IS_ARRAY 1 30 | # endif 31 | 32 | # undef HAVE_LARGEFILE_SUPPORT 33 | # ifndef __LP64__ 34 | # define HAVE_LARGEFILE_SUPPORT 1 35 | # endif 36 | 37 | # undef SIZEOF_LONG 38 | # ifdef __LP64__ 39 | # define SIZEOF__BOOL 1 40 | # define SIZEOF__BOOL 1 41 | # define SIZEOF_LONG 8 42 | # define SIZEOF_PTHREAD_T 8 43 | # define SIZEOF_SIZE_T 8 44 | # define SIZEOF_TIME_T 8 45 | # define SIZEOF_VOID_P 8 46 | # define SIZEOF_UINTPTR_T 8 47 | # define SIZEOF_PTHREAD_T 8 48 | # else 49 | # ifdef __ppc__ 50 | # define SIZEOF__BOOL 4 51 | # else 52 | # define SIZEOF__BOOL 1 53 | # endif 54 | # define SIZEOF_LONG 4 55 | # define SIZEOF_PTHREAD_T 4 56 | # define SIZEOF_SIZE_T 4 57 | # define SIZEOF_TIME_T 4 58 | # define SIZEOF_VOID_P 4 59 | # define SIZEOF_UINTPTR_T 4 60 | # define SIZEOF_PTHREAD_T 4 61 | # endif 62 | 63 | # if defined(__LP64__) 64 | /* MacOSX 10.4 (the first release to support 64-bit code 65 | * at all) only supports 64-bit in the UNIX layer. 66 | * Therefore surpress the toolbox-glue in 64-bit mode. 67 | */ 68 | 69 | /* In 64-bit mode setpgrp always has no argments, in 32-bit 70 | * mode that depends on the compilation environment 71 | */ 72 | # undef SETPGRP_HAVE_ARG 73 | 74 | # endif 75 | 76 | #ifdef __BIG_ENDIAN__ 77 | #define WORDS_BIGENDIAN 1 78 | #define DOUBLE_IS_BIG_ENDIAN_IEEE754 79 | #else 80 | #define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 81 | #endif /* __BIG_ENDIAN */ 82 | 83 | #ifdef __i386__ 84 | # define HAVE_GCC_ASM_FOR_X87 85 | #endif 86 | 87 | /* 88 | * The definition in pyconfig.h is only valid on the OS release 89 | * where configure ran on and not necessarily for all systems where 90 | * the executable can be used on. 91 | * 92 | * Specifically: OSX 10.4 has limited supported for '%zd', while 93 | * 10.5 has full support for '%zd'. A binary built on 10.5 won't 94 | * work properly on 10.4 unless we surpress the definition 95 | * of PY_FORMAT_SIZE_T 96 | */ 97 | #undef PY_FORMAT_SIZE_T 98 | 99 | 100 | #endif /* defined(_APPLE__) */ 101 | 102 | #endif /* PYMACCONFIG_H */ 103 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pymem.h: -------------------------------------------------------------------------------- 1 | /* The PyMem_ family: low-level memory allocation interfaces. 2 | See objimpl.h for the PyObject_ memory family. 3 | */ 4 | 5 | #ifndef Py_PYMEM_H 6 | #define Py_PYMEM_H 7 | 8 | #include "pyport.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* BEWARE: 15 | 16 | Each interface exports both functions and macros. Extension modules should 17 | use the functions, to ensure binary compatibility across Python versions. 18 | Because the Python implementation is free to change internal details, and 19 | the macros may (or may not) expose details for speed, if you do use the 20 | macros you must recompile your extensions with each Python release. 21 | 22 | Never mix calls to PyMem_ with calls to the platform malloc/realloc/ 23 | calloc/free. For example, on Windows different DLLs may end up using 24 | different heaps, and if you use PyMem_Malloc you'll get the memory from the 25 | heap used by the Python DLL; it could be a disaster if you free()'ed that 26 | directly in your own extension. Using PyMem_Free instead ensures Python 27 | can return the memory to the proper heap. As another example, in 28 | PYMALLOC_DEBUG mode, Python wraps all calls to all PyMem_ and PyObject_ 29 | memory functions in special debugging wrappers that add additional 30 | debugging info to dynamic memory blocks. The system routines have no idea 31 | what to do with that stuff, and the Python wrappers have no idea what to do 32 | with raw blocks obtained directly by the system routines then. 33 | 34 | The GIL must be held when using these APIs. 35 | */ 36 | 37 | /* 38 | * Raw memory interface 39 | * ==================== 40 | */ 41 | 42 | /* Functions 43 | 44 | Functions supplying platform-independent semantics for malloc/realloc/ 45 | free. These functions make sure that allocating 0 bytes returns a distinct 46 | non-NULL pointer (whenever possible -- if we're flat out of memory, NULL 47 | may be returned), even if the platform malloc and realloc don't. 48 | Returned pointers must be checked for NULL explicitly. No action is 49 | performed on failure (no exception is set, no warning is printed, etc). 50 | */ 51 | 52 | PyAPI_FUNC(void *) PyMem_Malloc(size_t); 53 | PyAPI_FUNC(void *) PyMem_Realloc(void *, size_t); 54 | PyAPI_FUNC(void) PyMem_Free(void *); 55 | 56 | /* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are 57 | no longer supported. They used to call PyErr_NoMemory() on failure. */ 58 | 59 | /* Macros. */ 60 | #ifdef PYMALLOC_DEBUG 61 | /* Redirect all memory operations to Python's debugging allocator. */ 62 | #define PyMem_MALLOC _PyMem_DebugMalloc 63 | #define PyMem_REALLOC _PyMem_DebugRealloc 64 | #define PyMem_FREE _PyMem_DebugFree 65 | 66 | #else /* ! PYMALLOC_DEBUG */ 67 | 68 | /* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL 69 | for malloc(0), which would be treated as an error. Some platforms 70 | would return a pointer with no memory behind it, which would break 71 | pymalloc. To solve these problems, allocate an extra byte. */ 72 | /* Returns NULL to indicate error if a negative size or size larger than 73 | Py_ssize_t can represent is supplied. Helps prevents security holes. */ 74 | #define PyMem_MALLOC(n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \ 75 | : malloc((n) ? (n) : 1)) 76 | #define PyMem_REALLOC(p, n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \ 77 | : realloc((p), (n) ? (n) : 1)) 78 | #define PyMem_FREE free 79 | 80 | #endif /* PYMALLOC_DEBUG */ 81 | 82 | /* 83 | * Type-oriented memory interface 84 | * ============================== 85 | * 86 | * Allocate memory for n objects of the given type. Returns a new pointer 87 | * or NULL if the request was too large or memory allocation failed. Use 88 | * these macros rather than doing the multiplication yourself so that proper 89 | * overflow checking is always done. 90 | */ 91 | 92 | #define PyMem_New(type, n) \ 93 | ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ 94 | ( (type *) PyMem_Malloc((n) * sizeof(type)) ) ) 95 | #define PyMem_NEW(type, n) \ 96 | ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ 97 | ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) 98 | 99 | /* 100 | * The value of (p) is always clobbered by this macro regardless of success. 101 | * The caller MUST check if (p) is NULL afterwards and deal with the memory 102 | * error if so. This means the original value of (p) MUST be saved for the 103 | * caller's memory error handler to not lose track of it. 104 | */ 105 | #define PyMem_Resize(p, type, n) \ 106 | ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ 107 | (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) 108 | #define PyMem_RESIZE(p, type, n) \ 109 | ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ 110 | (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) 111 | 112 | /* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used 113 | * anymore. They're just confusing aliases for PyMem_{Free,FREE} now. 114 | */ 115 | #define PyMem_Del PyMem_Free 116 | #define PyMem_DEL PyMem_FREE 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* !Py_PYMEM_H */ 123 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pystrcmp.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_STRCMP_H 2 | #define Py_STRCMP_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t); 9 | PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *); 10 | 11 | #if defined(MS_WINDOWS) || defined(PYOS_OS2) 12 | #define PyOS_strnicmp strnicmp 13 | #define PyOS_stricmp stricmp 14 | #else 15 | #define PyOS_strnicmp PyOS_mystrnicmp 16 | #define PyOS_stricmp PyOS_mystricmp 17 | #endif 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif /* !Py_STRCMP_H */ 24 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pystrtod.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_STRTOD_H 2 | #define Py_STRTOD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | 9 | PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr); 10 | PyAPI_FUNC(double) PyOS_ascii_atof(const char *str); 11 | 12 | /* Deprecated in 2.7 and 3.1. Will disappear in 2.8 (if it exists) and 3.2 */ 13 | PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, 14 | const char *format, double d); 15 | PyAPI_FUNC(double) PyOS_string_to_double(const char *str, 16 | char **endptr, 17 | PyObject *overflow_exception); 18 | 19 | /* The caller is responsible for calling PyMem_Free to free the buffer 20 | that's is returned. */ 21 | PyAPI_FUNC(char *) PyOS_double_to_string(double val, 22 | char format_code, 23 | int precision, 24 | int flags, 25 | int *type); 26 | 27 | PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr); 28 | 29 | 30 | /* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */ 31 | #define Py_DTSF_SIGN 0x01 /* always add the sign */ 32 | #define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */ 33 | #define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code 34 | specific */ 35 | 36 | /* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */ 37 | #define Py_DTST_FINITE 0 38 | #define Py_DTST_INFINITE 1 39 | #define Py_DTST_NAN 2 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* !Py_STRTOD_H */ 46 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/pythread.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_PYTHREAD_H 3 | #define Py_PYTHREAD_H 4 | 5 | typedef void *PyThread_type_lock; 6 | typedef void *PyThread_type_sema; 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | PyAPI_FUNC(void) PyThread_init_thread(void); 13 | PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); 14 | PyAPI_FUNC(void) PyThread_exit_thread(void); 15 | PyAPI_FUNC(long) PyThread_get_thread_ident(void); 16 | 17 | PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); 18 | PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); 19 | PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); 20 | #define WAIT_LOCK 1 21 | #define NOWAIT_LOCK 0 22 | PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); 23 | 24 | PyAPI_FUNC(size_t) PyThread_get_stacksize(void); 25 | PyAPI_FUNC(int) PyThread_set_stacksize(size_t); 26 | 27 | /* Thread Local Storage (TLS) API */ 28 | PyAPI_FUNC(int) PyThread_create_key(void); 29 | PyAPI_FUNC(void) PyThread_delete_key(int); 30 | PyAPI_FUNC(int) PyThread_set_key_value(int, void *); 31 | PyAPI_FUNC(void *) PyThread_get_key_value(int); 32 | PyAPI_FUNC(void) PyThread_delete_key_value(int key); 33 | 34 | /* Cleanup after a fork */ 35 | PyAPI_FUNC(void) PyThread_ReInitTLS(void); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* !Py_PYTHREAD_H */ 42 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/rangeobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Range object interface */ 3 | 4 | #ifndef Py_RANGEOBJECT_H 5 | #define Py_RANGEOBJECT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /* This is about the type 'xrange', not the built-in function range(), which 11 | returns regular lists. */ 12 | 13 | /* 14 | A range object represents an integer range. This is an immutable object; 15 | a range cannot change its value after creation. 16 | 17 | Range objects behave like the corresponding tuple objects except that 18 | they are represented by a start, stop, and step datamembers. 19 | */ 20 | 21 | PyAPI_DATA(PyTypeObject) PyRange_Type; 22 | 23 | #define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type) 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | #endif /* !Py_RANGEOBJECT_H */ 29 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/setobject.h: -------------------------------------------------------------------------------- 1 | /* Set object interface */ 2 | 3 | #ifndef Py_SETOBJECT_H 4 | #define Py_SETOBJECT_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | 10 | /* 11 | There are three kinds of slots in the table: 12 | 13 | 1. Unused: key == NULL 14 | 2. Active: key != NULL and key != dummy 15 | 3. Dummy: key == dummy 16 | 17 | Note: .pop() abuses the hash field of an Unused or Dummy slot to 18 | hold a search finger. The hash field of Unused or Dummy slots has 19 | no meaning otherwise. 20 | */ 21 | 22 | #define PySet_MINSIZE 8 23 | 24 | typedef struct { 25 | long hash; /* cached hash code for the entry key */ 26 | PyObject *key; 27 | } setentry; 28 | 29 | 30 | /* 31 | This data structure is shared by set and frozenset objects. 32 | */ 33 | 34 | typedef struct _setobject PySetObject; 35 | struct _setobject { 36 | PyObject_HEAD 37 | 38 | Py_ssize_t fill; /* # Active + # Dummy */ 39 | Py_ssize_t used; /* # Active */ 40 | 41 | /* The table contains mask + 1 slots, and that's a power of 2. 42 | * We store the mask instead of the size because the mask is more 43 | * frequently needed. 44 | */ 45 | Py_ssize_t mask; 46 | 47 | /* table points to smalltable for small tables, else to 48 | * additional malloc'ed memory. table is never NULL! This rule 49 | * saves repeated runtime null-tests. 50 | */ 51 | setentry *table; 52 | setentry *(*lookup)(PySetObject *so, PyObject *key, long hash); 53 | setentry smalltable[PySet_MINSIZE]; 54 | 55 | long hash; /* only used by frozenset objects */ 56 | PyObject *weakreflist; /* List of weak references */ 57 | }; 58 | 59 | PyAPI_DATA(PyTypeObject) PySet_Type; 60 | PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; 61 | 62 | /* Invariants for frozensets: 63 | * data is immutable. 64 | * hash is the hash of the frozenset or -1 if not computed yet. 65 | * Invariants for sets: 66 | * hash is -1 67 | */ 68 | 69 | #define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type) 70 | #define PyAnySet_CheckExact(ob) \ 71 | (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type) 72 | #define PyAnySet_Check(ob) \ 73 | (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \ 74 | PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ 75 | PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) 76 | #define PySet_Check(ob) \ 77 | (Py_TYPE(ob) == &PySet_Type || \ 78 | PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) 79 | #define PyFrozenSet_Check(ob) \ 80 | (Py_TYPE(ob) == &PyFrozenSet_Type || \ 81 | PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) 82 | 83 | PyAPI_FUNC(PyObject *) PySet_New(PyObject *); 84 | PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); 85 | PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset); 86 | #define PySet_GET_SIZE(so) (((PySetObject *)(so))->used) 87 | PyAPI_FUNC(int) PySet_Clear(PyObject *set); 88 | PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key); 89 | PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key); 90 | PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key); 91 | PyAPI_FUNC(int) _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **key); 92 | PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash); 93 | PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set); 94 | PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable); 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #endif /* !Py_SETOBJECT_H */ 100 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/sliceobject.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_SLICEOBJECT_H 2 | #define Py_SLICEOBJECT_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | /* The unique ellipsis object "..." */ 8 | 9 | PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */ 10 | 11 | #define Py_Ellipsis (&_Py_EllipsisObject) 12 | 13 | /* Slice object interface */ 14 | 15 | /* 16 | 17 | A slice object containing start, stop, and step data members (the 18 | names are from range). After much talk with Guido, it was decided to 19 | let these be any arbitrary python type. Py_None stands for omitted values. 20 | */ 21 | 22 | typedef struct { 23 | PyObject_HEAD 24 | PyObject *start, *stop, *step; /* not NULL */ 25 | } PySliceObject; 26 | 27 | PyAPI_DATA(PyTypeObject) PySlice_Type; 28 | PyAPI_DATA(PyTypeObject) PyEllipsis_Type; 29 | 30 | #define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type) 31 | 32 | PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, 33 | PyObject* step); 34 | PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop); 35 | PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length, 36 | Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); 37 | PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length, 38 | Py_ssize_t *start, Py_ssize_t *stop, 39 | Py_ssize_t *step, Py_ssize_t *slicelength); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif /* !Py_SLICEOBJECT_H */ 45 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/structmember.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_STRUCTMEMBER_H 2 | #define Py_STRUCTMEMBER_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | 8 | /* Interface to map C struct members to Python object attributes */ 9 | 10 | #include /* For offsetof */ 11 | 12 | /* The offsetof() macro calculates the offset of a structure member 13 | in its structure. Unfortunately this cannot be written down 14 | portably, hence it is provided by a Standard C header file. 15 | For pre-Standard C compilers, here is a version that usually works 16 | (but watch out!): */ 17 | 18 | #ifndef offsetof 19 | #define offsetof(type, member) ( (int) & ((type*)0) -> member ) 20 | #endif 21 | 22 | /* An array of memberlist structures defines the name, type and offset 23 | of selected members of a C structure. These can be read by 24 | PyMember_Get() and set by PyMember_Set() (except if their READONLY flag 25 | is set). The array must be terminated with an entry whose name 26 | pointer is NULL. */ 27 | 28 | struct memberlist { 29 | /* Obsolete version, for binary backwards compatibility */ 30 | char *name; 31 | int type; 32 | int offset; 33 | int flags; 34 | }; 35 | 36 | typedef struct PyMemberDef { 37 | /* Current version, use this */ 38 | char *name; 39 | int type; 40 | Py_ssize_t offset; 41 | int flags; 42 | char *doc; 43 | } PyMemberDef; 44 | 45 | /* Types */ 46 | #define T_SHORT 0 47 | #define T_INT 1 48 | #define T_LONG 2 49 | #define T_FLOAT 3 50 | #define T_DOUBLE 4 51 | #define T_STRING 5 52 | #define T_OBJECT 6 53 | /* XXX the ordering here is weird for binary compatibility */ 54 | #define T_CHAR 7 /* 1-character string */ 55 | #define T_BYTE 8 /* 8-bit signed int */ 56 | /* unsigned variants: */ 57 | #define T_UBYTE 9 58 | #define T_USHORT 10 59 | #define T_UINT 11 60 | #define T_ULONG 12 61 | 62 | /* Added by Jack: strings contained in the structure */ 63 | #define T_STRING_INPLACE 13 64 | 65 | /* Added by Lillo: bools contained in the structure (assumed char) */ 66 | #define T_BOOL 14 67 | 68 | #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError 69 | when the value is NULL, instead of 70 | converting to None. */ 71 | #ifdef HAVE_LONG_LONG 72 | #define T_LONGLONG 17 73 | #define T_ULONGLONG 18 74 | #endif /* HAVE_LONG_LONG */ 75 | 76 | #define T_PYSSIZET 19 /* Py_ssize_t */ 77 | 78 | 79 | /* Flags */ 80 | #define READONLY 1 81 | #define RO READONLY /* Shorthand */ 82 | #define READ_RESTRICTED 2 83 | #define PY_WRITE_RESTRICTED 4 84 | #define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) 85 | 86 | 87 | /* Obsolete API, for binary backwards compatibility */ 88 | PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *); 89 | PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *); 90 | 91 | /* Current API, use this */ 92 | PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *); 93 | PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *); 94 | 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #endif /* !Py_STRUCTMEMBER_H */ 100 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/structseq.h: -------------------------------------------------------------------------------- 1 | 2 | /* Tuple object interface */ 3 | 4 | #ifndef Py_STRUCTSEQ_H 5 | #define Py_STRUCTSEQ_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct PyStructSequence_Field { 11 | char *name; 12 | char *doc; 13 | } PyStructSequence_Field; 14 | 15 | typedef struct PyStructSequence_Desc { 16 | char *name; 17 | char *doc; 18 | struct PyStructSequence_Field *fields; 19 | int n_in_sequence; 20 | } PyStructSequence_Desc; 21 | 22 | extern char* PyStructSequence_UnnamedField; 23 | 24 | PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, 25 | PyStructSequence_Desc *desc); 26 | 27 | PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); 28 | 29 | typedef struct { 30 | PyObject_VAR_HEAD 31 | PyObject *ob_item[1]; 32 | } PyStructSequence; 33 | 34 | /* Macro, *only* to be used to fill in brand new objects */ 35 | #define PyStructSequence_SET_ITEM(op, i, v) \ 36 | (((PyStructSequence *)(op))->ob_item[i] = v) 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif /* !Py_STRUCTSEQ_H */ 42 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/symtable.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_SYMTABLE_H 2 | #define Py_SYMTABLE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock } 9 | _Py_block_ty; 10 | 11 | struct _symtable_entry; 12 | 13 | struct symtable { 14 | const char *st_filename; /* name of file being compiled */ 15 | struct _symtable_entry *st_cur; /* current symbol table entry */ 16 | struct _symtable_entry *st_top; /* module entry */ 17 | PyObject *st_symbols; /* dictionary of symbol table entries */ 18 | PyObject *st_stack; /* stack of namespace info */ 19 | PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ 20 | int st_nblocks; /* number of blocks */ 21 | PyObject *st_private; /* name of current class or NULL */ 22 | PyFutureFeatures *st_future; /* module's future features */ 23 | }; 24 | 25 | typedef struct _symtable_entry { 26 | PyObject_HEAD 27 | PyObject *ste_id; /* int: key in st_symbols */ 28 | PyObject *ste_symbols; /* dict: name to flags */ 29 | PyObject *ste_name; /* string: name of block */ 30 | PyObject *ste_varnames; /* list of variable names */ 31 | PyObject *ste_children; /* list of child ids */ 32 | _Py_block_ty ste_type; /* module, class, or function */ 33 | int ste_unoptimized; /* false if namespace is optimized */ 34 | int ste_nested; /* true if block is nested */ 35 | unsigned ste_free : 1; /* true if block has free variables */ 36 | unsigned ste_child_free : 1; /* true if a child block has free vars, 37 | including free refs to globals */ 38 | unsigned ste_generator : 1; /* true if namespace is a generator */ 39 | unsigned ste_varargs : 1; /* true if block has varargs */ 40 | unsigned ste_varkeywords : 1; /* true if block has varkeywords */ 41 | unsigned ste_returns_value : 1; /* true if namespace uses return with 42 | an argument */ 43 | int ste_lineno; /* first line of block */ 44 | int ste_opt_lineno; /* lineno of last exec or import * */ 45 | int ste_tmpname; /* counter for listcomp temp vars */ 46 | struct symtable *ste_table; 47 | } PySTEntryObject; 48 | 49 | PyAPI_DATA(PyTypeObject) PySTEntry_Type; 50 | 51 | #define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type) 52 | 53 | PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); 54 | 55 | PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *, 56 | PyFutureFeatures *); 57 | PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *); 58 | 59 | PyAPI_FUNC(void) PySymtable_Free(struct symtable *); 60 | 61 | /* Flags for def-use information */ 62 | 63 | #define DEF_GLOBAL 1 /* global stmt */ 64 | #define DEF_LOCAL 2 /* assignment in code block */ 65 | #define DEF_PARAM 2<<1 /* formal parameter */ 66 | #define USE 2<<2 /* name is used */ 67 | #define DEF_FREE 2<<3 /* name used but not defined in nested block */ 68 | #define DEF_FREE_CLASS 2<<4 /* free variable from class's method */ 69 | #define DEF_IMPORT 2<<5 /* assignment occurred via import */ 70 | 71 | #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) 72 | 73 | /* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol 74 | table. GLOBAL is returned from PyST_GetScope() for either of them. 75 | It is stored in ste_symbols at bits 12-14. 76 | */ 77 | #define SCOPE_OFF 11 78 | #define SCOPE_MASK 7 79 | 80 | #define LOCAL 1 81 | #define GLOBAL_EXPLICIT 2 82 | #define GLOBAL_IMPLICIT 3 83 | #define FREE 4 84 | #define CELL 5 85 | 86 | /* The following three names are used for the ste_unoptimized bit field */ 87 | #define OPT_IMPORT_STAR 1 88 | #define OPT_EXEC 2 89 | #define OPT_BARE_EXEC 4 90 | #define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */ 91 | 92 | #define GENERATOR 1 93 | #define GENERATOR_EXPRESSION 2 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | #endif /* !Py_SYMTABLE_H */ 99 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/sysmodule.h: -------------------------------------------------------------------------------- 1 | 2 | /* System module interface */ 3 | 4 | #ifndef Py_SYSMODULE_H 5 | #define Py_SYSMODULE_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | PyAPI_FUNC(PyObject *) PySys_GetObject(char *); 11 | PyAPI_FUNC(int) PySys_SetObject(char *, PyObject *); 12 | PyAPI_FUNC(FILE *) PySys_GetFile(char *, FILE *); 13 | PyAPI_FUNC(void) PySys_SetArgv(int, char **); 14 | PyAPI_FUNC(void) PySys_SetArgvEx(int, char **, int); 15 | PyAPI_FUNC(void) PySys_SetPath(char *); 16 | 17 | PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) 18 | Py_GCC_ATTRIBUTE((format(printf, 1, 2))); 19 | PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) 20 | Py_GCC_ATTRIBUTE((format(printf, 1, 2))); 21 | 22 | PyAPI_FUNC(void) PySys_ResetWarnOptions(void); 23 | PyAPI_FUNC(void) PySys_AddWarnOption(char *); 24 | PyAPI_FUNC(int) PySys_HasWarnOptions(void); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | #endif /* !Py_SYSMODULE_H */ 30 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/timefuncs.h: -------------------------------------------------------------------------------- 1 | /* timefuncs.h 2 | */ 3 | 4 | /* Utility function related to timemodule.c. */ 5 | 6 | #ifndef TIMEFUNCS_H 7 | #define TIMEFUNCS_H 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | 13 | /* Cast double x to time_t, but raise ValueError if x is too large 14 | * to fit in a time_t. ValueError is set on return iff the return 15 | * value is (time_t)-1 and PyErr_Occurred(). 16 | */ 17 | PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x); 18 | 19 | /* Get the current time since the epoch in seconds */ 20 | PyAPI_FUNC(double) _PyTime_FloatTime(void); 21 | 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | #endif /* TIMEFUNCS_H */ 27 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/token.h: -------------------------------------------------------------------------------- 1 | 2 | /* Token types */ 3 | 4 | #ifndef Py_TOKEN_H 5 | #define Py_TOKEN_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */ 11 | 12 | #define ENDMARKER 0 13 | #define NAME 1 14 | #define NUMBER 2 15 | #define STRING 3 16 | #define NEWLINE 4 17 | #define INDENT 5 18 | #define DEDENT 6 19 | #define LPAR 7 20 | #define RPAR 8 21 | #define LSQB 9 22 | #define RSQB 10 23 | #define COLON 11 24 | #define COMMA 12 25 | #define SEMI 13 26 | #define PLUS 14 27 | #define MINUS 15 28 | #define STAR 16 29 | #define SLASH 17 30 | #define VBAR 18 31 | #define AMPER 19 32 | #define LESS 20 33 | #define GREATER 21 34 | #define EQUAL 22 35 | #define DOT 23 36 | #define PERCENT 24 37 | #define BACKQUOTE 25 38 | #define LBRACE 26 39 | #define RBRACE 27 40 | #define EQEQUAL 28 41 | #define NOTEQUAL 29 42 | #define LESSEQUAL 30 43 | #define GREATEREQUAL 31 44 | #define TILDE 32 45 | #define CIRCUMFLEX 33 46 | #define LEFTSHIFT 34 47 | #define RIGHTSHIFT 35 48 | #define DOUBLESTAR 36 49 | #define PLUSEQUAL 37 50 | #define MINEQUAL 38 51 | #define STAREQUAL 39 52 | #define SLASHEQUAL 40 53 | #define PERCENTEQUAL 41 54 | #define AMPEREQUAL 42 55 | #define VBAREQUAL 43 56 | #define CIRCUMFLEXEQUAL 44 57 | #define LEFTSHIFTEQUAL 45 58 | #define RIGHTSHIFTEQUAL 46 59 | #define DOUBLESTAREQUAL 47 60 | #define DOUBLESLASH 48 61 | #define DOUBLESLASHEQUAL 49 62 | #define AT 50 63 | /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ 64 | #define OP 51 65 | #define ERRORTOKEN 52 66 | #define N_TOKENS 53 67 | 68 | /* Special definitions for cooperation with parser */ 69 | 70 | #define NT_OFFSET 256 71 | 72 | #define ISTERMINAL(x) ((x) < NT_OFFSET) 73 | #define ISNONTERMINAL(x) ((x) >= NT_OFFSET) 74 | #define ISEOF(x) ((x) == ENDMARKER) 75 | 76 | 77 | PyAPI_DATA(char *) _PyParser_TokenNames[]; /* Token names */ 78 | PyAPI_FUNC(int) PyToken_OneChar(int); 79 | PyAPI_FUNC(int) PyToken_TwoChars(int, int); 80 | PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | #endif /* !Py_TOKEN_H */ 86 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/traceback.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef Py_TRACEBACK_H 3 | #define Py_TRACEBACK_H 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | struct _frame; 9 | 10 | /* Traceback interface */ 11 | 12 | typedef struct _traceback { 13 | PyObject_HEAD 14 | struct _traceback *tb_next; 15 | struct _frame *tb_frame; 16 | int tb_lasti; 17 | int tb_lineno; 18 | } PyTracebackObject; 19 | 20 | PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *); 21 | PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *); 22 | PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, const char *, int, int); 23 | 24 | /* Reveal traceback type so we can typecheck traceback objects */ 25 | PyAPI_DATA(PyTypeObject) PyTraceBack_Type; 26 | #define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type) 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | #endif /* !Py_TRACEBACK_H */ 32 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/tupleobject.h: -------------------------------------------------------------------------------- 1 | 2 | /* Tuple object interface */ 3 | 4 | #ifndef Py_TUPLEOBJECT_H 5 | #define Py_TUPLEOBJECT_H 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /* 11 | Another generally useful object type is a tuple of object pointers. 12 | For Python, this is an immutable type. C code can change the tuple items 13 | (but not their number), and even use tuples are general-purpose arrays of 14 | object references, but in general only brand new tuples should be mutated, 15 | not ones that might already have been exposed to Python code. 16 | 17 | *** WARNING *** PyTuple_SetItem does not increment the new item's reference 18 | count, but does decrement the reference count of the item it replaces, 19 | if not nil. It does *decrement* the reference count if it is *not* 20 | inserted in the tuple. Similarly, PyTuple_GetItem does not increment the 21 | returned item's reference count. 22 | */ 23 | 24 | typedef struct { 25 | PyObject_VAR_HEAD 26 | PyObject *ob_item[1]; 27 | 28 | /* ob_item contains space for 'ob_size' elements. 29 | * Items must normally not be NULL, except during construction when 30 | * the tuple is not yet visible outside the function that builds it. 31 | */ 32 | } PyTupleObject; 33 | 34 | PyAPI_DATA(PyTypeObject) PyTuple_Type; 35 | 36 | #define PyTuple_Check(op) \ 37 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) 38 | #define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type) 39 | 40 | PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); 41 | PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); 42 | PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t); 43 | PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); 44 | PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); 45 | PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); 46 | PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); 47 | PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); 48 | 49 | /* Macro, trading safety for speed */ 50 | #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) 51 | #define PyTuple_GET_SIZE(op) Py_SIZE(op) 52 | 53 | /* Macro, *only* to be used to fill in brand new tuples */ 54 | #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) 55 | 56 | PyAPI_FUNC(int) PyTuple_ClearFreeList(void); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #endif /* !Py_TUPLEOBJECT_H */ 62 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/ucnhash.h: -------------------------------------------------------------------------------- 1 | /* Unicode name database interface */ 2 | 3 | #ifndef Py_UCNHASH_H 4 | #define Py_UCNHASH_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /* revised ucnhash CAPI interface (exported through a "wrapper") */ 10 | 11 | #define PyUnicodeData_CAPSULE_NAME "unicodedata.ucnhash_CAPI" 12 | 13 | typedef struct { 14 | 15 | /* Size of this struct */ 16 | int size; 17 | 18 | /* Get name for a given character code. Returns non-zero if 19 | success, zero if not. Does not set Python exceptions. 20 | If self is NULL, data come from the default version of the database. 21 | If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */ 22 | int (*getname)(PyObject *self, Py_UCS4 code, char* buffer, int buflen); 23 | 24 | /* Get character code for a given name. Same error handling 25 | as for getname. */ 26 | int (*getcode)(PyObject *self, const char* name, int namelen, Py_UCS4* code); 27 | 28 | } _PyUnicode_Name_CAPI; 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | #endif /* !Py_UCNHASH_H */ 34 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/warnings.h: -------------------------------------------------------------------------------- 1 | #ifndef Py_WARNINGS_H 2 | #define Py_WARNINGS_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | PyAPI_FUNC(void) _PyWarnings_Init(void); 8 | 9 | PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t); 10 | PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int, 11 | const char *, PyObject *); 12 | 13 | #define PyErr_WarnPy3k(msg, stacklevel) \ 14 | (Py_Py3kWarningFlag ? PyErr_WarnEx(PyExc_DeprecationWarning, msg, stacklevel) : 0) 15 | 16 | /* DEPRECATED: Use PyErr_WarnEx() instead. */ 17 | #define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1) 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif /* !Py_WARNINGS_H */ 23 | 24 | -------------------------------------------------------------------------------- /src/pybind11/python27/include/weakrefobject.h: -------------------------------------------------------------------------------- 1 | /* Weak references objects for Python. */ 2 | 3 | #ifndef Py_WEAKREFOBJECT_H 4 | #define Py_WEAKREFOBJECT_H 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | 10 | typedef struct _PyWeakReference PyWeakReference; 11 | 12 | /* PyWeakReference is the base struct for the Python ReferenceType, ProxyType, 13 | * and CallableProxyType. 14 | */ 15 | struct _PyWeakReference { 16 | PyObject_HEAD 17 | 18 | /* The object to which this is a weak reference, or Py_None if none. 19 | * Note that this is a stealth reference: wr_object's refcount is 20 | * not incremented to reflect this pointer. 21 | */ 22 | PyObject *wr_object; 23 | 24 | /* A callable to invoke when wr_object dies, or NULL if none. */ 25 | PyObject *wr_callback; 26 | 27 | /* A cache for wr_object's hash code. As usual for hashes, this is -1 28 | * if the hash code isn't known yet. 29 | */ 30 | long hash; 31 | 32 | /* If wr_object is weakly referenced, wr_object has a doubly-linked NULL- 33 | * terminated list of weak references to it. These are the list pointers. 34 | * If wr_object goes away, wr_object is set to Py_None, and these pointers 35 | * have no meaning then. 36 | */ 37 | PyWeakReference *wr_prev; 38 | PyWeakReference *wr_next; 39 | }; 40 | 41 | PyAPI_DATA(PyTypeObject) _PyWeakref_RefType; 42 | PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType; 43 | PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; 44 | 45 | #define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) 46 | #define PyWeakref_CheckRefExact(op) \ 47 | (Py_TYPE(op) == &_PyWeakref_RefType) 48 | #define PyWeakref_CheckProxy(op) \ 49 | ((Py_TYPE(op) == &_PyWeakref_ProxyType) || \ 50 | (Py_TYPE(op) == &_PyWeakref_CallableProxyType)) 51 | 52 | #define PyWeakref_Check(op) \ 53 | (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) 54 | 55 | 56 | PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob, 57 | PyObject *callback); 58 | PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob, 59 | PyObject *callback); 60 | PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref); 61 | 62 | PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head); 63 | 64 | PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); 65 | 66 | /* Explanation for the Py_REFCNT() check: when a weakref's target is part 67 | of a long chain of deallocations which triggers the trashcan mechanism, 68 | clearing the weakrefs can be delayed long after the target's refcount 69 | has dropped to zero. In the meantime, code accessing the weakref will 70 | be able to "see" the target object even though it is supposed to be 71 | unreachable. See issue #16602. */ 72 | 73 | #define PyWeakref_GET_OBJECT(ref) \ 74 | (Py_REFCNT(((PyWeakReference *)(ref))->wr_object) > 0 \ 75 | ? ((PyWeakReference *)(ref))->wr_object \ 76 | : Py_None) 77 | 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif /* !Py_WEAKREFOBJECT_H */ 83 | -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_bsddb.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_bsddb.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_ctypes.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_ctypes.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_ctypes_test.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_ctypes_test.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_elementtree.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_elementtree.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_hashlib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_hashlib.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_msi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_msi.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_multiprocessing.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_multiprocessing.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_socket.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_socket.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_sqlite3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_sqlite3.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_ssl.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_ssl.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_testcapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_testcapi.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/_tkinter.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/_tkinter.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/bz2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/bz2.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/libpython27.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/libpython27.a -------------------------------------------------------------------------------- /src/pybind11/python27/libs/pyexpat.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/pyexpat.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/python27.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/python27.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/select.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/select.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/unicodedata.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/unicodedata.lib -------------------------------------------------------------------------------- /src/pybind11/python27/libs/winsound.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/pybind11/python27/libs/winsound.lib -------------------------------------------------------------------------------- /src/pybind11/typeid.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/typeid.h: Compiler-independent access to type identifiers 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | #include 14 | 15 | #if defined(__GNUG__) 16 | #include 17 | #endif 18 | 19 | NAMESPACE_BEGIN(pybind11) 20 | NAMESPACE_BEGIN(detail) 21 | /// Erase all occurrences of a substring 22 | inline void erase_all(std::string &string, const std::string &search) { 23 | for (size_t pos = 0;;) { 24 | pos = string.find(search, pos); 25 | if (pos == std::string::npos) break; 26 | string.erase(pos, search.length()); 27 | } 28 | } 29 | 30 | PYBIND11_NOINLINE inline void clean_type_id(std::string &name) { 31 | #if defined(__GNUG__) 32 | int status = 0; 33 | std::unique_ptr res { 34 | abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), std::free }; 35 | if (status == 0) 36 | name = res.get(); 37 | #else 38 | detail::erase_all(name, "class "); 39 | detail::erase_all(name, "struct "); 40 | detail::erase_all(name, "enum "); 41 | #endif 42 | detail::erase_all(name, "pybind11::"); 43 | } 44 | NAMESPACE_END(detail) 45 | 46 | /// Return a string representation of a C++ type 47 | template static std::string type_id() { 48 | std::string name(typeid(T).name()); 49 | detail::clean_type_id(name); 50 | return name; 51 | } 52 | 53 | NAMESPACE_END(pybind11) 54 | -------------------------------------------------------------------------------- /src/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/stdafx.cpp -------------------------------------------------------------------------------- /src/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/stdafx.h -------------------------------------------------------------------------------- /src/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/src/targetver.h -------------------------------------------------------------------------------- /test/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cheetahsec/avmdbg/8cdff228ea50f273a5bc850ce65cecebad7c7933/test/app-debug.apk -------------------------------------------------------------------------------- /test/demo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | #coding=utf-8 4 | 5 | from avmdbg import * 6 | 7 | 8 | class JdwpTag: 9 | def __init__(self): 10 | pass 11 | BYTE = 66 12 | CHAR = 67 13 | DOUBLE = 68 14 | FLOAT = 70 15 | INT = 73 16 | LONG = 74 17 | OBJECT = 76 18 | SHORT = 83 19 | BOOLEAN = 90 20 | ARRAY = 91 21 | 22 | 23 | def breakPointCallback0(context): 24 | print "### breakPointCallback0 ###" 25 | # 线程、堆栈 26 | print "[threadId]:%d" % context["threadId"] 27 | print "[threadName]:%s" % context["threadName"] 28 | print "[frameId]:%d" % context["frameId"] 29 | 30 | # 输出参数 31 | print "[param]:" 32 | for k, v in context["param"].items(): 33 | print k + ":" + str(v) 34 | 35 | # This指针 36 | thisObjectId = context["param"]["p0"]["id"] 37 | print "[this]:" 38 | objectFields = debugger.getObjectFieldValues(thisObjectId) 39 | for item in objectFields: 40 | print str(item) 41 | 42 | # 附加信息 43 | print "[reqExt]:" 44 | for k, v in context["reqExt"].items(): 45 | print k + ":" + str(v) 46 | 47 | # 堆栈回溯 48 | print "[stackFrames]:" 49 | stackFrames = debugger.getStackFrames(context["threadId"]) 50 | for frame in stackFrames: 51 | print frame["class"] + " -> " + \ 52 | frame["method"] + frame["sign"] + " [+]" + \ 53 | hex(frame["index"]) 54 | 55 | 56 | def breakPointCallback1(context): 57 | print "### breakPointCallback1 ###" 58 | strArray = debugger.getRegisterValue(context, "p3", JdwpTag.ARRAY) 59 | print "[p3]:" + str(strArray) 60 | print " [0]:" + str(debugger.getStringValue(strArray["value"]["data"][0])) 61 | print " [1]:" + str(debugger.getStringValue(strArray["value"]["data"][1])) 62 | 63 | print "[v0]:" + str(debugger.getRegisterValue(context, "v0", JdwpTag.OBJECT)) 64 | print "[v1]:" + str(debugger.getRegisterValue(context, "v1", JdwpTag.INT)) 65 | 66 | 67 | if __name__ == '__main__': 68 | 69 | debugger = AvmDebugger() 70 | 71 | if not debugger.attach("com.example.x0r.demo"): 72 | print "[err]: process attach fail!" 73 | exit(-1) 74 | 75 | # .method private 76 | # test0(B, [I, J, String) V 77 | # .registers 9 78 | # .param p1, "a0" 79 | # .param p2, "a1" 80 | # .param p3, "a2" 81 | # .param p5, "a3" 82 | # .prologue 83 | bp0 = { 84 | "class": "Lcom/example/x0r/demo/LoginActivity;", 85 | "method": "test0", 86 | "sign": "(B[IJLjava/lang/String;)V", 87 | "index": 0, 88 | "registers": 9, 89 | "callback": breakPointCallback0 90 | } 91 | 92 | if not debugger.setBreakPoint(bp0): 93 | print "[err]: set breakpoint0 fail!" 94 | exit(-1) 95 | 96 | # @a const-string v0, "test1" 97 | # @c aget v1, p1, v2 98 | # @e add-int/lit8 v1, v1, 0xb 99 | # @10 invoke-static {v1}, Ljava/lang/Integer;->toString(I)Ljava/lang/String; 100 | bp1 = { 101 | "class": "Lcom/example/x0r/demo/LoginActivity;", 102 | "method": "test1", 103 | "sign": "(B[IC[Ljava/lang/String;)V", 104 | "index": 0x10, 105 | "registers": 7, 106 | "callback": breakPointCallback1 107 | } 108 | 109 | if not debugger.setBreakPoint(bp0): 110 | print "[err]: set breakpoint1 fail!" 111 | exit(-1) 112 | 113 | debugger.waitLoop() 114 | --------------------------------------------------------------------------------