00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016
00017
00025 #include <gobjconfig.h>
00026
00027 #ifndef gobj_lib_nativetypes_h
00028 #define gobj_lib_nativetypes_h
00029
00030 #include <gobj/decls.h>
00031 #include <gobj/context.h>
00032 #include <gobj/types.h>
00033 #include <gobj/path.h>
00034 #include <gobj/id.h>
00035 #include <gobj/stream.h>
00036
00037 #ifdef HAVE_WCHAR_H
00038 #include <wchar.h>
00039 #endif
00040
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 #if 0
00045 }
00046 #endif
00047
00048
00049 00050 00051 00052
00053
00058 typedef int Gj_NInt;
00059
00060
00065 typedef double Gj_NFloat;
00066
00067
00072 #ifdef GJ_BIGNUMS
00073 typedef Gj_Bignum* Gj_NBignum;
00074 #endif
00075
00080 #ifdef HAVE_WCHAR_H
00081 typedef wchar_t Gj_NChar;
00082 #else
00083 typedef char Gj_NChar
00084 #endif
00085
00086
00091 typedef char* Gj_NString;
00092
00093
00098 typedef Gj_Bool Gj_NBool;
00099
00100
00107 typedef struct gj_NLink_struct {
00108
00109 Gj_Path* path;
00110
00111 union {
00112
00113 Gj_Comm* comm;
00114 } resolved;
00115
00116 Gj_Bool remote;
00117
00118 } gj_NLink;
00119
00120
00125 typedef Gj_Path* Gj_NLink;
00126
00127
00134 typedef struct gj_NParamLink_struct {
00135
00136 int num;
00137
00138 Gj_Object* ptr;
00139
00140 } gj_NParamLink;
00141
00142
00147 typedef int Gj_NParamLink;
00148
00149
00156 typedef struct gj_NPropertyLink_struct {
00157
00158 int num;
00159
00160 Gj_Object* ptr;
00161
00162 } gj_NPropertyLink;
00163
00164
00169 typedef int Gj_NPropertyLink;
00170
00171
00178 typedef struct gj_NData_struct {
00179
00180 void* data;
00181
00182 Gj_Bool own;
00183
00184 } gj_NData;
00185
00186
00191 typedef void* Gj_NData;
00192
00193
00198 typedef enum Gj_Nativetype_enum {
00199
00200 GJ_NTYPES_NONE = 0,
00201 GJ_NTYPES_INT,
00202 GJ_NTYPES_FLOAT,
00203 #ifdef GJ_BIGNUMS
00204 GJ_NTYPES_BIGNUM,
00205 #endif
00206 GJ_NTYPES_CHAR,
00207 GJ_NTYPES_STRING,
00208 GJ_NTYPES_BOOL,
00209 GJ_NTYPES_LINK,
00210 GJ_NTYPES_PARAMLINK,
00211 GJ_NTYPES_PROPERTYLINK,
00212 GJ_NTYPES_DATA
00213
00214 } Gj_Nativetype;
00215
00216
00217 00218 00219 00220
00221 int Gj_nativetypes_getAllocSize(Gj_Nativetype type);
00222
00223
00224 00225 00226 00227
00228 const char* Gj_nativetypes_getName(Gj_Nativetype type);
00229
00230
00231 00232 00233 00234 00235
00236 int Gj_nativetypes_init(Gj_Ctx* ctx, Gj_Object* obj, Gj_Nativetype type);
00237
00238
00239 00240 00241 00242 00243
00244 int Gj_nativetypes_read(Gj_Ctx* ctx, Gj_Object* obj, Gj_Nativetype type, Gj_Stream* stream);
00245
00246
00247 00248 00249 00250 00251
00252 int Gj_nativetypes_copy(Gj_Ctx* ctx, Gj_Nativetype type, Gj_Object* src, Gj_Object* dest, Gj_Bool flat);
00253
00254
00255 00256 00257 00258 00259
00260 int Gj_nativetypes_finalize(Gj_Ctx* ctx, Gj_Object* obj, Gj_Nativetype type);
00261
00262
00263 00264 00265 00266 00267
00268 int Gj_nativetypes_write(Gj_Ctx* ctx, Gj_Object* obj, Gj_Nativetype type, Gj_Stream* stream);
00269
00270
00271 00272 00273 00274 00275 00276
00277 int Gj_object_setNInt(Gj_Ctx* ctx, Gj_Object* obj, Gj_NInt val);
00278 int Gj_object_setNFloat(Gj_Ctx* ctx, Gj_Object* obj, Gj_NFloat val);
00279 #ifdef GJ_BIGNUMS
00280 int Gj_object_setNBignum(Gj_Ctx* ctx, Gj_Object* obj, Gj_NBignum val);
00281 #endif
00282 int Gj_object_setNChar(Gj_Ctx* ctx, Gj_Object* obj, Gj_NChar val);
00283 int Gj_object_setNString(Gj_Ctx* ctx, Gj_Object* obj, Gj_NString val);
00284 int Gj_object_setNBool(Gj_Ctx* ctx, Gj_Object* obj, Gj_NBool val);
00285 int Gj_object_setNLink(Gj_Ctx* ctx, Gj_Object* obj, Gj_NLink val);
00286 int Gj_object_setNParamLink(Gj_Ctx* ctx, Gj_Object* obj, Gj_NParamLink val);
00287 int Gj_object_setNPropertyLink(Gj_Ctx* ctx, Gj_Object* obj, Gj_NPropertyLink val);
00288 int Gj_object_setNData(Gj_Ctx* ctx, Gj_Object* obj, Gj_NData val);
00289
00290 int gj_object_setNParamPropertyLinkPtr(Gj_Ctx* ctx, Gj_Object* obj, Gj_Object* val);
00291
00292
00293 00294 00295 00296 00297 00298
00299 int Gj_object_getNInt(Gj_Ctx* ctx, Gj_Object* obj, Gj_NInt* val);
00300 int Gj_object_getNFloat(Gj_Ctx* ctx, Gj_Object* obj, Gj_NFloat* val);
00301 #ifdef GJ_BIGNUMS
00302 int Gj_object_getNBignum(Gj_Ctx* ctx, Gj_Object* obj, Gj_NBignum* val);
00303 #endif
00304 int Gj_object_getNChar(Gj_Ctx* ctx, Gj_Object* obj, Gj_NChar* val);
00305 int Gj_object_getNString(Gj_Ctx* ctx, Gj_Object* obj, Gj_NString* val);
00306 int Gj_object_getNBool(Gj_Ctx* ctx, Gj_Object* obj, Gj_NBool* val);
00307 int Gj_object_getNLink(Gj_Ctx* ctx, Gj_Object* obj, Gj_NLink* val);
00308 int gj_object_getNLink(Gj_Ctx* ctx, Gj_Object* obj, Gj_NLink* val);
00309 int Gj_object_getNParamLink(Gj_Ctx* ctx, Gj_Object* obj, Gj_NParamLink* val);
00310 int Gj_object_getNPropertyLink(Gj_Ctx* ctx, Gj_Object* obj, Gj_NPropertyLink* val);
00311 int Gj_object_getNData(Gj_Ctx* ctx, Gj_Object* obj, Gj_NData* val);
00312
00313
00314
00315
00316 int gj_object_getNParamPropertyLinkPtr(Gj_Ctx* ctx, Gj_Object* obj, Gj_Object** val);
00317
00318
00319 00320 00321 00322 00323
00324 #define Gj_stream_writeNInt(ctx, stream, val) Gj_stream_writeInt((ctx), (stream), (val))
00325 #define Gj_stream_writeNFloat(ctx, stream, val) Gj_stream_writeDouble((ctx), (stream), (val))
00326 #ifdef GJ_BIGNUMS
00327 #define Gj_stream_writeNBignum(ctx, stream, val) Gj_bignum_write((ctx), (val), (stream))
00328 #endif
00329 #ifdef HAVE_WCHAR_H
00330 #define Gj_stream_writeNChar(ctx, stream, val) Gj_stream_writeWchar((ctx), (stream), (val))
00331 #else
00332 #define Gj_stream_writeNChar(ctx, stream, val) Gj_stream_writeChar((ctx), (stream), (val))
00333 #endif
00334 #define Gj_stream_writeNString(ctx, stream, val) Gj_stream_writeStr((ctx), (stream), (val))
00335 #define Gj_stream_writeNBool(ctx, stream, val) Gj_stream_writeChar((ctx), (stream), (val))
00336 #define Gj_stream_writeNLink(ctx, stream, val) Gj_path_write((ctx), (val), (stream))
00337 #define Gj_stream_writeNParamLink(ctx, stream, val) Gj_stream_writeInt((ctx), (stream), (val))
00338 #define Gj_stream_writeNPropertyLink(ctx, stream, val) Gj_stream_writeInt((ctx), (stream), (val))
00339 #define Gj_stream_writeNData(ctx, stream, val) (-1)
00340
00341
00342 00343 00344 00345 00346 00347
00348 #define Gj_stream_readNInt(ctx, stream, val) Gj_stream_readInt((ctx), (stream), (val))
00349 #define Gj_stream_readNFloat(ctx, stream, val) Gj_stream_readDouble((ctx), (stream), (val))
00350 #ifdef GJ_BIGNUMS
00351 #define Gj_stream_readNBignum(ctx, stream, val) (*(val) = Gj_bignum_create((ctx), (stream)), *(val) == 0 ? -1 : 0)
00352 #endif
00353 #ifdef HAVE_WCHAR_H
00354 #define Gj_stream_readNChar(ctx, stream, val) Gj_stream_readWchar((ctx), (stream), (val))
00355 #else
00356 #define Gj_stream_readNChar(ctx, stream, val) Gj_stream_readChar((ctx), (stream), (val))
00357 #endif
00358 #define Gj_stream_readNString(ctx, stream, val) Gj_stream_readStr((ctx), (stream), (val))
00359 #define Gj_stream_readNBool(ctx, stream, val) Gj_stream_readChar((ctx), (stream), (val))
00360 #define Gj_stream_readNLink(ctx, stream, val) (*(val) = Gj_path_create((ctx), (stream)), *(val) == 0 ? -1 : 0)
00361 #define Gj_stream_readNParamLink(ctx, stream, val) Gj_stream_readInt((ctx), (stream), (val))
00362 #define Gj_stream_readNPropertyLink(ctx, stream, val) Gj_stream_readInt((ctx), (stream), (val))
00363 #define Gj_stream_readNData(ctx, stream, val) (-1)
00364
00365
00366 00367 00368 00369 00370
00371 Gj_Object* gj_object_resolveNLink(Gj_Ctx* ctx, Gj_Object* obj, Gj_Bool* remote);
00372
00373
00374 00375 00376 00377 00378
00379 typedef struct gj_Linkrecord_struct gj_Linkrecord;
00380 int gj_object_resolveParamPropertyLinks(Gj_Ctx* ctx, Gj_Object* obj, gj_Linkrecord* linkrecord);
00381
00382
00383 #ifdef __cplusplus
00384 }
00385 #endif
00386
00387 #endif
00388