91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

Python源碼剖析——深度探索動態語言核心技術 一書中的兩個demo代碼,其一是Small Python,其二是對pyc文件的解析器,這兩個均是windows下工程。另外附加了一個在linux下編譯運行的smallPython。 上傳原因:原來書中下載鏈接失效 http://bv.csdn.net/resource/pythonympx.rar

資源截圖

代碼片段和文件信息

#include
#include
#include
#include
#include
#include
#include
#include
using?namespace?std;
#define?Pyobject_HEAD \
int?refCount;?\
struct?tagPyTypeobject?*type

#define?Pyobject_HEAD_INIT(typePtr)?\
0typePtr

typedef?struct?tagPyobject
{
Pyobject_HEAD;
}Pyobject;

typedef?void(*PrintFun)(Pyobject*object);
typedef?Pyobject*?(*AddFun)(Pyobject*?left?Pyobject*right);
typedef?long(*HashFun)(Pyobject*?object);

typedef?struct?tagPyTypeobject
{
Pyobject_HEAD;
char*?name;
PrintFun?print;
AddFun?add;
HashFun?hash;
}PyTypeobject;

PyTypeobject?PyType_Type?=
{
Pyobject_HEAD_INIT(&PyType_Type)
“type“
0
0
0
};

typedef?struct?tagIntobject
{
Pyobject_HEAD;
int?value;
}PyIntobject;

static??void?int_print(Pyobject*object);
static?Pyobject*?int_add(Pyobject*left?Pyobject*?right);
static?long?int_hash(Pyobject*?object);

PyTypeobject?PyInt_Type?=
{
Pyobject_HEAD_INIT(&PyType_Type)
“int“
int_print
int_add
int_hash
};


Pyobject*?PyInt_Create(int?value)
{
PyIntobject?*object?=?new?PyIntobject;
object->refCount?=?1;
object->type?=?&PyInt_Type;
object->value?=?value;
return?(Pyobject*)object;
}

static??void?int_print(Pyobject*object)
{
PyIntobject*?intobject?=?(PyIntobject*)object;
printf(“%d\n“?intobject->value);
}

static?Pyobject*?int_add(Pyobject*left?Pyobject*?right)
{
PyIntobject*?leftInt?=?(PyIntobject*)left;
PyIntobject*?rightInt?=?(PyIntobject*)right;
PyIntobject*?result?=?(PyIntobject*)PyInt_Create(0);
if?(result?==?NULL)
{
printf(“we?have?no?enough?memory“);
exit(1);
}
else
{
result->value?=?leftInt->value?+?rightInt->value;
}
return?(Pyobject*)result;
}

static?long?int_hash(Pyobject*?object)
{
return?(long)((PyIntobject*)object)->value;
}


typedef?struct?tagPyStrobject
{
Pyobject_HEAD;
int?length;
long?hashValue;
char?value[50];
}PyStringobject;
static?void?string_print(Pyobject*object);
static?long?string_hash(Pyobject*object);
static?Pyobject*?string_add(Pyobject*left?Pyobject*right);
PyTypeobject?PyString_Type?=
{
Pyobject_HEAD_INIT(&PyType_Type)
“str“
string_print
string_add
string_hash
};
Pyobject*?PyStr_Create(const?char*value)
{
PyStringobject*?object?=?new?PyStringobject;
object->refCount?=?1;
object->type?=?&PyString_Type;
object->length?=?(value?==?NULL???0?:?strlen(value));
object->hashValue?=?-1;
memset(object->value?0?50);
if?(value?!=?NULL)
{
strcpy(object->value?value);
}
return?(Pyobject*)object;
}

static?void?string_print(Pyobject*object)
{
PyStringobject*strobject?=?(PyStringobject*)object;
printf(“%s\n“?strobject->value);
}

static?long?string_hash(Pyobject*object)
{
PyStringobject*?strobject?=?(PyStringobject*)object;
register?int?len;
register?unsigned?char*?p;
register?long?x;

if?(strobject->hashValue?!=?-1)
r

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????17646??2008-05-19?09:56??Python源碼剖析——深度探索動態語言核心技術_代碼下載\pyc_parser.zip

?????文件??????11372??2008-05-19?09:56??Python源碼剖析——深度探索動態語言核心技術_代碼下載\samll_python.zip

?????文件???????7831??2018-03-03?13:03??Python源碼剖析——深度探索動態語言核心技術_代碼下載\smallPython(Linux下運行).cpp

?????目錄??????????0??2018-03-03?13:40??Python源碼剖析——深度探索動態語言核心技術_代碼下載

-----------?---------??----------?-----??----

????????????????36849????????????????????4


評論

共有 條評論

相關資源