]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
- Added ability to get at strings embedded in the struct
authorJack Jansen <jack.jansen@cwi.nl>
Wed, 14 Dec 1994 13:04:05 +0000 (13:04 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Wed, 14 Dec 1994 13:04:05 +0000 (13:04 +0000)
- For the mac, added ability to get at pascal-style strings

Include/structmember.h
Python/structmember.c

index 7a047b9307f454541d08ffcea2b81cdda21f0bdb..2e9bd0d2db2aa85d02d984384e1c0ea970ae2836 100644 (file)
@@ -74,6 +74,13 @@ struct memberlist {
 #define T_UINT         11
 #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 */
 #define READONLY       1
 #define RO             READONLY                /* Shorthand */
index 784bbf5b49996b21125a31693da9d7ba24d2d977..7ec48b341023791a6aca997c878ca88551f8b1a0 100644 (file)
@@ -108,6 +108,24 @@ getmember(addr, mlist, name)
                                else
                                        v = newstringobject(*(char**)addr);
                                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:
                                v = newsizedstringobject((char*)addr, 1);
                                break;
@@ -140,7 +158,11 @@ setmember(addr, mlist, name, v)
        
        for (l = mlist; l->name != NULL; l++) {
                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");
                                return -1;
                        }