- Added ability to get at strings embedded in the struct
- For the mac, added ability to get at pascal-style strings
This commit is contained in:
parent
e00637bdcf
commit
599f0d1c2c
|
@ -74,6 +74,13 @@ struct memberlist {
|
||||||
#define T_UINT 11
|
#define T_UINT 11
|
||||||
#define T_ULONG 12
|
#define T_ULONG 12
|
||||||
|
|
||||||
|
/* Added by Jack: strings contained in the structure */
|
||||||
|
#define T_STRING_INPLACE 13
|
||||||
|
#ifdef macintosh
|
||||||
|
#define T_PSTRING 14 /* macintosh pascal-style counted string */
|
||||||
|
#define T_PSTRING_INPLACE 15
|
||||||
|
#endif /* macintosh */
|
||||||
|
|
||||||
/* Readonly flag */
|
/* Readonly flag */
|
||||||
#define READONLY 1
|
#define READONLY 1
|
||||||
#define RO READONLY /* Shorthand */
|
#define RO READONLY /* Shorthand */
|
||||||
|
|
|
@ -108,6 +108,24 @@ getmember(addr, mlist, name)
|
||||||
else
|
else
|
||||||
v = newstringobject(*(char**)addr);
|
v = newstringobject(*(char**)addr);
|
||||||
break;
|
break;
|
||||||
|
case T_STRING_INPLACE:
|
||||||
|
v = newstringobject((char*)addr);
|
||||||
|
break;
|
||||||
|
#ifdef macintosh
|
||||||
|
case T_PSTRING:
|
||||||
|
if (*(char**)addr == NULL) {
|
||||||
|
INCREF(None);
|
||||||
|
v = None;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
v = newsizedstringobject((*(char**)addr)+1,
|
||||||
|
**(unsigned char**)addr);
|
||||||
|
break;
|
||||||
|
case T_PSTRING_INPLACE:
|
||||||
|
v = newsizedstringobject(((char*)addr)+1,
|
||||||
|
*(unsigned char*)addr);
|
||||||
|
break;
|
||||||
|
#endif /* macintosh */
|
||||||
case T_CHAR:
|
case T_CHAR:
|
||||||
v = newsizedstringobject((char*)addr, 1);
|
v = newsizedstringobject((char*)addr, 1);
|
||||||
break;
|
break;
|
||||||
|
@ -140,7 +158,11 @@ setmember(addr, mlist, name, v)
|
||||||
|
|
||||||
for (l = mlist; l->name != NULL; l++) {
|
for (l = mlist; l->name != NULL; l++) {
|
||||||
if (strcmp(l->name, name) == 0) {
|
if (strcmp(l->name, name) == 0) {
|
||||||
if (l->readonly || l->type == T_STRING) {
|
#ifdef macintosh
|
||||||
|
if (l->readonly || l->type == T_STRING || l->type == T_PSTRING) {
|
||||||
|
#else
|
||||||
|
if (l->readonly || l->type == T_STRING ) {
|
||||||
|
#endif /* macintosh */
|
||||||
err_setstr(TypeError, "readonly attribute");
|
err_setstr(TypeError, "readonly attribute");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue