Changeset 247


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

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

Location:
cpp
Files:
62 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/Convert.cpp

    r197 r247  
    88
    99#if defined __ANDROID__ || defined __BORLANDC__
    10  #include <ctype.h> //toupper, tolower
     10#include <ctype.h> //toupper, tolower
    1111#endif
    1212
    1313#ifdef SHP
    14  #include <cstdlib>
     14#include <cstdlib>
    1515#else
    16  #include <stdlib.h>
     16#include <stdlib.h>
    1717#endif
    1818
     
    2020
    2121
    22 int Convert::toInt(string s) {return atoi(s.c_str());}
    23 float Convert::toFloat(string s) {return (float)atof(s.c_str());}
    24 #ifndef __BORLANDC__ //the borland compiler compiles this file in GUI and CLI, but not in the theater app. Somehow it cannot find ::tolower and ::toupper; maybe this is because of various #defines in <cctype>, but why only in the theater app??
    25 string Convert::toLowerCase(string s) {std::transform(s.begin(), s.end(), s.begin(), ::tolower);  return s;}
    26 string Convert::toUpperCase(string s) {std::transform(s.begin(), s.end(), s.begin(), ::toupper);  return s;}
    27 #endif
    28 char Convert::toLowerCase(char c) {return (char)tolower(c);}
    29 char Convert::toUpperCase(char c) {return (char)toupper(c);}
     22int Convert::toInt(string s) { return atoi(s.c_str()); }
     23float Convert::toFloat(string s) { return (float)atof(s.c_str()); }
     24string Convert::toLowerCase(string s) { std::transform(s.begin(), s.end(), s.begin(), ::tolower);  return s; }
     25string Convert::toUpperCase(string s) { std::transform(s.begin(), s.end(), s.begin(), ::toupper);  return s; }
     26char Convert::toLowerCase(char c) { return (char)tolower(c); }
     27char Convert::toUpperCase(char c) { return (char)toupper(c); }
    3028
    31 template<class T> const char* printf_format_for(const T& value) {return "unknown type";}
    32 template<> const char* printf_format_for(const unsigned int& value) {return "%u";}
    33 template<> const char* printf_format_for(const int& value) {return "%d";}
    34 template<> const char* printf_format_for(const short& value) {return "%d";}
    35 template<> const char* printf_format_for(const float& value) {return "%g";}
    36 template<> const char* printf_format_for(const double& value) {return "%g";}
     29template<class T> const char* printf_format_for(const T& value) { return "unknown type"; }
     30template<> const char* printf_format_for(const unsigned int& value) { return "%u"; }
     31template<> const char* printf_format_for(const int& value) { return "%d"; }
     32template<> const char* printf_format_for(const short& value) { return "%d"; }
     33template<> const char* printf_format_for(const float& value) { return "%g"; }
     34template<> const char* printf_format_for(const double& value) { return "%g"; }
    3735
    3836template<class T> string Convert::_toString(const T& value)
    3937{
    40 char buf[30];
    41 sprintf(buf,printf_format_for(value),value);
    42 return string(buf);
    43 /*
    44 #ifndef MULTITHREADED
     38        char buf[30];
     39        sprintf(buf, printf_format_for(value), value);
     40        return string(buf);
     41        /*
     42        #ifndef MULTITHREADED
    4543        static
    46 #endif
     44        #endif
    4745        std::ostringstream oss; //pod VS tworzenie go trwa dlugo nawet w wersji release (szczegolnie jak np konwertuje sie cos setki tysiecy razy)
    4846        //dlatego robimy go raz (static) i potem tylko czyscimy
     
    5149        oss.clear(); //clear error flag
    5250        oss.str(""); //set empty string
    53   oss << value;
    54   return oss.str();
    55 */
     51        oss << value;
     52        return oss.str();
     53        */
    5654}
    5755
    58 string Convert::toString(unsigned int v) {return _toString(v);}
    59 string Convert::toString(int v) {return _toString(v);}
    60 string Convert::toString(short v) {return _toString(v);}
    61 string Convert::toString(float v) {return _toString(v);}
    62 string Convert::toString(double v) {return _toString(v);}
     56string Convert::toString(unsigned int v) { return _toString(v); }
     57string Convert::toString(int v) { return _toString(v); }
     58string Convert::toString(short v) { return _toString(v); }
     59string Convert::toString(float v) { return _toString(v); }
     60string Convert::toString(double v) { return _toString(v); }
     61
     62uint32_t Convert::hexToInt(const string& col)
     63{
     64        uint32_t value;
     65        std::istringstream iss(col);
     66        iss >> std::hex >> value;
     67        return value;
     68}
    6369
    6470#ifdef MULTITHREADED
     
    6975//z mutexa gdy drugi dalej by go inicjalizowal
    7076#include "threads.h"
    71 static pthread_mutex_t fix_unsafe_mutex=PTHREAD_MUTEX_INITIALIZER;
     77static pthread_mutex_t fix_unsafe_mutex = PTHREAD_MUTEX_INITIALIZER;
    7278#endif
    7379
     
    7682#ifndef MULTITHREADED
    7783
    78 return *::localtime(&timep);
     84        return *::localtime(&timep);
    7985
    8086#else
    8187
    82 struct tm ret;
     88        struct tm ret;
    8389
    8490#if defined LINUX // || android?
    85 return *::localtime_r(&timep,&ret);
     91        return *::localtime_r(&timep,&ret);
    8692#elif defined _WIN32 && !defined __BORLANDC__ // and not bada?
    87 ::localtime_s(&ret,&timep);
    88 return ret;
     93        ::localtime_s(&ret, &timep);
     94        return ret;
    8995#else //borland?
    90 pthread_mutex_lock(&fix_unsafe_mutex);
    91 ret=*::localtime(&timep);
    92 pthread_mutex_unlock(&fix_unsafe_mutex);
    93 return ret;
     96        pthread_mutex_lock(&fix_unsafe_mutex);
     97        ret=*::localtime(&timep);
     98        pthread_mutex_unlock(&fix_unsafe_mutex);
     99        return ret;
    94100#endif
    95101
     
    99105string Convert::asctime(const struct tm &tm)
    100106{
    101 char *ret;
     107        char *ret;
    102108#ifndef MULTITHREADED
    103109
    104 ret=::asctime(&tm);
     110        ret=::asctime(&tm);
    105111
    106112#else //MULTITHREADED
    107113
    108 char buf[26];
     114        char buf[26];
    109115#if defined LINUX // || android?
    110 ret=::asctime_r(&tm,buf);
     116        ret=::asctime_r(&tm,buf);
    111117#elif defined _WIN32 && !defined __BORLANDC__ // and not bada?
    112 asctime_s(buf,sizeof(buf),&tm);
    113 ret=buf;
     118        asctime_s(buf, sizeof(buf), &tm);
     119        ret = buf;
    114120#else //borland?
    115 pthread_mutex_lock(&fix_unsafe_mutex);
    116 strcpy(buf,::asctime(&tm));
    117 ret=buf;
    118 pthread_mutex_unlock(&fix_unsafe_mutex);
     121        pthread_mutex_lock(&fix_unsafe_mutex);
     122        strcpy(buf,::asctime(&tm));
     123        ret=buf;
     124        pthread_mutex_unlock(&fix_unsafe_mutex);
    119125#endif
    120126#endif
    121127
    122 return string(ret,24); //24 znaki z pominieciem ostatniego \n
     128        return string(ret, 24); //24 znaki z pominieciem ostatniego \n
    123129}
    124 
  • cpp/common/Convert.h

    r197 r247  
    1010#include "nonstd_stl.h"
    1111#include "2d.h"
     12#include <stdint.h>
     13
    1214
    1315typedef XY<double> Pt2D;
     
    1719{
    1820public:
    19   static int toInt(string s);
    20   static float toFloat(string s);
    21   static string toLowerCase(string s);
    22   static string toUpperCase(string s);
    23   static char toLowerCase(char c);
    24   static char toUpperCase(char c);
    25   template<class T> static string _toString(const T& value);
    26   static string toString(unsigned int v);
    27   static string toString(int v);
    28   static string toString(short v);
    29   static string toString(float v);
    30   static string toString(double v);// ze niby w badzie ma nie byc? ale w frams na pewno ma byc bo tu same double
    31   static string zeroPad(string s,int l) {while((int)s.length()<l) s=string("0")+s; return s;}
     21        static int toInt(string s);
     22        static float toFloat(string s);
     23        static string toLowerCase(string s);
     24        static string toUpperCase(string s);
     25        static char toLowerCase(char c);
     26        static char toUpperCase(char c);
     27        template<class T> static string _toString(const T& value);
     28        static string toString(unsigned int v);
     29        static string toString(int v);
     30        static string toString(short v);
     31        static string toString(float v);
     32        static string toString(double v);
     33        static string zeroPad(string s, int l) { while ((int)s.length() < l) s = string("0") + s; return s; }
     34        static uint32_t hexToInt(const string& col);
    3235
    33   static double toRadians(double kat) {return kat*M_PI/180;}
    34   static double toDegrees(double kat) {return kat/M_PI*180;}
    35   static double atan_2(double y,double x) {if (x==0 && y==0) return 0; else return atan2(y,x);} //needed by borland 5/6 only?
     36        static double toRadians(double angle) { return angle*M_PI / 180; }
     37        static double toDegrees(double angle) { return angle / M_PI * 180; }
     38        static double atan_2(double y, double x) { if (x == 0 && y == 0) return 0; else return atan2(y, x); } //needed by borland 5/6 only?
    3639
    37         static double odleglosc_sq(double x1,double y1,double x2,double y2) //odleglosc do kwadratu, wystarczy do porownywania
    38         {double dx=x2-x1, dy=y2-y1; return dx*dx+dy*dy;}
    39         static double odleglosc_sq(const Pt2D& p1,const Pt2D& p2) //odleglosc do kwadratu
    40         {return odleglosc_sq(p1.x,p1.y,p2.x,p2.y);}
     40        static double odleglosc_sq(double x1, double y1, double x2, double y2) //odleglosc do kwadratu, wystarczy do porownywania
     41        {
     42                double dx = x2 - x1, dy = y2 - y1; return dx*dx + dy*dy;
     43        }
     44        static double odleglosc_sq(const Pt2D& p1, const Pt2D& p2) //odleglosc do kwadratu
     45        {
     46                return odleglosc_sq(p1.x, p1.y, p2.x, p2.y);
     47        }
    4148
    42         static double odleglosc(double x1,double y1,double x2,double y2)        {return sqrt(odleglosc_sq(x1,y1,x2,y2));}
    43         static double odleglosc(const Pt2D& p1,const Pt2D& p2)
    44         {return sqrt(odleglosc_sq(p1,p2));}
    45        
    46   //static float odleglosc(int x1,int y1,int x2,int y2) {float dx=x1-x2; float dy=y1-y2; return sqrt(dx*dx+dy*dy);}
    47   //static float odleglosc(float x1,float y1,float x2,float y2) {return sqrt(odleglosc_sq(x1,y1,x2,y2));}
    48   //static float odleglosc_sq(float x1,float y1,float x2,float y2) {float dx=x1-x2; float dy=y1-y2; return dx*dx+dy*dy;}
     49        static double odleglosc(double x1, double y1, double x2, double y2)     { return sqrt(odleglosc_sq(x1, y1, x2, y2)); }
     50        static double odleglosc(const Pt2D& p1, const Pt2D& p2)
     51        {
     52                return sqrt(odleglosc_sq(p1, p2));
     53        }
    4954
    50   static struct tm localtime(const time_t &timep);//jak ::localtime ale zwraca strukture zamiast wskaznika, ref w parametrze dla wygodnego wywolywania
    51   static string asctime(const struct tm &tm);//jak ::asctime ale thread safe i bez glupiego \n na koncu, ref w parametrze dla wygodnego wywolywania
     55        //static float odleglosc(int x1,int y1,int x2,int y2) {float dx=x1-x2; float dy=y1-y2; return sqrt(dx*dx+dy*dy);}
     56        //static float odleglosc(float x1,float y1,float x2,float y2) {return sqrt(odleglosc_sq(x1,y1,x2,y2));}
     57        //static float odleglosc_sq(float x1,float y1,float x2,float y2) {float dx=x1-x2; float dy=y1-y2; return dx*dx+dy*dy;}
     58
     59        static struct tm localtime(const time_t &timep);//jak ::localtime ale zwraca strukture zamiast wskaznika, ref w parametrze dla wygodnego wywolywania
     60        static string asctime(const struct tm &tm);//jak ::asctime ale thread safe i bez glupiego \n na koncu, ref w parametrze dla wygodnego wywolywania
     61
     62        static std::wstring strTOwstr(const char *s)
     63        {
     64                string str(s);
     65                return std::wstring(str.begin(), str.end());
     66        }
     67
     68        static string wstrTOstr(const wchar_t *s)
     69        {
     70                wstring str(s);
     71                return string(str.begin(), str.end());
     72        }
     73
     74        static string wstrTOutf8(const wchar_t *s)
     75        {
     76                if (s == NULL) return "";
     77                string res;
     78                wchar_t *wcp = (wchar_t*)s;
     79                while (*wcp != 0)
     80                {
     81                        int c = *wcp;
     82                        if (c < 0x80) res += c;
     83                        else if (c < 0x800) { res += 192 + c / 64; res += 128 + c % 64; }
     84                        else if (c - 0xd800u < 0x800) res += "<ERR-CHAR>";
     85                        else if (c < 0x10000) { res += 224 + c / 4096; res += 128 + c / 64 % 64; res += 128 + c % 64; }
     86                        else if (c < 0x110000) { res += 240 + c / 262144; res += 128 + c / 4096 % 64; res += 128 + c / 64 % 64; res += 128 + c % 64; }
     87                        else res += "<ERR-CHAR>";
     88                        wcp++;
     89                }
     90                return res;
     91        }
     92        //#endif
    5293};
    5394
    5495
    5596
    56 struct Kat //znormalizowany k¹t w radianach [0,2pi) i stopniach [0,360) z obliczonymi sinus i cosinus oraz intem [0,359]
     97struct Angle //normalized angle in radians [0,2pi) and degrees [0,360) with pre-computed sine and cosine and degree as integer [0,359]
    5798{
    5899private:
    59         double kat; //w radianach, read-only
     100        double angle; //in radians, read-only
    60101public:
    61         double kat_stopnie; //read-only
    62         int kat_stopnie_int; //read-only
     102        double angle_deg; //read-only
     103        int angle_deg_int; //read-only
    63104
    64         Kat() {set(0);}
    65         Kat(double k) {set(k);}
    66         Kat(Kat &kt) {set(kt.get());}
    67         Kat(double dy,double dx) {set(dy,dx);}
    68         void set(double k) {k=fmod(k,M_PI*2); if (k<0) k+=M_PI*2; kat=k; sinus=sin(k); cosinus=cos(k); kat_stopnie=Convert::toDegrees(kat); kat_stopnie_int=roundToInt(kat_stopnie); kat_stopnie_int%=360; }
    69         void set(double dy,double dx) {set(Convert::atan_2(dy,dx));}
    70         void add(double dk) {set(kat+dk);}
    71         void add(Kat &kt) {set(kat+kt.get());}
    72         double get() {return kat;}
    73         double sinus,cosinus;
     105        Angle() { set(0); }
     106        Angle(double k) { set(k); }
     107        Angle(Angle &kt) { set(kt.get()); }
     108        Angle(double dy, double dx) { set(dy, dx); }
     109        void set(double k) { k = fmod(k, M_PI * 2); if (k < 0) k += M_PI * 2; angle = k; sine = sin(k); cosine = cos(k); angle_deg = Convert::toDegrees(angle); angle_deg_int = roundToInt(angle_deg); angle_deg_int %= 360; }
     110        void set(double dy, double dx) { set(Convert::atan_2(dy, dx)); }
     111        void add(double dk) { set(angle + dk); }
     112        void add(Angle &kt) { set(angle + kt.get()); }
     113        double get() { return angle; }
     114        double sine, cosine;
    74115};
    75116
  • cpp/common/nonstd.h

    r244 r247  
    5757#endif
    5858
    59 #if defined MACOS || defined __ANDROID__
     59#if defined MACOS || defined __ANDROID__ || defined IPHONE
    6060 #define stricmp(a,b) strcasecmp(a,b)
    6161#endif
     
    8686#ifdef LINUX
    8787 #define GET_APP_HOME "./"
     88 #define GET_APP_RESOURCES "./"
     89#endif
     90
     91#ifdef MACOS
     92#ifdef MACOS_APP_DIR //separate home/resources
     93 #include <string>
     94 std::string getAppHome();
     95 #define GET_APP_HOME getAppHome()
     96#else //old style
     97 #define GET_APP_HOME "./"
     98#endif
    8899 #define GET_APP_RESOURCES "./"
    89100#endif
  • cpp/common/nonstd_math.cpp

    r227 r247  
    2222
    2323
     24#ifdef IPHONE
     25//TODO! -> ? http://stackoverflow.com/questions/12762418/how-to-enable-sigfpe-signal-on-division-by-zero-in-ios-app
     26void fpExceptInit()
     27{}
     28
     29void fpExceptEnable()
     30{}
     31
     32void fpExceptDisable()
     33{}
     34#endif
    2435
    2536
    26 #if defined LINUX || defined TIZEN || defined __ANDROID__ || defined IPHONE
     37#if defined LINUX || defined TIZEN || defined __ANDROID__
    2738
    2839#include <fenv.h>
  • cpp/common/nonstd_stdio.cpp

    r227 r247  
    55#include "nonstd_stdio.h"
    66#include "nonstd.h"
     7#include "Convert.h" //strTOwstr()
     8#include <common/stl-util.h>
    79
    810#if defined _WIN32 && !defined SHP
    911 //<unistd.h> not needed for unlink()
    1012 #include "Shlwapi.h" //PathIsRelative()
    11  #include "Util.h" //strTOwstr()
     13 #include <sys/stat.h> //_stat
    1214#else
    1315 #include <unistd.h>
     
    2325}
    2426
     27bool directoryExists(const char* path)
     28{
     29struct _stat s;
     30if (_stat(path,&s)!=0) return false;
     31return S_ISDIR(s.st_mode);
     32}
     33
     34bool makeDirectory(const char* path)
     35{
     36#ifdef _WIN32
     37return mkdir(path)==0;
     38#else
     39return mkdir(path,0777)==0;
     40#endif
     41}
     42
     43bool makeDirectories(const char* path)
     44{
     45if (directoryExists(path)) return true;
     46string parentdir=getFileDir(path);
     47if (!makeDirectories(parentdir.c_str())) return false;
     48return makeDirectory(path);
     49}
     50
     51int getFileSize(const char* path)
     52{
     53int size;
     54MFILE *f=mfopen(path,FOPEN_READ_BINARY);
     55if (f==NULL) return -1;
     56size=getFileSize(f);
     57mfclose(f);
     58return size;
     59}
     60
     61int getFileSize(MFILE *f)
     62{
     63  int saved_pos = mftell(f);
     64  mfseek(f, 0, SEEK_END);
     65  int size = mftell(f);
     66  mfseek(f, saved_pos, SEEK_SET);
     67  return size;
     68}
     69
    2570bool removeFile(const char* path)
    2671{
     
    3580        return PathIsRelative(fname) == FALSE; //no wide char for old borland compiler
    3681 #else
    37         return PathIsRelative(Util::strTOwstr(fname).c_str()) == FALSE; //http://msdn.microsoft.com/en-us/library/bb773660%28v=vs.85%29.aspx
     82        return PathIsRelative(Convert::strTOwstr(fname).c_str()) == FALSE; //http://msdn.microsoft.com/en-us/library/bb773660%28v=vs.85%29.aspx
    3883 #endif
    3984#else
  • cpp/common/nonstd_stdio.h

    r227 r247  
    77
    88bool fileExists(const char* path);
     9bool directoryExists(const char* path);
     10bool makeDirectory(const char* path);
     11bool makeDirectories(const char* path);
    912bool removeFile(const char* path);
    1013bool isAbsolutePath(const char* fname);
     14int getFileSize(const char* path);
    1115
    1216#ifdef _WIN32
     
    2428#ifndef MOBILE2D
    2529 #include <io.h> //borland compiler: include <io.h> before <dir.h> causes the SimWorld class in "simul.h" be unrecognized, for unknown reason :O moreover, this problem is only pertinent to the CLI project, not GUI. Maybe this is caused by global defines like NOVCL, NO_STRICT etc.?
    26  #define makeDirectory(name) mkdir(name)
     30// #define makeDirectory(name) mkdir(name)
    2731#endif
    2832
     33 #define S_ISDIR(x) ((x & _S_IFDIR)==_S_IFDIR)
    2934
    3035#else
     
    3237 #include <unistd.h>
    3338 #include <sys/stat.h>
    34  #define makeDirectory(name) mkdir(name,0777)
     39// #define makeDirectory(name) mkdir(name,0777)
    3540 #define _unlink unlink //_unlink jest ISO-conformant, unlink jest POSIX-deprecated
    36 
     41 #define _stat stat
    3742#endif
    3843
     
    95100#endif
    96101
     102int getFileSize(MFILE *f);
     103
    97104#endif
  • cpp/common/random.h

    r197 r247  
    1212 #include <sys/stat.h>
    1313 #include <fcntl.h>
     14#endif
     15#ifdef __BORLANDC__
     16 #include <stdint.h> //uintptr_t in borland
    1417#endif
    1518#ifdef _WIN32
     
    7679                {
    7780                        counter++;
    78                         seed = time(NULL);              //time (seconds); could use hi-res timer but then we would depend on common/timer.h
    79                         seed ^= counter;                //incremented value, possibly randomly initialized
    80                         seed ^= (unsigned int)&counter; //memory address
     81                        seed = time(NULL);                         //time (seconds); could use hi-res timer but then we would depend on common/timer.h
     82                        seed ^= counter;                           //incremented value, possibly randomly initialized
     83                        seed ^= (unsigned int)(uintptr_t)&counter; //memory address
    8184                }
    8285#ifdef _WIN32 //add more randomness from uuid
  • cpp/common/stl-util.cpp

    r246 r247  
    1010#include "framsg.h"
    1111#include <assert.h>
     12#ifdef USE_VIRTFILE
     13 #include <frams/virtfile/virtfile.h>
     14#endif
     15#ifdef __BORLANDC__
     16 #define va_copy(to,from) to=from //borland does not have va_copy() at all; va_list is just a pointer in borland
     17#endif
    1218
    1319string ssprintf_va(const char* format, va_list ap)
     
    1622        long size = 256;
    1723        char* buf;
     24        va_list ap_copy; // "va_list ap" can only by used once by printf-type functions as they advance the current argument pointer (crashed on linux x86_64)
     25        // (does not apply to SString::sprintf, it does not have the va_list variant)
    1826
    1927        //almost like SString::sprintf, but there is no common code to share because SString can use its directWrite to avoid double allocating/copying
    2028#ifdef USE_VSCPRINTF
    21         size = _vscprintf(format, ap) + 1; //+1 for terminating null character
     29        va_copy(ap_copy,ap);
     30        size = _vscprintf(format, ap_copy) + 1; //+1 for terminating null character
     31        va_end(ap_copy);
    2232#endif
    2333
     
    2636                buf = (char*)malloc(size);
    2737                assert(buf != NULL);
    28                 int n = vsnprintf(buf, size, format, ap);
     38                va_copy(ap_copy,ap);
     39                int n = vsnprintf(buf, size, format, ap_copy);
     40                va_end(ap_copy);
    2941                if (n > -1 && n < size)
    3042                {
     
    5466bool readCompleteFile(const char* filename, vector<char>& data, bool warn_on_missing_file)
    5567{
     68    bool ok=false;
     69#ifdef USE_VIRTFILE
     70        if (!isAbsolutePath(filename))
     71                {
     72                VirtFILE *f=Vfopen(filename,FOPEN_READ_BINARY);
     73                if (f)
     74                        {
     75                        int size=f->getSize();
     76                        data.resize(size);
     77                        int przeczytane = f->Vread(&data[0], size, 1);
     78                        ok = przeczytane == 1;
     79                        delete f;
     80                        }
     81                }
     82        else
     83#endif
     84        {
    5685        MFILE *f = mfopen(filename, FOPEN_READ_BINARY);
    57         bool ok = f != NULL;
    5886        if (f)
    5987        {
    60                 mfseek(f, 0, SEEK_END);
    61                 long size = mftell(f);
    62                 mfseek(f, 0, SEEK_SET);
     88                int size=getFileSize(f);
    6389                data.resize(size);
    6490                int przeczytane = mfread(&data[0], size, 1, f);
    6591                mfclose(f);
    66                 ok &= przeczytane == 1;
     92                ok = przeczytane == 1;
     93        }
    6794        }
    6895        if (warn_on_missing_file && !ok)
  • 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.