From 17dcff67cb44b19249c7a3ec8390e08758d23e6a Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Tue, 15 Sep 2015 13:53:20 +1000 Subject: [PATCH] Functions accept const ObjectList*, not ObjectList* --- src/builtin.cpp | 14 +++++++------- src/builtin.h | 16 ++++++++-------- src/common.h | 2 +- src/globals.cpp | 4 ++-- src/globals.h | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index cc18bf9..df9ec0e 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -1,7 +1,7 @@ #include #include "object.h" -ObjectBase* Arifm_Add(ObjectList* input) +ObjectBase* Arifm_Add(const ObjectList* input) { if(input->Size()!=2) return 0; 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; 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; 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; 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; 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; 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; const ObjectBase *arg=input->At(0); diff --git a/src/builtin.h b/src/builtin.h index 2c980b9..64f3960 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -1,15 +1,15 @@ #include "object.h" -ObjectBase* Arifm_Add(ObjectList* input); -ObjectBase* Arifm_Sub(ObjectList* input); -ObjectBase* Arifm_Mul(ObjectList* input); -ObjectBase* Arifm_Div(ObjectList* input); -ObjectBase* Arifm_Pow(ObjectList* input); -ObjectBase* Arifm_Neg(ObjectList* input); -ObjectBase* Arifm_Pos(ObjectList* input); +ObjectBase* Arifm_Add(const ObjectList* input); +ObjectBase* Arifm_Sub(const ObjectList* input); +ObjectBase* Arifm_Mul(const ObjectList* input); +ObjectBase* Arifm_Div(const ObjectList* input); +ObjectBase* Arifm_Pow(const ObjectList* input); +ObjectBase* Arifm_Neg(const ObjectList* input); +ObjectBase* Arifm_Pos(const ObjectList* input); template -ObjectBase* Get(ObjectList* input) +ObjectBase* Get(const ObjectList* input) { if(input->Size()!=2) return 0; const ObjectBase* ob=input->At(0); diff --git a/src/common.h b/src/common.h index 77f00ea..05fa772 100644 --- a/src/common.h +++ b/src/common.h @@ -256,7 +256,7 @@ public: }; -typedef ObjectBase* (*Func)(ObjectList*); +typedef ObjectBase* (*Func)(const ObjectList*); extern "C" { EXPORT void RegisterFunction(const std::string& name, Func func); diff --git a/src/globals.cpp b/src/globals.cpp index b849bd4..f767340 100644 --- a/src/globals.cpp +++ b/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; 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; if(sz==0) return true; diff --git a/src/globals.h b/src/globals.h index eafc759..c993ec9 100644 --- a/src/globals.h +++ b/src/globals.h @@ -22,7 +22,7 @@ extern G_toType G_toprint; void ClearGlobals(); -bool Save(ObjectList* input); -bool Print(ObjectList* input); +bool Save(const ObjectList* input); +bool Print(const ObjectList* input); #endif