Annotation of objc/typedstreamprivate.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.0 (the 'License').  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License."
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: /*
        !            25:        typedstreamprivate.h
        !            26:        Copyright 1989 NeXT, Inc.
        !            27:        Responsibility: Bertrand Serlet
        !            28: */
        !            29: 
        !            30: #ifndef _OBJC_TYPEDSTREAMPRIVATE_H_
        !            31: #define _OBJC_TYPEDSTREAMPRIVATE_H_
        !            32: 
        !            33: /*
        !            34:  *     This module provides the type definitions necessary for typedstream.h
        !            35:  *     No client except typedstream should directly use this module.
        !            36:  *
        !            37:  */
        !            38:  
        !            39: 
        !            40: #import <streams/streams.h>
        !            41: #import "objc.h"
        !            42: #import "hashtable.h"
        !            43: 
        !            44: 
        !            45: /*************************************************************************
        !            46:  *     Low-Level: encoding tightly information, 
        !            47:  *     and sharing pointers and strings
        !            48:  **************************************************************************/
        !            49: 
        !            50: 
        !            51: typedef struct {
        !            52:     NXStream   *physical;      /* the underlying stream */
        !            53:     BOOL       swap;           /* should be swap bytes on reading */
        !            54:     BOOL       write;          /* are we writing */
        !            55:     NXHashTable        *strings;       /* maps strings to labels (vice versa for reading) */
        !            56:     int                stringCounter;  /* next string label */
        !            57:     int                stringCounterMax;
        !            58:     NXHashTable        *ptrs;          /* maps ptrs to labels (vice versa for reading) */
        !            59:     int                ptrCounter;     /* next ptr label */
        !            60:     int                ptrCounterMax;
        !            61:     NXZone     *scratch;
        !            62:     } _CodingStream;
        !            63: 
        !            64: /* Creation, destruction */
        !            65: static _CodingStream *_NXOpenEncodingStream (NXStream *physical);
        !            66:        /* creates an encoding stream, given physical stream */
        !            67: 
        !            68: static _CodingStream *_NXOpenDecodingStream (NXStream *physical);
        !            69:        /* creates an decoding stream, given physical stream */
        !            70: 
        !            71: static BOOL _NXEndOfCodingStream (_CodingStream *coder);
        !            72:        /* TRUE iff end of stream */
        !            73: 
        !            74: static void _NXCloseCodingStream (_CodingStream *coder);
        !            75: 
        !            76: /* Encoding/Decoding of usual quantities */
        !            77: 
        !            78: static void _NXEncodeBytes (_CodingStream *coder, const char *buf, int count);
        !            79: static void _NXDecodeBytes (_CodingStream *coder, char *buf, int count);
        !            80: 
        !            81: static void _NXEncodeChar (_CodingStream *coder, signed char c);
        !            82: static signed char _NXDecodeChar (_CodingStream *coder);
        !            83: 
        !            84: /* static void _NXEncode (_CodingStream *coder, short x); */
        !            85: static short _NXDecodeShort (_CodingStream *coder);
        !            86: 
        !            87: static void _NXEncodeInt (_CodingStream *coder, int x);
        !            88: static int _NXDecodeInt (_CodingStream *coder);
        !            89: 
        !            90: static void _NXEncodeFloat (_CodingStream *coder, float x);
        !            91: static float _NXDecodeFloat (_CodingStream *coder);
        !            92: 
        !            93: static void _NXEncodeDouble (_CodingStream *coder, double x);
        !            94: static double _NXDecodeDouble (_CodingStream *coder);
        !            95: 
        !            96: /* low-level string coding; should never be called directly */
        !            97: static void _NXEncodeChars (_CodingStream *coder, const char *str);
        !            98: static char *_NXDecodeChars (_CodingStream *coder, NXZone *zone);
        !            99: 
        !           100: /* Encoding/Decoding of shared quantities.  Forces sharing of strings: identical but non shared strings at encoding will end up shared at decoding */
        !           101: static void _NXEncodeSharedString (_CodingStream *coder, const char *str);
        !           102: static char *_NXDecodeSharedString (_CodingStream *coder);
        !           103: static const char *_NXDecodeUniqueString (_CodingStream *coder);
        !           104:        /* always returns a "unique" string, that should never be freed */
        !           105:        
        !           106: static void _NXEncodeString (_CodingStream *coder, const char *str);
        !           107: static char *_NXDecodeString (_CodingStream *coder, NXZone *zone);
        !           108:        /* always returns a new string */
        !           109:        
        !           110: static BOOL _NXEncodeShared (_CodingStream *coder, const void *ptr);
        !           111:        /* if ptr was previously encoded, encodes its previous label and returns FALSE
        !           112:        if this is a new ptr, encodes that it's a new one, increases the label counter and returns TRUE ; It is assumed that the information relative to ptr is then encoded */
        !           113: /* static BOOL _NXDecodeShared (_CodingStream *coder, void **pptr, int *label); */
        !           114:        /* if we are reading a previously read quantity or nil, its previous ptr is set, and FALSE is returned
        !           115:        if we are reading a new marker, sets the appropriate label and returns TRUE.  The data should then be read and _NXNoteShared should be called */
        !           116: /* static void _NXNoteShared (_CodingStream *coder, void *ptr, int label); */
        !           117: 
        !           118: /*************************************************************************
        !           119:  *     Encoding typed information, and dealing with ids
        !           120:  **************************************************************************/
        !           121: 
        !           122: typedef struct {
        !           123:     const char         *className;
        !           124:     int                        version;
        !           125:     } _ClassVersion;
        !           126: 
        !           127: typedef struct {
        !           128:     _CodingStream      *coder; /* the underlying stream */
        !           129:     NXHashTable                *ids;   /* Set of all visited IDs */
        !           130:     BOOL               write;  /* writing vs reading */
        !           131:     BOOL               noteConditionals; /* when TRUE, it's a no-write pass */
        !           132:     BOOL               doStatistics ; /* prints statistics */
        !           133:     const char         *fileName; /* unless nil, file to be written when stream is closed */
        !           134:     signed char                streamerVersion; /* changes in the meta-schema */
        !           135:     int                        systemVersion;  /* typically, appkit version */
        !           136:     NXHashTable                *classVersions; /* for read: [className -> version] */
        !           137:     int                        classVersionsCounter;
        !           138:     NXZone             *objectZone;
        !           139:     } TypedStream;
        !           140: 
        !           141: static void InternalWriteObject (TypedStream *s, id object);
        !           142:        /* writes an object without header */
        !           143: static id InternalReadObject (TypedStream *s);
        !           144:        /* reads an object without header */
        !           145: 
        !           146: static void NXWriteClass (NXTypedStream *stream, Class class);
        !           147:        /* Equivalent to NXWriteTypes (stream, "#", &class) */
        !           148: static Class NXReadClass (NXTypedStream *stream);
        !           149:        
        !           150: #endif /* _OBJC_TYPEDSTREAMPRIVATE_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.