Skip to content

Commit

Permalink
Python header fixes
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.dsource.org/projects/pyd/trunk@65 1df65b71-e716-0410-9316-ac55df2b1602
  • Loading branch information
KirkMcDonald authored and KirkMcDonald committed Dec 18, 2006
1 parent f01b7ce commit 507dd9d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
21 changes: 19 additions & 2 deletions infrastructure/python/2.4/python.d
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,10 @@ extern (C) {
// DSR:XXX:LAYOUT:
// Will the D layout for a 1-char array be the same as the C layout? I
// think the D array will be larger.
char ob_sval[1];
char _ob_sval[1];
char* ob_sval() {
return _ob_sval.ptr;
}
}

// &PyBaseString_Type is accessible via PyBaseString_Type_p.
Expand All @@ -1131,6 +1134,17 @@ extern (C) {
PyObject * PyString_FromFormat(char*, ...);
int PyString_Size(PyObject *);
char * PyString_AsString(PyObject *);
/* Use only if you know it's a string */
int PyString_CHECK_INTERNED(PyObject* op) {
return (cast(PyStringObject*)op).ob_sstate;
}
/* Macro, trading safety for speed */
char* PyString_AS_STRING(PyObject* op) {
return (cast(PyStringObject*)op).ob_sval;
}
int PyString_GET_SIZE(PyObject* op) {
return (cast(PyStringObject*)op).ob_size;
}
PyObject * PyString_Repr(PyObject *, int);
void PyString_Concat(PyObject **, PyObject *);
void PyString_ConcatAndDel(PyObject **, PyObject *);
Expand Down Expand Up @@ -2287,7 +2301,10 @@ extern (C) {
int f_ncells;
int f_nfreevars;
int f_stacksize;
PyObject *f_localsplus[1];
PyObject *_f_localsplus[1];
PyObject** f_localsplus() {
return _f_localsplus.ptr;
}
}

// &PyFrame_Type is accessible via PyFrame_Type_p.
Expand Down
24 changes: 19 additions & 5 deletions infrastructure/python/2.5/python.d
Original file line number Diff line number Diff line change
Expand Up @@ -1152,10 +1152,10 @@ extern (C) {
// DSR:XXX:LAYOUT:
// Will the D layout for a 1-char array be the same as the C layout? I
// think the D array will be larger.
// KGM:XXX:
// Almost added PyString_AS_STRING and friends, but realized this would
// probably cause problems.
char ob_sval[1];
char _ob_sval[1];
char* ob_sval() {
return _ob_sval.ptr;
}
}

// &PyBaseString_Type is accessible via PyBaseString_Type_p.
Expand All @@ -1176,6 +1176,17 @@ extern (C) {
PyObject * PyString_FromFormat(char*, ...);
Py_ssize_t PyString_Size(PyObject *);
char * PyString_AsString(PyObject *);
/* Use only if you know it's a string */
int PyString_CHECK_INTERNED(PyObject* op) {
return (cast(PyStringObject*)op).ob_sstate;
}
/* Macro, trading safety for speed */
char* PyString_AS_STRING(PyObject* op) {
return (cast(PyStringObject*)op).ob_sval;
}
Py_ssize_t PyString_GET_SIZE(PyObject* op) {
return (cast(PyStringObject*)op).ob_size;
}
PyObject * PyString_Repr(PyObject *, int);
void PyString_Concat(PyObject **, PyObject *);
void PyString_ConcatAndDel(PyObject **, PyObject *);
Expand Down Expand Up @@ -2504,7 +2515,10 @@ extern (C) {
int f_lineno;
int f_iblock;
PyTryBlock f_blockstack[CO_MAXBLOCKS];
PyObject *f_localsplus[1];
PyObject *_f_localsplus[1];
PyObject** f_localsplus() {
return _f_localsplus.ptr;
}
}

// &PyFrame_Type is accessible via PyFrame_Type_p.
Expand Down

0 comments on commit 507dd9d

Please sign in to comment.