- Timestamp:
- 11/07/14 17:51:01 (10 years ago)
- Location:
- cpp
- Files:
-
- 62 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/Convert.cpp
r197 r247 8 8 9 9 #if defined __ANDROID__ || defined __BORLANDC__ 10 10 #include <ctype.h> //toupper, tolower 11 11 #endif 12 12 13 13 #ifdef SHP 14 14 #include <cstdlib> 15 15 #else 16 16 #include <stdlib.h> 17 17 #endif 18 18 … … 20 20 21 21 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);} 22 int Convert::toInt(string s) { return atoi(s.c_str()); } 23 float Convert::toFloat(string s) { return (float)atof(s.c_str()); } 24 string Convert::toLowerCase(string s) { std::transform(s.begin(), s.end(), s.begin(), ::tolower); return s; } 25 string Convert::toUpperCase(string s) { std::transform(s.begin(), s.end(), s.begin(), ::toupper); return s; } 26 char Convert::toLowerCase(char c) { return (char)tolower(c); } 27 char Convert::toUpperCase(char c) { return (char)toupper(c); } 30 28 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";}29 template<class T> const char* printf_format_for(const T& value) { return "unknown type"; } 30 template<> const char* printf_format_for(const unsigned int& value) { return "%u"; } 31 template<> const char* printf_format_for(const int& value) { return "%d"; } 32 template<> const char* printf_format_for(const short& value) { return "%d"; } 33 template<> const char* printf_format_for(const float& value) { return "%g"; } 34 template<> const char* printf_format_for(const double& value) { return "%g"; } 37 35 38 36 template<class T> string Convert::_toString(const T& value) 39 37 { 40 char buf[30];41 sprintf(buf,printf_format_for(value),value);42 return string(buf);43 /*44 #ifndef MULTITHREADED38 char buf[30]; 39 sprintf(buf, printf_format_for(value), value); 40 return string(buf); 41 /* 42 #ifndef MULTITHREADED 45 43 static 46 #endif44 #endif 47 45 std::ostringstream oss; //pod VS tworzenie go trwa dlugo nawet w wersji release (szczegolnie jak np konwertuje sie cos setki tysiecy razy) 48 46 //dlatego robimy go raz (static) i potem tylko czyscimy … … 51 49 oss.clear(); //clear error flag 52 50 oss.str(""); //set empty string 53 54 55 */51 oss << value; 52 return oss.str(); 53 */ 56 54 } 57 55 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);} 56 string Convert::toString(unsigned int v) { return _toString(v); } 57 string Convert::toString(int v) { return _toString(v); } 58 string Convert::toString(short v) { return _toString(v); } 59 string Convert::toString(float v) { return _toString(v); } 60 string Convert::toString(double v) { return _toString(v); } 61 62 uint32_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 } 63 69 64 70 #ifdef MULTITHREADED … … 69 75 //z mutexa gdy drugi dalej by go inicjalizowal 70 76 #include "threads.h" 71 static pthread_mutex_t fix_unsafe_mutex =PTHREAD_MUTEX_INITIALIZER;77 static pthread_mutex_t fix_unsafe_mutex = PTHREAD_MUTEX_INITIALIZER; 72 78 #endif 73 79 … … 76 82 #ifndef MULTITHREADED 77 83 78 return *::localtime(&timep);84 return *::localtime(&timep); 79 85 80 86 #else 81 87 82 struct tm ret;88 struct tm ret; 83 89 84 90 #if defined LINUX // || android? 85 return *::localtime_r(&timep,&ret);91 return *::localtime_r(&timep,&ret); 86 92 #elif defined _WIN32 && !defined __BORLANDC__ // and not bada? 87 ::localtime_s(&ret,&timep);88 return ret;93 ::localtime_s(&ret, &timep); 94 return ret; 89 95 #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; 94 100 #endif 95 101 … … 99 105 string Convert::asctime(const struct tm &tm) 100 106 { 101 char *ret;107 char *ret; 102 108 #ifndef MULTITHREADED 103 109 104 ret=::asctime(&tm);110 ret=::asctime(&tm); 105 111 106 112 #else //MULTITHREADED 107 113 108 char buf[26];114 char buf[26]; 109 115 #if defined LINUX // || android? 110 ret=::asctime_r(&tm,buf);116 ret=::asctime_r(&tm,buf); 111 117 #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; 114 120 #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); 119 125 #endif 120 126 #endif 121 127 122 return string(ret,24); //24 znaki z pominieciem ostatniego \n128 return string(ret, 24); //24 znaki z pominieciem ostatniego \n 123 129 } 124 -
cpp/common/Convert.h
r197 r247 10 10 #include "nonstd_stl.h" 11 11 #include "2d.h" 12 #include <stdint.h> 13 12 14 13 15 typedef XY<double> Pt2D; … … 17 19 { 18 20 public: 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); 32 35 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? 36 39 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 } 41 48 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 } 49 54 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 52 93 }; 53 94 54 95 55 96 56 struct Kat //znormalizowany k¹t w radianach [0,2pi) i stopniach [0,360) z obliczonymi sinus i cosinus oraz intem[0,359]97 struct Angle //normalized angle in radians [0,2pi) and degrees [0,360) with pre-computed sine and cosine and degree as integer [0,359] 57 98 { 58 99 private: 59 double kat; //w radianach, read-only100 double angle; //in radians, read-only 60 101 public: 61 double kat_stopnie; //read-only62 int kat_stopnie_int; //read-only102 double angle_deg; //read-only 103 int angle_deg_int; //read-only 63 104 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 sin us,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; 74 115 }; 75 116 -
cpp/common/nonstd.h
r244 r247 57 57 #endif 58 58 59 #if defined MACOS || defined __ANDROID__ 59 #if defined MACOS || defined __ANDROID__ || defined IPHONE 60 60 #define stricmp(a,b) strcasecmp(a,b) 61 61 #endif … … 86 86 #ifdef LINUX 87 87 #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 88 99 #define GET_APP_RESOURCES "./" 89 100 #endif -
cpp/common/nonstd_math.cpp
r227 r247 22 22 23 23 24 #ifdef IPHONE 25 //TODO! -> ? http://stackoverflow.com/questions/12762418/how-to-enable-sigfpe-signal-on-division-by-zero-in-ios-app 26 void fpExceptInit() 27 {} 28 29 void fpExceptEnable() 30 {} 31 32 void fpExceptDisable() 33 {} 34 #endif 24 35 25 36 26 #if defined LINUX || defined TIZEN || defined __ANDROID__ || defined IPHONE37 #if defined LINUX || defined TIZEN || defined __ANDROID__ 27 38 28 39 #include <fenv.h> -
cpp/common/nonstd_stdio.cpp
r227 r247 5 5 #include "nonstd_stdio.h" 6 6 #include "nonstd.h" 7 #include "Convert.h" //strTOwstr() 8 #include <common/stl-util.h> 7 9 8 10 #if defined _WIN32 && !defined SHP 9 11 //<unistd.h> not needed for unlink() 10 12 #include "Shlwapi.h" //PathIsRelative() 11 #include "Util.h" //strTOwstr()13 #include <sys/stat.h> //_stat 12 14 #else 13 15 #include <unistd.h> … … 23 25 } 24 26 27 bool directoryExists(const char* path) 28 { 29 struct _stat s; 30 if (_stat(path,&s)!=0) return false; 31 return S_ISDIR(s.st_mode); 32 } 33 34 bool makeDirectory(const char* path) 35 { 36 #ifdef _WIN32 37 return mkdir(path)==0; 38 #else 39 return mkdir(path,0777)==0; 40 #endif 41 } 42 43 bool makeDirectories(const char* path) 44 { 45 if (directoryExists(path)) return true; 46 string parentdir=getFileDir(path); 47 if (!makeDirectories(parentdir.c_str())) return false; 48 return makeDirectory(path); 49 } 50 51 int getFileSize(const char* path) 52 { 53 int size; 54 MFILE *f=mfopen(path,FOPEN_READ_BINARY); 55 if (f==NULL) return -1; 56 size=getFileSize(f); 57 mfclose(f); 58 return size; 59 } 60 61 int 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 25 70 bool removeFile(const char* path) 26 71 { … … 35 80 return PathIsRelative(fname) == FALSE; //no wide char for old borland compiler 36 81 #else 37 return PathIsRelative( Util::strTOwstr(fname).c_str()) == FALSE; //http://msdn.microsoft.com/en-us/library/bb773660%28v=vs.85%29.aspx82 return PathIsRelative(Convert::strTOwstr(fname).c_str()) == FALSE; //http://msdn.microsoft.com/en-us/library/bb773660%28v=vs.85%29.aspx 38 83 #endif 39 84 #else -
cpp/common/nonstd_stdio.h
r227 r247 7 7 8 8 bool fileExists(const char* path); 9 bool directoryExists(const char* path); 10 bool makeDirectory(const char* path); 11 bool makeDirectories(const char* path); 9 12 bool removeFile(const char* path); 10 13 bool isAbsolutePath(const char* fname); 14 int getFileSize(const char* path); 11 15 12 16 #ifdef _WIN32 … … 24 28 #ifndef MOBILE2D 25 29 #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) 27 31 #endif 28 32 33 #define S_ISDIR(x) ((x & _S_IFDIR)==_S_IFDIR) 29 34 30 35 #else … … 32 37 #include <unistd.h> 33 38 #include <sys/stat.h> 34 #define makeDirectory(name) mkdir(name,0777)39 // #define makeDirectory(name) mkdir(name,0777) 35 40 #define _unlink unlink //_unlink jest ISO-conformant, unlink jest POSIX-deprecated 36 41 #define _stat stat 37 42 #endif 38 43 … … 95 100 #endif 96 101 102 int getFileSize(MFILE *f); 103 97 104 #endif -
cpp/common/random.h
r197 r247 12 12 #include <sys/stat.h> 13 13 #include <fcntl.h> 14 #endif 15 #ifdef __BORLANDC__ 16 #include <stdint.h> //uintptr_t in borland 14 17 #endif 15 18 #ifdef _WIN32 … … 76 79 { 77 80 counter++; 78 seed = time(NULL); //time (seconds); could use hi-res timer but then we would depend on common/timer.h79 seed ^= counter; //incremented value, possibly randomly initialized80 seed ^= (unsigned int) &counter; //memory address81 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 81 84 } 82 85 #ifdef _WIN32 //add more randomness from uuid -
cpp/common/stl-util.cpp
r246 r247 10 10 #include "framsg.h" 11 11 #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 12 18 13 19 string ssprintf_va(const char* format, va_list ap) … … 16 22 long size = 256; 17 23 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) 18 26 19 27 //almost like SString::sprintf, but there is no common code to share because SString can use its directWrite to avoid double allocating/copying 20 28 #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); 22 32 #endif 23 33 … … 26 36 buf = (char*)malloc(size); 27 37 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); 29 41 if (n > -1 && n < size) 30 42 { … … 54 66 bool readCompleteFile(const char* filename, vector<char>& data, bool warn_on_missing_file) 55 67 { 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 { 56 85 MFILE *f = mfopen(filename, FOPEN_READ_BINARY); 57 bool ok = f != NULL;58 86 if (f) 59 87 { 60 mfseek(f, 0, SEEK_END); 61 long size = mftell(f); 62 mfseek(f, 0, SEEK_SET); 88 int size=getFileSize(f); 63 89 data.resize(size); 64 90 int przeczytane = mfread(&data[0], size, 1, f); 65 91 mfclose(f); 66 ok &= przeczytane == 1; 92 ok = przeczytane == 1; 93 } 67 94 } 68 95 if (warn_on_missing_file && !ok) -
cpp/frams/Makefile-GDK
r194 r247 15 15 16 16 gdk_test: $(GDK_TEST_OBJS) 17 $(CXX) $(GDK_TEST_OBJS) -o $@17 $(CXX) $(GDK_TEST_OBJS) $(LDFLAGS) -o $@ 18 18 19 19 genoconv_test: $(GENOCONV_TEST_OBJS) 20 $(CXX) $(GENOCONV_TEST_OBJS) -o $@20 $(CXX) $(GENOCONV_TEST_OBJS) $(LDFLAGS) -o $@ 21 21 22 22 geno_test: $(GENO_TEST_OBJS) 23 $(CXX) $(GENO_TEST_OBJS) -o $@23 $(CXX) $(GENO_TEST_OBJS) $(LDFLAGS) -o $@ 24 24 25 25 genooper_test: $(GENOOPER_TEST_OBJS) 26 $(CXX) $(GENOOPER_TEST_OBJS) -o $@26 $(CXX) $(GENOOPER_TEST_OBJS) $(LDFLAGS) -o $@ 27 27 28 28 genooper_test_fTest: $(GENOOPER_TEST_FTEST_OBJS) 29 $(CXX) $(GENOOPER_TEST_FTEST_OBJS) -o $@29 $(CXX) $(GENOOPER_TEST_FTEST_OBJS) $(LDFLAGS) -o $@ 30 30 31 31 neuro_test: $(NEURO_TEST_OBJS) 32 $(CXX) $(NEURO_TEST_OBJS) -o $@32 $(CXX) $(NEURO_TEST_OBJS) $(LDFLAGS) -o $@ 33 33 34 34 loader_test: $(LOADER_TEST_OBJS) 35 $(CXX) $(LOADER_TEST_OBJS) -o $@35 $(CXX) $(LOADER_TEST_OBJS) $(LDFLAGS) -o $@ 36 36 37 37 serial_test: $(SERIAL_TEST_OBJS) 38 $(CXX) $(SERIAL_TEST_OBJS) -o $@38 $(CXX) $(SERIAL_TEST_OBJS) $(LDFLAGS) -o $@ 39 39 40 40 multiline_f0_test: $(MULTILINE_F0_OBJS) 41 $(CXX) $(MULTILINE_F0_OBJS) -o $@41 $(CXX) $(MULTILINE_F0_OBJS) $(LDFLAGS) -o $@ 42 42 43 43 f0_variants_test: $(F0_VARIANTS_OBJS) 44 $(CXX) $(F0_VARIANTS_OBJS) -o $@44 $(CXX) $(F0_VARIANTS_OBJS) $(LDFLAGS) -o $@ 45 45 46 46 full_props: $(FULL_PROPS_OBJS) 47 $(CXX) $(FULL_PROPS_OBJS) -o $@47 $(CXX) $(FULL_PROPS_OBJS) $(LDFLAGS) -o $@ 48 48 49 49 part_shapes: $(PART_SHAPES_OBJS) 50 $(CXX) $(PART_SHAPES_OBJS) -o $@50 $(CXX) $(PART_SHAPES_OBJS) $(LDFLAGS) -o $@ 51 51 52 52 neuro_layout_test: $(NEURO_LAYOUT_TEST_OBJS) 53 $(CXX) $(NEURO_LAYOUT_TEST_OBJS) -o $@ 54 53 $(CXX) $(NEURO_LAYOUT_TEST_OBJS) $(LDFLAGS) -o $@ 55 54 56 55 geometry_apices_test: $(GEOMETRY_APICES_TEST_OBJS) 57 $(CXX) $(GEOMETRY_APICES_TEST_OBJS) -o $@56 $(CXX) $(GEOMETRY_APICES_TEST_OBJS) $(LDFLAGS) -o $@ 58 57 59 58 geometry_info_test: $(GEOMETRY_INFO_TEST_OBJS) 60 $(CXX) $(GEOMETRY_INFO_TEST_OBJS) -o $@59 $(CXX) $(GEOMETRY_INFO_TEST_OBJS) $(LDFLAGS) -o $@ 61 60 62 61 geometry_surface_test: $(GEOMETRY_SURFACE_TEST_OBJS) 63 $(CXX) $(GEOMETRY_SURFACE_TEST_OBJS) -o $@62 $(CXX) $(GEOMETRY_SURFACE_TEST_OBJS) $(LDFLAGS) -o $@ 64 63 65 64 geometry_volume_test: $(GEOMETRY_VOLUME_TEST_OBJS) 66 $(CXX) $(GEOMETRY_VOLUME_TEST_OBJS) -o $@65 $(CXX) $(GEOMETRY_VOLUME_TEST_OBJS) $(LDFLAGS) -o $@ 67 66 68 67 -
cpp/frams/Makefile-GDK-files
r205 r247 19 19 GENMAN_COMMON_OBJS=frams/genetics/genman.o frams/param/mutableparam.o frams/param/mutparamlist.o frams/neuro/geneticneuroparam.o frams/neuro/neurolibparam.o 20 20 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.o21 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 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 22 22 23 23 GEOMETRY_OBJS=frams/model/geometry/meshbuilder.o frams/model/geometry/modelgeometryinfo.o frams/model/geometry/geometryutils.o … … 31 31 F0_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) 32 32 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)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 $(GDK_OBJS) $(GENOCONV_GDK_OBJS) 34 34 35 35 GENOCONV_TEST_OBJS= frams/_demos/genoconv_test.o frams/_demos/printconvmap.o frams/errmgr/stdouterr.o frams/virtfile/virtfile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) … … 39 39 GENOOPER_TEST_OBJS=frams/_demos/genooper_test.o frams/virtfile/virtfile.o frams/errmgr/stdouterr.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS) 40 40 41 GENOOPER_TEST_FTEST_OBJS=frams/_demos/genooper_test_fTest.o frams/virtfile/virtfile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS) 41 GENOOPER_TEST_FTEST_OBJS=frams/_demos/genooper_test_fTest.o frams/virtfile/virtfile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS) $(GENMAN_FT) 42 42 43 43 NEURO_TEST_OBJS= frams/_demos/neuro_test.o frams/errmgr/stdouterr.o frams/virtfile/virtfile.o \ … … 45 45 frams/neuro/impl/neuroimpl-fuzzy.o frams/neuro/impl/neuroimpl-fuzzy-f0.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS) 46 46 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)47 FULL_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) 48 48 49 49 SERIAL_TEST_OBJS= frams/_demos/serial_test.o frams/virtfile/virtfile.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) … … 53 53 NEURO_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 54 54 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)55 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 $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS) 56 56 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)57 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 $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS) 58 58 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)59 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 $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS) 60 60 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)61 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 $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GEOMETRY_OBJS) -
cpp/frams/canvas/neurodiagram.cpp
r240 r247 235 235 } 236 236 237 void NeuroDiagram::onKill(void*obj, longdummy)237 void NeuroDiagram::onKill(void*obj, intptr_t dummy) 238 238 { 239 239 show(0); … … 678 678 //// 679 679 680 void NeuroDiagram::probeSampling(void*obj, longdummy)680 void NeuroDiagram::probeSampling(void*obj, intptr_t dummy) 681 681 { 682 682 FOREACH(NeuroProbe*,pr,probes) pr->sampling(); -
cpp/frams/canvas/nn_smart_layout.cpp
r197 r247 6 6 #include <vector> 7 7 #include "common/nonstd_stl.h" 8 #ifdef __BORLANDC__ 9 #include <alloc.h> //borland needs for alloc/free 10 #endif 8 11 9 12 #define DB(x) -
cpp/frams/config/f0.def
r187 r247 47 47 PROP(dy,1,1024,delta.y,f,-2,2,0,d.y) 48 48 PROP(dz,1,1024,delta.z,f,-2,2,0,d.z) 49 PROP(sh, 1,0,shape,d,0,1,0,shape)49 PROP(sh,2,0,shape,d,0,1,0,shape) 50 50 XPROP(stif,2,0,stiffness,f,0.0,1.0,1.0,stif) 51 51 XPROP(rotstif,2,0,rotation stiffness,f,0.0,1.0,1.0,rotstif) … … 65 65 PROP(p1,0,1024,`part1 ref#',d,-1,999999,-1,p1_refno) 66 66 PROP(p2,0,1024,`part2 ref#',d,-1,999999,-1,p2_refno) 67 PROP(sh, 1,0,shape,d,0,1,0,shape)67 PROP(sh,2,0,shape,d,0,1,0,shape) 68 68 XPROP(stif,2,0,stiffness,f,0.0,1.0,1.0,stif) 69 69 XPROP(rotstif,2,0,rotation stiffness,f,0.0,1.0,1.0,rotstif) -
cpp/frams/config/f0def.xml
r187 r247 50 50 <PROP ID="dy" NAME="delta.y" GROUP="1" FLAGS="1024" TYPE="f" MIN="-2" MAX="2" DEF="0" /> 51 51 <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" /> 53 53 <PROP ID="stif" XTRA="1" NAME="stiffness" GROUP="2" FLAGS="0" TYPE="f" MIN="0.0" MAX="1.0" DEF="1.0" /> 54 54 <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 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 5 #define MAIN_REL_ID "4.0rc 9"5 #define MAIN_REL_ID "4.0rc10" -
cpp/frams/genetics/f4/f4_general.cpp
r197 r247 593 593 594 594 595 int f4_Cell::addlink(f4_Cell * nfrom, double nw, longnt)595 int f4_Cell::addlink(f4_Cell * nfrom, double nw, int nt) 596 596 { 597 597 if (nolink >= MAXINPUTS - 1) return -1; // full! … … 675 675 676 676 677 f4_CellLink::f4_CellLink(f4_Cell * nfrom, double nw, longnt)677 f4_CellLink::f4_CellLink(f4_Cell * nfrom, double nw, int nt) 678 678 { 679 679 from = nfrom; … … 1234 1234 int i, j, t, res; 1235 1235 char tc1, tc2; 1236 longrelfrom;1236 int relfrom; 1237 1237 double w; 1238 1238 unsigned gpos, oldpos; -
cpp/frams/genetics/f4/f4_general.h
r197 r247 101 101 int onestep(); // execute one simulation step (till a division) 102 102 103 int addlink(f4_Cell * nfrom, double nw, longnt);103 int addlink(f4_Cell * nfrom, double nw, int nt); 104 104 void adjustRec(); 105 105 … … 129 129 //f4_OrientMat OM; 130 130 double mz; // freedom in z 131 longp2_refno; // number of last end part object, used in f0132 longjoint_refno; // number of the joint object, used in f0133 longneuro_refno; // number of the neuro object, used in f0134 135 longctrl; // neuron type131 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 136 136 double state; 137 137 double inertia; … … 147 147 { 148 148 public: 149 f4_CellLink(f4_Cell * nfrom, double nw, longnt);149 f4_CellLink(f4_Cell * nfrom, double nw, int nt); 150 150 f4_Cell * from; 151 151 // type: 0: input, 1 '*', 2 'G', 3 'T', 4 'S' 152 longt;152 int t; 153 153 double w; 154 154 }; … … 205 205 int pos; // original position in string 206 206 int i1; // internal int parameter1 207 longl1; // internal long parameter1207 int l1; // internal long parameter1 208 208 double f1; // internal double parameter1 209 209 -
cpp/frams/genetics/f4/oper_f4.cpp
r199 r247 606 606 607 607 608 u nsigned longGeno_f4::style(const char *g, int pos)608 uint32_t Geno_f4::style(const char *g, int pos) 609 609 { 610 610 char ch = g[pos]; … … 616 616 if (!strchr(STYL4CAT_MODIFIC STYL4CAT_NEUMOD STYL4CAT_DIGIT STYL4CAT_REST, ch)) 617 617 return GENSTYLE_CS(0, GENSTYLE_INVALID); 618 u nsigned longstyle = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); //default, should be changed below618 uint32_t style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); //default, should be changed below 619 619 if (strchr("X ", ch)) style = GENSTYLE_CS(0, GENSTYLE_NONE); 620 620 if (strchr("N", ch)) style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_NONE); -
cpp/frams/genetics/f4/oper_f4.h
r197 r247 38 38 int crossOver(char *&g1, char *&g2, float& chg1, float& chg2); 39 39 const char* getSimplest() { return "X"; } 40 u nsigned longstyle(const char *g, int pos);40 uint32_t style(const char *g, int pos); 41 41 42 42 // mutation probabilities -
cpp/frams/genetics/f9/oper_f9.cpp
r197 r247 109 109 110 110 ///Applying some colors and font styles... 111 u nsigned longGenoOper_f9::style(const char *g, int pos)111 uint32_t GenoOper_f9::style(const char *g, int pos) 112 112 { 113 113 char ch = g[pos]; 114 u nsigned longstyle = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below114 uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below 115 115 char *ptr = strchr((char*)turtle_commands_f9, ch); 116 116 if (ptr) -
cpp/frams/genetics/f9/oper_f9.h
r197 r247 17 17 int mutate(char *&g,float& chg,int &method); 18 18 int crossOver(char *&g1,char *&g2,float& chg1,float& chg2); 19 u nsigned longstyle(const char *g, int pos);19 uint32_t style(const char *g, int pos); 20 20 const char* getSimplest() {return "R";} 21 21 -
cpp/frams/genetics/fF/oper_fF.cpp
r197 r247 89 89 90 90 ///Applying some colors and font styles... 91 u nsigned longGenoOper_fF::style(const char *g, int pos)91 uint32_t GenoOper_fF::style(const char *g, int pos) 92 92 { 93 93 char ch = g[pos]; 94 u nsigned longstyle = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below94 uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below 95 95 if (strchr("-.e 0123456789", ch) != NULL) 96 96 style = GENSTYLE_CS(GENCOLOR_NUMBER, GENSTYLE_NONE); -
cpp/frams/genetics/fF/oper_fF.h
r197 r247 17 17 int mutate(char *&g, float& chg, int &method); 18 18 int crossOver(char *&g1, char *&g2, float& chg1, float& chg2); 19 u nsigned longstyle(const char *g, int pos);19 uint32_t style(const char *g, int pos); 20 20 const char* getSimplest() { return "6, 1.05, 1.05, 1.05, 0, 0, 0"; } 21 21 -
cpp/frams/genetics/fT/oper_fTest.cpp
r194 r247 115 115 116 116 ///Applying some colors and font styles... 117 u nsigned longGenoOper_fTest::style(const char *g, int pos)117 uint32_t GenoOper_fTest::style(const char *g, int pos) 118 118 { 119 119 char ch = g[pos]; 120 u nsigned longstyle = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below120 uint32_t style = GENSTYLE_CS(0, GENSTYLE_INVALID); //default, should be changed below 121 121 if (ch == 'A') style = GENSTYLE_RGBS(200, 0, 0, GENSTYLE_BOLD); 122 122 if (ch == 'T') style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_BOLD); -
cpp/frams/genetics/fT/oper_fTest.h
r194 r247 29 29 int mutate(char *&geno, float& chg, int &method); 30 30 int crossOver(char *&g1, char *&g2, float& chg1, float& chg2); 31 u nsigned longstyle(const char *g, int pos);31 uint32_t style(const char *g, int pos); 32 32 const char* getSimplest() { return "GATCGATTACA"; } 33 33 -
cpp/frams/genetics/genman.cpp
r240 r247 371 371 } 372 372 373 u nsigned longGenMan::Style(const char *g, int pos)373 uint32_t GenMan::Style(const char *g, int pos) 374 374 { 375 375 Geno G(g); … … 380 380 } 381 381 382 void GenMan::GetFullStyle(const char *g, u nsigned long*styletab)382 void GenMan::GetFullStyle(const char *g, uint32_t *styletab) 383 383 { 384 384 Geno G(g); … … 404 404 int chars = 0, lines = 0; 405 405 bool shortened = false; 406 u nsigned long *styletab = new unsigned long[len];406 uint32_t *styletab = new uint32_t[len]; 407 407 GetFullStyle(g, styletab); 408 408 SString html = "\n<div style=\"background:white;padding:0.2em;font-family:arial,helvetica,sans-serif;font-size:90%\">"; 409 u nsigned longprevstyle, prevcolor, style = 0, color = 0;409 uint32_t prevstyle, prevcolor, style = 0, color = 0; 410 410 for (int i = 0; i<len; i++) 411 411 { … … 501 501 } 502 502 503 void GenMan::onDelGen(void *obj, longn)503 void GenMan::onDelGen(void *obj, intptr_t n) 504 504 { 505 505 //old code needs update: -
cpp/frams/genetics/genman.h
r197 r247 46 46 Geno CrossOver(const Geno&, const Geno&); //returns xover genotype ("child") or empty if errors 47 47 float Similarity(const Geno&, const Geno&); //returns GENOPER_NOOPER or normalized similarity (1: identical, 0: different) 48 u nsigned longStyle(const char* g, int pos); //returns Style (and validity) of a genotype char.49 void GetFullStyle(const char *g, u nsigned 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). 50 50 SString HTMLize(const char *g); //returns colored genotype in HTML. 51 51 SString HTMLizeShort(const char *g); //returns colored genotype (abbreviated if needed) in HTML. … … 83 83 #undef STATRICKCLASS 84 84 void clearStats(); 85 static void onDelGen(void*, long);85 static void onDelGen(void*, intptr_t); 86 86 }; 87 87 -
cpp/frams/genetics/genoconv.h
r197 r247 46 46 out_format; //< output format, eg. '0' 47 47 const char *info; //< detailed info about converter, format or copyright 48 longenabled; //< don't touch this! (used by configuration module)49 longmapsupport; //< set to 1 if your converter supports genotype mapping48 paInt enabled; //< don't touch this! (used by configuration module) 49 paInt mapsupport; //< set to 1 if your converter supports genotype mapping 50 50 51 51 /// You have to reimplement this method. -
cpp/frams/genetics/oper_fx.cpp
r197 r247 58 58 if (p->type(i)[0] == 'd') 59 59 { 60 long_mn = 0, _mx = 1, _def = 0;60 paInt _mn = 0, _mx = 1, _def = 0; 61 61 defined = p->getMinMax(i, _mn, _mx, _def); 62 62 if (defined == 1) _mx = _mn + 1; … … 150 150 void GenoOperators::setIntFromDoubleWithProbabilisticDithering(ParamInterface &p, int index, double value) //TODO 151 151 { 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!) 153 153 } 154 154 … … 187 187 NeuroClass* GenoOperators::parseNeuroClass(char*& s) 188 188 { 189 int len = strlen(s);189 int len = (int)strlen(s); 190 190 int Len = 0; 191 191 NeuroClass *I = NULL; … … 193 193 { 194 194 const char *n = Neuro::getClass(i)->name; 195 int l = strlen(n);195 int l = (int)strlen(n); 196 196 if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = Neuro::getClass(i); Len = l; } 197 197 } … … 210 210 int GenoOperators::neuroClassProp(char*& s, NeuroClass *nc, bool also_v1_N_props) 211 211 { 212 int len = strlen(s);212 int len = (int)strlen(s); 213 213 int Len = 0, I = -1; 214 214 if (nc) … … 218 218 { 219 219 const char *n = p.id(i); 220 int l = strlen(n);220 int l = (int)strlen(n); 221 221 if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = 100 + i; Len = l; } 222 222 if (also_v1_N_props) //recognize old properties symbols /=! … … 225 225 if (strcmp(n, "in") == 0) n = "="; else 226 226 if (strcmp(n, "fo") == 0) n = "!"; 227 l = strlen(n);227 l = (int)strlen(n); 228 228 if (len >= l && l > Len && (strncmp(s, n, l) == 0)) { I = 100 + i; Len = l; } 229 229 } … … 235 235 { 236 236 const char *n = p.id(i); 237 int l = strlen(n);237 int l = (int)strlen(n); 238 238 if (len >= l && l>Len && (strncmp(s, n, l) == 0)) { I = i; Len = l; } 239 239 } -
cpp/frams/genetics/oper_fx.h
r201 r247 31 31 /** \name other useful style/color macros */ 32 32 //@{ 33 #define GENRGB(r,g,b) ((u nsigned long)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16)))34 #define GENSTYLE_RGBS(r,g,b,s) ((u nsigned long)((unsigned char)s)<<24 | GENRGB(r,g,b))35 #define GENSTYLE_CS(rgb,s) ((u nsigned 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) 36 36 37 37 #define GENGETSTYLE(style) ((style)>>24) … … 168 168 Assume white background. 169 169 \sa GENSTYLE_* macros, like GENSTYLE_BOLD*/ 170 virtual u nsigned longstyle(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);} 171 171 172 172 ///currently not used (similarity of two genotypes) -
cpp/frams/model/model.cpp
r197 r247 129 129 Model::~Model() 130 130 { 131 delmodel_list.action(( long)this);131 delmodel_list.action((intptr_t)this); 132 132 clear(); 133 133 } -
cpp/frams/model/modelparts.cpp
r197 r247 163 163 { 164 164 case 'd': t+=" integer"; 165 { longa,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);} 166 166 break; 167 167 case 'f': t+=" float"; -
cpp/frams/model/modelparts.h
r197 r247 38 38 MultiRange *mapped; 39 39 enum PartBaseFlags { Selected=1 }; 40 longflags;40 int flags; 41 41 Model *owner; ///< backlink to the model 42 42 … … 80 80 Param extraProperties(); 81 81 Param properties(); 82 longrefno;82 paInt refno; 83 83 Pt3D rot;///< rotation angles 84 84 85 85 /// 86 longshape;///default=old framsticks compatible, do not mix with shapes>086 paInt shape;///default=old framsticks compatible, do not mix with shapes>0 87 87 enum Shape {SHAPE_DEFAULT=0, SHAPE_ELLIPSOID=1, SHAPE_CUBOID=2, SHAPE_CYLINDER=3}; 88 88 double mass,size,density,friction,ingest,assim; … … 119 119 public: 120 120 // base properties: 121 longp1_refno,p2_refno; ///< parts' reference numbers121 paInt p1_refno,p2_refno; ///< parts' reference numbers 122 122 123 123 Part *part1,*part2; ///< references to parts … … 125 125 class Pt3D rot; ///< orientation delta between parts expressed as 3 angles 126 126 enum Shape {SHAPE_DEFAULT=0, SHAPE_SOLID=1}; 127 longshape;///< 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 entity127 paInt 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 128 128 129 129 Joint(); … … 159 159 160 160 // do not touch these: 161 longrefno; ///< this joint's reference number161 paInt refno; ///< this joint's reference number 162 162 double stamina; 163 163 double stif,rotstif; ///< stiffness for moving and bending forces … … 189 189 ParamEntry *props; 190 190 bool ownedprops;//< destructor will free props using ParamObject::freeParamTab 191 longprefinputs,prefoutput;192 longpreflocation;191 paInt prefinputs,prefoutput; 192 paInt preflocation; 193 193 int *vectordata; 194 longvisualhints;194 paInt visualhints; 195 195 196 196 //void *impl; … … 220 220 extra inputs may be ignored by the object (depends on the class). 221 221 */ 222 int getPreferredInputs() {return prefinputs;}222 int getPreferredInputs() {return (int)prefinputs;} 223 223 224 224 /** @return 0 if this object doesn't provide useful output signal. */ 225 int getPreferredOutput() {return prefoutput;}225 int getPreferredOutput() {return (int)prefoutput;} 226 226 227 227 /** @return 0 if the object doesn't need any assignment to the body element. … … 229 229 @return 2 = the object prefers to have the Joint ( @see Neuro::attachToJoint() ) 230 230 */ 231 int getPreferredLocation() {return preflocation;}231 int getPreferredLocation() {return (int)preflocation;} 232 232 /** vector drawing to be used in neuro net diagram. 233 233 interpretation: … … 251 251 */ 252 252 int getVisualHints() 253 {return visualhints;}253 {return (int)visualhints;} 254 254 255 255 enum Hint … … 377 377 SyntParam classProperties(bool handle_defaults_when_saving=true); 378 378 // base properties: 379 longrefno; ///< unique reference number (former 'neuro' refno)380 381 longpart_refno; ///< can be used by some items as the part ref#382 longjoint_refno; ///< can be used by some items as the joint ref#379 paInt refno; ///< unique reference number (former 'neuro' refno) 380 381 paInt part_refno; ///< can be used by some items as the part ref# 382 paInt joint_refno; ///< can be used by some items as the joint ref# 383 383 384 384 Pt3D pos,rot; ///< default = zero … … 451 451 or -1 if 'child' is not connected with this Neuro.*/ 452 452 int findInput(Neuro* child) const; 453 void removeInput( int refno);453 void removeInput(paInt refno); 454 454 /** @return reference number of the child connection, like findInput() */ 455 455 int removeInput(Neuro* child); … … 470 470 #ifdef MODEL_V1_COMPATIBLE 471 471 friend class OldItems; 472 longneuro_refno; ///< parent ref# (called neuro_refno for compatibility with old Neuro class), @see moredata473 longconn_refno; ///< the other neuron ref# in N-N connections, can be used by some other items472 paInt neuro_refno; ///< parent ref# (called neuro_refno for compatibility with old Neuro class), @see moredata 473 paInt conn_refno; ///< the other neuron ref# in N-N connections, can be used by some other items 474 474 double weight; ///< weight of the N-N connection and (all?) receptors 475 475 double inertia,force,sigmo; //!!! -
cpp/frams/neuro/geneticneuroparam.cpp
r197 r247 11 11 {} 12 12 13 longGeneticNeuroParam::getInt(int i)13 paInt GeneticNeuroParam::getInt(int i) 14 14 {return Neuro::getClass(i)->genactive;} 15 15 16 int GeneticNeuroParam::setInt(int i, longv)16 int GeneticNeuroParam::setInt(int i,paInt v) 17 17 {Neuro::getClass(i)->genactive=v;return PSET_CHANGED;} 18 18 -
cpp/frams/neuro/geneticneuroparam.h
r197 r247 15 15 GeneticNeuroParam(const char* groupname,const char* myname, const char* prefix,const char* typ=0); 16 16 17 longgetInt(int i);18 int setInt(int i, longv);17 paInt getInt(int i); 18 int setInt(int i,paInt v); 19 19 const char *type(int i) {return types?types:NeuroLibParam::type(i);} 20 20 }; -
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 5 1 6 2 // 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 5 1 6 2 // do not edit - generated automatically from "f0.def" -
cpp/frams/neuro/neuroimpl.h
r197 r247 108 108 109 109 public: 110 longintParameter;110 paInt intParameter; 111 111 double fpParameter; 112 112 SString txtParameter; -
cpp/frams/neuro/neurolibparam.cpp
r197 r247 22 22 } 23 23 24 void NeuroLibParam::neuroclassAdded(void* data, longi)24 void NeuroLibParam::neuroclassAdded(void* data,intptr_t i) 25 25 {onadd.action(i);} 26 void NeuroLibParam::neuroclassRemoved(void* data, longi)26 void NeuroLibParam::neuroclassRemoved(void* data,intptr_t i) 27 27 {ondelete.action(i);} 28 28 -
cpp/frams/param/mutableparam.cpp
r240 r247 108 108 switch(pe->type[0]) 109 109 { 110 case 'd': d=new int(); *((int*)d)=0; break;110 case 'd': d=new paInt(); *((paInt*)d)=0; break; 111 111 case 'f': d=new double(); *((double*)d)=0; break; 112 112 case 's': d=new SString(); break; … … 114 114 case 'o': d=new ExtObject(); break; 115 115 } 116 pe->offset=(int )d;116 pe->offset=(intptr_t)d; 117 117 } 118 118 onadd.action(position); … … 134 134 switch(pe->type[0]) 135 135 { 136 case 'd': delete ( int*)d; break;136 case 'd': delete (paInt*)d; break; 137 137 case 'f': delete (double*)d; break; 138 138 case 's': delete (SString*)d; break; … … 173 173 pe->group=(short)group; 174 174 pe->flags=(short)(flags | MUTPARAM_ALLOCENTRY); 175 pe->offset=( long)data;175 pe->offset=(intptr_t)data; 176 176 pe->id=strdup(id); 177 177 pe->type=strdup(type); … … 209 209 } 210 210 211 int MutableParam::setInt(int i, longv)211 int MutableParam::setInt(int i,paInt v) 212 212 { 213 213 int ret=SimpleAbstractParam::setInt(i,v); -
cpp/frams/param/mutableparam.h
r197 r247 23 23 SList entries; 24 24 SList groups; 25 longchanged;25 int changed; 26 26 ParamEntry *entry(int i) {return (i<staticprops)? pe_tab+i : ((ParamEntry*)entries(i-staticprops));} 27 27 void *getTarget(int i) {return (i<staticprops)? SimpleAbstractParam::getTarget(i) : (void*)entry(i)->offset;} … … 54 54 void notify(int id); 55 55 56 int setInt(int, long);56 int setInt(int,paInt); 57 57 int setDouble(int,double); 58 58 int setString(int,const SString &); -
cpp/frams/param/mutparamlist.cpp
r197 r247 126 126 } 127 127 128 void MutableParamList::onPropAdd(void* data, longi)128 void MutableParamList::onPropAdd(void* data,intptr_t i) 129 129 { 130 130 ParamInfo *pi=(ParamInfo*)data; … … 136 136 } 137 137 138 void MutableParamList::onPropDelete(void* data, longi)138 void MutableParamList::onPropDelete(void* data,intptr_t i) 139 139 { 140 140 ParamInfo *pi=(ParamInfo*)data; … … 146 146 } 147 147 148 void MutableParamList::onPropChange(void* data, longi)148 void MutableParamList::onPropChange(void* data,intptr_t i) 149 149 { 150 150 ParamInfo *pi=(ParamInfo*)data; … … 152 152 } 153 153 154 void MutableParamList::onPropActivate(void* data, longi)154 void MutableParamList::onPropActivate(void* data,intptr_t i) 155 155 { 156 156 ParamInfo *pi=(ParamInfo*)data; … … 158 158 } 159 159 160 void MutableParamList::onGroupAdd(void* data, longi)160 void MutableParamList::onGroupAdd(void* data,intptr_t i) 161 161 { 162 162 ParamInfo *pi=(ParamInfo*)data; … … 168 168 } 169 169 170 void MutableParamList::onGroupDelete(void* data, longi)170 void MutableParamList::onGroupDelete(void* data,intptr_t i) 171 171 { 172 172 ParamInfo *pi=(ParamInfo*)data; … … 178 178 } 179 179 180 void MutableParamList::onGroupChange(void* data, longi)180 void MutableParamList::onGroupChange(void* data,intptr_t i) 181 181 { 182 182 ParamInfo *pi=(ParamInfo*)data; … … 295 295 FUN(int,flags,0) 296 296 FUN(SString,getString,SString()) 297 FUN( long,getInt,0)297 FUN(paInt,getInt,0) 298 298 FUN(double,getDouble,0) 299 FUN(ExtValue,getExtValue,ExtValue(( long)0))299 FUN(ExtValue,getExtValue,ExtValue((paInt)0)) 300 300 FUN(ExtObject,getObject,ExtObject()) 301 301 … … 322 322 } 323 323 324 FUN2(int,setInt, long)324 FUN2(int,setInt,paInt) 325 325 FUN2(int,setDouble,double) 326 326 FUN2(int,setString,const SString &) -
cpp/frams/param/mutparamlist.h
r197 r247 75 75 76 76 SString getString(int); 77 longgetInt(int);77 paInt getInt(int); 78 78 double getDouble(int); 79 79 ExtValue getExtValue(int); 80 80 ExtObject getObject(int); 81 81 82 int setInt(int, long);82 int setInt(int,paInt); 83 83 int setDouble(int,double); 84 84 int setString(int,const SString &); -
cpp/frams/param/param.cpp
r230 r247 37 37 static const char *strchrlimit(const char *t, int ch, const char *limit) 38 38 { 39 int n = limit - t;39 int n = (int)(limit - t); 40 40 for (; (n > 0) && *t; t++, n--) 41 41 if (*t == ch) return t; … … 72 72 } 73 73 74 int ParamInterface::getMinMax(int prop, long& minumum, long& maximum, long&def)74 int ParamInterface::getMinMax(int prop, paInt& minumum, paInt& maximum, paInt &def) 75 75 { 76 76 const char* t = type(prop) + 1; 77 77 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); 79 79 } 80 80 … … 121 121 case 'd': 122 122 { 123 longa = 0, b = 0, c = 0;123 paInt a = 0, b = 0, c = 0; 124 124 if (getMinMax(i, a, b, c) < 3) c = a; 125 125 setInt(i, c); … … 144 144 case 'd': 145 145 { 146 longa = 0, b = 0, c = 0;146 paInt a = 0, b = 0, c = 0; 147 147 getMinMax(i, a, b, c); 148 148 setInt(i, a); … … 167 167 case 'd': 168 168 { 169 longa = 0, b = 0, c = 0;169 paInt a = 0, b = 0, c = 0; 170 170 getMinMax(i, a, b, c); 171 171 setInt(i, b); … … 178 178 SString ParamInterface::getStringById(const char*prop) 179 179 {int i=findId(prop); if (i>=0) return getString(i); else return SString();} 180 longParamInterface::getIntById(const char*prop)180 paInt ParamInterface::getIntById(const char*prop) 181 181 {int i=findId(prop); if (i>=0) return getInt(i); else return 0;} 182 182 double ParamInterface::getDoubleById(const char*prop) … … 187 187 {int i=findId(prop); if (i>=0) return getExtValue(i); else return ExtValue();} 188 188 189 int ParamInterface::setIntById(const char* prop, longv)189 int ParamInterface::setIntById(const char* prop,paInt v) 190 190 {int i=findId(prop); if (i>=0) return setInt(i,v); else return PSET_NOPROPERTY;} 191 191 int ParamInterface::setDoubleById(const char* prop,double v) … … 260 260 { 261 261 select(defdata); 262 longx = getInt(i);262 paInt x = getInt(i); 263 263 select(backup); 264 264 return x == getInt(i); … … 347 347 if (!*p0) break; 348 348 p = strchr(p0, ':'); if (!p) continue; 349 p_len = p - p0;349 p_len = (int)(p - p0); 350 350 loaded = false; 351 351 if (p_len && ((i = findIdn(p0, p_len)) >= 0) && (!(flags(i)&PARAM_DONTLOAD))) … … 442 442 if (!stringIsNumeric(str)) 443 443 { 444 longa, b, c;444 paInt a, b, c; 445 445 if (getMinMax(i, a, b, c) >= 3) 446 446 return setInt(i, c); 447 447 else 448 return setInt(i, ( long)0);448 return setInt(i, (paInt)0); 449 449 } 450 450 else … … 536 536 const char *t2 = strchr(t, '~'); 537 537 if (!t2) t2 = t + strlen(t); 538 return SString(t, t2 - t);538 return SString(t, (int)(t2 - t)); 539 539 } 540 540 } … … 599 599 #endif 600 600 601 longSimpleAbstractParam::getInt(int i)601 paInt SimpleAbstractParam::getInt(int i) 602 602 { 603 603 SANITY_CHECK(i); … … 612 612 { 613 613 void *target = getTarget(i); 614 return *(( long*)target);614 return *((paInt*)target); 615 615 } 616 616 } … … 687 687 //////// set 688 688 689 int SimpleAbstractParam::setInt(int i, longx)689 int SimpleAbstractParam::setInt(int i, paInt x) 690 690 { 691 691 SANITY_CHECK(i); … … 693 693 ParamEntry *pe = entry(i); 694 694 if (pe->flags&PARAM_READONLY) return PSET_RONLY; 695 longxcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below696 longa = 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; 697 697 int result = 0; 698 698 const char* t = pe->type + 1; 699 699 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) 701 701 if (a <= b) // if max<min then the min/max constraint check is not supported 702 702 { … … 713 713 { 714 714 void *target = getTarget(i); 715 if (dontcheckchanges || (*(( long*)target) != x))715 if (dontcheckchanges || (*((paInt*)target) != x)) 716 716 { 717 717 result |= PSET_CHANGED; 718 *(( long*)target) = x;718 *((paInt*)target) = x; 719 719 } 720 720 } … … 770 770 const char* t = pe->type + 1; 771 771 while (*t) if (*t == ' ') break; else t++; 772 longa = 0, b = 0;772 paInt a = 0, b = 0; 773 773 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) 775 775 { 776 776 if ((x.len() > b) && (b > 0)) … … 883 883 const char *lf = strchr(beg, '\n'); 884 884 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(); } 886 886 while (lf >= beg) if ((*lf == '\n') || (*lf == '\r')) lf--; else break; 887 len = lf - beg+ 1;887 len = (int)(lf - beg) + 1; 888 888 return beg; 889 889 } … … 939 939 if (equals_sign) // have parameter name 940 940 { 941 tmpi = findIdn(t, equals_sign - t);941 tmpi = findIdn(t, (int)(equals_sign - t)); 942 942 i = tmpi; 943 943 if (tmpi < 0) … … 960 960 if (quote) 961 961 { 962 tmpvalue.copyFrom(quote + 1, quote2 - quote- 1);962 tmpvalue.copyFrom(quote + 1, (int)(quote2 - quote) - 1); 963 963 sstringUnquote(tmpvalue); 964 964 value = tmpvalue; -
cpp/frams/param/param.h
r230 r247 7 7 8 8 #include <stdio.h> 9 #include <stdint.h> 9 10 #include <frams/util/sstring.h> 10 11 #include <frams/util/list.h> … … 33 34 #define PARAM_DEPRECATED 8192 34 35 36 typedef int32_t paInt; 37 #define PA_INT_SCANF "%d" 38 35 39 // the result of param::set() is a combination of bits: 36 40 … … 92 96 93 97 virtual SString getString(int) = 0; ///< get string value, you can only use this for "s" type property 94 virtual longgetInt(int) = 0; ///< get long value, you can only use this for "d" type property98 virtual paInt getInt(int) = 0; ///< get long value, you can only use this for "d" type property 95 99 virtual double getDouble(int) = 0; ///< get double value, you can only use this for "f" type property 96 100 virtual ExtObject getObject(int) = 0; ///< get object reference, you can only use this for "o" type property … … 101 105 102 106 SString getStringById(const char*prop); ///< get string value, you can only use this for "s" type property 103 longgetIntById(const char* prop); ///< get long value, you can only use this for "d" type property107 paInt getIntById(const char* prop); ///< get long value, you can only use this for "d" type property 104 108 double getDoubleById(const char* prop);///< get double value, you can only use this for "f" type property 105 109 ExtObject getObjectById(const char* prop);///< get object reference, you can only use this for "o" type property … … 109 113 int setInt(int i, const char* str); 110 114 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 prop115 virtual int setInt(int, paInt) = 0; ///< set long value, you can only use this for "d" type prop 112 116 virtual int setDouble(int, double) = 0; ///< set double value, you can only use this for "f" type prop 113 117 virtual int setString(int, const SString &) = 0; ///< set string value, you can only use this for "s" type prop … … 119 123 int set(int, const char*); ///< oldstyle set, can convert string to long or double 120 124 121 int setIntById(const char* prop, long);///< set long value, you can only use this for "d" type prop125 int setIntById(const char* prop, paInt);///< set long value, you can only use this for "d" type prop 122 126 int setDoubleById(const char* prop, double);///< set double value, you can only use this for "f" type prop 123 127 int setStringById(const char* prop, const SString &);///< set string value, you can only use this for "s" type prop … … 128 132 /** get valid minimum, maximum and default value for property 'prop' 129 133 @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); 131 135 /** get valid minimum, maximum and default value for property 'prop' 132 136 @return 0 if min/max/def information is not available */ … … 172 176 #define SETOFFSET(_proc_) ( (int (*)(void*,const ExtValue*)) &(FIELDSTRUCT :: _proc_ ## _statrick)) 173 177 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)))) 175 179 176 180 #ifdef DEBUG 177 #define PARAM_ILLEGAL_OFFSET (( long)0xdeadbeef)181 #define PARAM_ILLEGAL_OFFSET ((intptr_t)0xdeadbeef) 178 182 #else 179 183 #define PARAM_ILLEGAL_OFFSET 0 … … 205 209 short group, flags; 206 210 const char *name, *type; 207 longoffset;211 intptr_t offset; 208 212 void *fun1; ///< procedure or get 209 213 void *fun2; ///< set … … 214 218 { 215 219 public: 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) 217 221 { 218 222 id = _id; group = _group; flags = _flags; name = _name; type = _type; offset = _offset; fun1 = _fun1; fun2 = _fun2; help = _help; … … 254 258 255 259 SString getString(int); 256 longgetInt(int);260 paInt getInt(int); 257 261 double getDouble(int); 258 262 ExtObject getObject(int); … … 270 274 } 271 275 272 int setInt(int, long);276 int setInt(int, paInt); 273 277 int setDouble(int, double); 274 278 int setString(int, const SString &); -
cpp/frams/util/callbacks.cpp
r197 r247 61 61 } 62 62 63 void Callback::action( longdata)63 void Callback::action(intptr_t data) 64 64 { 65 65 if (size()==0) return; -
cpp/frams/util/callbacks.h
r197 r247 8 8 #include "list.h" 9 9 #include "statrick.h" 10 #include <stdint.h> 10 11 11 12 //#define USEMEMBERCALLBACK … … 15 16 public: 16 17 virtual ~CallbackNode() {} 17 virtual void action( longcalldata)=0;18 virtual void action(intptr_t calldata)=0; 18 19 virtual int equals(CallbackNode*n) {return (this==n);} 19 20 }; … … 25 26 void *userdata; 26 27 CallBase *object; 27 void (CallBase::*member)(void*, long);28 void (CallBase::*member)(void*,intptr_t); 28 29 public: 29 MemberCallbackNode(CallBase *o,void (CallBase::*m)(void*, long),void *d):object(o),member(m),userdata(d) {}30 void action( longcalldata) {(object->*member)(userdata,calldata);}30 MemberCallbackNode(CallBase *o,void (CallBase::*m)(void*,intptr_t),void *d):object(o),member(m),userdata(d) {} 31 void action(intptr_t calldata) {(object->*member)(userdata,calldata);} 31 32 int equals(CallbackNode*); 32 33 }; 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)) 34 35 #endif 35 36 … … 37 38 { 38 39 void *userdata; 39 void (*fun)(void*, long);40 void (*fun)(void*,intptr_t); 40 41 public: 41 FunctionCallbackNode(void (*f)(void*, long),void *d):userdata(d),fun(f) {}42 void action( longcalldata) {(*fun)(userdata,calldata);}42 FunctionCallbackNode(void (*f)(void*,intptr_t),void *d):userdata(d),fun(f) {} 43 void action(intptr_t calldata) {(*fun)(userdata,calldata);} 43 44 int equals(CallbackNode*); 44 45 }; 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)) 46 47 47 48 class StatrickCallbackNode :public CallbackNode … … 49 50 void *object; 50 51 void *userdata; 51 void (*fun)(void*,void*, long);52 void (*fun)(void*,void*,intptr_t); 52 53 public: 53 StatrickCallbackNode(void *o,void (*f)(void*,void*, long),void *d):object(o),userdata(d),fun(f) {}54 void action( longcalldata) {(*fun)(object,userdata,calldata);}54 StatrickCallbackNode(void *o,void (*f)(void*,void*,intptr_t),void *d):object(o),userdata(d),fun(f) {} 55 void action(intptr_t calldata) {(*fun)(object,userdata,calldata);} 55 56 int equals(CallbackNode*); 56 57 }; 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)) 58 59 59 60 /** … … 61 62 add(Function* fun, void* anydata) 62 63 '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, longeventdata)64 and event specific value as the second argument (intptr_t) 65 fun(void* anydata,intptr_t eventdata) 65 66 66 67 'StatrickCallbackNode' uses static functions to emulate object member calls. … … 81 82 ~Callback(); 82 83 CallbackNode* add(CallbackNode*n); 83 CallbackNode* add(void (*f)(void*, long),void *d)84 CallbackNode* add(void (*f)(void*,intptr_t),void *d) 84 85 {return add(new FunctionCallbackNode(f,d));} 85 void remove(void (*f)(void*, long),void *d)86 void remove(void (*f)(void*,intptr_t),void *d) 86 87 {remove(new FunctionCallbackNode(f,d));} 87 88 void remove(CallbackNode*n); 88 89 void 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( longdata);90 void operator+=(void* fun) {add((void (*)(void*,intptr_t))fun,0);} 91 void operator-=(void* fun) {remove((void (*)(void*,intptr_t))fun,0);} 92 void action(intptr_t data); 92 93 void action() {action(0);} 93 94 int size() {return SList::size();} … … 97 98 /////////////////// 98 99 99 #define STCALLBACKDEF(name) STATRICKDEF2(name,void*, long)100 #define STCALLBACKDEFC(cls,name) STATRICKSTUB2(cls,name,void*, long) \101 void name(void* arg1, longarg2)102 #define VIRTCALLBACKDEF(name) STATRICKSTUB2(STATRICKCLASS,name,void*, long) \103 virtual void name(void* arg1, longarg2)104 #define VIRTCALLBACKDEFC(cls,name) STATRICKSTUB2(cls,name,void*, long) \105 virtual void name(void* arg1, longarg2)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) 106 107 107 108 /* STCALLBACKDEFC(Class,name) … … 115 116 */ 116 117 117 #define CALLBACKARGS void* arg1, longarg2118 #define CALLBACKARGS void* arg1,intptr_t arg2 118 119 119 120 #endif -
cpp/frams/util/extvalue.cpp
r228 r247 281 281 } 282 282 283 static long longsign(longx)283 static int longsign(paInt x) 284 284 { 285 285 if (x<0) return -1; … … 288 288 } 289 289 290 static longcompareNull(const ExtValue& v)290 static int compareNull(const ExtValue& v) 291 291 { 292 292 switch(v.type) … … 299 299 } 300 300 301 longExtValue::compare(const ExtValue& src) const302 { 303 if ( type==TUnknown)301 int ExtValue::compare(const ExtValue& src) const 302 { 303 if (isNull()) 304 304 return compareNull(src); 305 else if (src. type==TUnknown)305 else if (src.isNull()) 306 306 return compareNull(*this); 307 307 switch(type) … … 309 309 case TInt: 310 310 { 311 longt=src.getInt();311 paInt t=src.getInt(); 312 312 if (idata()>0) 313 313 {if (t>0) return longsign(idata()-t); else return +1;} … … 545 545 if (args.finished() && (type!=0) && (type!='%')) 546 546 { 547 ret+=fmt.substr( curr-begin);547 ret+=fmt.substr((int)(curr-begin)); 548 548 break; 549 549 } 550 SString sub=fmt.substr( curr-begin,next-curr);550 SString sub=fmt.substr((int)(curr-begin),(int)(next-curr)); 551 551 switch(type) 552 552 { … … 601 601 } 602 602 603 longExtValue::getInt(const char* s)603 paInt ExtValue::getInt(const char* s) 604 604 { 605 605 if ((s[0]=='0')&&(s[1]=='x')) 606 606 { 607 longval;607 paInt val; 608 608 sscanf(s+2,"%lx",&val); 609 609 return val; … … 612 612 { 613 613 if (strchr(s,'e')||(strchr(s,'E'))) 614 return ( long)atof(s);614 return (paInt)atof(s); 615 615 else 616 return ato l(s);616 return atoi(s); 617 617 } 618 618 } … … 622 622 if ((s[0]=='0')&&(s[1]=='x')) 623 623 { 624 longval;624 paInt val; 625 625 sscanf(s+2,"%lx",&val); 626 626 return val; … … 630 630 } 631 631 632 longExtValue::getInt() const632 paInt ExtValue::getInt() const 633 633 { 634 634 switch(type) … … 639 639 case TObj: 640 640 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; 642 642 default:; 643 643 } … … 654 654 case TObj: 655 655 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; 657 657 default:; 658 658 } … … 732 732 else 733 733 { 734 setInt(ato l(in));734 setInt(atoi(in)); 735 735 return p; 736 736 } … … 769 769 { 770 770 ret=skipQuoteString(in+1,NULL); 771 SString s(in+1, ret-(in+1));771 SString s(in+1,(int)(ret-(in+1))); 772 772 sstringUnquote(s); 773 773 setString(s); … … 864 864 else if ((ret=skipWord(in))&&(ret!=in)) 865 865 { 866 SString clsname(in, ret-in);866 SString clsname(in,(int)(ret-in)); 867 867 ExtValue tmp; 868 868 ret=tmp.deserialize(ret); … … 929 929 ExtValue ExtValue::getExtType() 930 930 { 931 if (getType()!=TObj) return ExtValue(( long)getType());931 if (getType()!=TObj) return ExtValue((paInt)getType()); 932 932 ExtObject& o=odata(); 933 933 return ExtValue(SString(o.isEmpty()?"":o.interfaceName())); -
cpp/frams/util/extvalue.h
r228 r247 101 101 #ifdef EXTVALUEUNION 102 102 long data[(EXTVALUEUNIONSIZE+sizeof(long)-1)/sizeof(long)]; 103 long& idata() const {return (long&)data[0];};103 paInt& idata() const {return (paInt&)data[0];}; 104 104 double& ddata() const {return *(double*)data;}; 105 105 ExtObject& odata() const {return *(ExtObject*)data;}; … … 107 107 #else 108 108 union { 109 longi;109 paInt i; 110 110 double d; 111 111 SString *s; 112 112 ExtObject *o; 113 113 }; 114 long& idata() const {return (long&)i;};114 paInt& idata() const {return (paInt&)i;}; 115 115 double& ddata() const {return (double&)d;}; 116 116 ExtObject& odata() const {return *o;}; … … 123 123 ExtValue():type(TUnknown){} 124 124 ~ExtValue() {setEmpty();} 125 ExtValue( longv) {seti(v);}125 ExtValue(paInt v) {seti(v);} 126 126 ExtValue(double v) {setd(v);} 127 127 ExtValue(const SString &v) {sets(v);} 128 128 ExtValue(const ExtObject &srco) {seto(srco);} 129 129 static ExtValue invalid() {ExtValue v; v.setInvalid(); return v;} 130 longcompare(const ExtValue& src) const;130 int compare(const ExtValue& src) const; 131 131 int operator==(const ExtValue& src) const; 132 132 void operator+=(const ExtValue& src); … … 144 144 ExtPType getType() {return type;} 145 145 void *getObjectTarget(const char* classname,bool warn=true) const; 146 void setInt( longv) {if (type!=TInt) setri(v); else idata()=v;}146 void setInt(paInt v) {if (type!=TInt) setri(v); else idata()=v;} 147 147 void setDouble(double v) {if (type!=TDouble) setrd(v); else ddata()=v;} 148 148 void setString(const SString &v) {if (type!=TString) setrs(v); else sdata()=v;} 149 149 void setObject(const ExtObject &src) {if (type!=TObj) setro(src); else odata()=src;} 150 static longgetInt(const char* s);150 static paInt getInt(const char* s); 151 151 static double getDouble(const char* s); 152 longgetInt() const;152 paInt getInt() const; 153 153 double getDouble() const; 154 154 SString getString() const; … … 176 176 void setr(const ExtValue& src){setEmpty();set(src);} 177 177 void set(const ExtValue& src); 178 void setri( longv) {setEmpty();seti(v);}178 void setri(paInt v) {setEmpty();seti(v);} 179 179 void setrd(double v) {setEmpty();setd(v);} 180 void seti( longv) {type=TInt;idata()=v;}180 void seti(paInt v) {type=TInt;idata()=v;} 181 181 void setd(double v) {type=TDouble;ddata()=v;} 182 182 #ifdef EXTVALUEUNION -
cpp/frams/util/hashtable.h
r226 r247 29 29 int threshold; 30 30 float load; 31 longsync;31 int sync; 32 32 33 33 int hash(const SString &s); -
cpp/frams/util/list.h
r197 r247 55 55 public: 56 56 57 SListTempl(const SListTempl<T>& src):have(0),used(0), mem(0),pos(0)57 SListTempl(const SListTempl<T>& src):have(0),used(0),pos(0),mem(0) 58 58 {(*this)=src;} 59 59 SListTempl():have(0),used(0),pos(0),mem(0) -
cpp/frams/util/rndutil.cpp
r197 r247 5 5 #include "rndutil.h" 6 6 #include <common/nonstd_math.h> 7 #include <cstdint> 7 8 #include <stdlib.h> 8 9 9 10 unsigned short pseudornd(short x) 10 11 { 11 static longseed = 0;12 longy;12 static int32_t seed = 0; 13 int32_t y; 13 14 if (x <= 0) { seed = -x; return 0; } 14 15 seed = (y = (3677 * seed + 3680) & 0x7fffffff) - 1; -
cpp/frams/util/sstring.cpp
r226 r247 113 113 // to be moved somewhere else? 114 114 // public domain source: http://isthe.com/chongo/src/fnv 115 typedef u nsigned longFnv32_t;115 typedef uint32_t Fnv32_t; 116 116 117 117 #define FNV_32_PRIME ((Fnv32_t)0x01000193) … … 143 143 ////////////////////////////////////////////////// 144 144 145 u nsigned longSBuf::hash() const145 uint32_t SBuf::hash() const 146 146 { 147 147 return fnv_32a_buf(txt,used,FNV1_32A_INIT); … … 339 339 /////////////////////////////////////// 340 340 341 intSString::equals(const SString& s) const342 { 343 if (s.buf==buf) return 1;344 return !strcmp(buf->txt,s.buf->txt);341 bool SString::equals(const SString& s) const 342 { 343 if (s.buf==buf) return true; 344 return strcmp(buf->txt,s.buf->txt)==0; 345 345 } 346 346 -
cpp/frams/util/sstring.h
r198 r247 22 22 // - mutex required to be thread safe 23 23 24 #include <stdint.h> 24 25 #include <string.h> 25 26 #include <stdlib.h> … … 47 48 SBuf(); 48 49 ~SBuf(); 49 u nsigned longhash() const; // 32-bit FNV-1 hash -> http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash50 uint32_t hash() const; // 32-bit FNV-1 hash -> http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash 50 51 }; 51 52 … … 155 156 void operator+=(const SString&); ///< append other SString 156 157 157 intequals(const SString &s) const; ///< TRUE if equal158 intoperator==(const SString &s) const {return equals(s);} ///< TRUE if equal159 intoperator!=(const SString &s) const {return !equals(s);}158 bool equals(const SString &s) const; ///< TRUE if equal 159 bool operator==(const SString &s) const {return equals(s);} ///< TRUE if equal 160 bool operator!=(const SString &s) const {return !equals(s);} 160 161 const char* operator()(int p) const {return buf->txt+p;} ///< pointer to p'th character in SString 161 162 char operator[](int i) const {return buf->txt[i];} ///< get char like in array … … 175 176 int startsWith(const char *pattern) const; 176 177 char charAt(int pos) const {return buf->txt[pos];} 177 u nsigned longhash() const {return buf->hash();}178 uint32_t hash() const {return buf->hash();} 178 179 179 180 static SString valueOf(int); -
cpp/frams/virtfile/stdiofile.h
r227 r247 33 33 StdioFILE(MFILE *f,const SString& p) {file=f;path=p;} 34 34 static 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);}35 size_t Vread(void *ptr, size_t size, size_t nmemb) {return mfread(ptr,size,nmemb,file);} 36 size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {return mfwrite(ptr,size,nmemb,file);} 37 37 int Veof() {return mfeof(file);} 38 38 int Vputs(const char *s) {return mfputs(s,file);} 39 39 char *Vgets(char *s, int size) {return mfgets(s,size,file);} 40 40 int Vseek(long offset, int whence) {return mfseek(file,offset,whence);} 41 intVtell() {return mftell(file);}41 long Vtell() {return mftell(file);} 42 42 int Vflush() {return 0;/*NOT IMPLEMENTED!*/;} 43 43 const char* VgetPath() {return path;} … … 55 55 StdioFILE(FILE *f,const SString& p) {file=f;path=p;} 56 56 static 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);}57 size_t Vread(void *ptr, size_t size, size_t nmemb) {return fread(ptr,size,nmemb,file);} 58 size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {return fwrite(ptr,size,nmemb,file);} 59 59 int Veof() {return feof(file);} 60 60 int Vputc(int c) {return fputc(c,file);} … … 64 64 int Vprintf(const char *format, va_list args) { return vfprintf(file,format,args); } 65 65 int Vseek(long offset, int whence) {return fseek(file,offset,whence);} 66 intVtell() {return ftell(file);}66 long Vtell() {return ftell(file);} 67 67 void Vrewind() {rewind(file);} 68 68 int Vflush() {return fflush(file);} -
cpp/frams/virtfile/stringfile.cpp
r207 r247 7 7 #include <errno.h> //EINVAL 8 8 9 int StringFILE::Vread(void *ptr, size_t size, size_t nmemb)9 size_t StringFILE::Vread(void *ptr, size_t size, size_t nmemb) 10 10 { 11 int have= str.len()-pos;11 int have=(int)(str.len()-pos); 12 12 if (have<=0) return 0; 13 int need= size*nmemb;14 if (need>have) {nmemb=have/size; need= size*nmemb;}13 int need=(int)(size*nmemb); 14 if (need>have) {nmemb=have/size; need=(int)(size*nmemb);} 15 15 memcpy(ptr,((const char*)str)+pos,need); 16 16 pos+=need; … … 23 23 return EOF; 24 24 else 25 return str [pos++];25 return str.operator[]((int)pos++); 26 26 } 27 27 28 28 char *StringFILE::Vgets(char *s, int size) 29 29 { 30 int have=str.len()- pos;30 int have=str.len()-(int)pos; 31 31 if (have<=0) return 0; 32 32 if (size<0) size=0; -
cpp/frams/virtfile/stringfile.h
r207 r247 16 16 public: 17 17 StringFILE(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;}18 size_t Vread(void *ptr, size_t size, size_t nmemb); 19 size_t Vwrite(const void *ptr, size_t size, size_t nmemb) {str.append((const char*)ptr,(int)(size*nmemb)); return size*nmemb;} 20 20 int Veof() {return pos>=str.len();} 21 21 int Vputc(int c) {str+=(char)c; return c;} 22 int Vputs(const char *s) {str.append(s, strlen(s)); return 0;}22 int Vputs(const char *s) {str.append(s,(int)strlen(s)); return 0;} 23 23 int Vgetc(); 24 24 char *Vgets(char *s, int size); 25 25 int Vseek(long offset, int whence); 26 intVtell() {return pos;}26 long Vtell() {return pos;} 27 27 int Vflush() {return 0;} 28 28 }; -
cpp/frams/virtfile/virtfile.cpp
r225 r247 45 45 va_end(argptr); 46 46 return ret; 47 } 48 49 int 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; 47 56 } 48 57 -
cpp/frams/virtfile/virtfile.h
r225 r247 23 23 { 24 24 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;25 virtual size_t Vread(void *ptr, size_t size, size_t nmemb)=0; 26 virtual size_t Vwrite(const void *ptr, size_t size, size_t nmemb)=0; 27 27 virtual int Veof()=0; 28 28 virtual int Vputc(int c) {unsigned char data=(unsigned char)c; return (Vwrite(&data,1,1)==1)?data:EOF;} … … 30 30 virtual int Vgetc() {unsigned char data; if (Vread(&data,1,1)==1) return data; else return EOF;} 31 31 virtual int Vseek(long offset, int whence)=0; 32 virtual intVtell()=0;32 virtual long Vtell()=0; 33 33 virtual void Vrewind() {Vseek(0,SEEK_SET);} 34 34 virtual int Vflush()=0; … … 37 37 int printf(const char *format, ...); 38 38 virtual const char *VgetPath() {return 0;} // 0=unspecified path 39 virtual int getSize(); 39 40 virtual ~VirtFILE(); 40 41 static VirtFILE *Vstdin,*Vstdout,*Vstderr; -
cpp/frams/vm/classes/3dobject.cpp
r241 r247 472 472 {return ExtObject(&getStaticParam(),p);} 473 473 474 ParamEntry* ReferenceObj::getStaticParamtab()475 {476 #define FIELDSTRUCT ReferenceObj477 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 FIELDSTRUCT489 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 #else498 static Param static_refobjectparam(getStaticParamtab());499 #endif500 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 else513 *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 else534 {535 trace+=this;536 if (value)537 s+=value->getString();538 else539 {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 else557 {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 else569 {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 593 474 ///////////// 594 475 -
cpp/frams/vm/classes/3dobject.h
r241 r247 82 82 }; 83 83 84 class ReferenceObj: public DestrBase85 {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 ReferenceObj96 PARAMPROCDEF(p_newS);97 PARAMPROCDEF(p_newO);98 PARAMPROCDEF(p_copyFrom);99 PARAMGETDEF(toString);100 PARAMGETDEF(value);101 PARAMSETDEF(value);102 #undef STATRICKCLASS103 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 111 84 #endif -
cpp/frams/vm/framscript.y
r245 r247 1003 1003 if (loc!=TranslatorStack::NOTFOUND) 1004 1004 { 1005 trctx.out->printf("push &%d\n call Ref.newS\n",loc-trstack.currentPos());trstack.adjust(-1);1005 trctx.out->printf("push &%d\n",loc-trstack.currentPos());trstack.adjust(-1); 1006 1006 } 1007 1007 else if (globalOk($2))
Note: See TracChangeset
for help on using the changeset viewer.