Changeset 247 for cpp/frams


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

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

Location:
cpp/frams
Files:
54 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/Makefile-GDK

    r194 r247  
    1515
    1616gdk_test: $(GDK_TEST_OBJS)
    17         $(CXX) $(GDK_TEST_OBJS) -o $@
     17        $(CXX) $(GDK_TEST_OBJS) $(LDFLAGS) -o $@
    1818
    1919genoconv_test: $(GENOCONV_TEST_OBJS)
    20         $(CXX) $(GENOCONV_TEST_OBJS) -o $@
     20        $(CXX) $(GENOCONV_TEST_OBJS) $(LDFLAGS) -o $@
    2121
    2222geno_test: $(GENO_TEST_OBJS)
    23         $(CXX) $(GENO_TEST_OBJS) -o $@
     23        $(CXX) $(GENO_TEST_OBJS) $(LDFLAGS) -o $@
    2424
    2525genooper_test: $(GENOOPER_TEST_OBJS)
    26         $(CXX) $(GENOOPER_TEST_OBJS) -o $@
     26        $(CXX) $(GENOOPER_TEST_OBJS) $(LDFLAGS) -o $@
    2727
    2828genooper_test_fTest: $(GENOOPER_TEST_FTEST_OBJS)
    29         $(CXX) $(GENOOPER_TEST_FTEST_OBJS) -o $@
     29        $(CXX) $(GENOOPER_TEST_FTEST_OBJS) $(LDFLAGS) -o $@
    3030
    3131neuro_test: $(NEURO_TEST_OBJS)
    32         $(CXX) $(NEURO_TEST_OBJS) -o $@
     32        $(CXX) $(NEURO_TEST_OBJS) $(LDFLAGS) -o $@
    3333
    3434loader_test: $(LOADER_TEST_OBJS)
    35         $(CXX) $(LOADER_TEST_OBJS) -o $@
     35        $(CXX) $(LOADER_TEST_OBJS) $(LDFLAGS) -o $@
    3636
    3737serial_test: $(SERIAL_TEST_OBJS)
    38         $(CXX) $(SERIAL_TEST_OBJS) -o $@
     38        $(CXX) $(SERIAL_TEST_OBJS) $(LDFLAGS) -o $@
    3939
    4040multiline_f0_test: $(MULTILINE_F0_OBJS)
    41         $(CXX) $(MULTILINE_F0_OBJS) -o $@
     41        $(CXX) $(MULTILINE_F0_OBJS) $(LDFLAGS) -o $@
    4242
    4343f0_variants_test: $(F0_VARIANTS_OBJS)
    44         $(CXX) $(F0_VARIANTS_OBJS) -o $@
     44        $(CXX) $(F0_VARIANTS_OBJS) $(LDFLAGS) -o $@
    4545
    4646full_props: $(FULL_PROPS_OBJS)
    47         $(CXX) $(FULL_PROPS_OBJS) -o $@
     47        $(CXX) $(FULL_PROPS_OBJS) $(LDFLAGS) -o $@
    4848
    4949part_shapes: $(PART_SHAPES_OBJS)
    50         $(CXX) $(PART_SHAPES_OBJS) -o $@
     50        $(CXX) $(PART_SHAPES_OBJS) $(LDFLAGS) -o $@
    5151
    5252neuro_layout_test: $(NEURO_LAYOUT_TEST_OBJS)
    53         $(CXX) $(NEURO_LAYOUT_TEST_OBJS) -o $@
    54 
     53        $(CXX) $(NEURO_LAYOUT_TEST_OBJS) $(LDFLAGS) -o $@
    5554
    5655geometry_apices_test: $(GEOMETRY_APICES_TEST_OBJS)
    57         $(CXX) $(GEOMETRY_APICES_TEST_OBJS) -o $@
     56        $(CXX) $(GEOMETRY_APICES_TEST_OBJS) $(LDFLAGS) -o $@
    5857
    5958geometry_info_test: $(GEOMETRY_INFO_TEST_OBJS)
    60         $(CXX) $(GEOMETRY_INFO_TEST_OBJS) -o $@
     59        $(CXX) $(GEOMETRY_INFO_TEST_OBJS) $(LDFLAGS) -o $@
    6160
    6261geometry_surface_test: $(GEOMETRY_SURFACE_TEST_OBJS)
    63         $(CXX) $(GEOMETRY_SURFACE_TEST_OBJS) -o $@
     62        $(CXX) $(GEOMETRY_SURFACE_TEST_OBJS) $(LDFLAGS) -o $@
    6463
    6564geometry_volume_test: $(GEOMETRY_VOLUME_TEST_OBJS)
    66         $(CXX) $(GEOMETRY_VOLUME_TEST_OBJS) -o $@
     65        $(CXX) $(GEOMETRY_VOLUME_TEST_OBJS) $(LDFLAGS) -o $@
    6766
    6867
  • cpp/frams/Makefile-GDK-files

    r205 r247  
    1919GENMAN_COMMON_OBJS=frams/genetics/genman.o frams/param/mutableparam.o frams/param/mutparamlist.o frams/neuro/geneticneuroparam.o frams/neuro/neurolibparam.o
    2020
    21 GDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/framsg.o common/stl-util.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o frams/errmgr/errmanager.o frams/param/paramobj.o frams/genetics/oper_fx.o common/nonstd_math.o frams/errmgr/stderrors.o common/Convert.o frams/util/rndutil.o
     21GDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/framsg.o common/stl-util.o common/nonstd_stdio.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o frams/errmgr/errmanager.o frams/param/paramobj.o frams/genetics/oper_fx.o common/nonstd_math.o frams/errmgr/stderrors.o common/Convert.o frams/util/rndutil.o
    2222
    2323GEOMETRY_OBJS=frams/model/geometry/meshbuilder.o frams/model/geometry/modelgeometryinfo.o frams/model/geometry/geometryutils.o
     
    3131F0_VARIANTS_OBJS=frams/_demos/f0_variants_test.o frams/virtfile/stringfile.o frams/virtfile/virtfile.o frams/errmgr/stdouterr.o   $(GDK_OBJS) $(GENOCONV_GDK_OBJS)
    3232
    33 LOADER_TEST_OBJS=frams/_demos/genotypeloader.o frams/_demos/loader_test.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o common/nonstd_stdio.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS)
     33LOADER_TEST_OBJS=frams/_demos/genotypeloader.o frams/_demos/loader_test.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS)
    3434
    3535GENOCONV_TEST_OBJS= frams/_demos/genoconv_test.o frams/_demos/printconvmap.o frams/errmgr/stdouterr.o frams/virtfile/virtfile.o  $(GDK_OBJS) $(GENOCONV_GDK_OBJS)
     
    3939GENOOPER_TEST_OBJS=frams/_demos/genooper_test.o frams/virtfile/virtfile.o frams/errmgr/stdouterr.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS)
    4040
    41 GENOOPER_TEST_FTEST_OBJS=frams/_demos/genooper_test_fTest.o frams/virtfile/virtfile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS)
     41GENOOPER_TEST_FTEST_OBJS=frams/_demos/genooper_test_fTest.o frams/virtfile/virtfile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS) $(GENMAN_FT)
    4242
    4343NEURO_TEST_OBJS= frams/_demos/neuro_test.o frams/errmgr/stdouterr.o frams/virtfile/virtfile.o \
     
    4545        frams/neuro/impl/neuroimpl-fuzzy.o frams/neuro/impl/neuroimpl-fuzzy-f0.o  $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS)
    4646
    47 FULL_PROPS_OBJS= frams/_demos/full_props.o frams/errmgr/stdouterr.o frams/virtfile/virtfile.o  frams/virtfile/stdiofile.o common/nonstd_stdio.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS)
     47FULL_PROPS_OBJS= frams/_demos/full_props.o frams/errmgr/stdouterr.o frams/virtfile/virtfile.o  frams/virtfile/stdiofile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS)
    4848
    4949SERIAL_TEST_OBJS= frams/_demos/serial_test.o frams/virtfile/virtfile.o  $(GDK_OBJS) $(GENOCONV_GDK_OBJS)
     
    5353NEURO_LAYOUT_TEST_OBJS= frams/_demos/neuro_layout_test.o frams/virtfile/virtfile.o frams/errmgr/stdouterr.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS) frams/canvas/nn_layout_model.o frams/canvas/nn_simple_layout.o frams/canvas/nn_smart_layout.o
    5454
    55 GEOMETRY_APICES_TEST_OBJS=frams/_demos/geometry/apices_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o common/nonstd_stdio.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS)
     55GEOMETRY_INFO_TEST_OBJS=frams/_demos/geometry/info_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS)
    5656
    57 GEOMETRY_INFO_TEST_OBJS=frams/_demos/geometry/info_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o common/nonstd_stdio.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS)
     57GEOMETRY_SURFACE_TEST_OBJS=frams/_demos/geometry/surface_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS)
    5858
    59 GEOMETRY_SURFACE_TEST_OBJS=frams/_demos/geometry/surface_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o common/nonstd_stdio.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS)
     59GEOMETRY_VOLUME_TEST_OBJS=frams/_demos/geometry/volume_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS)
    6060
    61 GEOMETRY_VOLUME_TEST_OBJS=frams/_demos/geometry/volume_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o common/nonstd_stdio.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS)
     61GEOMETRY_APICES_TEST_OBJS=frams/_demos/geometry/apices_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile-autoinit.o frams/virtfile/stdiofile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS)
  • cpp/frams/canvas/neurodiagram.cpp

    r240 r247  
    235235}
    236236
    237 void NeuroDiagram::onKill(void*obj, long dummy)
     237void NeuroDiagram::onKill(void*obj, intptr_t dummy)
    238238{
    239239        show(0);
     
    678678////
    679679
    680 void NeuroDiagram::probeSampling(void*obj, long dummy)
     680void NeuroDiagram::probeSampling(void*obj, intptr_t dummy)
    681681{
    682682        FOREACH(NeuroProbe*,pr,probes) pr->sampling();
  • cpp/frams/canvas/nn_smart_layout.cpp

    r197 r247  
    66#include <vector>
    77#include "common/nonstd_stl.h"
     8#ifdef __BORLANDC__
     9 #include <alloc.h> //borland needs for alloc/free
     10#endif
    811
    912#define DB(x)
  • cpp/frams/config/f0.def

    r187 r247  
    4747PROP(dy,1,1024,delta.y,f,-2,2,0,d.y)
    4848PROP(dz,1,1024,delta.z,f,-2,2,0,d.z)
    49 PROP(sh,1,0,shape,d,0,1,0,shape)
     49PROP(sh,2,0,shape,d,0,1,0,shape)
    5050XPROP(stif,2,0,stiffness,f,0.0,1.0,1.0,stif)
    5151XPROP(rotstif,2,0,rotation stiffness,f,0.0,1.0,1.0,rotstif)
     
    6565PROP(p1,0,1024,`part1 ref#',d,-1,999999,-1,p1_refno)
    6666PROP(p2,0,1024,`part2 ref#',d,-1,999999,-1,p2_refno)
    67 PROP(sh,1,0,shape,d,0,1,0,shape)
     67PROP(sh,2,0,shape,d,0,1,0,shape)
    6868XPROP(stif,2,0,stiffness,f,0.0,1.0,1.0,stif)
    6969XPROP(rotstif,2,0,rotation stiffness,f,0.0,1.0,1.0,rotstif)
  • cpp/frams/config/f0def.xml

    r187 r247  
    5050  <PROP ID="dy" NAME="delta.y" GROUP="1" FLAGS="1024" TYPE="f" MIN="-2" MAX="2" DEF="0" />
    5151  <PROP ID="dz" NAME="delta.z" GROUP="1" FLAGS="1024" TYPE="f" MIN="-2" MAX="2" DEF="0" />
    52   <PROP ID="sh" NAME="shape" GROUP="1" FLAGS="0" TYPE="d" MIN="0" MAX="1" DEF="0" />
     52  <PROP ID="sh" NAME="shape" GROUP="2" FLAGS="0" TYPE="d" MIN="0" MAX="1" DEF="0" />
    5353  <PROP ID="stif" XTRA="1" NAME="stiffness" GROUP="2" FLAGS="0" TYPE="f" MIN="0.0" MAX="1.0" DEF="1.0" />
    5454  <PROP ID="rotstif" XTRA="1" NAME="rotation stiffness" GROUP="2" FLAGS="0" TYPE="f" MIN="0.0" MAX="1.0" DEF="1.0" />
  • cpp/frams/config/version.h

    r225 r247  
    33// Refer to http://www.framsticks.com/ for further information.
    44
    5 #define MAIN_REL_ID "4.0rc9"
     5#define MAIN_REL_ID "4.0rc10"
  • cpp/frams/genetics/f4/f4_general.cpp

    r197 r247  
    593593
    594594
    595 int f4_Cell::addlink(f4_Cell * nfrom, double nw, long nt)
     595int f4_Cell::addlink(f4_Cell * nfrom, double nw, int nt)
    596596{
    597597        if (nolink >= MAXINPUTS - 1) return -1; // full!
     
    675675
    676676
    677 f4_CellLink::f4_CellLink(f4_Cell * nfrom, double nw, long nt)
     677f4_CellLink::f4_CellLink(f4_Cell * nfrom, double nw, int nt)
    678678{
    679679        from = nfrom;
     
    12341234        int i, j, t, res;
    12351235        char tc1, tc2;
    1236         long relfrom;
     1236        int relfrom;
    12371237        double w;
    12381238        unsigned gpos, oldpos;
  • cpp/frams/genetics/f4/f4_general.h

    r197 r247  
    101101        int onestep();  // execute one simulation step (till a division)
    102102
    103         int   addlink(f4_Cell * nfrom, double nw, long nt);
     103        int   addlink(f4_Cell * nfrom, double nw, int nt);
    104104        void  adjustRec();
    105105
     
    129129        //f4_OrientMat OM;
    130130        double       mz;            // freedom in z
    131         long         p2_refno;   // number of last end part object, used in f0
    132         long         joint_refno;   // number of the joint object, used in f0
    133         long         neuro_refno;   // number of the neuro object, used in f0
    134 
    135         long         ctrl;  // neuron type
     131        int          p2_refno;   // number of last end part object, used in f0
     132        int          joint_refno;   // number of the joint object, used in f0
     133        int          neuro_refno;   // number of the neuro object, used in f0
     134
     135        int          ctrl;  // neuron type
    136136        double       state;
    137137        double       inertia;
     
    147147{
    148148public:
    149         f4_CellLink(f4_Cell * nfrom, double nw, long nt);
     149        f4_CellLink(f4_Cell * nfrom, double nw, int nt);
    150150        f4_Cell *    from;
    151151        // type: 0: input, 1 '*', 2 'G', 3 'T', 4 'S'
    152         long         t;
     152        int          t;
    153153        double       w;
    154154};
     
    205205        int       pos;        // original position in string
    206206        int       i1;           // internal int  parameter1
    207         long      l1;           // internal long parameter1
     207        int       l1;           // internal long parameter1
    208208        double    f1;           // internal double parameter1
    209209
  • cpp/frams/genetics/f4/oper_f4.cpp

    r199 r247  
    606606
    607607
    608 unsigned long Geno_f4::style(const char *g, int pos)
     608uint32_t Geno_f4::style(const char *g, int pos)
    609609{
    610610        char ch = g[pos];
     
    616616        if (!strchr(STYL4CAT_MODIFIC STYL4CAT_NEUMOD STYL4CAT_DIGIT STYL4CAT_REST, ch))
    617617                return GENSTYLE_CS(0, GENSTYLE_INVALID);
    618         unsigned long style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); //default, should be changed below
     618        uint32_t style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); //default, should be changed below
    619619        if (strchr("X ", ch))              style = GENSTYLE_CS(0, GENSTYLE_NONE);
    620620        if (strchr("N", ch))               style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_NONE);
  • cpp/frams/genetics/f4/oper_f4.h

    r197 r247  
    3838        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
    3939        const char* getSimplest() { return "X"; }
    40         unsigned long style(const char *g, int pos);
     40        uint32_t style(const char *g, int pos);
    4141
    4242        // mutation probabilities
  • cpp/frams/genetics/f9/oper_f9.cpp

    r197 r247  
    109109
    110110///Applying some colors and font styles...
    111 unsigned long GenoOper_f9::style(const char *g, int pos)
     111uint32_t GenoOper_f9::style(const char *g, int pos)
    112112{
    113113        char ch = g[pos];
    114         unsigned long style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
     114        uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
    115115        char *ptr = strchr((char*)turtle_commands_f9, ch);
    116116        if (ptr)
  • cpp/frams/genetics/f9/oper_f9.h

    r197 r247  
    1717        int mutate(char *&g,float& chg,int &method);
    1818        int crossOver(char *&g1,char *&g2,float& chg1,float& chg2);
    19         unsigned long style(const char *g, int pos);
     19        uint32_t style(const char *g, int pos);
    2020        const char* getSimplest() {return "R";}
    2121
  • cpp/frams/genetics/fF/oper_fF.cpp

    r197 r247  
    8989
    9090///Applying some colors and font styles...
    91 unsigned long GenoOper_fF::style(const char *g, int pos)
     91uint32_t GenoOper_fF::style(const char *g, int pos)
    9292{
    9393        char ch = g[pos];
    94         unsigned long style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
     94        uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
    9595        if (strchr("-.e 0123456789", ch) != NULL)
    9696                style = GENSTYLE_CS(GENCOLOR_NUMBER, GENSTYLE_NONE);
  • cpp/frams/genetics/fF/oper_fF.h

    r197 r247  
    1717        int mutate(char *&g, float& chg, int &method);
    1818        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
    19         unsigned long style(const char *g, int pos);
     19        uint32_t style(const char *g, int pos);
    2020        const char* getSimplest() { return "6, 1.05, 1.05, 1.05, 0, 0, 0"; }
    2121
  • cpp/frams/genetics/fT/oper_fTest.cpp

    r194 r247  
    115115
    116116///Applying some colors and font styles...
    117 unsigned long GenoOper_fTest::style(const char *g, int pos)
     117uint32_t GenoOper_fTest::style(const char *g, int pos)
    118118{
    119119        char ch = g[pos];
    120         unsigned long style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
     120        uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below
    121121        if (ch == 'A') style = GENSTYLE_RGBS(200, 0, 0, GENSTYLE_BOLD);
    122122        if (ch == 'T') style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_BOLD);
  • cpp/frams/genetics/fT/oper_fTest.h

    r194 r247  
    2929        int mutate(char *&geno, float& chg, int &method);
    3030        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
    31         unsigned long style(const char *g, int pos);
     31        uint32_t style(const char *g, int pos);
    3232        const char* getSimplest() { return "GATCGATTACA"; }
    3333
  • cpp/frams/genetics/genman.cpp

    r240 r247  
    371371}
    372372
    373 unsigned long GenMan::Style(const char *g, int pos)
     373uint32_t GenMan::Style(const char *g, int pos)
    374374{
    375375        Geno G(g);
     
    380380}
    381381
    382 void GenMan::GetFullStyle(const char *g, unsigned long *styletab)
     382void GenMan::GetFullStyle(const char *g, uint32_t *styletab)
    383383{
    384384        Geno G(g);
     
    404404        int chars = 0, lines = 0;
    405405        bool shortened = false;
    406         unsigned long *styletab = new unsigned long[len];
     406        uint32_t *styletab = new uint32_t[len];
    407407        GetFullStyle(g, styletab);
    408408        SString html = "\n<div style=\"background:white;padding:0.2em;font-family:arial,helvetica,sans-serif;font-size:90%\">";
    409         unsigned long prevstyle, prevcolor, style = 0, color = 0;
     409        uint32_t prevstyle, prevcolor, style = 0, color = 0;
    410410        for (int i = 0; i<len; i++)
    411411        {
     
    501501}
    502502
    503 void GenMan::onDelGen(void *obj, long n)
     503void GenMan::onDelGen(void *obj, intptr_t n)
    504504{
    505505        //old code needs update:
  • cpp/frams/genetics/genman.h

    r197 r247  
    4646        Geno CrossOver(const Geno&, const Geno&); //returns xover genotype ("child") or empty if errors
    4747        float Similarity(const Geno&, const Geno&); //returns GENOPER_NOOPER or normalized similarity (1: identical, 0: different)
    48         unsigned long Style(const char* g, int pos); //returns Style (and validity) of a genotype char.
    49         void GetFullStyle(const char *g, unsigned long *styletab); //optimized. Fills styletab with styles for all genotype chars. sizeof(*styletab) must be at least strlen(g).
     48        uint32_t Style(const char* g, int pos); //returns Style (and validity) of a genotype char.
     49        void GetFullStyle(const char *g, uint32_t *styletab); //optimized. Fills styletab with styles for all genotype chars. sizeof(*styletab) must be at least strlen(g).
    5050        SString HTMLize(const char *g); //returns colored genotype in HTML.
    5151        SString HTMLizeShort(const char *g); //returns colored genotype (abbreviated if needed) in HTML.
     
    8383#undef STATRICKCLASS
    8484        void clearStats();
    85         static void onDelGen(void*, long);
     85        static void onDelGen(void*, intptr_t);
    8686};
    8787
  • cpp/frams/genetics/genoconv.h

    r197 r247  
    4646                out_format;     //< output format, eg. '0'
    4747        const char *info;       //< detailed info about converter, format or copyright
    48         long enabled;   //< don't touch this! (used by configuration module)
    49         long mapsupport; //< set to 1 if your converter supports genotype mapping
     48        paInt enabled;  //< don't touch this! (used by configuration module)
     49        paInt mapsupport; //< set to 1 if your converter supports genotype mapping
    5050
    5151        /// You have to reimplement this method.
  • cpp/frams/genetics/oper_fx.cpp

    r197 r247  
    5858        if (p->type(i)[0] == 'd')
    5959        {
    60                 long _mn = 0, _mx = 1, _def = 0;
     60                paInt _mn = 0, _mx = 1, _def = 0;
    6161                defined = p->getMinMax(i, _mn, _mx, _def);
    6262                if (defined == 1) _mx = _mn + 1;
     
    150150void GenoOperators::setIntFromDoubleWithProbabilisticDithering(ParamInterface &p, int index, double value) //TODO
    151151{
    152         p.setInt(index, value); //TODO value=2.5 will result in 2 but we want it to be 2 or 3 with equal probability. value=2.1 would be mostly 2, rarely 3. Careful with negative values (test it!)
     152        p.setInt(index, (paInt)value); //TODO value=2.5 will result in 2 but we want it to be 2 or 3 with equal probability. value=2.1 would be mostly 2, rarely 3. Careful with negative values (test it!)
    153153}
    154154
     
    187187NeuroClass* GenoOperators::parseNeuroClass(char*& s)
    188188{
    189         int len = strlen(s);
     189        int len = (int)strlen(s);
    190190        int Len = 0;
    191191        NeuroClass *I = NULL;
     
    193193        {
    194194                const char *n = Neuro::getClass(i)->name;
    195                 int l = strlen(n);
     195                int l = (int)strlen(n);
    196196                if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = Neuro::getClass(i); Len = l; }
    197197        }
     
    210210int GenoOperators::neuroClassProp(char*& s, NeuroClass *nc, bool also_v1_N_props)
    211211{
    212         int len = strlen(s);
     212        int len = (int)strlen(s);
    213213        int Len = 0, I = -1;
    214214        if (nc)
     
    218218                {
    219219                        const char *n = p.id(i);
    220                         int l = strlen(n);
     220                        int l = (int)strlen(n);
    221221                        if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = 100 + i; Len = l; }
    222222                        if (also_v1_N_props) //recognize old properties symbols /=!
     
    225225                                        if (strcmp(n, "in") == 0) n = "="; else
    226226                                                if (strcmp(n, "fo") == 0) n = "!";
    227                                 l = strlen(n);
     227                                l = (int)strlen(n);
    228228                                if (len >= l && l > Len && (strncmp(s, n, l) == 0)) { I = 100 + i; Len = l; }
    229229                        }
     
    235235        {
    236236                const char *n = p.id(i);
    237                 int l = strlen(n);
     237                int l = (int)strlen(n);
    238238                if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = i; Len = l; }
    239239        }
  • cpp/frams/genetics/oper_fx.h

    r201 r247  
    3131/** \name other useful style/color macros */
    3232//@{
    33 #define GENRGB(r,g,b) ((unsigned long)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16)))
    34 #define GENSTYLE_RGBS(r,g,b,s) ((unsigned long)((unsigned char)s)<<24 | GENRGB(r,g,b))
    35 #define GENSTYLE_CS(rgb,s) ((unsigned long)((unsigned char)s)<<24 | rgb)
     33#define GENRGB(r,g,b) ((uint32_t)(((uint8_t)(r)|((uint16_t)((uint8_t)(g))<<8))|(((uint32_t)(uint8_t)(b))<<16)))
     34#define GENSTYLE_RGBS(r,g,b,s) ((uint32_t)((uint8_t)s)<<24 | GENRGB(r,g,b))
     35#define GENSTYLE_CS(rgb,s) ((uint32_t)((uint8_t)s)<<24 | rgb)
    3636
    3737#define GENGETSTYLE(style) ((style)>>24)
     
    168168Assume white background.
    169169\sa GENSTYLE_* macros, like GENSTYLE_BOLD*/
    170    virtual unsigned long style(const char *geno,int pos) {return GENSTYLE_RGBS(0,0,0,GENSTYLE_NONE);}
     170   virtual uint32_t style(const char *geno,int pos) {return GENSTYLE_RGBS(0,0,0,GENSTYLE_NONE);}
    171171
    172172///currently not used (similarity of two genotypes)
  • cpp/frams/model/model.cpp

    r197 r247  
    129129Model::~Model()
    130130{
    131 delmodel_list.action((long)this);
     131delmodel_list.action((intptr_t)this);
    132132clear();
    133133}
  • cpp/frams/model/modelparts.cpp

    r197 r247  
    163163                        {
    164164                        case 'd': t+=" integer";
    165                         {long a,b,c; if (p.getMinMax(i,a,b,c)>=2) t+=SString::sprintf(" %d..%d",a,b);}
     165                        {paInt a,b,c; if (p.getMinMax(i,a,b,c)>=2) t+=SString::sprintf(" %d..%d",a,b);}
    166166                                break;
    167167                        case 'f': t+=" float";
  • cpp/frams/model/modelparts.h

    r197 r247  
    3838MultiRange *mapped;
    3939enum PartBaseFlags { Selected=1 };
    40 long flags;
     40int flags;
    4141Model *owner;   ///< backlink to the model
    4242
     
    8080Param extraProperties();
    8181Param properties();
    82 long refno;
     82paInt refno;
    8383Pt3D rot;///< rotation angles
    8484
    8585///
    86 long shape;///default=old framsticks compatible, do not mix with shapes>0
     86paInt shape;///default=old framsticks compatible, do not mix with shapes>0
    8787enum Shape {SHAPE_DEFAULT=0, SHAPE_ELLIPSOID=1, SHAPE_CUBOID=2, SHAPE_CYLINDER=3};
    8888double mass,size,density,friction,ingest,assim;
     
    119119public:
    120120// base properties:
    121 long p1_refno,p2_refno; ///< parts' reference numbers
     121paInt p1_refno,p2_refno; ///< parts' reference numbers
    122122
    123123Part *part1,*part2;     ///< references to parts
     
    125125class Pt3D rot; ///< orientation delta between parts expressed as 3 angles
    126126enum Shape {SHAPE_DEFAULT=0, SHAPE_SOLID=1};
    127 long shape;///< default=old framsticks compatible, creates a physical rod between parts (cylinder or cuboid), do not mix with shape>0,  solid=merge parts into one physical entity
     127paInt shape;///< default=old framsticks compatible, creates a physical rod between parts (cylinder or cuboid), do not mix with shape>0,  solid=merge parts into one physical entity
    128128
    129129Joint();
     
    159159
    160160// do not touch these:
    161 long refno; ///< this joint's reference number
     161paInt refno; ///< this joint's reference number
    162162double stamina;
    163163double stif,rotstif;    ///< stiffness for moving and bending forces
     
    189189ParamEntry *props;
    190190bool ownedprops;//< destructor will free props using ParamObject::freeParamTab
    191 long prefinputs,prefoutput;
    192 long preflocation;
     191paInt prefinputs,prefoutput;
     192paInt preflocation;
    193193int *vectordata;
    194 long visualhints;
     194paInt visualhints;
    195195
    196196//void *impl;
     
    220220    extra inputs may be ignored by the object (depends on the class).
    221221 */
    222 int getPreferredInputs() {return prefinputs;}
     222int getPreferredInputs() {return (int)prefinputs;}
    223223
    224224/** @return 0 if this object doesn't provide useful output signal. */
    225 int getPreferredOutput() {return prefoutput;}
     225int getPreferredOutput() {return (int)prefoutput;}
    226226
    227227/** @return 0 if the object doesn't need any assignment to the body element.
     
    229229    @return 2 = the object prefers to have the Joint ( @see Neuro::attachToJoint() )
    230230 */
    231 int getPreferredLocation() {return preflocation;}
     231int getPreferredLocation() {return (int)preflocation;}
    232232/** vector drawing to be used in neuro net diagram.
    233233    interpretation:
     
    251251 */
    252252int getVisualHints()
    253  {return visualhints;}
     253 {return (int)visualhints;}
    254254
    255255enum Hint
     
    377377SyntParam classProperties(bool handle_defaults_when_saving=true);
    378378// base properties:
    379 long refno; ///< unique reference number (former 'neuro' refno)
    380 
    381 long part_refno; ///< can be used by some items as the part ref#
    382 long joint_refno; ///< can be used by some items as the joint ref#
     379paInt refno; ///< unique reference number (former 'neuro' refno)
     380
     381paInt part_refno; ///< can be used by some items as the part ref#
     382paInt joint_refno; ///< can be used by some items as the joint ref#
    383383
    384384Pt3D pos,rot;   ///< default = zero
     
    451451   or -1 if 'child' is not connected with this Neuro.*/
    452452int findInput(Neuro* child) const;
    453 void removeInput(int refno);
     453void removeInput(paInt refno);
    454454/**    @return reference number of the child connection, like findInput() */
    455455int removeInput(Neuro* child);
     
    470470#ifdef MODEL_V1_COMPATIBLE
    471471friend class OldItems;
    472 long neuro_refno; ///< parent ref# (called neuro_refno for compatibility with old Neuro class), @see moredata
    473 long conn_refno; ///< the other neuron ref# in N-N connections, can be used by some other items
     472paInt neuro_refno; ///< parent ref# (called neuro_refno for compatibility with old Neuro class), @see moredata
     473paInt conn_refno; ///< the other neuron ref# in N-N connections, can be used by some other items
    474474double weight; ///< weight of the N-N connection and (all?) receptors
    475475double inertia,force,sigmo; //!!!
  • cpp/frams/neuro/geneticneuroparam.cpp

    r197 r247  
    1111{}
    1212
    13 long GeneticNeuroParam::getInt(int i)
     13paInt GeneticNeuroParam::getInt(int i)
    1414{return Neuro::getClass(i)->genactive;}
    1515
    16 int GeneticNeuroParam::setInt(int i,long v)
     16int GeneticNeuroParam::setInt(int i,paInt v)
    1717{Neuro::getClass(i)->genactive=v;return PSET_CHANGED;}
    1818
  • cpp/frams/neuro/geneticneuroparam.h

    r197 r247  
    1515GeneticNeuroParam(const char* groupname,const char* myname, const char* prefix,const char* typ=0);
    1616
    17 long getInt(int i);
    18 int setInt(int i,long v);
     17paInt getInt(int i);
     18int setInt(int i,paInt v);
    1919const char *type(int i) {return types?types:NeuroLibParam::type(i);}
    2020};
  • cpp/frams/neuro/neurocls-f0-GDK-factory.h

    r197 r247  
    1 // This file is a part of the Framsticks GDK.
    2 // Copyright (C) 1999-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
    3 // Refer to http://www.framsticks.com/ for further information.
    4 
    51
    62// do not edit - generated automatically from "f0.def"
  • cpp/frams/neuro/neurocls-f0-GDK-library.h

    r197 r247  
    1 // This file is a part of the Framsticks GDK.
    2 // Copyright (C) 1999-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
    3 // Refer to http://www.framsticks.com/ for further information.
    4 
    51
    62// do not edit - generated automatically from "f0.def"
  • cpp/frams/neuro/neuroimpl.h

    r197 r247  
    108108
    109109public:
    110   long intParameter;
     110  paInt intParameter;
    111111  double fpParameter;
    112112  SString txtParameter;
  • cpp/frams/neuro/neurolibparam.cpp

    r197 r247  
    2222}
    2323
    24 void NeuroLibParam::neuroclassAdded(void* data,long i)
     24void NeuroLibParam::neuroclassAdded(void* data,intptr_t i)
    2525{onadd.action(i);}
    26 void NeuroLibParam::neuroclassRemoved(void* data,long i)
     26void NeuroLibParam::neuroclassRemoved(void* data,intptr_t i)
    2727{ondelete.action(i);}
    2828
  • cpp/frams/param/mutableparam.cpp

    r240 r247  
    108108        switch(pe->type[0])
    109109                {
    110                 case 'd': d=new int(); *((int*)d)=0; break;
     110                case 'd': d=new paInt(); *((paInt*)d)=0; break;
    111111                case 'f': d=new double(); *((double*)d)=0; break;
    112112                case 's': d=new SString(); break;
     
    114114                case 'o': d=new ExtObject(); break;
    115115                }
    116         pe->offset=(int)d;
     116        pe->offset=(intptr_t)d;
    117117        }
    118118onadd.action(position);
     
    134134        switch(pe->type[0])
    135135                {
    136                 case 'd': delete (int*)d; break;
     136                case 'd': delete (paInt*)d; break;
    137137                case 'f': delete (double*)d; break;
    138138                case 's': delete (SString*)d; break;
     
    173173pe->group=(short)group;
    174174pe->flags=(short)(flags | MUTPARAM_ALLOCENTRY);
    175 pe->offset=(long)data;
     175pe->offset=(intptr_t)data;
    176176pe->id=strdup(id);
    177177pe->type=strdup(type);
     
    209209}
    210210
    211 int MutableParam::setInt(int i,long v)
     211int MutableParam::setInt(int i,paInt v)
    212212{
    213213int ret=SimpleAbstractParam::setInt(i,v);
  • cpp/frams/param/mutableparam.h

    r197 r247  
    2323SList entries;
    2424SList groups;
    25 long changed;
     25int changed;
    2626ParamEntry *entry(int i) {return (i<staticprops)? pe_tab+i : ((ParamEntry*)entries(i-staticprops));}
    2727void *getTarget(int i) {return (i<staticprops)? SimpleAbstractParam::getTarget(i) : (void*)entry(i)->offset;}
     
    5454void notify(int id);
    5555
    56 int setInt(int,long);
     56int setInt(int,paInt);
    5757int setDouble(int,double);
    5858int setString(int,const SString &);
  • cpp/frams/param/mutparamlist.cpp

    r197 r247  
    126126}
    127127
    128 void MutableParamList::onPropAdd(void* data,long i)
     128void MutableParamList::onPropAdd(void* data,intptr_t i)
    129129{
    130130ParamInfo *pi=(ParamInfo*)data;
     
    136136}
    137137
    138 void MutableParamList::onPropDelete(void* data,long i)
     138void MutableParamList::onPropDelete(void* data,intptr_t i)
    139139{
    140140ParamInfo *pi=(ParamInfo*)data;
     
    146146}
    147147
    148 void MutableParamList::onPropChange(void* data,long i)
     148void MutableParamList::onPropChange(void* data,intptr_t i)
    149149{
    150150ParamInfo *pi=(ParamInfo*)data;
     
    152152}
    153153
    154 void MutableParamList::onPropActivate(void* data,long i)
     154void MutableParamList::onPropActivate(void* data,intptr_t i)
    155155{
    156156ParamInfo *pi=(ParamInfo*)data;
     
    158158}
    159159
    160 void MutableParamList::onGroupAdd(void* data,long i)
     160void MutableParamList::onGroupAdd(void* data,intptr_t i)
    161161{
    162162ParamInfo *pi=(ParamInfo*)data;
     
    168168}
    169169
    170 void MutableParamList::onGroupDelete(void* data,long i)
     170void MutableParamList::onGroupDelete(void* data,intptr_t i)
    171171{
    172172ParamInfo *pi=(ParamInfo*)data;
     
    178178}
    179179
    180 void MutableParamList::onGroupChange(void* data,long i)
     180void MutableParamList::onGroupChange(void* data,intptr_t i)
    181181{
    182182ParamInfo *pi=(ParamInfo*)data;
     
    295295FUN(int,flags,0)
    296296FUN(SString,getString,SString())
    297 FUN(long,getInt,0)
     297FUN(paInt,getInt,0)
    298298FUN(double,getDouble,0)
    299 FUN(ExtValue,getExtValue,ExtValue((long)0))
     299FUN(ExtValue,getExtValue,ExtValue((paInt)0))
    300300FUN(ExtObject,getObject,ExtObject())
    301301
     
    322322}
    323323
    324 FUN2(int,setInt,long)
     324FUN2(int,setInt,paInt)
    325325FUN2(int,setDouble,double)
    326326FUN2(int,setString,const SString &)
  • cpp/frams/param/mutparamlist.h

    r197 r247  
    7575
    7676SString getString(int);
    77 long getInt(int);
     77paInt getInt(int);
    7878double getDouble(int);
    7979ExtValue getExtValue(int);
    8080ExtObject getObject(int);
    8181
    82 int setInt(int,long);
     82int setInt(int,paInt);
    8383int setDouble(int,double);
    8484int setString(int,const SString &);
  • cpp/frams/param/param.cpp

    r230 r247  
    3737static const char *strchrlimit(const char *t, int ch, const char *limit)
    3838{
    39         int n = limit - t;
     39        int n = (int)(limit - t);
    4040        for (; (n > 0) && *t; t++, n--)
    4141                if (*t == ch) return t;
     
    7272}
    7373
    74 int ParamInterface::getMinMax(int prop, long& minumum, long& maximum, long &def)
     74int ParamInterface::getMinMax(int prop, paInt& minumum, paInt& maximum, paInt &def)
    7575{
    7676        const char* t = type(prop) + 1;
    7777        while (*t) if (*t == ' ') break; else t++;
    78         return sscanf(t, "%ld %ld %ld", &minumum, &maximum, &def);
     78        return sscanf(t, PA_INT_SCANF " " PA_INT_SCANF " " PA_INT_SCANF, &minumum, &maximum, &def);
    7979}
    8080
     
    121121        case 'd':
    122122        {
    123                 long a = 0, b = 0, c = 0;
     123                paInt a = 0, b = 0, c = 0;
    124124                if (getMinMax(i, a, b, c) < 3) c = a;
    125125                setInt(i, c);
     
    144144        case 'd':
    145145        {
    146                 long a = 0, b = 0, c = 0;
     146                paInt a = 0, b = 0, c = 0;
    147147                getMinMax(i, a, b, c);
    148148                setInt(i, a);
     
    167167        case 'd':
    168168        {
    169                 long a = 0, b = 0, c = 0;
     169                paInt a = 0, b = 0, c = 0;
    170170                getMinMax(i, a, b, c);
    171171                setInt(i, b);
     
    178178SString ParamInterface::getStringById(const char*prop)
    179179{int i=findId(prop); if (i>=0) return getString(i); else return SString();}
    180 long ParamInterface::getIntById(const char*prop)
     180paInt ParamInterface::getIntById(const char*prop)
    181181{int i=findId(prop); if (i>=0) return getInt(i); else return 0;}
    182182double ParamInterface::getDoubleById(const char*prop)
     
    187187{int i=findId(prop); if (i>=0) return getExtValue(i); else return ExtValue();}
    188188
    189 int ParamInterface::setIntById(const char* prop,long v)
     189int ParamInterface::setIntById(const char* prop,paInt v)
    190190{int i=findId(prop); if (i>=0) return setInt(i,v); else return PSET_NOPROPERTY;}
    191191int ParamInterface::setDoubleById(const char* prop,double v)
     
    260260        {
    261261                select(defdata);
    262                 long x = getInt(i);
     262                paInt x = getInt(i);
    263263                select(backup);
    264264                return x == getInt(i);
     
    347347                if (!*p0) break;
    348348                p = strchr(p0, ':'); if (!p) continue;
    349                 p_len = p - p0;
     349                p_len = (int)(p - p0);
    350350                loaded = false;
    351351                if (p_len && ((i = findIdn(p0, p_len)) >= 0) && (!(flags(i)&PARAM_DONTLOAD)))
     
    442442        if (!stringIsNumeric(str))
    443443        {
    444                 long a, b, c;
     444                paInt a, b, c;
    445445                if (getMinMax(i, a, b, c) >= 3)
    446446                        return setInt(i, c);
    447447                else
    448                         return setInt(i, (long)0);
     448                        return setInt(i, (paInt)0);
    449449        }
    450450        else
     
    536536                        const char *t2 = strchr(t, '~');
    537537                        if (!t2) t2 = t + strlen(t);
    538                         return SString(t, t2 - t);
     538                        return SString(t, (int)(t2 - t));
    539539                }
    540540        }
     
    599599#endif
    600600
    601 long SimpleAbstractParam::getInt(int i)
     601paInt SimpleAbstractParam::getInt(int i)
    602602{
    603603        SANITY_CHECK(i);
     
    612612        {
    613613                void *target = getTarget(i);
    614                 return *((long*)target);
     614                return *((paInt*)target);
    615615        }
    616616}
     
    687687//////// set
    688688
    689 int SimpleAbstractParam::setInt(int i, long x)
     689int SimpleAbstractParam::setInt(int i, paInt x)
    690690{
    691691        SANITY_CHECK(i);
     
    693693        ParamEntry *pe = entry(i);
    694694        if (pe->flags&PARAM_READONLY) return PSET_RONLY;
    695         long xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
    696         long a = 0, b = 0;
     695        paInt xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below
     696        paInt a = 0, b = 0;
    697697        int result = 0;
    698698        const char* t = pe->type + 1;
    699699        while (*t) if (*t == ' ') break; else t++;
    700         if (sscanf(t, "%ld %ld", &a, &b) == 2)
     700        if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &a, &b) == 2)
    701701                if (a <= b) // if max<min then the min/max constraint check is not supported
    702702                {
     
    713713        {
    714714                void *target = getTarget(i);
    715                 if (dontcheckchanges || (*((long*)target) != x))
     715                if (dontcheckchanges || (*((paInt*)target) != x))
    716716                {
    717717                        result |= PSET_CHANGED;
    718                         *((long*)target) = x;
     718                        *((paInt*)target) = x;
    719719                }
    720720        }
     
    770770        const char* t = pe->type + 1;
    771771        while (*t) if (*t == ' ') break; else t++;
    772         long a = 0, b = 0;
     772        paInt a = 0, b = 0;
    773773        int result = 0;
    774         if (sscanf(t, "%ld %ld", &a, &b) == 2)
     774        if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &a, &b) == 2)
    775775        {
    776776                if ((x.len() > b) && (b > 0))
     
    883883        const char *lf = strchr(beg, '\n');
    884884        if (!lf) { lf = (const char*)s + s.len() - 1; poz = s.len(); }
    885         else { poz = (lf - (const char*)s) + 1; if (poz > s.len()) poz = s.len(); }
     885        else { poz = (int)(lf - (const char*)s) + 1; if (poz > s.len()) poz = s.len(); }
    886886        while (lf >= beg) if ((*lf == '\n') || (*lf == '\r')) lf--; else break;
    887         len = lf - beg + 1;
     887        len = (int)(lf - beg) + 1;
    888888        return beg;
    889889}
     
    939939                if (equals_sign) // have parameter name
    940940                {
    941                         tmpi = findIdn(t, equals_sign - t);
     941                        tmpi = findIdn(t, (int)(equals_sign - t));
    942942                        i = tmpi;
    943943                        if (tmpi < 0)
     
    960960                        if (quote)
    961961                        {
    962                                 tmpvalue.copyFrom(quote + 1, quote2 - quote - 1);
     962                                tmpvalue.copyFrom(quote + 1, (int)(quote2 - quote) - 1);
    963963                                sstringUnquote(tmpvalue);
    964964                                value = tmpvalue;
  • 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 &);
  • cpp/frams/util/callbacks.cpp

    r197 r247  
    6161}
    6262
    63 void Callback::action(long data)
     63void Callback::action(intptr_t data)
    6464{
    6565if (size()==0) return;
  • cpp/frams/util/callbacks.h

    r197 r247  
    88#include "list.h"
    99#include "statrick.h"
     10#include <stdint.h>
    1011
    1112//#define USEMEMBERCALLBACK
     
    1516public:
    1617virtual ~CallbackNode() {}
    17 virtual void action(long calldata)=0;
     18virtual void action(intptr_t calldata)=0;
    1819virtual int equals(CallbackNode*n) {return (this==n);}
    1920};
     
    2526void *userdata;
    2627CallBase *object;
    27 void (CallBase::*member)(void*,long);
     28void (CallBase::*member)(void*,intptr_t);
    2829  public:
    29 MemberCallbackNode(CallBase *o,void (CallBase::*m)(void*,long),void *d):object(o),member(m),userdata(d) {}
    30 void action(long calldata) {(object->*member)(userdata,calldata);}
     30MemberCallbackNode(CallBase *o,void (CallBase::*m)(void*,intptr_t),void *d):object(o),member(m),userdata(d) {}
     31void action(intptr_t calldata) {(object->*member)(userdata,calldata);}
    3132int equals(CallbackNode*);
    3233};
    33 #define MEMBERCALLBACK(obj,mem,dat) new MemberCallbackNode((CallBase*)(obj),(void (CallBase::*)(void*,long))(mem),(void*)(dat))
     34#define MEMBERCALLBACK(obj,mem,dat) new MemberCallbackNode((CallBase*)(obj),(void (CallBase::*)(void*,intptr_t))(mem),(void*)(dat))
    3435#endif
    3536
     
    3738{
    3839void *userdata;
    39 void (*fun)(void*,long);
     40void (*fun)(void*,intptr_t);
    4041  public:
    41 FunctionCallbackNode(void (*f)(void*,long),void *d):userdata(d),fun(f) {}
    42 void action(long calldata) {(*fun)(userdata,calldata);}
     42FunctionCallbackNode(void (*f)(void*,intptr_t),void *d):userdata(d),fun(f) {}
     43void action(intptr_t calldata) {(*fun)(userdata,calldata);}
    4344int equals(CallbackNode*);
    4445};
    45 #define FUNCTIONCALLBACK(fun,dat) new FunctionCallbackNode((void (*)(void*,long))(fun),(void*)(dat))
     46#define FUNCTIONCALLBACK(fun,dat) new FunctionCallbackNode((void (*)(void*,intptr_t))(fun),(void*)(dat))
    4647
    4748class StatrickCallbackNode :public CallbackNode
     
    4950void *object;
    5051void *userdata;
    51 void (*fun)(void*,void*,long);
     52void (*fun)(void*,void*,intptr_t);
    5253  public:
    53 StatrickCallbackNode(void *o,void (*f)(void*,void*,long),void *d):object(o),userdata(d),fun(f) {}
    54 void action(long calldata) {(*fun)(object,userdata,calldata);}
     54StatrickCallbackNode(void *o,void (*f)(void*,void*,intptr_t),void *d):object(o),userdata(d),fun(f) {}
     55void action(intptr_t calldata) {(*fun)(object,userdata,calldata);}
    5556int equals(CallbackNode*);
    5657};
    57 #define STATRICKCALLBACK(obj,name,dat) new StatrickCallbackNode((void*)(obj),(void (*)(void*,void*,long))STATRICKNAME(name),(void*)(dat))
     58#define STATRICKCALLBACK(obj,name,dat) new StatrickCallbackNode((void*)(obj),(void (*)(void*,void*,intptr_t))STATRICKNAME(name),(void*)(dat))
    5859
    5960/**
     
    6162      add(Function* fun, void* anydata)
    6263   'fun' will be called with your pointer as the first argument (void*)
    63    and event specific value as the second argument (long)
    64       fun(void* anydata,long eventdata)
     64   and event specific value as the second argument (intptr_t)
     65      fun(void* anydata,intptr_t eventdata)
    6566
    6667   'StatrickCallbackNode' uses static functions to emulate object member calls.
     
    8182~Callback();
    8283CallbackNode* add(CallbackNode*n);
    83 CallbackNode* add(void (*f)(void*,long),void *d)
     84CallbackNode* add(void (*f)(void*,intptr_t),void *d)
    8485        {return add(new FunctionCallbackNode(f,d));}
    85 void remove(void (*f)(void*,long),void *d)
     86void remove(void (*f)(void*,intptr_t),void *d)
    8687        {remove(new FunctionCallbackNode(f,d));}
    8788void remove(CallbackNode*n);
    8889void removeNode(CallbackNode*n);
    89 void operator+=(void* fun) {add((void (*)(void*,long))fun,0);}
    90 void operator-=(void* fun) {remove((void (*)(void*,long))fun,0);}
    91 void action(long data);
     90void operator+=(void* fun) {add((void (*)(void*,intptr_t))fun,0);}
     91void operator-=(void* fun) {remove((void (*)(void*,intptr_t))fun,0);}
     92void action(intptr_t data);
    9293void action() {action(0);}
    9394int size() {return SList::size();}
     
    9798///////////////////
    9899
    99 #define STCALLBACKDEF(name) STATRICKDEF2(name,void*,long)
    100 #define STCALLBACKDEFC(cls,name) STATRICKSTUB2(cls,name,void*,long)  \
    101         void name(void* arg1,long arg2)
    102 #define VIRTCALLBACKDEF(name) STATRICKSTUB2(STATRICKCLASS,name,void*,long)  \
    103         virtual void name(void* arg1,long arg2)
    104 #define VIRTCALLBACKDEFC(cls,name) STATRICKSTUB2(cls,name,void*,long)  \
    105         virtual void name(void* arg1,long arg2)
     100#define STCALLBACKDEF(name) STATRICKDEF2(name,void*,intptr_t)
     101#define STCALLBACKDEFC(cls,name) STATRICKSTUB2(cls,name,void*,intptr_t)  \
     102        void name(void* arg1,intptr_t arg2)
     103#define VIRTCALLBACKDEF(name) STATRICKSTUB2(STATRICKCLASS,name,void*,intptr_t)  \
     104        virtual void name(void* arg1,intptr_t arg2)
     105#define VIRTCALLBACKDEFC(cls,name) STATRICKSTUB2(cls,name,void*,intptr_t)  \
     106        virtual void name(void* arg1,intptr_t arg2)
    106107
    107108/* STCALLBACKDEFC(Class,name)
     
    115116 */
    116117
    117 #define CALLBACKARGS void* arg1,long arg2
     118#define CALLBACKARGS void* arg1,intptr_t arg2
    118119
    119120#endif
  • cpp/frams/util/extvalue.cpp

    r228 r247  
    281281}
    282282
    283 static long longsign(long x)
     283static int longsign(paInt x)
    284284{
    285285if (x<0) return -1;
     
    288288}
    289289
    290 static long compareNull(const ExtValue& v)
     290static int compareNull(const ExtValue& v)
    291291{
    292292switch(v.type)
     
    299299}
    300300
    301 long ExtValue::compare(const ExtValue& src) const
    302 {
    303 if (type==TUnknown)
     301int ExtValue::compare(const ExtValue& src) const
     302{
     303if (isNull())
    304304        return compareNull(src);
    305 else if (src.type==TUnknown)
     305else if (src.isNull())
    306306        return compareNull(*this);
    307307switch(type)
     
    309309        case TInt:
    310310        {
    311         long t=src.getInt();
     311        paInt t=src.getInt();
    312312        if (idata()>0)
    313313                {if (t>0) return longsign(idata()-t); else return +1;}
     
    545545        if (args.finished() && (type!=0) && (type!='%'))
    546546                {
    547                 ret+=fmt.substr(curr-begin);
     547                ret+=fmt.substr((int)(curr-begin));
    548548                break;
    549549                }
    550         SString sub=fmt.substr(curr-begin,next-curr);
     550        SString sub=fmt.substr((int)(curr-begin),(int)(next-curr));
    551551        switch(type)
    552552                {
     
    601601}
    602602
    603 long ExtValue::getInt(const char* s)
     603paInt ExtValue::getInt(const char* s)
    604604{
    605605if ((s[0]=='0')&&(s[1]=='x'))
    606606        {
    607         long val;
     607        paInt val;
    608608        sscanf(s+2,"%lx",&val);
    609609        return val;
     
    612612        {
    613613        if (strchr(s,'e')||(strchr(s,'E')))
    614                 return (long)atof(s);
     614                return (paInt)atof(s);
    615615        else
    616                 return atol(s);
     616                return atoi(s);
    617617        }
    618618}
     
    622622if ((s[0]=='0')&&(s[1]=='x'))
    623623        {
    624         long val;
     624        paInt val;
    625625        sscanf(s+2,"%lx",&val);
    626626        return val;
     
    630630}
    631631
    632 long ExtValue::getInt() const
     632paInt ExtValue::getInt() const
    633633{
    634634switch(type)
     
    639639        case TObj:
    640640                FMprintf("ExtValue","getInt",FMLV_WARN,"Getting integer value from object reference (%s)",(const char*)getString());
    641                 return (long)odata().param;
     641                return (paInt)(intptr_t)odata().param;
    642642        default:;
    643643        }
     
    654654        case TObj:
    655655                FMprintf("ExtValue","getDouble",FMLV_WARN,"Getting floating point value from object reference (%s)",(const char*)getString());
    656                 return (double)(long)odata().param;
     656                return (double)(intptr_t)odata().param;
    657657        default:;
    658658        }
     
    732732        else
    733733                {
    734                 setInt(atol(in));
     734                setInt(atoi(in));
    735735                return p;
    736736                }
     
    769769        {
    770770        ret=skipQuoteString(in+1,NULL);
    771         SString s(in+1,ret-(in+1));
     771        SString s(in+1,(int)(ret-(in+1)));
    772772        sstringUnquote(s);
    773773        setString(s);
     
    864864else if ((ret=skipWord(in))&&(ret!=in))
    865865        {
    866         SString clsname(in,ret-in);
     866        SString clsname(in,(int)(ret-in));
    867867        ExtValue tmp;
    868868        ret=tmp.deserialize(ret);
     
    929929ExtValue ExtValue::getExtType()
    930930{
    931 if (getType()!=TObj) return ExtValue((long)getType());
     931if (getType()!=TObj) return ExtValue((paInt)getType());
    932932ExtObject& o=odata();
    933933return ExtValue(SString(o.isEmpty()?"":o.interfaceName()));
  • cpp/frams/util/extvalue.h

    r228 r247  
    101101#ifdef EXTVALUEUNION
    102102long data[(EXTVALUEUNIONSIZE+sizeof(long)-1)/sizeof(long)];
    103 long& idata() const {return (long&)data[0];};
     103paInt& idata() const {return (paInt&)data[0];};
    104104double& ddata() const {return *(double*)data;};
    105105ExtObject& odata() const {return *(ExtObject*)data;};
     
    107107#else
    108108union {
    109 long i;
     109paInt i;
    110110double d;
    111111SString *s;
    112112ExtObject *o;
    113113};
    114 long& idata() const {return (long&)i;};
     114paInt& idata() const {return (paInt&)i;};
    115115double& ddata() const {return (double&)d;};
    116116ExtObject& odata() const {return *o;};
     
    123123ExtValue():type(TUnknown){}
    124124~ExtValue() {setEmpty();}
    125 ExtValue(long v) {seti(v);}
     125ExtValue(paInt v) {seti(v);}
    126126ExtValue(double v) {setd(v);}
    127127ExtValue(const SString &v) {sets(v);}
    128128ExtValue(const ExtObject &srco) {seto(srco);}
    129129static ExtValue invalid() {ExtValue v; v.setInvalid(); return v;}
    130 long compare(const ExtValue& src) const;
     130int compare(const ExtValue& src) const;
    131131int operator==(const ExtValue& src) const;
    132132void operator+=(const ExtValue& src);
     
    144144ExtPType getType() {return type;}
    145145void *getObjectTarget(const char* classname,bool warn=true) const;
    146 void setInt(long v) {if (type!=TInt) setri(v); else idata()=v;}
     146void setInt(paInt v) {if (type!=TInt) setri(v); else idata()=v;}
    147147void setDouble(double v) {if (type!=TDouble) setrd(v); else ddata()=v;}
    148148void setString(const SString &v) {if (type!=TString) setrs(v); else sdata()=v;}
    149149void setObject(const ExtObject &src) {if (type!=TObj) setro(src); else odata()=src;}
    150 static long getInt(const char* s);
     150static paInt getInt(const char* s);
    151151static double getDouble(const char* s);
    152 long getInt() const;
     152paInt getInt() const;
    153153double getDouble() const;
    154154SString getString() const;
     
    176176void setr(const ExtValue& src){setEmpty();set(src);}
    177177void set(const ExtValue& src);
    178 void setri(long v) {setEmpty();seti(v);}
     178void setri(paInt v) {setEmpty();seti(v);}
    179179void setrd(double v) {setEmpty();setd(v);}
    180 void seti(long v) {type=TInt;idata()=v;}
     180void seti(paInt v) {type=TInt;idata()=v;}
    181181void setd(double v) {type=TDouble;ddata()=v;}
    182182#ifdef EXTVALUEUNION
  • cpp/frams/util/hashtable.h

    r226 r247  
    2929int threshold;
    3030float load;
    31 long sync;
     31int sync;
    3232
    3333int hash(const SString &s);
  • cpp/frams/util/list.h

    r197 r247  
    5555public:
    5656
    57 SListTempl(const SListTempl<T>& src):have(0),used(0),mem(0),pos(0)
     57SListTempl(const SListTempl<T>& src):have(0),used(0),pos(0),mem(0)
    5858        {(*this)=src;}
    5959SListTempl():have(0),used(0),pos(0),mem(0)
  • cpp/frams/util/rndutil.cpp

    r197 r247  
    55#include "rndutil.h"
    66#include <common/nonstd_math.h>
     7#include <cstdint>
    78#include <stdlib.h>
    89
    910unsigned short pseudornd(short x)
    1011{
    11         static long seed = 0;
    12         long y;
     12        static int32_t seed = 0;
     13        int32_t y;
    1314        if (x <= 0) { seed = -x; return 0; }
    1415        seed = (y = (3677 * seed + 3680) & 0x7fffffff) - 1;
  • cpp/frams/util/sstring.cpp

    r226 r247  
    113113// to be moved somewhere else?
    114114// public domain source: http://isthe.com/chongo/src/fnv
    115 typedef unsigned long Fnv32_t;
     115typedef uint32_t Fnv32_t;
    116116
    117117#define FNV_32_PRIME ((Fnv32_t)0x01000193)
     
    143143//////////////////////////////////////////////////
    144144
    145 unsigned long SBuf::hash() const
     145uint32_t SBuf::hash() const
    146146{
    147147return fnv_32a_buf(txt,used,FNV1_32A_INIT);
     
    339339///////////////////////////////////////
    340340
    341 int SString::equals(const SString& s) const
    342 {
    343 if (s.buf==buf) return 1;
    344 return !strcmp(buf->txt,s.buf->txt);
     341bool SString::equals(const SString& s) const
     342{
     343if (s.buf==buf) return true;
     344return strcmp(buf->txt,s.buf->txt)==0;
    345345}
    346346
  • cpp/frams/util/sstring.h

    r198 r247  
    2222// - mutex required to be thread safe
    2323
     24#include <stdint.h>
    2425#include <string.h>
    2526#include <stdlib.h>
     
    4748SBuf();
    4849~SBuf();
    49 unsigned long hash() const; // 32-bit FNV-1 hash -> http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash
     50uint32_t hash() const; // 32-bit FNV-1 hash -> http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash
    5051};
    5152
     
    155156void operator+=(const SString&); ///< append other SString
    156157
    157 int equals(const SString &s) const; ///< TRUE if equal
    158 int operator==(const SString &s) const {return equals(s);} ///< TRUE if equal
    159 int operator!=(const SString &s) const {return !equals(s);}
     158bool equals(const SString &s) const; ///< TRUE if equal
     159bool operator==(const SString &s) const {return equals(s);} ///< TRUE if equal
     160bool operator!=(const SString &s) const {return !equals(s);}
    160161const char* operator()(int p) const {return buf->txt+p;} ///< pointer to p'th character in SString
    161162char operator[](int i) const {return buf->txt[i];} ///< get char like in array
     
    175176int startsWith(const char *pattern) const;
    176177char charAt(int pos) const {return buf->txt[pos];}
    177 unsigned long hash() const {return buf->hash();}
     178uint32_t hash() const {return buf->hash();}
    178179
    179180static SString valueOf(int);
  • cpp/frams/virtfile/stdiofile.h

    r227 r247  
    3333StdioFILE(MFILE *f,const SString& p) {file=f;path=p;}
    3434static void setStdio();
    35 int Vread(void *ptr, size_t size, size_t nmemb) {return mfread(ptr,size,nmemb,file);}
    36 int Vwrite(const void *ptr, size_t size, size_t nmemb) {return mfwrite(ptr,size,nmemb,file);}
     35size_t Vread(void *ptr, size_t size, size_t nmemb) {return mfread(ptr,size,nmemb,file);}
     36size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {return mfwrite(ptr,size,nmemb,file);}
    3737int Veof() {return mfeof(file);}
    3838int Vputs(const char *s) {return mfputs(s,file);}
    3939char *Vgets(char *s, int size) {return mfgets(s,size,file);}
    4040int Vseek(long offset, int whence) {return mfseek(file,offset,whence);}
    41 int Vtell() {return mftell(file);}
     41long Vtell() {return mftell(file);}
    4242int Vflush() {return 0;/*NOT IMPLEMENTED!*/;}
    4343const char* VgetPath() {return path;}
     
    5555StdioFILE(FILE *f,const SString& p) {file=f;path=p;}
    5656static void setStdio();
    57 int Vread(void *ptr, size_t size, size_t nmemb) {return fread(ptr,size,nmemb,file);}
    58 int Vwrite(const void *ptr, size_t size, size_t nmemb) {return fwrite(ptr,size,nmemb,file);}
     57size_t Vread(void *ptr, size_t size, size_t nmemb) {return fread(ptr,size,nmemb,file);}
     58size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {return fwrite(ptr,size,nmemb,file);}
    5959int Veof() {return feof(file);}
    6060int Vputc(int c) {return fputc(c,file);}
     
    6464int Vprintf(const char *format, va_list args) { return vfprintf(file,format,args); }
    6565int Vseek(long offset, int whence) {return fseek(file,offset,whence);}
    66 int Vtell() {return ftell(file);}
     66long Vtell() {return ftell(file);}
    6767void Vrewind() {rewind(file);}
    6868int Vflush() {return fflush(file);}
  • cpp/frams/virtfile/stringfile.cpp

    r207 r247  
    77#include <errno.h> //EINVAL
    88
    9 int StringFILE::Vread(void *ptr, size_t size, size_t nmemb)
     9size_t StringFILE::Vread(void *ptr, size_t size, size_t nmemb)
    1010{
    11 int have=str.len()-pos;
     11int have=(int)(str.len()-pos);
    1212if (have<=0) return 0;
    13 int need=size*nmemb;
    14 if (need>have) {nmemb=have/size; need=size*nmemb;}
     13int need=(int)(size*nmemb);
     14if (need>have) {nmemb=have/size; need=(int)(size*nmemb);}
    1515memcpy(ptr,((const char*)str)+pos,need);
    1616pos+=need;
     
    2323        return EOF;
    2424else
    25         return str[pos++];
     25        return str.operator[]((int)pos++);
    2626}
    2727
    2828char *StringFILE::Vgets(char *s, int size)
    2929{
    30 int have=str.len()-pos;
     30int have=str.len()-(int)pos;
    3131if (have<=0) return 0;
    3232if (size<0) size=0;
  • cpp/frams/virtfile/stringfile.h

    r207 r247  
    1616  public:
    1717StringFILE(SString& s):str(s),pos(0) {}
    18 int Vread(void *ptr, size_t size, size_t nmemb);
    19 int Vwrite(const void *ptr, size_t size, size_t nmemb) {str.append((const char*)ptr,size*nmemb); return size*nmemb;}
     18size_t Vread(void *ptr, size_t size, size_t nmemb);
     19size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {str.append((const char*)ptr,(int)(size*nmemb)); return size*nmemb;}
    2020int Veof() {return pos>=str.len();}
    2121int Vputc(int c) {str+=(char)c; return c;}
    22 int Vputs(const char *s) {str.append(s,strlen(s)); return 0;}
     22int Vputs(const char *s) {str.append(s,(int)strlen(s)); return 0;}
    2323int Vgetc();
    2424char *Vgets(char *s, int size);
    2525int Vseek(long offset, int whence);
    26 int Vtell() {return pos;}
     26long Vtell() {return pos;}
    2727int Vflush() {return 0;}
    2828};
  • cpp/frams/virtfile/virtfile.cpp

    r225 r247  
    4545va_end(argptr);
    4646return ret;
     47}
     48
     49int VirtFILE::getSize()
     50{
     51  int saved_pos = Vtell();
     52  Vseek(0, SEEK_END);
     53  int size = Vtell();
     54  Vseek(saved_pos, SEEK_SET);
     55  return size;
    4756}
    4857
  • cpp/frams/virtfile/virtfile.h

    r225 r247  
    2323{
    2424  public:
    25 virtual int Vread(void *ptr, size_t size, size_t nmemb)=0;
    26 virtual int Vwrite(const void *ptr, size_t size, size_t nmemb)=0;
     25virtual size_t Vread(void *ptr, size_t size, size_t nmemb)=0;
     26virtual size_t Vwrite(const void *ptr, size_t size, size_t nmemb)=0;
    2727virtual int Veof()=0;
    2828virtual int Vputc(int c) {unsigned char data=(unsigned char)c; return (Vwrite(&data,1,1)==1)?data:EOF;}
     
    3030virtual int Vgetc() {unsigned char data; if (Vread(&data,1,1)==1) return data; else return EOF;}
    3131virtual int Vseek(long offset, int whence)=0;
    32 virtual int Vtell()=0;
     32virtual long Vtell()=0;
    3333virtual void Vrewind() {Vseek(0,SEEK_SET);}
    3434virtual int Vflush()=0;
     
    3737int printf(const char *format, ...);
    3838virtual const char *VgetPath() {return 0;} // 0=unspecified path
     39virtual int getSize();
    3940virtual ~VirtFILE();
    4041static VirtFILE *Vstdin,*Vstdout,*Vstderr;
  • cpp/frams/vm/classes/3dobject.cpp

    r241 r247  
    472472{return ExtObject(&getStaticParam(),p);}
    473473
    474 ParamEntry* ReferenceObj::getStaticParamtab()
    475 {
    476 #define FIELDSTRUCT ReferenceObj
    477 static ParamEntry paramtab[]=
    478 {
    479 {"Ref",1,5,"Ref","Reference objects. Useful for returning things from functions.\n\nExample:\nvar x=111;\nsquare(&x);// '&' creates the Reference object\nSimulator.print(x);//x is now 12321\n\nfunction square(r)\n{r.value=r.value*r.value;}\n//square receives the Reference objects and changes its 'value' field"},
    480 
    481 {"value",0,PARAM_NOSTATIC,"value","x",GETSET(value),},
    482 {"newS",0,0,"create new reference","p",PROCEDURE(p_newS),"(for internal use only) use &variablename to create Ref objects.",},
    483 {"newO",0,0,"create new reference","p",PROCEDURE(p_newO),"(for internal use only) use &variablename to create Ref objects.",},
    484 {"copyFrom",0,0,"copy the reference","p(oRef)",PROCEDURE(p_copyFrom),"make the reference point to the same target,"},
    485 {"toString",0,PARAM_READONLY | PARAM_NOSTATIC,"textual form","s",GETONLY(toString),},
    486 {0,0,0,},
    487 };
    488 #undef FIELDSTRUCT
    489 return paramtab;
    490 }
    491 
    492 Param& ReferenceObj::getStaticParam()
    493 {
    494 #ifdef __CODEGUARD__
    495 static ReferenceObj static_referenceobj;
    496 static Param static_refobjectparam(getStaticParamtab(),&static_referenceobj);
    497 #else
    498 static Param static_refobjectparam(getStaticParamtab());
    499 #endif
    500 return static_refobjectparam;
    501 }
    502 
    503 void ReferenceObj::p_newS(ExtValue *args,ExtValue *ret)
    504 {
    505 *ret=makeDynamicObject(new ReferenceObj((ExtValue*)args->getInt()));
    506 }
    507 
    508 void ReferenceObj::p_newO(ExtValue *args,ExtValue *ret)
    509 {
    510 if (args[0].type==TInt)
    511         *ret=makeDynamicObject(new ReferenceObj(args[1].getObject(),args[0].getInt()));
    512 else
    513         *ret=makeDynamicObject(new ReferenceObj(args[1].getObject(),args[0].getString()));
    514 }
    515 
    516 void ReferenceObj::p_copyFrom(ExtValue *args,ExtValue *ret)
    517 {
    518 ReferenceObj* other=fromObject(args[0]);
    519 if (other)
    520         {
    521         value=other->value;
    522         obj=other->obj;
    523         prop=other->prop;
    524         }
    525 }
    526 
    527 void ReferenceObj::get_toString(ExtValue *ret)
    528 {
    529 SString s="(";
    530 static SListTempl<ReferenceObj*> trace;
    531 if (trace.find(this)>=0)
    532         s+="...";
    533 else
    534         {
    535         trace+=this;
    536         if (value)
    537                 s+=value->getString();
    538         else
    539                 {
    540                 ExtValue v;
    541                 Param tmp_param;
    542                 ParamInterface *pi=obj.getParamInterface(tmp_param);
    543                 pi->get(prop,v);
    544                 s+=v.getString();
    545                 }
    546         trace-=this;
    547         }
    548 s+=")";
    549 ret->setString(s);
    550 }
    551 
    552 void ReferenceObj::get_value(ExtValue *ret)
    553 {
    554 if (value)
    555         *ret=*value;
    556 else
    557         {
    558         Param tmp_param;
    559         ParamInterface *pi=obj.getParamInterface(tmp_param);
    560         pi->get(prop,*ret);
    561         }
    562 }
    563 
    564 int ReferenceObj::set_value(const ExtValue *val)
    565 {
    566 if (value)
    567         *value=*val;
    568 else
    569         {
    570         Param tmp_param;
    571         ParamInterface *pi=obj.getParamInterface(tmp_param);
    572         pi->set(prop,*val);
    573         }
    574 return PSET_CHANGED;
    575 }
    576 
    577 ReferenceObj::ReferenceObj(const ExtObject &o,const SString &p)
    578         :value(0),obj(o)
    579 {
    580 Param tmp_param;
    581 ParamInterface *pi=obj.getParamInterface(tmp_param);
    582 prop=pi->findId(p);
    583 }
    584 
    585 ExtObject ReferenceObj::makeDynamicObject(ReferenceObj* r)
    586 {return ExtObject(&getStaticParam(),r);}
    587 
    588 ReferenceObj* ReferenceObj::fromObject(const ExtValue& v)
    589 {
    590 return (ReferenceObj*)v.getObjectTarget(getStaticParam().getName());
    591 }
    592 
    593474/////////////
    594475
  • cpp/frams/vm/classes/3dobject.h

    r241 r247  
    8282};
    8383
    84 class ReferenceObj: public DestrBase
    85 {
    86   public:
    87 ExtValue *value;
    88 ExtObject obj;
    89 int prop;
    90 
    91 ReferenceObj(ExtValue *val):value(val) {}
    92 ReferenceObj() {}
    93 ReferenceObj(const ExtObject &o,int p):value(0),obj(o),prop(p) {}
    94 ReferenceObj(const ExtObject &o,const SString &p);
    95 #define STATRICKCLASS ReferenceObj
    96 PARAMPROCDEF(p_newS);
    97 PARAMPROCDEF(p_newO);
    98 PARAMPROCDEF(p_copyFrom);
    99 PARAMGETDEF(toString);
    100 PARAMGETDEF(value);
    101 PARAMSETDEF(value);
    102 #undef STATRICKCLASS
    103 
    104 static ParamInterface* getInterface();
    105 static ExtObject makeDynamicObject(ReferenceObj* r);
    106 static ReferenceObj* fromObject(const ExtValue& v);
    107 static Param& getStaticParam();
    108 static ParamEntry* getStaticParamtab();
    109 };
    110 
    11184#endif
  • cpp/frams/vm/framscript.y

    r245 r247  
    10031003        if (loc!=TranslatorStack::NOTFOUND)
    10041004                {
    1005                 trctx.out->printf("push &%d\ncall Ref.newS\n",loc-trstack.currentPos());trstack.adjust(-1);
     1005                trctx.out->printf("push &%d\n",loc-trstack.currentPos());trstack.adjust(-1);
    10061006                }
    10071007        else if (globalOk($2))
Note: See TracChangeset for help on using the changeset viewer.