Solution refactoring and restructuring, removed Boost dependency, removed unused tools

This commit is contained in:
2022-11-21 23:42:01 +02:00
parent 33f19f9ff6
commit 9ef9f39e88
817 changed files with 326 additions and 59698 deletions

View File

@ -0,0 +1,77 @@
#include "StdAfx.h"
extern IPythonExceptionSender * g_pkExceptionSender;
PyObject* dbgLogBox(PyObject* poSelf, PyObject* poArgs)
{
char* szMsg;
char* szCaption;
if (!PyTuple_GetString(poArgs, 0, &szMsg))
return Py_BuildException();
if (!PyTuple_GetString(poArgs, 1, &szCaption))
{
LogBox(szMsg);
}
else
{
LogBox(szMsg,szCaption);
}
return Py_BuildNone();
}
PyObject* dbgTrace(PyObject* poSelf, PyObject* poArgs)
{
char* szMsg;
if (!PyTuple_GetString(poArgs, 0, &szMsg))
return Py_BuildException();
Trace(szMsg);
return Py_BuildNone();
}
PyObject* dbgTracen(PyObject* poSelf, PyObject* poArgs)
{
char* szMsg;
if (!PyTuple_GetString(poArgs, 0, &szMsg))
return Py_BuildException();
Tracen(szMsg);
return Py_BuildNone();
}
PyObject* dbgTraceError(PyObject* poSelf, PyObject* poArgs)
{
char* szMsg;
if (!PyTuple_GetString(poArgs, 0, &szMsg))
return Py_BuildException();
TraceError( "%s", szMsg );
return Py_BuildNone();
}
PyObject* dbgRegisterExceptionString(PyObject* poSelf, PyObject* poArgs)
{
char* szMsg;
if (!PyTuple_GetString(poArgs, 0, &szMsg))
return Py_BuildException();
if (g_pkExceptionSender)
g_pkExceptionSender->RegisterExceptionString(szMsg);
return Py_BuildNone();
}
void initdbg()
{
static PyMethodDef s_methods[] =
{
{ "LogBox", dbgLogBox, METH_VARARGS },
{ "Trace", dbgTrace, METH_VARARGS },
{ "Tracen", dbgTracen, METH_VARARGS },
{ "TraceError", dbgTraceError, METH_VARARGS },
{ "RegisterExceptionString", dbgRegisterExceptionString, METH_VARARGS },
{ NULL, NULL},
};
Py_InitModule("dbg", s_methods);
}

View File

@ -0,0 +1,3 @@
#pragma once
void initdbg();

View File

@ -0,0 +1,281 @@
#include "StdAfx.h"
#include "../eterPack/EterPackManager.h"
#include "PythonLauncher.h"
CPythonLauncher::CPythonLauncher()
{
Py_Initialize();
}
CPythonLauncher::~CPythonLauncher()
{
Clear();
}
void CPythonLauncher::Clear()
{
Py_Finalize();
}
std::string g_stTraceBuffer[512];
int g_nCurTraceN = 0;
void Traceback()
{
std::string str;
for (int i = 0; i < g_nCurTraceN; ++i)
{
str.append(g_stTraceBuffer[i]);
str.append("\n");
}
PyObject * exc;
PyObject * v;
PyObject * tb;
const char * errStr;
PyErr_Fetch(&exc, &v, &tb);
if (PyString_Check(v))
{
errStr = PyString_AS_STRING(v);
str.append("Error: ");
str.append(errStr);
Tracef("%s\n", errStr);
}
Py_DECREF(exc);
Py_DECREF(v);
Py_DECREF(tb);
LogBoxf("Traceback:\n\n%s\n", str.c_str());
}
int TraceFunc(PyObject * obj, PyFrameObject * f, int what, PyObject *arg)
{
const char * funcname;
char szTraceBuffer[128];
switch (what)
{
case PyTrace_CALL:
if (g_nCurTraceN >= 512)
return 0;
if (Py_OptimizeFlag)
f->f_lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
funcname = PyString_AsString(f->f_code->co_name);
_snprintf(szTraceBuffer, sizeof(szTraceBuffer), "Call: File \"%s\", line %d, in %s",
PyString_AsString(f->f_code->co_filename),
f->f_lineno,
funcname);
g_stTraceBuffer[g_nCurTraceN++]=szTraceBuffer;
break;
case PyTrace_RETURN:
if (g_nCurTraceN > 0)
--g_nCurTraceN;
break;
case PyTrace_EXCEPTION:
if (g_nCurTraceN >= 512)
return 0;
PyObject * exc_type, * exc_value, * exc_traceback;
PyTuple_GetObject(arg, 0, &exc_type);
PyTuple_GetObject(arg, 1, &exc_value);
PyTuple_GetObject(arg, 2, &exc_traceback);
int len;
const char * exc_str;
PyObject_AsCharBuffer(exc_type, &exc_str, &len);
_snprintf(szTraceBuffer, sizeof(szTraceBuffer), "Exception: File \"%s\", line %d, in %s",
PyString_AS_STRING(f->f_code->co_filename),
f->f_lineno,
PyString_AS_STRING(f->f_code->co_name));
g_stTraceBuffer[g_nCurTraceN++]=szTraceBuffer;
break;
}
return 0;
}
void CPythonLauncher::SetTraceFunc(int (*pFunc)(PyObject * obj, PyFrameObject * f, int what, PyObject *arg))
{
PyEval_SetTrace(pFunc, NULL);
}
bool CPythonLauncher::Create(const char* c_szProgramName)
{
NANOBEGIN
Py_SetProgramName((char*)c_szProgramName);
#ifdef _DEBUG
PyEval_SetTrace(TraceFunc, NULL);
#endif
m_poModule = PyImport_AddModule((char *) "__main__");
if (!m_poModule)
return false;
m_poDic = PyModule_GetDict(m_poModule);
PyObject * builtins = PyImport_ImportModule("__builtin__");
PyModule_AddIntConstant(builtins, "TRUE", 1);
PyModule_AddIntConstant(builtins, "FALSE", 0);
PyDict_SetItemString(m_poDic, "__builtins__", builtins);
Py_DECREF(builtins);
if (!RunLine("import __main__"))
return false;
if (!RunLine("import sys"))
return false;
NANOEND
return true;
}
bool CPythonLauncher::RunCompiledFile(const char* c_szFileName)
{
NANOBEGIN
FILE * fp = fopen(c_szFileName, "rb");
if (!fp)
return false;
PyCodeObject *co;
PyObject *v;
long magic;
long PyImport_GetMagicNumber(void);
magic = _PyMarshal_ReadLongFromFile(fp);
if (magic != PyImport_GetMagicNumber())
{
PyErr_SetString(PyExc_RuntimeError, "Bad magic number in .pyc file");
fclose(fp);
return false;
}
_PyMarshal_ReadLongFromFile(fp);
v = _PyMarshal_ReadLastObjectFromFile(fp);
fclose(fp);
if (!v || !PyCode_Check(v))
{
Py_XDECREF(v);
PyErr_SetString(PyExc_RuntimeError, "Bad code object in .pyc file");
return false;
}
co = (PyCodeObject *) v;
v = PyEval_EvalCode(co, m_poDic, m_poDic);
/* if (v && flags)
flags->cf_flags |= (co->co_flags & PyCF_MASK);*/
Py_DECREF(co);
if (!v)
{
Traceback();
return false;
}
Py_DECREF(v);
if (Py_FlushLine())
PyErr_Clear();
NANOEND
return true;
}
bool CPythonLauncher::RunMemoryTextFile(const char* c_szFileName, UINT uFileSize, const VOID* c_pvFileData)
{
NANOBEGIN
const CHAR* c_pcFileData=(const CHAR*)c_pvFileData;
std::string stConvFileData;
stConvFileData.reserve(uFileSize);
stConvFileData+="exec(compile('''";
// ConvertPythonTextFormat
{
for (UINT i=0; i<uFileSize; ++i)
{
if (c_pcFileData[i]!=13)
stConvFileData+=c_pcFileData[i];
}
}
stConvFileData+= "''', ";
stConvFileData+= "'";
stConvFileData+= c_szFileName;
stConvFileData+= "', ";
stConvFileData+= "'exec'))";
const CHAR* c_pcConvFileData=stConvFileData.c_str();
NANOEND
return RunLine(c_pcConvFileData);
}
bool CPythonLauncher::RunFile(const char* c_szFileName)
{
char* acBufData=NULL;
DWORD dwBufSize=0;
{
CMappedFile file;
const VOID* pvData;
CEterPackManager::Instance().Get(file, c_szFileName, &pvData);
dwBufSize=file.Size();
if (dwBufSize==0)
return false;
acBufData=new char[dwBufSize];
memcpy(acBufData, pvData, dwBufSize);
}
bool ret=false;
ret=RunMemoryTextFile(c_szFileName, dwBufSize, acBufData);
delete [] acBufData;
return ret;
}
bool CPythonLauncher::RunLine(const char* c_szSrc)
{
PyObject * v = PyRun_String((char *) c_szSrc, Py_file_input, m_poDic, m_poDic);
if (!v)
{
Traceback();
return false;
}
Py_DECREF(v);
return true;
}
const char* CPythonLauncher::GetError()
{
PyObject* exc;
PyObject* v;
PyObject* tb;
PyErr_Fetch(&exc, &v, &tb);
if (PyString_Check(v))
return PyString_AS_STRING(v);
return "";
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <python2.7/frameobject.h>
#include "../eterBase/Singleton.h"
class CPythonLauncher : public CSingleton<CPythonLauncher>
{
public:
CPythonLauncher();
virtual ~CPythonLauncher();
void Clear();
bool Create(const char* c_szProgramName="eter.python");
void SetTraceFunc(int (*pFunc)(PyObject * obj, PyFrameObject * f, int what, PyObject *arg));
bool RunLine(const char* c_szLine);
bool RunFile(const char* c_szFileName);
bool RunMemoryTextFile(const char* c_szFileName, UINT uFileSize, const VOID* c_pvFileData);
bool RunCompiledFile(const char* c_szFileName);
const char* GetError();
protected:
PyObject* m_poModule;
PyObject* m_poDic;
};

View File

@ -0,0 +1,479 @@
/* Write Python objects to files and read them back.
This is intended for writing and reading compiled Python code only;
a true persistent storage facility would be much harder, since
it would have to take circular links and sharing into account. */
#include "Stdafx.h"
#include <python2.7/longintrepr.h>
#include <python2.7/marshal.h>
/* High water mark to determine when the marshalled object is dangerously deep
* and risks coring the interpreter. When the object stack gets this deep,
* raise an exception instead of continuing.
*/
#define MAX_MARSHAL_STACK_DEPTH 5000
#define TYPE_NULL '0'
#define TYPE_NONE 'N'
#define TYPE_STOPITER 'S'
#define TYPE_ELLIPSIS '.'
#define TYPE_INT 'i'
#define TYPE_INT64 'I'
#define TYPE_FLOAT 'f'
#define TYPE_COMPLEX 'x'
#define TYPE_LONG 'l'
#define TYPE_STRING 's'
#define TYPE_TUPLE '('
#define TYPE_LIST '['
#define TYPE_DICT '{'
#define TYPE_CODE 'c'
#define TYPE_UNICODE 'u'
#define TYPE_UNKNOWN '?'
typedef struct
{
FILE * fp;
int error;
int depth;
PyObject * str;
char * ptr;
char * end;
} WFILE;
typedef WFILE RFILE; /* Same struct with different invariants */
#define rs_byte(p) (((p)->ptr != (p)->end) ? (unsigned char)*(p)->ptr++ : EOF)
#define r_byte(p) ((p)->fp ? getc((p)->fp) : rs_byte(p))
static int r_string(char *s, int n, RFILE *p)
{
if (p->fp != NULL)
return fread(s, 1, n, p->fp);
if (p->end - p->ptr < n)
n = p->end - p->ptr;
memcpy(s, p->ptr, n);
p->ptr += n;
return n;
}
static int r_short(RFILE *p)
{
register short x;
x = (short) r_byte(p);
x |= (short) r_byte(p) << 8;
/* Sign-extension, in case short greater than 16 bits */
x |= -(x & 0x8000);
return x;
}
static long r_long(RFILE *p)
{
register long x;
register FILE *fp = p->fp;
if (fp) {
x = getc(fp);
x |= (long)getc(fp) << 8;
x |= (long)getc(fp) << 16;
x |= (long)getc(fp) << 24;
}
else {
x = rs_byte(p);
x |= (long)rs_byte(p) << 8;
x |= (long)rs_byte(p) << 16;
x |= (long)rs_byte(p) << 24;
}
#if SIZEOF_LONG > 4
/* Sign extension for 64-bit machines */
x |= -(x & 0x80000000L);
#endif
return x;
}
/* r_long64 deals with the TYPE_INT64 code. On a machine with
sizeof(long) > 4, it returns a Python int object, else a Python long
object. Note that w_long64 writes out TYPE_INT if 32 bits is enough,
so there's no inefficiency here in returning a PyLong on 32-bit boxes
for everything written via TYPE_INT64 (i.e., if an int is written via
TYPE_INT64, it *needs* more than 32 bits).
*/
static PyObject * r_long64(RFILE *p)
{
long lo4 = r_long(p);
long hi4 = r_long(p);
#if SIZEOF_LONG > 4
long x = (hi4 << 32) | (lo4 & 0xFFFFFFFFL);
return PyInt_FromLong(x);
#else
unsigned char buf[8];
int one = 1;
int is_little_endian = (int)*(char*)&one;
if (is_little_endian) {
memcpy(buf, &lo4, 4);
memcpy(buf+4, &hi4, 4);
}
else {
memcpy(buf, &hi4, 4);
memcpy(buf+4, &lo4, 4);
}
return _PyLong_FromByteArray(buf, 8, is_little_endian, 1);
#endif
}
static PyObject * r_object(RFILE *p)
{
PyObject *v, *v2;
long i, n;
int type = r_byte(p);
switch (type) {
case EOF:
PyErr_SetString(PyExc_EOFError,
"EOF read where object expected");
return NULL;
case TYPE_NULL:
return NULL;
case TYPE_NONE:
Py_INCREF(Py_None);
return Py_None;
case TYPE_STOPITER:
Py_INCREF(PyExc_StopIteration);
return PyExc_StopIteration;
case TYPE_ELLIPSIS:
Py_INCREF(Py_Ellipsis);
return Py_Ellipsis;
case TYPE_INT:
return PyInt_FromLong(r_long(p));
case TYPE_INT64:
return r_long64(p);
case TYPE_LONG:
{
int size;
PyLongObject* ob;
n = r_long(p);
size = n<0 ? -n : n;
ob = _PyLong_New(size);
if (ob == NULL)
return NULL;
ob->ob_size = n;
for (i = 0; i < size; i++)
ob->ob_digit[i] = (short) r_short(p);
return (PyObject *) ob;
}
case TYPE_FLOAT:
{
char buf[256];
double dx;
n = r_byte(p);
if (r_string(buf, (int)n, p) != n) {
PyErr_SetString(PyExc_EOFError,
"EOF read where object expected");
return NULL;
}
buf[n] = '\0';
PyFPE_START_PROTECT("atof", return 0)
dx = atof(buf);
PyFPE_END_PROTECT(dx)
return PyFloat_FromDouble(dx);
}
#ifndef WITHOUT_COMPLEX
case TYPE_COMPLEX:
{
char buf[256];
Py_complex c;
n = r_byte(p);
if (r_string(buf, (int)n, p) != n) {
PyErr_SetString(PyExc_EOFError,
"EOF read where object expected");
return NULL;
}
buf[n] = '\0';
PyFPE_START_PROTECT("atof", return 0)
c.real = atof(buf);
PyFPE_END_PROTECT(c)
n = r_byte(p);
if (r_string(buf, (int)n, p) != n) {
PyErr_SetString(PyExc_EOFError,
"EOF read where object expected");
return NULL;
}
buf[n] = '\0';
PyFPE_START_PROTECT("atof", return 0)
c.imag = atof(buf);
PyFPE_END_PROTECT(c)
return PyComplex_FromCComplex(c);
}
#endif
case TYPE_STRING:
n = r_long(p);
if (n < 0) {
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
v = PyString_FromStringAndSize((char *)NULL, n);
if (v != NULL) {
if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
Py_DECREF(v);
v = NULL;
PyErr_SetString(PyExc_EOFError,
"EOF read where object expected");
}
}
return v;
#ifdef Py_USING_UNICODE
case TYPE_UNICODE:
{
char *buffer;
n = r_long(p);
if (n < 0) {
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
buffer = PyMem_NEW(char, n);
if (buffer == NULL)
return PyErr_NoMemory();
if (r_string(buffer, (int)n, p) != n) {
PyMem_DEL(buffer);
PyErr_SetString(PyExc_EOFError,
"EOF read where object expected");
return NULL;
}
v = PyUnicode_DecodeUTF8(buffer, n, NULL);
PyMem_DEL(buffer);
return v;
}
#endif
case TYPE_TUPLE:
n = r_long(p);
if (n < 0) {
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
v = PyTuple_New((int)n);
if (v == NULL)
return v;
for (i = 0; i < n; i++) {
v2 = r_object(p);
if ( v2 == NULL ) {
Py_DECREF(v);
v = NULL;
break;
}
PyTuple_SET_ITEM(v, (int)i, v2);
}
return v;
case TYPE_LIST:
n = r_long(p);
if (n < 0) {
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
v = PyList_New((int)n);
if (v == NULL)
return v;
for (i = 0; i < n; i++) {
v2 = r_object(p);
if ( v2 == NULL ) {
Py_DECREF(v);
v = NULL;
break;
}
PyList_SetItem(v, (int)i, v2);
}
return v;
case TYPE_DICT:
v = PyDict_New();
if (v == NULL)
return NULL;
for (;;) {
PyObject *key, *val;
key = r_object(p);
if (key == NULL)
break; /* XXX Assume TYPE_NULL, not an error */
val = r_object(p);
if (val != NULL)
PyDict_SetItem(v, key, val);
Py_DECREF(key);
Py_XDECREF(val);
}
return v;
case TYPE_CODE:
if (PyEval_GetRestricted()) {
PyErr_SetString(PyExc_RuntimeError,
"cannot unmarshal code objects in "
"restricted execution mode");
return NULL;
}
else {
int argcount = r_short(p);
int nlocals = r_short(p);
int stacksize = r_short(p);
int flags = r_short(p);
PyObject *code = NULL;
PyObject *consts = NULL;
PyObject *names = NULL;
PyObject *varnames = NULL;
PyObject *freevars = NULL;
PyObject *cellvars = NULL;
PyObject *filename = NULL;
PyObject *name = NULL;
int firstlineno = 0;
PyObject *lnotab = NULL;
code = r_object(p);
if (code) consts = r_object(p);
if (consts) names = r_object(p);
if (names) varnames = r_object(p);
if (varnames) freevars = r_object(p);
if (freevars) cellvars = r_object(p);
if (cellvars) filename = r_object(p);
if (filename) name = r_object(p);
if (name) {
firstlineno = r_short(p);
lnotab = r_object(p);
}
if (!PyErr_Occurred()) {
v = (PyObject *) PyCode_New(
argcount, nlocals, stacksize, flags,
code, consts, names, varnames,
freevars, cellvars, filename, name,
firstlineno, lnotab);
}
else
v = NULL;
Py_XDECREF(code);
Py_XDECREF(consts);
Py_XDECREF(names);
Py_XDECREF(varnames);
Py_XDECREF(freevars);
Py_XDECREF(cellvars);
Py_XDECREF(filename);
Py_XDECREF(name);
Py_XDECREF(lnotab);
}
return v;
default:
/* Bogus data got written, which isn't ideal.
This will let you keep working and recover. */
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
}
int _PyMarshal_ReadShortFromFile(FILE *fp)
{
RFILE rf;
rf.fp = fp;
return r_short(&rf);
}
long _PyMarshal_ReadLongFromFile(FILE *fp)
{
RFILE rf;
rf.fp = fp;
return r_long(&rf);
}
/* Return size of file in bytes; < 0 if unknown. */
static off_t getfilesize(FILE *fp)
{
struct stat st;
if (fstat(fileno(fp), &st) != 0)
return -1;
else
return st.st_size;
}
/* If we can get the size of the file up-front, and it's reasonably small,
* read it in one gulp and delegate to ...FromString() instead. Much quicker
* than reading a byte at a time from file; speeds .pyc imports.
* CAUTION: since this may read the entire remainder of the file, don't
* call it unless you know you're done with the file.
*/
PyObject *_PyMarshal_ReadLastObjectFromFile(FILE *fp)
{
/* 75% of 2.1's .pyc files can exploit SMALL_FILE_LIMIT.
* REASONABLE_FILE_LIMIT is by defn something big enough for Tkinter.pyc.
*/
#define SMALL_FILE_LIMIT (1L << 14)
#define REASONABLE_FILE_LIMIT (1L << 18)
off_t filesize;
if (PyErr_Occurred())
{
fprintf(stderr, "XXX rd_object called with exception set\n");
return NULL;
}
filesize = getfilesize(fp);
if (filesize > 0) {
char buf[SMALL_FILE_LIMIT];
char* pBuf = NULL;
if (filesize <= SMALL_FILE_LIMIT)
pBuf = buf;
else if (filesize <= REASONABLE_FILE_LIMIT)
pBuf = (char *)PyMem_MALLOC(filesize);
if (pBuf != NULL) {
PyObject* v;
size_t n = fread(pBuf, 1, filesize, fp);
v = PyMarshal_ReadObjectFromString(pBuf, n);
if (pBuf != buf)
PyMem_FREE(pBuf);
return v;
}
}
/* We don't have fstat, or we do but the file is larger than
* REASONABLE_FILE_LIMIT or malloc failed -- read a byte at a time.
*/
return _PyMarshal_ReadObjectFromFile(fp);
#undef SMALL_FILE_LIMIT
#undef REASONABLE_FILE_LIMIT
}
PyObject * _PyMarshal_ReadObjectFromFile(FILE *fp)
{
RFILE rf;
if (PyErr_Occurred()) {
fprintf(stderr, "XXX rd_object called with exception set\n");
return NULL;
}
rf.fp = fp;
return r_object(&rf);
}
PyObject * _PyMarshal_ReadObjectFromString(char *str, int len)
{
RFILE rf;
if (PyErr_Occurred()) {
fprintf(stderr, "XXX rds_object called with exception set\n");
return NULL;
}
rf.fp = NULL;
rf.str = NULL;
rf.ptr = str;
rf.end = str + len;
return r_object(&rf);
}

View File

@ -0,0 +1,8 @@
#ifndef __INC_ETERMARSHAL_H__
#define __INC_ETERMARSHAL_H__
extern PyObject * _PyMarshal_ReadObjectFromFile(FILE* fp);
extern PyObject * _PyMarshal_ReadLastObjectFromFile(FILE* fp);
extern long _PyMarshal_ReadLongFromFile(FILE *fp);
#endif

View File

@ -0,0 +1,428 @@
#include "StdAfx.h"
#include "PythonUtils.h"
#define PyLong_AsLong PyLong_AsLongLong
#define Pylong_AsUnsignedLong PyLong_AsUnsignedLongLong
IPythonExceptionSender * g_pkExceptionSender = NULL;
bool __PyCallClassMemberFunc_ByCString(PyObject* poClass, const char* c_szFunc, PyObject* poArgs, PyObject** poRet);
bool __PyCallClassMemberFunc_ByPyString(PyObject* poClass, PyObject* poFuncName, PyObject* poArgs, PyObject** poRet);
bool __PyCallClassMemberFunc(PyObject* poClass, PyObject* poFunc, PyObject* poArgs, PyObject** poRet);
PyObject * Py_BadArgument()
{
PyErr_BadArgument();
return NULL;
}
PyObject * Py_BuildException(const char * c_pszErr, ...)
{
if (!c_pszErr)
PyErr_Clear();
else
{
char szErrBuf[512+1];
va_list args;
va_start(args, c_pszErr);
vsnprintf(szErrBuf, sizeof(szErrBuf), c_pszErr, args);
va_end(args);
PyErr_SetString(PyExc_RuntimeError, szErrBuf);
}
return Py_BuildNone();
//return NULL;
}
PyObject * Py_BuildNone()
{
Py_INCREF(Py_None);
return Py_None;
}
void Py_ReleaseNone()
{
Py_DECREF(Py_None);
}
bool PyTuple_GetObject(PyObject* poArgs, int pos, PyObject** ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject * poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
*ret = poItem;
return true;
}
bool PyTuple_GetLong(PyObject* poArgs, int pos, long* ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject* poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
*ret = PyLong_AsLong(poItem);
return true;
}
bool PyTuple_GetDouble(PyObject* poArgs, int pos, double* ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject* poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
*ret = PyFloat_AsDouble(poItem);
return true;
}
bool PyTuple_GetFloat(PyObject* poArgs, int pos, float* ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject * poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
*ret = float(PyFloat_AsDouble(poItem));
return true;
}
bool PyTuple_GetByte(PyObject* poArgs, int pos, unsigned char* ret)
{
int val;
bool result = PyTuple_GetInteger(poArgs,pos,&val);
*ret = unsigned char(val);
return result;
}
bool PyTuple_GetInteger(PyObject* poArgs, int pos, unsigned char* ret)
{
int val;
bool result = PyTuple_GetInteger(poArgs,pos,&val);
*ret = unsigned char(val);
return result;
}
bool PyTuple_GetInteger(PyObject* poArgs, int pos, WORD* ret)
{
int val;
bool result = PyTuple_GetInteger(poArgs,pos,&val);
*ret = WORD(val);
return result;
}
bool PyTuple_GetInteger(PyObject* poArgs, int pos, int* ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject* poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
*ret = PyLong_AsLong(poItem);
return true;
}
bool PyTuple_GetUnsignedLong(PyObject* poArgs, int pos, unsigned long* ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject * poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
*ret = PyLong_AsUnsignedLong(poItem);
return true;
}
bool PyTuple_GetUnsignedInteger(PyObject* poArgs, int pos, unsigned int* ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject* poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
*ret = PyLong_AsUnsignedLong(poItem);
return true;
}
bool PyTuple_GetString(PyObject* poArgs, int pos, char** ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject* poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
if (!PyString_Check(poItem))
return false;
*ret = PyString_AsString(poItem);
return true;
}
bool PyTuple_GetBoolean(PyObject* poArgs, int pos, bool* ret)
{
if (pos >= PyTuple_Size(poArgs))
return false;
PyObject* poItem = PyTuple_GetItem(poArgs, pos);
if (!poItem)
return false;
*ret = PyLong_AsLong(poItem) ? true : false;
return true;
}
bool PyCallClassMemberFunc(PyObject* poClass, PyObject* poFunc, PyObject* poArgs)
{
PyObject* poRet;
// NOTE : NULL üũ <20>߰<EFBFBD>.. - [levites]
if (!poClass)
{
Py_XDECREF(poArgs);
return false;
}
if (!__PyCallClassMemberFunc(poClass, poFunc, poArgs, &poRet))
return false;
Py_DECREF(poRet);
return true;
}
bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs)
{
PyObject* poRet;
// NOTE : NULL üũ <20>߰<EFBFBD>.. - [levites]
if (!poClass)
{
Py_XDECREF(poArgs);
return false;
}
if (!__PyCallClassMemberFunc_ByCString(poClass, c_szFunc, poArgs, &poRet))
return false;
Py_DECREF(poRet);
return true;
}
bool PyCallClassMemberFunc_ByPyString(PyObject* poClass, PyObject* poFuncName, PyObject* poArgs)
{
PyObject* poRet;
// NOTE : NULL üũ <20>߰<EFBFBD>.. - [levites]
if (!poClass)
{
Py_XDECREF(poArgs);
return false;
}
if (!__PyCallClassMemberFunc_ByPyString(poClass, poFuncName, poArgs, &poRet))
return false;
Py_DECREF(poRet);
return true;
}
bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs, bool* pisRet)
{
PyObject* poRet;
if (!__PyCallClassMemberFunc_ByCString(poClass, c_szFunc, poArgs, &poRet))
return false;
if (PyNumber_Check(poRet))
*pisRet = (PyLong_AsLong(poRet) != 0);
else
*pisRet = true;
Py_DECREF(poRet);
return true;
}
bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs, long * plRetValue)
{
PyObject* poRet;
if (!__PyCallClassMemberFunc_ByCString(poClass, c_szFunc, poArgs, &poRet))
return false;
if (PyNumber_Check(poRet))
{
*plRetValue = PyLong_AsLong(poRet);
Py_DECREF(poRet);
return true;
}
Py_DECREF(poRet);
return false;
}
/*
* <09><> <20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʵ<EFBFBD><CAB5><EFBFBD> <20>Ѵ<EFBFBD>.
* <09>ε<EFBFBD><CEB5><EFBFBD> <20>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><ECBFA1> <20>ݵ<EFBFBD><DDB5><EFBFBD> false <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>
* Py_DECREF(poArgs); <20><> <20><><EFBFBD>ش<EFBFBD>.
*/
bool __PyCallClassMemberFunc_ByCString(PyObject* poClass, const char* c_szFunc, PyObject* poArgs, PyObject** ppoRet)
{
if (!poClass)
{
Py_XDECREF(poArgs);
return false;
}
PyObject * poFunc = PyObject_GetAttrString(poClass, (char *)c_szFunc); // New Reference
if (!poFunc)
{
PyErr_Clear();
Py_XDECREF(poArgs);
return false;
}
if (!PyCallable_Check(poFunc))
{
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return false;
}
PyObject * poRet = PyObject_CallObject(poFunc, poArgs); // New Reference
if (!poRet)
{
if (g_pkExceptionSender)
g_pkExceptionSender->Clear();
PyErr_Print();
if (g_pkExceptionSender)
g_pkExceptionSender->Send();
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return false;
}
*ppoRet = poRet;
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return true;
}
bool __PyCallClassMemberFunc_ByPyString(PyObject* poClass, PyObject* poFuncName, PyObject* poArgs, PyObject** ppoRet)
{
if (!poClass)
{
Py_XDECREF(poArgs);
return false;
}
PyObject * poFunc = PyObject_GetAttr(poClass, poFuncName); // New Reference
if (!poFunc)
{
PyErr_Clear();
Py_XDECREF(poArgs);
return false;
}
if (!PyCallable_Check(poFunc))
{
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return false;
}
PyObject * poRet = PyObject_CallObject(poFunc, poArgs); // New Reference
if (!poRet)
{
if (g_pkExceptionSender)
g_pkExceptionSender->Clear();
PyErr_Print();
if (g_pkExceptionSender)
g_pkExceptionSender->Send();
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return false;
}
*ppoRet = poRet;
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return true;
}
bool __PyCallClassMemberFunc(PyObject* poClass, PyObject * poFunc, PyObject* poArgs, PyObject** ppoRet)
{
if (!poClass)
{
Py_XDECREF(poArgs);
return false;
}
if (!poFunc)
{
PyErr_Clear();
Py_XDECREF(poArgs);
return false;
}
if (!PyCallable_Check(poFunc))
{
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return false;
}
PyObject * poRet = PyObject_CallObject(poFunc, poArgs); // New Reference
if (!poRet)
{
PyErr_Print();
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return false;
}
*ppoRet = poRet;
Py_DECREF(poFunc);
Py_XDECREF(poArgs);
return true;
}

View File

@ -0,0 +1,28 @@
#pragma once
#define SET_EXCEPTION(x) PyErr_SetString(PyExc_RuntimeError, #x)
bool PyTuple_GetString(PyObject* poArgs, int pos, char** ret);
bool PyTuple_GetInteger(PyObject* poArgs, int pos, unsigned char* ret);
bool PyTuple_GetInteger(PyObject* poArgs, int pos, int* ret);
bool PyTuple_GetInteger(PyObject* poArgs, int pos, WORD* ret);
bool PyTuple_GetByte(PyObject* poArgs, int pos, unsigned char* ret);
bool PyTuple_GetUnsignedInteger(PyObject* poArgs, int pos, unsigned int* ret);
bool PyTuple_GetLong(PyObject* poArgs, int pos, long* ret);
bool PyTuple_GetUnsignedLong(PyObject* poArgs, int pos, unsigned long* ret);
bool PyTuple_GetFloat(PyObject* poArgs, int pos, float* ret);
bool PyTuple_GetDouble(PyObject* poArgs, int pos, double* ret);
bool PyTuple_GetObject(PyObject* poArgs, int pos, PyObject** ret);
bool PyTuple_GetBoolean(PyObject* poArgs, int pos, bool* ret);
bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs);
bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs, bool* pisRet);
bool PyCallClassMemberFunc(PyObject* poClass, const char* c_szFunc, PyObject* poArgs, long * plRetValue);
bool PyCallClassMemberFunc_ByPyString(PyObject* poClass, PyObject* poFuncName, PyObject* poArgs);
bool PyCallClassMemberFunc(PyObject* poClass, PyObject* poFunc, PyObject* poArgs);
PyObject * Py_BuildException(const char * c_pszErr = NULL, ...);
PyObject * Py_BadArgument();
PyObject * Py_BuildNone();
PyObject * Py_BuildEmptyTuple();

105
src/ScriptLib/Resource.cpp Normal file
View File

@ -0,0 +1,105 @@
#include "StdAfx.h"
#include "../eterLib/GrpExpandedImageInstance.h"
#include "../eterLib/GrpTextInstance.h"
#include "../eterLib/GrpMarkInstance.h"
#include "../eterLib/GrpSubImage.h"
#include "../eterLib/GrpText.h"
#include "../eterLib/AttributeData.h"
#include "../eterGrnLib/Thing.h"
#include "../eterGrnLib/ThingInstance.h"
#include "../effectLib/EffectMesh.h"
#include "../effectLib/EffectInstance.h"
#include "../gamelib/WeaponTrace.h"
#include "../gamelib/MapType.h"
#include "../gamelib/GameType.h"
#include "../gamelib/RaceData.h"
#include "../gamelib/RaceMotionData.h"
#include "../gamelib/ActorInstance.h"
#include "../gamelib/Area.h"
#include "../gamelib/ItemData.h"
#include "../gamelib/FlyingData.h"
#include "../gamelib/FlyTrace.h"
#include "../gamelib/FlyingInstance.h"
#include "../gamelib/FlyingData.h"
#include "Resource.h"
CResource * NewImage(const char* c_szFileName)
{
return new CGraphicImage(c_szFileName);
}
CResource * NewSubImage(const char* c_szFileName)
{
return new CGraphicSubImage(c_szFileName);
}
CResource * NewText(const char* c_szFileName)
{
return new CGraphicText(c_szFileName);
}
CResource * NewThing(const char* c_szFileName)
{
return new CGraphicThing(c_szFileName);
}
CResource * NewEffectMesh(const char* c_szFileName)
{
return new CEffectMesh(c_szFileName);
}
CResource * NewAttributeData(const char* c_szFileName)
{
return new CAttributeData(c_szFileName);
}
void CPythonResource::DumpFileList(const char * c_szFileName)
{
m_resManager.DumpFileListToTextFile(c_szFileName);
}
void CPythonResource::Destroy()
{
CFlyingInstance::DestroySystem();
CActorInstance::DestroySystem();
CArea::DestroySystem();
CGraphicExpandedImageInstance::DestroySystem();
CGraphicImageInstance::DestroySystem();
CGraphicMarkInstance::DestroySystem();
CGraphicThingInstance::DestroySystem();
CGrannyModelInstance::DestroySystem();
CGraphicTextInstance::DestroySystem();
CEffectInstance::DestroySystem();
CWeaponTrace::DestroySystem();
CFlyTrace::DestroySystem();
m_resManager.DestroyDeletingList();
CFlyingData::DestroySystem();
CItemData::DestroySystem();
CEffectData::DestroySystem();
CEffectMesh::SEffectMeshData::DestroySystem();
CRaceData::DestroySystem();
NRaceData::DestroySystem();
CRaceMotionData::DestroySystem();
m_resManager.Destroy();
}
CPythonResource::CPythonResource()
{
m_resManager.RegisterResourceNewFunctionPointer("sub", NewSubImage);
m_resManager.RegisterResourceNewFunctionPointer("dds", NewImage);
m_resManager.RegisterResourceNewFunctionPointer("jpg", NewImage);
m_resManager.RegisterResourceNewFunctionPointer("tga", NewImage);
m_resManager.RegisterResourceNewFunctionPointer("bmp", NewImage);
m_resManager.RegisterResourceNewFunctionPointer("fnt", NewText);
m_resManager.RegisterResourceNewFunctionPointer("gr2", NewThing);
m_resManager.RegisterResourceNewFunctionPointer("mde", NewEffectMesh);
m_resManager.RegisterResourceNewFunctionPointer("mdatr", NewAttributeData);
}
CPythonResource::~CPythonResource()
{
}

24
src/ScriptLib/Resource.h Normal file
View File

@ -0,0 +1,24 @@
#pragma once
#include "../EffectLib/StdAfx.h"
#include "../eterlib/Resource.h"
#include "../eterlib/ResourceManager.h"
enum EResourceTypes
{
RES_TYPE_UNKNOWN,
};
class CPythonResource : public CSingleton<CPythonResource>
{
public:
CPythonResource();
virtual ~CPythonResource();
void Destroy();
void DumpFileList(const char * c_szFileName);
protected:
CResourceManager m_resManager;
};

View File

@ -0,0 +1,358 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Distribute|Win32">
<Configuration>Distribute</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="MfcDebug|Win32">
<Configuration>MfcDebug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="MfcRelease|Win32">
<Configuration>MfcRelease</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="VTune|Win32">
<Configuration>VTune</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<ProjectName>ScriptLib</ProjectName>
<ProjectGuid>{E682CEA2-1D79-4DE9-A2CE-6AED27E4170E}</ProjectGuid>
<RootNamespace>ScriptLib</RootNamespace>
<SccProjectName>SAK</SccProjectName>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<SccProvider>SAK</SccProvider>
<Keyword>MFCProj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>17.0.32203.90</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<VcpkgUseStatic>true</VcpkgUseStatic>
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
<VcpkgUseStatic>true</VcpkgUseStatic>
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<VcpkgUseStatic>true</VcpkgUseStatic>
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
<ClCompile>
<AdditionalOptions>/Gs %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\VTune/scriptLib.pch</PrecompiledHeaderOutputFile>
<AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>.\VTune/</AssemblerListingLocation>
<ObjectFileName>.\VTune/</ObjectFileName>
<ProgramDataBaseFileName>.\VTune/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<OutputFile>.\VTune\scriptLib.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\Distribute/scriptLib.pch</PrecompiledHeaderOutputFile>
<AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>.\Distribute/</AssemblerListingLocation>
<ObjectFileName>.\Distribute/</ObjectFileName>
<ProgramDataBaseFileName>.\Distribute/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\Debug/scriptLib.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
<ObjectFileName>.\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
<IgnoreStandardIncludePath>true</IgnoreStandardIncludePath>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\MfcRelease/scriptLib.pch</PrecompiledHeaderOutputFile>
<AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>.\MfcRelease/</AssemblerListingLocation>
<ObjectFileName>.\MfcRelease/</ObjectFileName>
<ProgramDataBaseFileName>.\MfcRelease/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<OutputFile>.\MfcRelease\scriptLib.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\MfcDebug/scriptLib.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\MfcDebug/</AssemblerListingLocation>
<ObjectFileName>.\MfcDebug/</ObjectFileName>
<ProgramDataBaseFileName>.\MfcDebug/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<OutputFile>.\MfcDebug\scriptLib.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\Release/scriptLib.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Release/</AssemblerListingLocation>
<ObjectFileName>.\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="PythonDebugModule.cpp" />
<ClCompile Include="PythonLauncher.cpp" />
<ClCompile Include="PythonMarshal.cpp" />
<ClCompile Include="PythonUtils.cpp" />
<ClCompile Include="Resource.cpp" />
<ClCompile Include="StdAfx.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">Create</PrecompiledHeader>
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Create</PrecompiledHeader>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">Create</PrecompiledHeader>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="PythonDebugModule.h" />
<ClInclude Include="PythonLauncher.h" />
<ClInclude Include="PythonMarshal.h" />
<ClInclude Include="PythonUtils.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="StdAfx.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{c12a4e58-779a-4bc1-83df-514473947af7}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{8e67423c-1001-4e06-bf0b-f17cdd50e6a2}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="PythonDebugModule.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PythonLauncher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PythonMarshal.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PythonUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Resource.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StdAfx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="PythonDebugModule.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PythonLauncher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PythonMarshal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PythonUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StdAfx.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

10
src/ScriptLib/StdAfx.cpp Normal file
View File

@ -0,0 +1,10 @@
// stdafx.cpp : source file that includes just the standard includes
// scriptLib.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
void SetExceptionSender(IPythonExceptionSender * pkExceptionSender)
{
g_pkExceptionSender = pkExceptionSender;
}

38
src/ScriptLib/StdAfx.h Normal file
View File

@ -0,0 +1,38 @@
#pragma once
#include "../eterLib/StdAfx.h"
#include "../eterGrnLib/StdAfx.h"
#include <python2.7/Python.h>
#include "PythonUtils.h"
#include "PythonLauncher.h"
#include "PythonMarshal.h"
#include "Resource.h"
void initdbg();
// PYTHON_EXCEPTION_SENDER
class IPythonExceptionSender
{
public:
void Clear()
{
m_strExceptionString = "";
}
void RegisterExceptionString(const char * c_szString)
{
m_strExceptionString += c_szString;
}
virtual void Send() = 0;
protected:
std::string m_strExceptionString;
};
extern IPythonExceptionSender * g_pkExceptionSender;
void SetExceptionSender(IPythonExceptionSender * pkExceptionSender);
// END_OF_PYTHON_EXCEPTION_SENDER