1. biolab
  2. Untitled project
  3. orange

Commits

Aleš Erjavec  committed 2bb7726

Fixes for clang compiler support.

Added 'TOrangeVector::classDescription()' specialization to
'DEFINE_TOrangeVector_classDescription' macro and removed its default implementation
in the template class (static 'st_classDescription' member must be initialized/specialized before
its use).

A similar problem arises in the included '.ppp' files where st_classDescription is used. So I
moved all '.ppp. includes after the "DEFINE_*"s.

Removed unnecessary/duplicate VWRAPPER/WRAPPER uses.

Added 'this->...' qualifier in template classes (that inherit a from a template class) for
accessing base class methods, otherwise clang does not find them (as per C++ standard).

Moved the TVarList and TAttributed*List definitions/implementations from 'orvector' to 'vars'.
Fixed includes in other files using the two headers accordingly.

Fixed some casts to int with more appropriate casts to size_t/uintptr_t.

Added explicit casts of constants to template class in include/stat.hpp
statistics functions.

(references #1219).

  • Participants
  • Parent commits d8f18f7
  • Branches default

Comments (0)

Files changed (33)

File source/include/stat.hpp

View file
 
 
 template<class T>
+T middleelement(const vector<T> &med)
+{ DEFINE_TYPENAME
+  const_iterator medmid(med.begin()+med.size()/2);
+  if (med.size()%2)
+    return *min_element(medmid, med.end());
+  else
+    return (*max_element(med.begin(), medmid) + *min_element(medmid, med.end()))/2.0;
+}
+
+
+template<class T>
 T median(const vector<T> &med)
 { if (!med.size())
     throw StatException("median: empty list");
 
 
 template<class T>
-T middleelement(const vector<T> &med)
-{ DEFINE_TYPENAME
-  const_iterator medmid(med.begin()+med.size()/2);
-  if (med.size()%2)
-    return *min_element(medmid, med.end());
-  else
-    return (*max_element(med.begin(), medmid) + *min_element(medmid, med.end()))/2.0;
-}
-
-
-template<class T>
 int mode(const vector<T> &flist, vector<T> &mode)
 { DEFINE_TYPENAME
   typedef typename map<T, int>::iterator mapiterator;
 
 /* *********** MOMENTS ************/
 
+
+template<class T> T samplevar(const vector<T>&);
+template<class T> T samplestdev(const vector<T>&);
+
+
 template<class T>
 T moment(const vector<T> &flist, const int &mom)
 { DEFINE_TYPENAME
 
   min=*min_element(flist.begin(), flist.end());
   max=*max_element(flist.begin(), flist.end());
-  T ebw=(max-min)/T(numbins) + 1.0;
+  T ebw=(max-min)/T(numbins) + T(1.0);
   binsize=(max-min+ebw)/T(numbins);
-  min-=binsize/2;
+  min-=binsize/T(2);
 
   counts=vector<int>(numbins, 0);
   extrapoints=0;
 {
     static T cof[6] = {76.18009173, -86.50532033, 24.01409822, -1.231739516, 0.120858003e-2, -0.536382e-5};
 
-    T x=xx, y=xx, tmp=x+5.5;
-    tmp-=(x+0.5)*log(tmp);
+    T x=xx, y=xx, tmp=x+T(5.5);
+    tmp-=(x+T(0.5))*log(tmp);
     T ser=1.000000000190015;
     for(int j=0; j<6; j++)
      ser+=cof[j]/++y;
   const T EPS=3.0e-7;
 
   gln = gammln(a);
-  T b=x+1.0-a;
+  T b=x+T(1.0)-a;
   T c=T(1.0)/FPMIN;
   T d=T(1.0)/b;
   T h=d;
   for(int i=1; i<=ITMAX; i++) {
-    T an=(a-double(i))*i;
-    b += 2.0;
+    T an=(a-T(double(i)))*i;
+    b += T(2.0);
     d=an*d+b;
     if (abs(d) < FPMIN) d=FPMIN;
     c=b+an/c;
     d=T(1.0)/d;
     T del=d*c;
     h *= del;
-    if (abs(del-1.0) < EPS)
+    if (abs(del-T(1.0)) < EPS)
       return exp(-x+a*log(x)-gln)*h;
   }
 
 { const int ITMAX=100;
   const T EPS=3.0e-7;
   gln=gammln(a);
-  if (x<=0.0)
+  if (x<=T(0.0))
     throw StatException("gser: negative x");
 
   T ap=a;
 
 template<class T>
 T gammp(const T &a, const T &x)
-{ if ((x<0.0) || (a<=0.0))
+{ if ((x<T(0.0)) || (a<=T(0.0)))
     throw StatException("gammp: invalid arguments");
 
   T gln;
-  return (x<(a+1.0)) ? gammser(a, x, gln) : -gammcf(a, x, gln)+1.0;
+  return (x<(a+T(1.0))) ? gammser(a, x, gln) : -gammcf(a, x, gln)+T(1.0);
 }
 
 
 template<class T>
 T gammq(const T &a, const T &x)
-{ if ((x<0.0) || (a<=0.0))
+{ if ((x<T(0.0)) || (a<=T(0.0)))
     throw StatException("gammp: invalid arguments");
 
   T gln;
-  return (x<(a+1.0)) ? -gammser(a, x, gln)+1.0 : gammcf(a, x, gln);
+  return (x<(a+T(1.0))) ? -gammser(a, x, gln)+T(1.0) : gammcf(a, x, gln);
 }
 
       
     T bm=1.0, az=1.0, am=1.0;
 
     T qab=a+b;
-    T qap=a+1.0;
-    T qam=a-1.0;
-    T bz= -qab*x/qap + 1.0;
+    T qap=a+T(1.0);
+    T qam=a-T(1.0);
+    T bz= -qab*x/qap + T(1.0);
     for(int i=0; i<=ITMAX; i++) {
 	    T em = i+1;
 	    T tem = em*2;
 { if ((x<0.0) || (x>1.0))
     throw StatException("betai: bad x");
 
-  T bt= ((x==0.0) || (x==1.0)) ? 0.0 : exp(gammln(a+b)-gammln(a)-gammln(b)+a*log(x)+b*log(- x + 1.0));
-  return (x < (a+1.0)/(a+b+2.0)) ? bt*betacf(a,b,x)/a : -bt*betacf(b,a, -x+1.0)/b + 1.0;
+  T bt= ((x==0.0) || (x==1.0)) ? 0.0 : exp(gammln(a+b)-gammln(a)-gammln(b)+a*log(x)+b*log(- x + T(1.0)));
+  return (x < (a+T(1.0))/(a+b+T(2.0))) ? bt*betacf(a,b,x)/a : -bt*betacf(b,a, -x+T(1.0))/b + T(1.0);
 }
 
 
     else if (y < 1.0) {
       T w = sqr(y);
 	    x = ((((((((w * 0.000124818987
-                  -0.001075204047) * w +0.005198775019) * w
-                -0.019198292004) * w +0.059054035642) * w
-              -0.151968751364) * w +0.319152932694) * w
-            -0.531923007300) * w +0.797884560593) * y * 2.0;
+                  -T(0.001075204047)) * w + T(005198775019.0)) * w
+                -T(0.019198292004)) * w + T(0.059054035642)) * w
+              -T(0.151968751364)) * w + T(0.319152932694)) * w
+            -T(0.531923007300)) * w + T(0.797884560593)) * y * 2.0;
     }
 	  else {
 	    y -= 2.0;
-	    x = (((((((((((((y * -0.000045255659
-                       +0.000152529290) * y -0.000019538132) * y
-                     -0.000676904986) * y +0.001390604284) * y
-                   -0.000794620820) * y -0.002034254874) * y
-                 +0.006549791214) * y -0.010557625006) * y
-               +0.011630447319) * y -0.009279453341) * y
-             +0.005353579108) * y -0.002141268741) * y
-           +0.000535310849) * y +0.999936657524;
+	    x = (((((((((((((y * T(-0.000045255659)
+                       +T(0.000152529290)) * y - T(0.000019538132)) * y
+                     -T(0.000676904986)) * y + T(0.001390604284)) * y
+                   -T(0.000794620820)) * y - T(0.002034254874)) * y
+                 +T(0.006549791214)) * y - T(0.010557625006)) * y
+               +T(0.011630447319)) * y - T(0.009279453341)) * y
+             +T(0.005353579108)) * y - T(0.002141268741)) * y
+           +T(0.000535310849)) * y + T(0.999936657524);
     }
   }
 
-  return (z > 0.0) ? (x+1.0)*0.5 : (-x+1.0)*0.5;
+  return (z > 0.0) ? (x+T(1.0))*T(0.5) : (-x+T(1.0))*T(0.5);
 }
 
 
 template<class T>
 T erfcc(const T& x)
 { T z = abs(x);
-  T t = T(1.0) / (z*0.5+1.0);
-  T ans = t * exp(-z*z-1.26551223 + t*(t*(t*(t*(t*(t*(t*(t*(t*0.17087277-0.82215223)+1.48851587)-1.13520398)+0.27886807)-0.18628806)+0.9678418)+0.37409196)+1.00002368));
-  return (x >= 0.0) ?  ans : -ans +2.0;
+  T t = T(1.0) / (z*T(0.5)+T(1.0));
+  T ans = t * exp(-z*z-T(1.26551223) + t*(t*(t*(t*(t*(t*(t*(t*(t*T(0.17087277-0.82215223))+T(1.48851587))-T(1.13520398))+T(0.27886807))-T(0.18628806))+T(0.9678418))+T(0.37409196))+T(1.00002368)));
+  return (x >= 0.0) ?  ans : -ans + T(2.0);
 }
 
 
   T r_den = sqrt( (sumx2*n - sqr(sumx) ) * (sumy2*n - sqr(sumy)) );
   T r = r_num / r_den;
   T df=n-2;
-  T t = r * sqrt( df / ( (-r+1.0+TINY)*(r+1.0+TINY) ) );
+  T t = r * sqrt( df / ( (-r+T(1.0)+T(TINY))*(r+T(1.0)+T(TINY)) ) );
   probrs=betai(df*0.5, T(0.5), df/(df+t*t));
   return r;
 }
   T r_den = sqrt( (sumx2*n - sqr(sumx) ) * (sumy2*n - sqr(sumy)) );
   r = r_num / r_den;
   T df=n-2;
-  T t = r * sqrt( df / ( (-r+1.0+TINY)*(r+1.0+TINY) ) );
+  T t = r * sqrt( df / ( (-r+T(1.0)+T(TINY))*(r+T(1.0)+T(TINY)) ) );
   probrs=betai(df*0.5, T(0.5), df/(df+t*t));
 
 //  T z = log((r+1.0+TINY)/(-r+1.0+TINY));
 
   slope = r_num / (sumx2*n - sqr(sumx));
   intercepr = meany - slope*meanx;
-  sterrest = sqrt(-sqr(r)+1.0) * samplestdev(flist2);
+  sterrest = sqrt(-sqr(r)+T(1.0)) * samplestdev(flist2);
 }
 
 
 template<class T>
 T ttest_1samp(const vector<T> &flist, const T &popmean, T &prob)
 {
-  T n=flist.size(), df=n-1.0;
+  T n=flist.size(), df=n-T(1.0);
   T t= (mean(flist) - popmean) / sqrt(var(flist)/n);
   prob=betai(df*0.5, T(0.5), df/(df+t*t));
   return t;
 
 template<class T>
 T ttest_ind(const vector<T> &x, const vector<T> &y, T &prob)
-{ T n1=x.size(), n2=y.size(), df=n1+n2-2.0;
-  T svar= ( sqr(stdev(x))*(n1-1.0) + sqr(stdev(y))*(n2-1.0) )  /  df;
+{ T n1=x.size(), n2=y.size(), df=n1+n2-T(2.0);
+  T svar= ( sqr(stdev(x))*(n1-T(1.0)) + sqr(stdev(y))*(n2-T(1.0)) )  /  df;
   T t= ( mean(x) - mean(y) ) / sqrt(svar * ( (n1+n2)/(n1*n2) ) );
   prob=betai(df*0.5, T(0.5), df/(df+t*t));
   return t;
   T cov=0.0;
   for(int i=0; i<x.size(); i++)
     cov += (x[i]-meanx) * (y[i]-meany);
-  T df=n-1.0;
+  T df=n-T(1.0);
   cov /= df;
-  T sd = sqrt((var(x)+var(y) - cov*2.0)/n);
+  T sd = sqrt((var(x)+var(y) - cov*T(2.0))/n);
   if (sd==0.0)
     throw StatException("ttest_rel: sd==0, can't divide");
   T t = (mean(x)-mean(y))/sd;

File source/orange/assoc.cpp

View file
 #include "spec_gen.hpp"
 #include "table.hpp"
 
-#include "assoc.ppp"
+#include "assoc.hpp"
 
 DEFINE_TOrangeVector_classDescription(PAssociationRule, "TAssociationRules", true, ORANGE_API)
 
+#include "assoc.ppp"
 
 TItemSetValue::TItemSetValue(int al)
 : value(al),

File source/orange/assoc.hpp

View file
 #include "examples.hpp"
 #include "classify.hpp"
 #include "learn.hpp"
+#include "orvector.hpp"
 
 WRAPPER(Example)
-VWRAPPER(IntList)
 WRAPPER(ExampleTable)
 
 class ORANGE_API TAssociationRule : public TOrange {

File source/orange/c4.5.cpp

View file
 #include "learn.hpp"
 #include "getarg.hpp"
 
-#include "c4.5.ppp"
+#include "c4.5.hpp"
 
 DEFINE_TOrangeVector_classDescription(PC45TreeNode, "TC45TreeNodeList", true, ORANGE_API)
 
+#include "c4.5.ppp"
+
 bool c45Loaded = false;
 
 typedef void *learnFunc(int trials, char gainRatio, char subset, char batch, char probThresh,

File source/orange/callback.cpp

View file
 }
 
 PFilter TFilter_Python::deepCopy() const
-{   
+{
+    const char * method = PyObject_HasAttrString((PyObject *)myWrapper, "deep_copy") ? "deep_copy" : "deepCopy";
+
     PyObject *result = PyObject_CallMethod((PyObject *) myWrapper,
-            PyObject_HasAttrString((PyObject *)myWrapper, "deep_copy") ? "deep_copy" : "deepCopy",
+            (char *) method,
             NULL);
     if (!result)
         raiseError("An exception has been thrown in method deepCopy!");

File source/orange/cls_example.cpp

View file
 
 PyObject *Example_reference(TPyExample *pex) PYARGS(METH_NOARGS, "unique reference (pointer to) the object")
 {
-  return PyInt_FromLong(int(&PyExample_AS_ExampleReference(pex)));
+  return PyInt_FromSize_t(size_t(&PyExample_AS_ExampleReference(pex)));
 }
 
 

File source/orange/converts.hpp

View file
 PyObject *convertToPython(const string &);
 PyObject *convertToPython(const float &);
 PyObject *convertToPython(const pair<float, float> &);
+PyObject *convertToPython(const pair<int, float> &);
 PyObject *convertToPython(const int &);
+PyObject *convertToPython(const long &);
 PyObject *convertToPython(const unsigned char &);
 PyObject *convertToPython(const bool &);
 
 string convertToString(const string &);
 string convertToString(const float &);
 string convertToString(const pair<float, float> &);
+string convertToString(const pair<int, float> &);
 string convertToString(const int &);
+string convertToString(const long &);
 string convertToString(const unsigned char &);
 //string convertToString(const PContingency &);
 

File source/orange/domaindepot.hpp

View file
 using namespace std;
 
 #include "getarg.hpp"
+#include "orvector.hpp"
+#include "vars.hpp"
+#include "domain.hpp"
 
-VWRAPPER(StringList)
-VWRAPPER(VarList)
-WRAPPER(Domain)
 class TMetaVector;
 
 #define TDomainList TOrangeVector<PDomain> 

File source/orange/estimateprob.cpp

View file
 #include "contingency.hpp"
 #include "examplegen.hpp"
 
-#include "estimateprob.ppp"
+#include "estimateprob.hpp"
 #include "stat.hpp"
 #include "random.hpp"
 
 DEFINE_TOrangeVector_classDescription(PProbabilityEstimator, "TProbabilityEstimatorList", true, ORANGE_API)
 DEFINE_TOrangeVector_classDescription(PConditionalProbabilityEstimator, "TConditionalProbabilityEstimatorList", true, ORANGE_API)
 
+#include "estimateprob.ppp"
+
 TProbabilityEstimator::TProbabilityEstimator(const bool &disc, const bool &cont)
 : supportsDiscrete(disc),
   supportsContinuous(cont)

File source/orange/exampleclustering.hpp

View file
 
 PClassifier completeTable(PExampleGenerator examples, int completion, int weightID=0);
 
-
 WRAPPER(ExampleCluster);
 WRAPPER(Example);
 
 };
 
 
-#define TExampleSets TOrangeVector<PExampleGenerator> 
-VWRAPPER(ExampleSets)
-
+#define PExampleSets PExampleGeneratorList
+#define TExampleSets TExampleGeneratorList
 
 WRAPPER(Classifier)
 WRAPPER(Variable)

File source/orange/examplegen.hpp

View file
   TExampleIterator(TExampleGenerator *agen=NULL, TExample *anexam=NULL, void *adata =NULL);
   TExampleIterator(const TExample &anexam, TExampleGenerator *agen=NULL, void *adata =NULL);
   TExampleIterator(PDomain domain, TExampleGenerator *agen=NULL, void *adata =NULL);
-  TExampleIterator::TExampleIterator(const TExampleIterator &other);
+  TExampleIterator(const TExampleIterator &other);
   int traverse(visitproc visit, void *arg) const;
   int dropReferences();
   ~TExampleIterator();

File source/orange/filter.cpp

View file
 #include "distvars.hpp"
 #include "examplegen.hpp"
 
-#include "filter.ppp"
-
+#include "filter.hpp"
 
 DEFINE_TOrangeVector_classDescription(PValueFilter, "TValueFilterList", true, ORANGE_API)
 DEFINE_TOrangeVector_classDescription(PFilter, "TFilterList", true, ORANGE_API)
 
+#include "filter.ppp"
+
+
 // Sets the negate field (default is false)
 TFilter::TFilter(bool anegate, PDomain dom) 
 : negate(anegate),

File source/orange/filter.hpp

View file
 #include "examples.hpp"
 #include "distvars.hpp"
 #include "trindex.hpp"
+#include "orvector.hpp"
+#include "vars.hpp"
 
 
 WRAPPER(Filter);

File source/orange/garbage.hpp

View file
 
   inline bool operator < (const GCPtr<T> &ps) const
   { return    (!counter && ps.counter)
-           || (int(counter->ptr) < int(ps.counter->ptr)); }
+           || (uintptr_t(counter->ptr) < uintptr_t(ps.counter->ptr)); }
 
 
   inline T *getUnwrappedPtr()

File source/orange/hclust.cpp

View file
 
 #include "progress.hpp"
 
+#include "hclust.hpp"
+
+DEFINE_TOrangeVector_classDescription(PHierarchicalCluster, "THierarchicalClusterList", true, ORANGE_API)
+
 #include "hclust.ppp"
 
-DEFINE_TOrangeVector_classDescription(PHierarchicalCluster, "THierarchicalClusterList", true, ORANGE_API)
 
 class TClusterW {
 public:

File source/orange/lib_preprocess.cpp

View file
 
 typedef MapMethods<PVariableFilterMap, TVariableFilterMap, PVariable, PValueFilter> TMM_VariableFilterMap;
 
+INITIALIZE_MAPMETHODS(TMM_VariableFilterMap, &PyOrVariable_Type, &PyOrValueFilter_Type, _orangeValueFromPython<PVariable>, _orangeValueFromPython<PValueFilter>, _orangeValueToPython<PVariable>, _orangeValueToPython<PValueFilter>)
+
 int VariableFilterMap_setitemlow(TVariableFilterMap *aMap, PVariable var, PyObject *pyvalue)
 {
   PValueFilter value;
 
 
 // modified setitem to accept intervals/names of values
-INITIALIZE_MAPMETHODS(TMM_VariableFilterMap, &PyOrVariable_Type, &PyOrValueFilter_Type, _orangeValueFromPython<PVariable>, _orangeValueFromPython<PValueFilter>, _orangeValueToPython<PVariable>, _orangeValueToPython<PValueFilter>)
 
 PVariableFilterMap PVariableFilterMap_FromArguments(PyObject *arg) { return TMM_VariableFilterMap::P_FromArguments(arg); }
 PyObject *VariableFilterMap_FromArguments(PyTypeObject *type, PyObject *arg) { return TMM_VariableFilterMap::_FromArguments(type, arg); }

File source/orange/ormap.hpp

View file
 { public:
     int traverse(visitproc visit, void *arg) const
     { TRAVERSE(TOrange::traverse);
-      for(typename TOrangeMap<K, V>::const_iterator be=begin(), ee=end(); be!=ee; be++)
+      for(typename TOrangeMap<K, V>::const_iterator be=this->begin(), ee=this->end(); be!=ee; be++)
         PVISIT((*be).first);
       return 0;
     }
 { public:
     int traverse(visitproc visit, void *arg) const
     { TRAVERSE(TOrange::traverse);
-      for(typename TOrangeMap<K,V>::const_iterator be=begin(), ee=end(); be!=ee; be++)
+      for(typename TOrangeMap<K,V>::const_iterator be=this->begin(), ee=this->end(); be!=ee; be++)
         if (this->value_is_orange)
           PVISIT((*be).second);
       return 0;
 
     int traverse(visitproc visit, void *arg) const
     { TRAVERSE(TOrange::traverse);
-      for(const_iterator be=begin(), ee=end(); be!=ee; be++) {
+      for(const_iterator be=this->begin(), ee=this->end(); be!=ee; be++) {
         PVISIT((*be).first);
         PVISIT((*be).second);
       }

File source/orange/orvector.cpp

View file
   #pragma warning (disable : 4290)
 #endif
 
-#include "orvector.ppp"
+#include "orvector.hpp"
 
 DEFINE_TOrangeVector_classDescription(bool, "TBoolList", false, ORANGE_API)
 DEFINE_TOrangeVector_classDescription(char, "TBoolList", false, ORANGE_API)
 DEFINE_TOrangeVector_classDescription(PFloatList, "TFloatListList", true, ORANGE_API)
 
 
-DEFINE_AttributedList_classDescription(TAttributedFloatList, TFloatList)
-DEFINE_AttributedList_classDescription(TAttributedBoolList, TBoolList)
-
-// TValueList's properties are defined in vars.cpp
-
 #define pff pair<float, float>
 DEFINE_TOrangeVector_classDescription(pff, "TFloatFloatList", false, ORANGE_API)
 
 #define pif pair<int, float>
 DEFINE_TOrangeVector_classDescription(pif, "TIntFloatList", false, ORANGE_API)
 
-#ifdef _MSC_VER_60
-TClassDescription template TOrangeVector<TValue, false>::st_classDescription;
-ORANGE_EXTERN template class ORANGE_API TOrangeVector<TValue, false>;
-#else
- DEFINE_TOrangeVector_classDescription(TValue, "TOrangeVector<TValue, false>", false, ORANGE_API)
-//template<> TClassDescription TOrangeVector<TValue, false>::st_classDescription; // =  = { "StringList", &typeid(TValueList), &TOrange::st_classDescription, TOrange_properties, TOrange_components };
-#endif
-
-
 
 /* This function is stolen from Python 2.3 (file listobject.c):
    n between 2^m-1 and 2^m, is round up to a multiple of 2^(m-5) */

File source/orange/orvector.hpp

View file
  #pragma warning (disable : 4786 4114 4018 4267)
 #endif
 
+#include <cstddef>
 #include <vector>
 #include "root.hpp"
 #include "stladdon.hpp"
 #else
   #define DEFINE_TOrangeVector_classDescription(_TYPE, _NAME, _WRAPPED, _API) \
     template<> \
-    TClassDescription TOrangeVector< _TYPE, _WRAPPED >::st_classDescription = { _NAME, &typeid(TOrangeVector< _TYPE, _WRAPPED >), &TOrange::st_classDescription, TOrange_properties, TOrange_components };
+    TClassDescription TOrangeVector< _TYPE, _WRAPPED >::st_classDescription = { \
+      _NAME, \
+      &typeid(TOrangeVector< _TYPE, _WRAPPED >), \
+      &TOrange::st_classDescription, \
+      TOrange_properties, \
+      TOrange_components }; \
+  \
+  template<> \
+  TClassDescription const *TOrangeVector< _TYPE, _WRAPPED >::classDescription() const { \
+      return &st_classDescription; \
+  }
 #endif
 
 
 
-  #define DEFINE_AttributedList_classDescription(_NAME, _PARENT) \
+#define DEFINE_AttributedList_classDescription(_NAME, _PARENT) \
   TPropertyDescription _NAME##_properties[] = { \
-    {"attributes", "list of attributes (for indexing)", &typeid(POrange), &TVarList::st_classDescription, offsetof(_NAME, attributes), false, false}, \
+    {"attributes", \
+     "list of attributes (for indexing)", \
+     &typeid(POrange), \
+     &TVarList::st_classDescription, \
+     offsetof(_NAME, attributes), \
+     false, \
+     false}, \
     {NULL} \
   }; \
-   \
+  \
   size_t const _NAME##_components[] = { offsetof(_NAME, attributes), 0}; \
-   \
-  TClassDescription _NAME::st_classDescription = { #_NAME, &typeid(_NAME), &_PARENT::st_classDescription, _NAME##_properties, _NAME##_components }; \
-  TClassDescription const *_NAME::classDescription() const { return &_NAME::st_classDescription; } \
-  TOrange *_NAME::clone() const { return mlnew _NAME(*this); }
-
+  \
+  TClassDescription _NAME::st_classDescription = { \
+     #_NAME, \
+     &typeid(_NAME), \
+     &_PARENT::st_classDescription, \
+     _NAME##_properties, \
+     _NAME##_components \
+  }; \
+  \
+  TClassDescription const *_NAME::classDescription() const { \
+      return &_NAME::st_classDescription; \
+  } \
+  \
+  TOrange *_NAME::clone() const { \
+      return mlnew _NAME(*this); \
+  }
 
 
 int ORANGE_API _RoundUpSize(const int &n);
     iterator _First, _Last, _End;
 
     static TClassDescription st_classDescription;
-    virtual TClassDescription const *classDescription() const     { return &st_classDescription; }
+    virtual TClassDescription const *classDescription() const;
     virtual TOrange *clone() const                                { return mlnew TOrangeVector<T, Wrapped>(*this); }
 
     class reverse_iterator {
 #define TFloatFloatList TOrangeVector<pair<float, float>, false >
 #define TDoubleList TOrangeVector<double, false>
 #define TStringList TOrangeVector<string, false>
-
 #define TFloatListList TOrangeVector<PFloatList>
 
 VWRAPPER(BoolList)
 VWRAPPER(DoubleList)
 VWRAPPER(StringList)
 
-WRAPPER(Variable)
-
-#include "values.hpp"
-#include "vars.hpp"
-
-#ifdef _MSC_VER
-  #pragma warning(push)
-  #pragma warning(disable: 4275)
-#endif
-
-/* This is to fool pyprops
-#define TValueList _TOrangeVector<float>
-*/
-
-
-
-#define TVarList TOrangeVector<PVariable> 
-VWRAPPER(VarList)
-
-
-#define __REGISTER_NO_PYPROPS_CLASS __REGISTER_CLASS
-
-class ORANGE_API TAttributedFloatList : public TOrangeVector<float, false>
-{
-public:
-  __REGISTER_NO_PYPROPS_CLASS
-
-  PVarList attributes;
-
-  inline TAttributedFloatList()
-  {}
-
-  inline TAttributedFloatList(PVarList vlist)
-  : attributes(vlist)
-  {}
-
-  inline TAttributedFloatList(PVarList vlist, const int &i_N, const float &f = 0.0)
-  : TOrangeVector<float, false>(i_N, f),
-    attributes(vlist)
-  {}
-
-  inline TAttributedFloatList(PVarList vlist, const vector<float> &i_X)
-  : TOrangeVector<float,false>(i_X),
-    attributes(vlist)
-  {}
-};
-
-
-class ORANGE_API TAttributedBoolList : public TOrangeVector<bool, false>
-{
-public:
-  __REGISTER_NO_PYPROPS_CLASS
-
-  PVarList attributes;
-
-  inline TAttributedBoolList()
-  {}
-
-  inline TAttributedBoolList(PVarList vlist)
-  : attributes(vlist)
-  {}
-
-  inline TAttributedBoolList(PVarList vlist, const int &i_N, const bool b= false)
-  : TOrangeVector<bool, false>(i_N, b),
-    attributes(vlist)
-  {}
-
-  inline TAttributedBoolList(PVarList vlist, const vector<bool> &i_X)
-  : TOrangeVector<bool, false>(i_X),
-    attributes(vlist)
-  {}
-};
-
-
-
-class ORANGE_API TValueList : public TOrangeVector<TValue, false>
-{
-public:
-  __REGISTER_CLASS
-
-  PVariable variable; //P the variable to which the list applies
-
-  inline TValueList(PVariable var = PVariable())
-  : TOrangeVector<TValue, false>(),
-    variable(var)
-  {}
- 
-  inline TValueList(const int &N, const TValue &V = TValue(), PVariable var = PVariable())
-  : TOrangeVector<TValue, false>(N, V),
-    variable(var)
-  {}
-
-  inline TValueList(const TOrangeVector<TValue, false> &i_X, PVariable var = PVariable())
-  : TOrangeVector<TValue, false>(i_X),
-    variable(var)
-  {}
-
-  inline TValueList(const TValueList &other)
-  : TOrangeVector<TValue, false>(other),
-    variable(other.variable)
-  {}
-
-  int traverse(visitproc visit, void *arg) const
-  { 
-    TRAVERSE(TOrange::traverse);
-
-    for(TValue *p = _First; p != _Last; p++)
-      if (p->svalV)
-        PVISIT(p->svalV);
-
-    return 0;
-  }
-
-  int dropReferences()
-  { DROPREFERENCES(TOrange::dropReferences);
-    return 0;
-  }
-};
-
-
-WRAPPER(ValueList)
-
-#ifdef _MSC_VER
-  #pragma warning(pop)
-#endif
-
-/* This is to fool pyprops.py
-#define TAttributedFloatList _TOrangeVector<float>
-#define TAttributedBoolList _TOrangeVector<bool>
-*/
-WRAPPER(AttributedFloatList)
-WRAPPER(AttributedBoolList)
 
 #ifdef _MSC_VER
   #pragma warning (push)
   #pragma warning (disable : 4290)
   template class ORANGE_API std::vector<int>;
   template class ORANGE_API std::vector<float>;
+
+  template class ORANGE_API std::vector<pair<int, int> >;
+  template class ORANGE_API std::vector<int>;
   #pragma warning (pop)
 #endif
 
-/* These are defined as classes, not templates, so that 
-class TIntIntPair {
-public:
-  int first, second;
-  TIntIntPair(const int &f, const int &s)
-  : first(f),
-    second(s)
-  {}
-};
-
-class TIntIntPair {
-public:
-  int first, second;
-  TIntIntPair(const int &f, const int &s)
-  : first(f),
-    second(s)
-  {}
-};
-
-class TIntIntPair {
-public:
-  int first, second;
-  TIntIntPair(const int &f, const int &s)
-  : first(f),
-    second(s)
-  {}
-};
-
-class TIntIntPair {
-public:
-  int first, second;
-  TIntIntPair(const int &f, const int &s)
-  : first(f),
-    second(s)
-  {}
-};
-*/
-
-#ifdef _MSC_VER
-  template class ORANGE_API std::vector<pair<int, int> >;
-  template class ORANGE_API std::vector<int>;
 #endif
-
-#endif

File source/orange/pnn.hpp

View file
 #define __PNN_HPP
 
 #include "classify.hpp"
+#include "orvector.hpp"
+#include "domain.hpp"
+#include "examplegen.hpp"
 
-WRAPPER(Domain)
-WRAPPER(ExampleGenerator)
-VWRAPPER(FloatList)
 
 class ORANGE_API TPNN : public TClassifierFD {
 public:

File source/orange/pq.cpp

View file
  * @summary: Binary heap PQ implementation with 'decrease key'
  */
 
+#include <stdlib.h>
+
 #include "pq.hpp"
 
 template <class Key>
 }
 
 template <class Key>
-PQHeap<Key>::PQHeap(int size=DEFAULT_SIZE)
+PQHeap<Key>::PQHeap(int size)
   : m_size(size),
     m_noNodes(0),
     m_nodes(size)

File source/orange/pqueue_i.hpp

View file
 public:
   ~TPriorityQueue()
     { typedef typename vector<TPQNode *>::iterator iterator;
-      for(iterator ii(begin()); ii!=end(); mldelete *(ii++)); 
+      for(iterator ii(this->begin()); ii!=this->end(); mldelete *(ii++)); 
     }
 
   void sink(int i)
-    { TPQNode *sank=at(i);
+    { TPQNode *sank=this->at(i);
 
-      int msize = size();
+      int msize = this->size();
       for(int newi = 2*i+1; newi < msize; newi = 2*(i=newi)+1) {
         if (newi+1<msize) {
-          int cmp = at(newi)->compare(*at(newi+1));
+          int cmp = this->at(newi)->compare(*this->at(newi+1));
           if (cmp<0)
             newi++;
         }
 
-        int cmp = at(newi)->compare(*sank);
+        int cmp = this->at(newi)->compare(*sank);
         if (cmp>0)
-          (at(i) = at(newi))->queueIndex = i;
+          (this->at(i) = this->at(newi))->queueIndex = i;
         else 
           break;
       }
 
-      (operator[](i) = sank)->queueIndex = i;
+      (this->operator[](i) = sank)->queueIndex = i;
     }
 
 
   void insert(TPQNode *node)
-    { push_back((TPQNode *)NULL);
-      int down = size()-1;
+    { this->push_back((TPQNode *)NULL);
+      int down = this->size()-1;
       for(int up; down; down=up) {
         up = (down-1)/2;
-        int cmp=node->compare(*at(up));
+        int cmp=node->compare(*this->at(up));
         if (cmp>0)
-          (at(down) = at(up))->queueIndex = down;
+          (this->at(down) = this->at(up))->queueIndex = down;
         else
           break;
       }
 
-      (at(down) = node)->queueIndex = down;
+      (this->at(down) = node)->queueIndex = down;
     }
 
 
   void remove(int oldi)
-    { mldelete at(oldi);
-      if (oldi == int(size()-1)) {
-        at(oldi) = NULL;
-        erase(end()-1);
+    { mldelete this->at(oldi);
+      if (oldi == int(this->size()-1)) {
+        this->at(oldi) = NULL;
+        this->erase(this->end()-1);
       }
       else {
-        (at(oldi) = back())->queueIndex = oldi;
-        back() = NULL;
-        erase(end()-1);
-        sink(oldi);
+        (this->at(oldi) = this->back())->queueIndex = oldi;
+        this->back() = NULL;
+        this->erase(this->end()-1);
+        this->sink(oldi);
       }
     }
 };

File source/orange/preprocessors.cpp

View file
 #include "learn.hpp"
 
 #include <string>
-#include "preprocessors.ppp"
+#include "preprocessors.hpp"
 
 DEFINE_TOrangeMap_classDescription(TOrangeMap_KV, PVariable, PValueFilter, "VariableFilterMap")
 DEFINE_TOrangeMap_classDescription(TOrangeMap_K, PVariable, float, "VariableFloatMap")
 
+#include "preprocessors.ppp"
+
 #ifdef _MSC_VER
   #pragma warning (disable : 4100) // unreferenced local parameter (macros name all arguments)
 #endif

File source/orange/preprocessors.hpp

View file
 
 WRAPPER(Filter);
 WRAPPER(ExampleTable);
-VWRAPPER(ExampleGeneratorList);
 
 
 class ORANGE_API TPreprocessor : public TOrange {

File source/orange/rule_conditions.hpp

View file
   typedef typename vector<TCondition<T> *>::iterator iterator;
 
   virtual bool operator()(T example) {
-    if (!size()) return true;
-    iterator ci(begin()), ce(end());
+    if (!this->size()) return true;
+    iterator ci(this->begin()), ce(this->end());
     for( ; (ci!=ce) && (**ci)(example); ci++);
     return (ci==ce);
   }
   typedef typename vector<TCondition<T> *>::iterator iterator;
 
   virtual bool operator()(T example) {
-    if (!size()) return true;
-    iterator ci(begin()), ce(end());
+    if (!this->size()) return true;
+    iterator ci(this->begin()), ce(this->end());
     for( ; (ci!=ce) && !(**ci)(example); ci++);
     return (ci!=ce);
   }

File source/orange/rulelearner.cpp

View file
 #include "distvars.hpp"
 #include "classfromvar.hpp"
 #include "progress.hpp"
-
-
-#include "rulelearner.ppp"
+#include "rulelearner.hpp"
 
 DEFINE_TOrangeVector_classDescription(PRule, "TRuleList", true, ORANGE_API)
 DEFINE_TOrangeVector_classDescription(PEVDist, "TEVDistList", true, ORANGE_API)
 
+#include "rulelearner.ppp"
+
 #ifdef _MSC_VER
 #if _MSC_VER < 1300
 template<class T>

File source/orange/subsets.hpp

View file
 
 #include "boolcnt.hpp"
 #include "root.hpp"
-
-VWRAPPER(VarList);
-VWRAPPER(VarListList);
+#include "vars.hpp"
 
 WRAPPER(SubsetsGenerator_iterator)
 

File source/orange/tabdelim.hpp

View file
 
   static const TIdentifierDeclaration typeIdentifiers[] ;
 
-  TTabDelimExampleGenerator::TTabDelimExampleGenerator(const TTabDelimExampleGenerator &old);
+  TTabDelimExampleGenerator(const TTabDelimExampleGenerator &old);
   TTabDelimExampleGenerator(const string &, bool autoDetect, bool csv, 
                             const int createNewOn, vector<int> &status, vector<pair<int, int> > &metaStatus,
                             const char *aDK = NULL, const char *aDC = NULL, bool noCodedDiscrete = false, bool noClass = false);

File source/orange/tdidt.cpp

View file
 #include "tdidt_split.hpp"
 #include "tdidt_stop.hpp"
 
-#include "tdidt.ppp"
-
+#include "tdidt.hpp"
 
 DEFINE_TOrangeVector_classDescription(PTreeNode, "TTreeNodeList", true, ORANGE_API)
 
+#include "tdidt.ppp"
 
 /* Default components for split constructor -- split constructors for
    discrete and continuous attributes and classes, and the corresponding

File source/orange/transval.hpp

View file
 
 #include "root.hpp"
 #include "orvector.hpp"
+#include "vars.hpp"
 
 WRAPPER(TransformValue);
 WRAPPER(Domain);

File source/orange/vars.cpp

View file
 #include "orvector.hpp"
 #include "stringvars.hpp"
 
+#include "vars.hpp"
+
+DEFINE_TOrangeVector_classDescription(PVariable, "TVarList", true, ORANGE_API)
+DEFINE_TOrangeVector_classDescription(PVarList, "TVarListList", true, ORANGE_API)
+
+DEFINE_AttributedList_classDescription(TAttributedFloatList, TFloatList)
+DEFINE_AttributedList_classDescription(TAttributedBoolList, TBoolList)
+
+
+#ifdef _MSC_VER_60
+ TClassDescription template TOrangeVector<TValue, false>::st_classDescription;
+ ORANGE_EXTERN template class ORANGE_API TOrangeVector<TValue, false>;
+#else
+ DEFINE_TOrangeVector_classDescription(TValue, "TOrangeVector<TValue, false>", false, ORANGE_API)
+#endif
 
 #include "vars.ppp"
 
 	}
 };
 
-DEFINE_TOrangeVector_classDescription(PVariable, "TVarList", true, ORANGE_API)
-DEFINE_TOrangeVector_classDescription(PVarList, "TVarListList", true, ORANGE_API)
 
 MMV TVariable::allVariablesMap;
 
     vname = buf;
   }
 }
+

File source/orange/vars.hpp

View file
 #include <list>
 #include <set>
 #include <map>
+
 #include "orvector.hpp"
+#include "values.hpp"
 
 using namespace std;
 
 
 WRAPPER(Variable)
 
-#define TVarList TOrangeVector<PVariable> 
+#define TVarList TOrangeVector<PVariable>
 VWRAPPER(VarList)
 
 #define TVarListList TOrangeVector<PVarList> 
   int str2val_low(const string &valname, TValue &valu);
 };
 
+
+#ifdef _MSC_VER
+  #pragma warning(push)
+  #pragma warning(disable: 4275)
 #endif
+
+/* This is to fool pyprops
+#define TValueList _TOrangeVector<float>
+*/
+
+
+
+#define __REGISTER_NO_PYPROPS_CLASS __REGISTER_CLASS
+
+class ORANGE_API TAttributedFloatList : public TOrangeVector<float, false>
+{
+public:
+  __REGISTER_NO_PYPROPS_CLASS
+
+  PVarList attributes;
+
+  inline TAttributedFloatList()
+  {}
+
+  inline TAttributedFloatList(PVarList vlist)
+  : attributes(vlist)
+  {}
+
+  inline TAttributedFloatList(PVarList vlist, const int &i_N, const float &f = 0.0)
+  : TOrangeVector<float, false>(i_N, f),
+    attributes(vlist)
+  {}
+
+  inline TAttributedFloatList(PVarList vlist, const vector<float> &i_X)
+  : TOrangeVector<float,false>(i_X),
+    attributes(vlist)
+  {}
+};
+
+
+class ORANGE_API TAttributedBoolList : public TOrangeVector<bool, false>
+{
+public:
+  __REGISTER_NO_PYPROPS_CLASS
+
+  PVarList attributes;
+
+  inline TAttributedBoolList()
+  {}
+
+  inline TAttributedBoolList(PVarList vlist)
+  : attributes(vlist)
+  {}
+
+  inline TAttributedBoolList(PVarList vlist, const int &i_N, const bool b= false)
+  : TOrangeVector<bool, false>(i_N, b),
+    attributes(vlist)
+  {}
+
+  inline TAttributedBoolList(PVarList vlist, const vector<bool> &i_X)
+  : TOrangeVector<bool, false>(i_X),
+    attributes(vlist)
+  {}
+};
+
+
+
+class ORANGE_API TValueList : public TOrangeVector<TValue, false>
+{
+public:
+  __REGISTER_CLASS
+
+  PVariable variable; //P the variable to which the list applies
+
+  inline TValueList(PVariable var = PVariable())
+  : TOrangeVector<TValue, false>(),
+    variable(var)
+  {}
+ 
+  inline TValueList(const int &N, const TValue &V = TValue(), PVariable var = PVariable())
+  : TOrangeVector<TValue, false>(N, V),
+    variable(var)
+  {}
+
+  inline TValueList(const TOrangeVector<TValue, false> &i_X, PVariable var = PVariable())
+  : TOrangeVector<TValue, false>(i_X),
+    variable(var)
+  {}
+
+  inline TValueList(const TValueList &other)
+  : TOrangeVector<TValue, false>(other),
+    variable(other.variable)
+  {}
+
+  int traverse(visitproc visit, void *arg) const
+  { 
+    TRAVERSE(TOrange::traverse);
+
+    for(TValue *p = _First; p != _Last; p++)
+      if (p->svalV)
+        PVISIT(p->svalV);
+
+    return 0;
+  }
+
+  int dropReferences()
+  { DROPREFERENCES(TOrange::dropReferences);
+    return 0;
+  }
+};
+
+
+WRAPPER(ValueList)
+
+#ifdef _MSC_VER
+  #pragma warning(pop)
+#endif
+
+/* This is to fool pyprops.py
+#define TAttributedFloatList _TOrangeVector<float>
+#define TAttributedBoolList _TOrangeVector<bool>
+*/
+WRAPPER(AttributedFloatList)
+WRAPPER(AttributedBoolList)
+
+
+#endif

File source/orange/vectortemplates.hpp

View file
 #endif
 
 #include "orvector.hpp"
+#include "cls_orange.hpp"
+#include "converts.hpp"
 #include "c2py.hpp"
 
 
 
   static PyObject *_new(PyTypeObject *type, PyObject *args, PyObject *)
   { if (!args || (PySequence_Check(args) && !PySequence_Size(args)))
-      return _CreateEmptyList(type);
+      return CommonListMethods<_WrappedListType, _ListType>::_CreateEmptyList(type);
 
     if (PyTuple_Check(args) && PyTuple_Size(args)==1) {
       PyObject *arg=PyTuple_GetItem(args, 0);
 
   static PyObject *_new(PyTypeObject *type, PyObject *args, PyObject *)
   { if (!args || (PySequence_Check(args) && !PySequence_Size(args)))
-      return _CreateEmptyList(type);
+      return CommonListMethods<_WrappedListType, _ListType>::_CreateEmptyList(type);
 
     if (PyTuple_Check(args) && PyTuple_Size(args)==1) {
       PyObject *arg=PyTuple_GetItem(args, 0);