Back to index

lightning-sunbird  0.9+nobinonly
mork.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-  */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef _MORK_
00039 #define _MORK_ 1
00040 
00041 #ifndef _MDB_
00042 #include "mdb.h"
00043 #endif
00044 
00045 #include "nscore.h"
00046 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00047 
00048 
00049 // { %%%%% begin disable unused param warnings %%%%%
00050 #define MORK_USED_1(x) (void)(&x)
00051 #define MORK_USED_2(x,y) (void)(&x);(void)(&y);
00052 #define MORK_USED_3(x,y,z) (void)(&x);(void)(&y);(void)(&z);
00053 #define MORK_USED_4(w,x,y,z) (void)(&w);(void)(&x);(void)(&y);(void)(&z);
00054 
00055 // } %%%%% end disable unused param warnings %%%%%
00056 
00057 // { %%%%% begin macro for finding class member offset %%%%%
00058 
00059 /*| OffsetOf: the unsigned integer offset of a class or struct
00060 **| field from the beginning of that class or struct.  This is
00061 **| the same as the similarly named public domain IronDoc macro,
00062 **| and is also the same as another macro appearing in stdlib.h.
00063 **| We want these offsets so we can correctly convert pointers
00064 **| to member slots back into pointers to enclosing objects, and
00065 **| have this exactly match what the compiler thinks is true.
00066 **|
00067 **|| Bascially we are asking the compiler to determine the offset at
00068 **| compile time, and we use the definition of address artithmetic
00069 **| to do this.  By casting integer zero to a pointer of type obj*,
00070 **| we can reference the address of a slot in such an object that
00071 **| is hypothetically physically placed at address zero, but without
00072 **| actually dereferencing a memory location.  The absolute address
00073 **| of slot is the same as offset of that slot, when the object is
00074 **| placed at address zero.
00075 |*/
00076 #define mork_OffsetOf(obj,slot) ((unsigned int)&((obj*) 0)->slot)
00077 
00078 // } %%%%% end macro for finding class member offset %%%%%
00079 
00080 // { %%%%% begin specific-size integer scalar typedefs %%%%%
00081 typedef unsigned char  mork_u1;  // make sure this is one byte
00082 typedef unsigned short mork_u2;  // make sure this is two bytes
00083 typedef short          mork_i2;  // make sure this is two bytes
00084 typedef PRUint32       mork_u4;  // make sure this is four bytes
00085 typedef PRInt32        mork_i4;  // make sure this is four bytes
00086 typedef PRWord         mork_ip;  // make sure sizeof(mork_ip) == sizeof(void*)
00087 
00088 typedef mork_u1 mork_ch;    // small byte-sized character (never wide)
00089 typedef mork_u1 mork_flags;  // one byte's worth of predicate bit flags
00090 
00091 typedef mork_u2 mork_base;    // 2-byte magic class signature slot in object
00092 typedef mork_u2 mork_derived; // 2-byte magic class signature slot in object
00093 typedef mork_u2 mork_uses;    // 2-byte strong uses count
00094 typedef mork_u2 mork_refs;    // 2-byte actual reference count
00095 
00096 typedef mork_u4 mork_token;      // unsigned token for atomized string
00097 typedef mork_token mork_scope;   // token used to id scope for rows
00098 typedef mork_token mork_kind;    // token used to id kind for tables
00099 typedef mork_token mork_cscode;  // token used to id charset names
00100 typedef mork_token mork_aid;     // token used to id atomize cell values
00101 
00102 typedef mork_token mork_column;  // token used to id columns for rows
00103 typedef mork_column mork_delta;  // mork_column plus mork_change 
00104 
00105 typedef mork_token mork_color;   // bead ID
00106 #define morkColor_kNone ((mork_color) 0)
00107 
00108 typedef mork_u4 mork_magic;      // unsigned magic signature
00109 
00110 typedef mork_u4 mork_seed;       // unsigned collection change counter
00111 typedef mork_u4 mork_count;      // unsigned collection member count
00112 typedef mork_count mork_num;     // synonym for count
00113 typedef mork_u4 mork_size;       // unsigned physical media size
00114 typedef mork_u4 mork_fill;       // unsigned logical content size
00115 typedef mork_u4 mork_more;       // more available bytes for larger buffer
00116 
00117 typedef mdb_u4 mork_percent; // 0..100, with values >100 same as 100
00118 
00119 typedef mork_i4 mork_pos; // negative means "before first" (at zero pos)
00120 typedef mork_i4 mork_line; // negative means "before first line in file"
00121 
00122 typedef mork_u1 mork_usage;   // 1-byte magic usage signature slot in object
00123 typedef mork_u1 mork_access;  // 1-byte magic access signature slot in object
00124 
00125 typedef mork_u1 mork_change; // add, cut, put, set, nil
00126 typedef mork_u1 mork_priority; // 0..9, for a total of ten different values
00127 
00128 typedef mork_u1 mork_able; // on, off, asleep (clone IronDoc's fe_able)
00129 typedef mork_u1 mork_load; // dirty or clean (clone IronDoc's fe_load)
00130 // } %%%%% end specific-size integer scalar typedefs %%%%%
00131 
00132 // 'test' is a public domain Mithril for key equality tests in probe maps
00133 typedef mork_i2 mork_test; /* neg=>kVoid, zero=>kHit, pos=>kMiss */
00134 
00135 #define morkTest_kVoid ((mork_test) -1) /* -1: nil key slot, no key order */
00136 #define morkTest_kHit  ((mork_test) 0)  /*  0: keys are equal, a map hit */
00137 #define morkTest_kMiss ((mork_test) 1)  /*  1: keys not equal, a map miss */
00138 
00139 // { %%%%% begin constants for Mork scalar types %%%%%
00140 #define morkPriority_kHi  ((mork_priority) 0) /* best priority */
00141 #define morkPriority_kMin ((mork_priority) 0) /* best priority is smallest */
00142 
00143 #define morkPriority_kLo  ((mork_priority) 9) /* worst priority */
00144 #define morkPriority_kMax ((mork_priority) 9) /* worst priority is biggest */
00145 
00146 #define morkPriority_kCount 10 /* number of distinct priority values */
00147 
00148 #define morkAble_kEnabled  ((mork_able) 0x55) /* same as IronDoc constant */
00149 #define morkAble_kDisabled ((mork_able) 0xAA) /* same as IronDoc constant */
00150 #define morkAble_kAsleep   ((mork_able) 0x5A) /* same as IronDoc constant */
00151 
00152 #define morkChange_kAdd 'a' /* add member */
00153 #define morkChange_kCut 'c' /* cut member */
00154 #define morkChange_kPut 'p' /* put member */
00155 #define morkChange_kSet 's' /* set all members */
00156 #define morkChange_kNil 0   /* no change in this member */
00157 #define morkChange_kDup 'd' /* duplicate changes have no effect */
00158 // kDup is intended to replace another change constant in an object as a
00159 // conclusion about change feasibility while staging intended alterations.
00160 
00161 #define morkLoad_kDirty ((mork_load) 0xDD) /* same as IronDoc constant */
00162 #define morkLoad_kClean ((mork_load) 0x22) /* same as IronDoc constant */
00163 
00164 #define morkAccess_kOpen    'o'
00165 #define morkAccess_kClosing 'c'
00166 #define morkAccess_kShut    's'
00167 #define morkAccess_kDead    'd'
00168 // } %%%%% end constants for Mork scalar types %%%%%
00169 
00170 // { %%%%% begin non-specific-size integer scalar typedefs %%%%%
00171 typedef int mork_char; // nominal type for ints used to hold input byte
00172 #define morkChar_IsWhite(c) \
00173   ((c) == 0xA || (c) == 0x9 || (c) == 0xD || (c) == ' ')
00174 // } %%%%% end non-specific-size integer scalar typedefs %%%%%
00175 
00176 // { %%%%% begin mdb-driven scalar typedefs %%%%%
00177 // easier to define bool exactly the same as mdb:
00178 typedef mdb_bool mork_bool; // unsigned byte with zero=false, nonzero=true
00179 
00180 /* canonical boolean constants provided only for code clarity: */
00181 #define morkBool_kTrue  ((mork_bool) 1) /* actually any nonzero means true */
00182 #define morkBool_kFalse ((mork_bool) 0) /* only zero means false */
00183 
00184 // mdb clients can assign these, so we cannot pick maximum size:
00185 typedef mdb_id mork_id;    // unsigned object identity in a scope
00186 typedef mork_id mork_rid;  // unsigned row identity inside scope
00187 typedef mork_id mork_tid;  // unsigned table identity inside scope
00188 typedef mork_id mork_gid;  // unsigned group identity without any scope
00189 
00190 // we only care about neg, zero, pos -- so we don't care about size:
00191 typedef mdb_order mork_order; // neg:lessthan, zero:equalto, pos:greaterthan 
00192 // } %%%%% end mdb-driven scalar typedefs %%%%%
00193 
00194 #define morkId_kMinusOne ((mdb_id) -1)
00195 
00196 // { %%%%% begin class forward defines %%%%%
00197 // try to put these in alphabetical order for easier examination:
00198 class morkMid;
00199 class morkAtom;
00200 class morkAtomSpace;
00201 class morkBookAtom;
00202 class morkBuf;
00203 class morkBuilder;
00204 class morkCell;
00205 class morkCellObject;
00206 class morkCursor;
00207 class morkEnv;
00208 class morkFactory;
00209 class morkFile;
00210 class morkHandle;
00211 class morkHandleFace; // just an opaque cookie type
00212 class morkHandleFrame;
00213 class morkHashArrays;
00214 class morkMap;
00215 class morkNode;
00216 class morkObject;
00217 class morkOidAtom;
00218 class morkParser;
00219 class morkPool;
00220 class morkPlace;
00221 class morkPort;
00222 class morkPortTableCursor;
00223 class morkProbeMap;
00224 class morkRow;
00225 class morkRowCellCursor;
00226 class morkRowObject;
00227 class morkRowSpace;
00228 class morkSorting;
00229 class morkSortingRowCursor;
00230 class morkSpace;
00231 class morkSpan;
00232 class morkStore;
00233 class morkStream;
00234 class morkTable;
00235 class morkTableChange;
00236 class morkTableRowCursor;
00237 class morkThumb;
00238 class morkWriter;
00239 class morkZone;
00240 // } %%%%% end class forward defines %%%%%
00241 
00242 // include this config file last for platform & environment specific stuff:
00243 #ifndef _MORKCONFIG_
00244 #include "morkConfig.h"
00245 #endif
00246 
00247 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00248 
00249 #endif /* _MORK_ */