Browse Source

Functions accept const ObjectList*, not ObjectList*

test
Michael Uleysky 9 years ago
parent
commit
17dcff67cb
  1. 14
      src/builtin.cpp
  2. 16
      src/builtin.h
  3. 2
      src/common.h
  4. 4
      src/globals.cpp
  5. 4
      src/globals.h

14
src/builtin.cpp

@ -1,7 +1,7 @@
#include <math.h> #include <math.h>
#include "object.h" #include "object.h"
ObjectBase* Arifm_Add(ObjectList* input) ObjectBase* Arifm_Add(const ObjectList* input)
{ {
if(input->Size()!=2) return 0; if(input->Size()!=2) return 0;
const ObjectBase *arg1=input->At(0),*arg2=input->At(1); const ObjectBase *arg1=input->At(0),*arg2=input->At(1);
@ -26,7 +26,7 @@ ObjectBase* Arifm_Add(ObjectList* input)
} }
ObjectBase* Arifm_Sub(ObjectList* input) ObjectBase* Arifm_Sub(const ObjectList* input)
{ {
if(input->Size()!=2) return 0; if(input->Size()!=2) return 0;
const ObjectBase *arg1=input->At(0),*arg2=input->At(1); const ObjectBase *arg1=input->At(0),*arg2=input->At(1);
@ -51,7 +51,7 @@ ObjectBase* Arifm_Sub(ObjectList* input)
} }
ObjectBase* Arifm_Mul(ObjectList* input) ObjectBase* Arifm_Mul(const ObjectList* input)
{ {
if(input->Size()!=2) return 0; if(input->Size()!=2) return 0;
const ObjectBase *arg1=input->At(0),*arg2=input->At(1); const ObjectBase *arg1=input->At(0),*arg2=input->At(1);
@ -76,7 +76,7 @@ ObjectBase* Arifm_Mul(ObjectList* input)
} }
ObjectBase* Arifm_Div(ObjectList* input) ObjectBase* Arifm_Div(const ObjectList* input)
{ {
if(input->Size()!=2) return 0; if(input->Size()!=2) return 0;
const ObjectBase *arg1=input->At(0),*arg2=input->At(1); const ObjectBase *arg1=input->At(0),*arg2=input->At(1);
@ -101,7 +101,7 @@ ObjectBase* Arifm_Div(ObjectList* input)
} }
ObjectBase* Arifm_Pow(ObjectList* input) ObjectBase* Arifm_Pow(const ObjectList* input)
{ {
if(input->Size()!=2) return 0; if(input->Size()!=2) return 0;
const ObjectBase *arg1=input->At(0),*arg2=input->At(1); const ObjectBase *arg1=input->At(0),*arg2=input->At(1);
@ -123,7 +123,7 @@ ObjectBase* Arifm_Pow(ObjectList* input)
} }
ObjectBase* Arifm_Neg(ObjectList* input) ObjectBase* Arifm_Neg(const ObjectList* input)
{ {
if(input->Size()!=1) return 0; if(input->Size()!=1) return 0;
const ObjectBase *arg=input->At(0); const ObjectBase *arg=input->At(0);
@ -139,7 +139,7 @@ ObjectBase* Arifm_Neg(ObjectList* input)
} }
ObjectBase* Arifm_Pos(ObjectList* input) ObjectBase* Arifm_Pos(const ObjectList* input)
{ {
if(input->Size()!=1) return 0; if(input->Size()!=1) return 0;
const ObjectBase *arg=input->At(0); const ObjectBase *arg=input->At(0);

16
src/builtin.h

@ -1,15 +1,15 @@
#include "object.h" #include "object.h"
ObjectBase* Arifm_Add(ObjectList* input); ObjectBase* Arifm_Add(const ObjectList* input);
ObjectBase* Arifm_Sub(ObjectList* input); ObjectBase* Arifm_Sub(const ObjectList* input);
ObjectBase* Arifm_Mul(ObjectList* input); ObjectBase* Arifm_Mul(const ObjectList* input);
ObjectBase* Arifm_Div(ObjectList* input); ObjectBase* Arifm_Div(const ObjectList* input);
ObjectBase* Arifm_Pow(ObjectList* input); ObjectBase* Arifm_Pow(const ObjectList* input);
ObjectBase* Arifm_Neg(ObjectList* input); ObjectBase* Arifm_Neg(const ObjectList* input);
ObjectBase* Arifm_Pos(ObjectList* input); ObjectBase* Arifm_Pos(const ObjectList* input);
template<class T> template<class T>
ObjectBase* Get(ObjectList* input) ObjectBase* Get(const ObjectList* input)
{ {
if(input->Size()!=2) return 0; if(input->Size()!=2) return 0;
const ObjectBase* ob=input->At(0); const ObjectBase* ob=input->At(0);

2
src/common.h

@ -256,7 +256,7 @@ public:
}; };
typedef ObjectBase* (*Func)(ObjectList*); typedef ObjectBase* (*Func)(const ObjectList*);
extern "C" { extern "C" {
EXPORT void RegisterFunction(const std::string& name, Func func); EXPORT void RegisterFunction(const std::string& name, Func func);

4
src/globals.cpp

@ -30,7 +30,7 @@ void RegisterFunction(const std::string& name, Func func)
} }
bool Save(ObjectList* input) bool Save(const ObjectList* input)
{ {
ObjectList::ListValues::size_type sz=input->Size(), i; ObjectList::ListValues::size_type sz=input->Size(), i;
if(sz<2 || sz%2==1 ) if(sz<2 || sz%2==1 )
@ -68,7 +68,7 @@ bool Save(ObjectList* input)
} }
bool Print(ObjectList* input) bool Print(const ObjectList* input)
{ {
ObjectList::ListValues::size_type sz=input->Size(), i; ObjectList::ListValues::size_type sz=input->Size(), i;
if(sz==0) return true; if(sz==0) return true;

4
src/globals.h

@ -22,7 +22,7 @@ extern G_toType G_toprint;
void ClearGlobals(); void ClearGlobals();
bool Save(ObjectList* input); bool Save(const ObjectList* input);
bool Print(ObjectList* input); bool Print(const ObjectList* input);
#endif #endif

Loading…
Cancel
Save