Ignore:
Timestamp:
11/07/14 17:51:01 (9 years ago)
Author:
Maciej Komosinski
Message:

Sources support both 32-bit and 64-bit, and more compilers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.h

    r230 r247  
    77
    88#include <stdio.h>
     9#include <stdint.h>
    910#include <frams/util/sstring.h>
    1011#include <frams/util/list.h>
     
    3334#define PARAM_DEPRECATED        8192
    3435
     36typedef int32_t paInt;
     37#define PA_INT_SCANF "%d"
     38
    3539// the result of param::set() is a combination of bits:
    3640
     
    9296
    9397        virtual SString getString(int) = 0;     ///< get string value, you can only use this for "s" type property
    94         virtual long getInt(int) = 0;   ///< get long value, you can only use this for "d" type property
     98        virtual paInt getInt(int) = 0;  ///< get long value, you can only use this for "d" type property
    9599        virtual double getDouble(int) = 0;      ///< get double value, you can only use this for "f" type property
    96100        virtual ExtObject getObject(int) = 0;   ///< get object reference, you can only use this for "o" type property
     
    101105
    102106        SString getStringById(const char*prop);  ///< get string value, you can only use this for "s" type property
    103         long getIntById(const char* prop);    ///< get long value, you can only use this for "d" type property
     107        paInt getIntById(const char* prop);    ///< get long value, you can only use this for "d" type property
    104108        double getDoubleById(const char* prop);///< get double value, you can only use this for "f" type property
    105109        ExtObject getObjectById(const char* prop);///< get object reference, you can only use this for "o" type property
     
    109113        int setInt(int i, const char* str);
    110114        int setDouble(int i, const char* str);
    111         virtual int setInt(int, long) = 0;              ///< set long value, you can only use this for "d" type prop
     115        virtual int setInt(int, paInt) = 0;             ///< set long value, you can only use this for "d" type prop
    112116        virtual int setDouble(int, double) = 0; ///< set double value, you can only use this for "f" type prop
    113117        virtual int setString(int, const SString &) = 0;        ///< set string value, you can only use this for "s" type prop
     
    119123        int set(int, const char*);              ///< oldstyle set, can convert string to long or double
    120124
    121         int setIntById(const char* prop, long);///< set long value, you can only use this for "d" type prop
     125        int setIntById(const char* prop, paInt);///< set long value, you can only use this for "d" type prop
    122126        int setDoubleById(const char* prop, double);///< set double value, you can only use this for "f" type prop
    123127        int setStringById(const char* prop, const SString &);///< set string value, you can only use this for "s" type prop
     
    128132        /** get valid minimum, maximum and default value for property 'prop'
    129133                @return 0 if min/max/def information is not available */
    130         int getMinMax(int prop, long& minumum, long& maximum, long& def);
     134        int getMinMax(int prop, paInt& minumum, paInt& maximum, paInt& def);
    131135        /** get valid minimum, maximum and default value for property 'prop'
    132136                @return 0 if min/max/def information is not available */
     
    172176#define SETOFFSET(_proc_) ( (int (*)(void*,const ExtValue*)) &(FIELDSTRUCT :: _proc_ ## _statrick))
    173177
    174 #define FIELDOFFSET(_fld_) ((long)((char*)(&((FIELDSTRUCT*)&MakeCodeGuardHappy)->_fld_)-((char*)((FIELDSTRUCT*)&MakeCodeGuardHappy))))
     178#define FIELDOFFSET(_fld_) ((intptr_t)((char*)(&((FIELDSTRUCT*)&MakeCodeGuardHappy)->_fld_)-((char*)((FIELDSTRUCT*)&MakeCodeGuardHappy))))
    175179
    176180#ifdef DEBUG
    177 #define PARAM_ILLEGAL_OFFSET ((long)0xdeadbeef)
     181#define PARAM_ILLEGAL_OFFSET ((intptr_t)0xdeadbeef)
    178182#else
    179183#define PARAM_ILLEGAL_OFFSET 0
     
    205209        short group, flags;
    206210        const char *name, *type;
    207         long offset;
     211        intptr_t offset;
    208212        void *fun1; ///< procedure or get
    209213        void *fun2; ///< set
     
    214218{
    215219public:
    216         ParamEntryConstructor(const char *_id, short _group = 0, short _flags = 0, const char *_name = 0, const char *_type = 0, long _offset = 0, void *_fun1 = 0, void *_fun2 = 0, const char *_help = 0)
     220        ParamEntryConstructor(const char *_id, short _group = 0, short _flags = 0, const char *_name = 0, const char *_type = 0, intptr_t _offset = 0, void *_fun1 = 0, void *_fun2 = 0, const char *_help = 0)
    217221        {
    218222                id = _id; group = _group; flags = _flags; name = _name; type = _type; offset = _offset; fun1 = _fun1; fun2 = _fun2; help = _help;
     
    254258
    255259        SString getString(int);
    256         long getInt(int);
     260        paInt getInt(int);
    257261        double getDouble(int);
    258262        ExtObject getObject(int);
     
    270274        }
    271275
    272         int setInt(int, long);
     276        int setInt(int, paInt);
    273277        int setDouble(int, double);
    274278        int setString(int, const SString &);
Note: See TracChangeset for help on using the changeset viewer.