Changeset 82


Ignore:
Timestamp:
02/08/13 03:44:31 (12 years ago)
Author:
Maciej Komosinski
Message:

compiles under more platforms and OSes

Location:
cpp/gdk
Files:
5 added
13 edited

Legend:

Unmodified
Added
Removed
  • cpp/gdk/defassign.m4

    r66 r82  
    1212define(`ENDCLASS',`dnl')
    1313define(`CLASS',`ifelse($2,USECLASS,
    14 `// default assignments for $1 : define(`PROP',`ifelse($'8`,,`dnl',$'9`=MAYBE_QUOTE($'5`,$'8`));')dnl'
     14`// default assignments for $1 : define(`PROP',`ifelse($'8`,,`dnl',ifelse($'10`,,$'9`=MAYBE_QUOTE($'5`,$'8`);))')dnl'
    1515,
    1616`define(`PROP',`dnl')dnl'
  • cpp/gdk/extvalue.cpp

    r74 r82  
    196196                double d=ddata();
    197197                d/=src.getDouble();
     198#ifdef IPHONE
     199        if (!isinf(d))
     200#else
    198201                if (finite(d))
     202#endif
    199203                        ddata()=d;
    200204                else
  • cpp/gdk/framsg.cpp

    r66 r82  
    1 // This file is a part of the Framsticks GDK library.
    2 // Copyright (C) 2002-2011  Szymon Ulatowski.  See LICENSE.txt for details.
    3 // Refer to http://www.framsticks.com/ for further information.
     1#include "framsg.h"
     2#include "nonstd_stdio.h"
    43
    5 #include "nonstd.h"
    6 #include "framsg.h"
    7 #include <stdio.h>
     4#ifdef SHP
     5#include <FBaseSys.h> //AppLog
     6#endif
     7
     8#ifdef MOBILE2D
     9#include <Winbase.h>
     10#include "Util.h"
     11#endif
     12
     13static const char *warn="[warn] ";
     14static const char *err="[ERROR] ";
     15
     16/* TODO integracja z error managerem
     17void FramMessage(const char *o,const char *m,const char *bl,int w)
     18{
     19  const char *lvl="";
     20  if (w==1) lvl=warn; else if (w>1) lvl=err;
     21#ifdef SHP
     22  //jesli chcemy zeby nawet w trybie release wysylal komunikaty:
     23  //#define AppLog(...)      __App_info(__PRETTY_FUNCTION__ , __LINE__, __VA_ARGS__)
     24        AppLog("%s%s::%s - %s\n",lvl,o,m,bl);
     25#elif defined MOBILE2D
     26        char buf[1000];
     27        sprintf(buf,"%s%s::%s - %s\n",lvl,o,m,bl);
     28        OutputDebugString(Util::strTOwstr(buf).c_str());
     29#else
     30        fprintf(w>0?stderr:stdout,"%s%s::%s - %s\n",lvl,o,m,bl);
     31#endif
     32}
     33*/
    834
    935void FMprintf(const char *o,const char *m,int w,const char *bl, ...)
     
    1238   va_list argptr;
    1339   va_start(argptr,bl);
    14   vsnprintf(buf,10000,bl,argptr);
    15   va_end(argptr);
     40        vsnprintf(buf,10000,bl,argptr);
     41        va_end(argptr);
    1642   FramMessage(o,m,buf,w);
    1743}
     
    2349   FramMessage(o,m,buf,w);
    2450}
     51
     52void FMprintf(const char *bl,...)
     53{
     54        va_list argptr;
     55        va_start(argptr,bl);
     56        FMprintf("Message","printf",0,bl,argptr);
     57        va_end(argptr);
     58}
  • cpp/gdk/framsg.h

    r66 r82  
    1 // This file is a part of the Framsticks GDK library.
    2 // Copyright (C) 2002-2011  Szymon Ulatowski.  See LICENSE.txt for details.
    3 // Refer to http://www.framsticks.com/ for further information.
    4 
    51#ifndef _FRAMSG_H_
    62#define _FRAMSG_H_
     
    106void FMprintf(const char *o,const char *m,int w,const char *bl, ...);
    117void FMprintf(const char *o,const char *m,int w,const char *bl,va_list va);
     8void FMprintf(const char *bl,...); //dla leniwych - zastepuje printf
    129void FramMessage(const char *o,const char *m,const char *bl,int w);
    1310
  • cpp/gdk/gen-config.h

    r66 r82  
    88 USE_GENCONV_xxx - configure converters
    99 USE_GENMAN_xxx - configure genman
     10*/
    1011
    11  */
     12#define BASIC_GENETICS //excludes f0-fuzzy and f8 (which is not stable for incorrect genotypes)
    1213
    1314#define USE_GENCONV_F10
    14 //#define USE_GENCONV_F21
    15 //#define USE_GENCONV_F30
    16 //#define USE_GENCONV_F40
     15#define USE_GENCONV_F20
     16#define USE_GENCONV_F32
     17#define USE_GENCONV_F40
    1718//#define USE_GENCONV_F41_TEST
    1819//#define USE_GENCONV_F50
     20//#define USE_GENCONV_F60
     21#define USE_GENCONV_F70
     22#ifndef BASIC_GENETICS
     23 #define USE_GENCONV_F81
     24#endif
     25#define USE_GENCONV_F90
    1926
    20 //#define USE_GENMAN_F0
    21 //#define USE_GENMAN_F1
    22 //#define USE_GENMAN_F2
    23 //#define USE_GENMAN_F3
    24 //#define USE_GENMAN_F4
     27#define USE_GENMAN_F0
     28#ifndef BASIC_GENETICS
     29 #define USE_GENMAN_F0FUZZY
     30#endif
     31#define USE_GENMAN_F1
     32#define USE_GENMAN_F2
     33#define USE_GENMAN_F3
     34#define USE_GENMAN_F4
    2535//#define USE_GENMAN_F5
     36//#define USE_GENMAN_F6
     37#define USE_GENMAN_F7
     38#ifndef BASIC_GENETICS
     39 #define USE_GENMAN_F8
     40#endif
     41#define USE_GENMAN_F9
     42
  • cpp/gdk/genoconv.cpp

    r66 r82  
    9090GenoConverter *gc;
    9191for (converters.start();gc=(GenoConverter*)converters();) delete gc;
    92 if (globalobject==this) globalobject=0;
    93 }
    94 
    95 GenoConvManager *GenoConvManager::globalobject=0;
     92if (globalobject==this) globalobject=NULL;
     93}
     94
     95GenoConvManager *GenoConvManager::globalobject=NULL;
    9696
    9797void GenoConvManager::addConverter(GenoConverter *gc)
  • cpp/gdk/model.cpp

    r66 r82  
    33// Refer to http://www.framsticks.com/ for further information.
    44
    5 #include "nonstd.h"
     5#include "nonstd_math.h"
    66#include "model.h"
    77#include "framsg.h"
    88#include "multimap.h"
    99#include "errmanager.h"
    10 
    11 #include <math.h>
    1210
    1311#define FIELDSTRUCT Model
     
    384382}
    385383
    386 void Model::makeGeno(Geno &g,MultiMap *map)
     384void Model::makeGeno(Geno &g,MultiMap *map,bool handle_defaults)
    387385{
    388386if ((buildstatus!=valid)&&(buildstatus!=building))
     
    419417        modelparam.select(this);
    420418        gen+="m:";
    421         modelparam.save2(gen,&defaultmodel);
     419        modelparam.save2(gen,handle_defaults ? &defaultmodel : NULL,true,!handle_defaults);
    422420        }
    423421
     
    427425        len=gen.len();
    428426        gen+="p:";
    429         partparam.save2(gen,&defaultpart);
     427        partparam.save2(gen,handle_defaults ? &defaultpart : NULL,true,!handle_defaults);
    430428        if (map)
    431429                map->add(len,gen.len()-1,partToMap(i));
     
    437435        jointparam.setParamTab(j->usedelta?f0_joint_paramtab:f0_nodeltajoint_paramtab);
    438436        gen+="j:";
    439         jointparam.save2(gen,&defaultjoint);
     437        jointparam.save2(gen,handle_defaults ? &defaultjoint : NULL,true,!handle_defaults);
    440438        if (map)
    441439                map->add(len,gen.len()-1,jointToMap(i));
     
    446444        len=gen.len();
    447445        gen+="n:";
    448         neuroparam.save2(gen,&defaultneuro);
     446        neuroparam.save2(gen,handle_defaults ? &defaultneuro : NULL,true,!handle_defaults);
    449447        if (map)
    450448                map->add(len,gen.len()-1,neuroToMap(i));
     
    477475                len=gen.len();
    478476                gen+="c:";
    479                 connparam.save2(gen,&defaultconn);
     477                connparam.save2(gen,handle_defaults ? &defaultconn : NULL,true,!handle_defaults);
    480478                if (map)
    481479                        map->add(len,gen.len()-1,neuroToMap(n->refno));
  • cpp/gdk/model.h

    r66 r82  
    66#define _MODEL_H_
    77
     8#include "nonstd_math.h"
    89#include <stdlib.h>
    9 #include <math.h>
    1010#include <stdio.h>
    1111
     
    109109/// make the model from current genotype
    110110void build();
    111 
    112 /// make f0 genotype from current construction
    113 void makeGeno(Geno &,MultiMap *map=0);
    114111
    115112friend class NeuroNetFactory;
     
    217214const Geno &getF0Geno();
    218215
     216/// make f0 genotype from current construction (low level version of getF0Geno)
     217void makeGeno(Geno &,MultiMap *map=0,bool handle_defaults=true);
     218
    219219/** @return mapping from source genotype (0-based position in text) to model elements reference numbers.
    220220    the map can be empty if the mapping hasn't been requested earlier (in constructor)
  • cpp/gdk/multirange.cpp

    r66 r82  
    44
    55#include "multirange.h"
     6#include "nonstd_stl.h"
    67
    78#include <stdio.h>
  • cpp/gdk/neuroimpl-channels.cpp

    r66 r82  
    44
    55#include "neuroimpl-channels.h"
     6#include "nonstd_stl.h"
    67
    78void NI_Channelize::go()
  • cpp/gdk/neuroimpl-fuzzy-f0.cpp

    r66 r82  
    77
    88#include "neuroimpl-fuzzy-f0.h"
    9 // nonstd z powodu max()
    10 #include "nonstd.h"
     9#include "nonstd_stl.h" //min,max
    1110
    1211//this part concerns fuzzy sets transformation
  • cpp/gdk/neuroimpl-fuzzy.cpp

    r66 r82  
    55#include "neuroimpl-fuzzy.h"
    66#include "neuroimpl-fuzzy-f0.h"
     7#include "nonstd_stl.h" //min,max
    78
    89int NI_FuzzyNeuro::countOuts(const Model *m, const Neuro *fuzzy)
  • cpp/gdk/nonstd.h

    r69 r82  
    1 //Define rnd01, rnd0N, and randomN so that they
    2 //work in your C++ environment.
    3 //Some other functions/macros may also be needed if they
    4 //are missing in your environment, like min, max, etc.
     1#ifndef _NONSTD_H_
     2#define _NONSTD_H_
    53
    6 #ifndef __NONSTD_H
    7 #define __NONSTD_H
    8 
    9 #define APPLICATION_NAME "Framsticks"
    10 #define MAIN_FRAMSTICKS
    114#define SAFEDELETE(p) {if (p) {delete p; p=NULL;}}
    125#define SAFEDELETEARRAY(p) {if (p) {delete[] p; p=NULL;}}
    136
    14 //#ifndef _Windows   included below?
    15 //#include <stdlib.h>
    16 //#endif
     7#define roundToInt(x) ((int)(floor((x)+0.5)))
     8
     9
     10#define CPP_STR(s) CPP_XSTR(s)
     11#define CPP_XSTR(s) #s
     12
    1713
    1814#define DB(x) //output debug info. If needed, use #define DB(x) x
    1915//#define DB(x) x
    2016
     17
    2118// ms visual c++
    2219#ifdef _MSC_VER
    23  #define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
    24  #include <windows.h>
    25  #include <stdio.h>
    26  #include <stdarg.h>
     20 #include <stdio.h> //musi byc najpierw ten include zeby robic definy ponizej (albo bedzie '_vsnprintf': attributes inconsistent with previous declaration, stdio.h:358)
    2721 #define vsnprintf _vsnprintf
    28  #define _USE_MATH_DEFINES //after this is defined, the next #include <math.h> or <cmath> will define:
    29  //#ifndef M_PI
    30  //#define M_PI 3.1415926535897932384626433832795
    31  //#endif
    32  //#ifndef M_PI_2
    33  //#define M_PI_2 (M_PI/2)
    34  //#endif
     22 #define snprintf _snprintf
     23#endif
    3524
     25#ifdef MOBILE2D
     26 #define strdup _strdup
    3627#endif
    3728
    3829/////////////////////////////////////////////////////// 64-bit int type and other macros
    39 #ifdef _Windows
     30#ifdef _WIN32
    4031        typedef __int64 LONGLONG;
    41         #define PATHSEPARATORCHAR '\\'
    42         #define PATHSEPARATORSTRING "\\"
     32        #define PATH_SEPARATOR_CHAR '\\'
     33        #define PATH_SEPARATOR_STRING "\\"
    4334        #define FPU_THROWS_EXCEPTIONS
    4435        #define FOPEN_READ "rt"
     
    4738#else
    4839        #define LONGLONG long long int
    49         #define PATHSEPARATORCHAR '/'
    50         #define PATHSEPARATORSTRING "/"
     40        #define PATH_SEPARATOR_CHAR '/'
     41        #define PATH_SEPARATOR_STRING "/"
    5142        #define FOPEN_READ "r"
    5243        #define FOPEN_WRITE "w"
     
    5445#endif
    5546
    56 #ifdef __BORLANDC__
    57         #define fileExists(f) (!access(f,0))
    58         #include "stdlib.h" //random
    59         #define rnd01 ((double)((double)_lrand()/(double)(LRAND_MAX+1)))
    60         //#define rnd01 ((double)((double)rand()/(RAND_MAX+1)))
    61         #define rnd0N(num) ((double)((num)*rnd01))
    62         #define randomN(num) random(num) //uses _lrand
    63 #else
    64         #ifdef _MSC_VER
    65         #define fileExists(f) (!access(f,0))
    66         #else
    67         #define fileExists(f) (!access(f,R_OK))
    68         #endif
    6947
    70         //#define FLOATRAND
    71         #ifdef FLOATRAND
    72                 #define randomN(x) ((int)((x)*drand48()))
    73                 #define rnd01 (drand48())
    74                 #define rnd0N(x) (drand48()*(x))
    75         #else
    76                 #define rnd01 ((double)(rand()/(RAND_MAX+1.0)))
    77                 #define rnd0N(x) ((x)*rnd01)
    78                 #define randomN(x) ((int)rnd0N(x))
    79         #endif
     48
     49#ifdef LINUX
     50 #include <strings.h>
     51 #define stricmp(a,b) strcasecmp(a,b)
     52 #define _isnan(a) isnan(a) //do nonstd_math.h?
     53 #define GET_APP_HOME "./"
     54 #define GET_APP_RESOURCES "./"
    8055#endif
    8156
    82 
    83 #ifdef __GNUC__
    84 /*
    85         #define min(a,b) (((a)>(b))?(b):(a))
    86         #define max(a,b) (((a)>(b))?(a):(b))
    87         #define abs(a) ((a)>=0?(a):-(a))
    88 */
    89 #include <algorithm>
    90 using namespace std;
     57#ifdef IPHONE
     58 #include <string>
     59 #define _isnan(a) isnan(a) //do nonstd_math.h?
     60 std::string getAppHome(); //w tym pliku deklaracja funkcji nie pasuje...
     61 std::string getAppResources();
     62 #define GET_APP_HOME getAppHome()
     63 #define GET_APP_RESOURCES getAppResources()
    9164#endif
    9265
    93 #ifdef DEFINE_STRICMP_AS_STRCASECMP
    94 #define stricmp(a,b) strcasecmp(a,b)
     66#ifdef SHP
     67 //#define __assert_func(a,b,c,d) 0 //Currently, we are sorry to inform you that assert() is not yet supported. We have considered your request for internal discussion. No ale na szczêœcie w³asna (byle by by³a, bo i tak zak³adamy ze assert ktore przeciez dziala tylko w trybie debug nie jest potrzebne na bada) implementacja w "bada-assert.cpp"
     68 #define GET_APP_HOME "/Home/"
     69 #define GET_APP_RESOURCES "/Res/"
    9570#endif
    9671
     72#if defined(_WIN32) && !defined(SHP)
     73    #define GET_APP_HOME ".\\"
     74    #define GET_APP_RESOURCES ".\\"
    9775#endif
     76
     77//typedef unsigned char boolean; //niestety nie mozna uzyc 'bool' bo VC w rpcndr.h wlasnie tak definiuje booleana, jako unsigned char
     78//typedef char byte; //rozne srodowiska c++ definiuja byte jako unsigned char! w javie jest inaczej -> trzeba i tak zmienic w portowanych zrodlach byte na char.
     79
     80#endif
Note: See TracChangeset for help on using the changeset viewer.