this shouldn't be in svn
[supertux.git] / src / squirrel / squirrel / sqarray.h
index b747e07..b463e81 100644 (file)
@@ -5,13 +5,13 @@
 struct SQArray : public CHAINABLE_OBJ\r
 {\r
 private:\r
-       SQArray(SQSharedState *ss,int nsize){_values.resize(nsize);_uiRef=0;INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this);}\r
+       SQArray(SQSharedState *ss,SQInteger nsize){_values.resize(nsize); INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this);}\r
        ~SQArray()\r
        {\r
                REMOVE_FROM_CHAIN(&_ss(this)->_gc_chain,this);\r
        }\r
 public:\r
-       static SQArray* Create(SQSharedState *ss,int nInitialSize){\r
+       static SQArray* Create(SQSharedState *ss,SQInteger nInitialSize){\r
                SQArray *newarray=(SQArray*)SQ_MALLOC(sizeof(SQArray));\r
                new (newarray) SQArray(ss,nInitialSize);\r
                return newarray;\r
@@ -22,29 +22,31 @@ public:
        void Finalize(){\r
                _values.resize(0);\r
        }\r
-       bool Get(const int nidx,SQObjectPtr &val)\r
+       bool Get(const SQInteger nidx,SQObjectPtr &val)\r
        {\r
-               if(nidx>=0 && nidx<(int)_values.size()){\r
-                       val=_values[nidx];\r
+               if(nidx>=0 && nidx<(SQInteger)_values.size()){\r
+                       SQObjectPtr &o = _values[nidx];\r
+                       val = _realval(o);\r
                        return true;\r
                }\r
                else return false;\r
        }\r
-       bool Set(const int nidx,const SQObjectPtr &val)\r
+       bool Set(const SQInteger nidx,const SQObjectPtr &val)\r
        {\r
-               if(nidx>=0 && nidx<(int)_values.size()){\r
+               if(nidx>=0 && nidx<(SQInteger)_values.size()){\r
                        _values[nidx]=val;\r
                        return true;\r
                }\r
                else return false;\r
        }\r
-       int Next(const SQObjectPtr &refpos,SQObjectPtr &outkey,SQObjectPtr &outval)\r
+       SQInteger Next(const SQObjectPtr &refpos,SQObjectPtr &outkey,SQObjectPtr &outval)\r
        {\r
-               unsigned int idx=TranslateIndex(refpos);\r
+               SQUnsignedInteger idx=TranslateIndex(refpos);\r
                while(idx<_values.size()){\r
                        //first found\r
                        outkey=(SQInteger)idx;\r
-                       outval=_values[idx];\r
+                       SQObjectPtr &o = _values[idx];\r
+                       outval = _realval(o);\r
                        //return idx for the next iteration\r
                        return ++idx;\r
                }\r
@@ -52,19 +54,19 @@ public:
                return -1;\r
        }\r
        SQArray *Clone(){SQArray *anew=Create(_opt_ss(this),Size()); anew->_values.copy(_values); return anew; }\r
-       int Size() const {return _values.size();}\r
-       void Resize(int size,SQObjectPtr &fill = _null_) { _values.resize(size,fill); ShrinkIfNeeded(); }\r
-       void Reserve(int size) { _values.reserve(size); }\r
+       SQInteger Size() const {return _values.size();}\r
+       void Resize(SQInteger size,SQObjectPtr &fill = _null_) { _values.resize(size,fill); ShrinkIfNeeded(); }\r
+       void Reserve(SQInteger size) { _values.reserve(size); }\r
        void Append(const SQObject &o){_values.push_back(o);}\r
        void Extend(const SQArray *a);\r
        SQObjectPtr &Top(){return _values.top();}\r
        void Pop(){_values.pop_back(); ShrinkIfNeeded(); }\r
-       void Insert(const SQObject& idx,const SQObject &val){_values.insert((unsigned int)tointeger(idx),val);}\r
+       void Insert(const SQObject& idx,const SQObject &val){_values.insert((SQUnsignedInteger)tointeger(idx),val);}\r
        void ShrinkIfNeeded() {\r
                if(_values.size() <= _values.capacity()>>2) //shrink the array\r
                        _values.shrinktofit();\r
        }\r
-       void Remove(unsigned int idx){\r
+       void Remove(SQUnsignedInteger idx){\r
                _values.remove(idx);\r
                ShrinkIfNeeded();\r
        }\r