File diff r23537:f6a6d4ce4bd5 → r23538:8df50944b27a
src/script/squirrel_helper.hpp
Show inline comments
 
@@ -20,25 +20,25 @@
 

	
 
template <class CL, ScriptType ST> const char *GetClassName();
 

	
 
/**
 
 * The Squirrel convert routines
 
 */
 
namespace SQConvert {
 
	/**
 
	 * Pointers assigned to this class will be free'd when this instance
 
	 *  comes out of scope. Useful to make sure you can use stredup(),
 
	 *  without leaking memory.
 
	 */
 
	struct SQAutoFreePointers : SmallVector<void *, 1> {
 
	struct SQAutoFreePointers : std::vector<void *> {
 
		~SQAutoFreePointers()
 
		{
 
			for (uint i = 0; i < std::vector<void *>::size(); i++) free(std::vector<void *>::operator[](i));
 
		}
 
	};
 

	
 
	template <bool Y> struct YesT {
 
		static const bool Yes = Y;
 
		static const bool No = !Y;
 
	};
 

	
 
	/**
 
@@ -123,25 +123,25 @@ namespace SQConvert {
 
	}
 

	
 
	template <> inline Array      *GetParam(ForceType<Array *>,      HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr)
 
	{
 
		/* Sanity check of the size. */
 
		if (sq_getsize(vm, index) > UINT16_MAX) throw sq_throwerror(vm, "an array used as parameter to a function is too large");
 

	
 
		SQObject obj;
 
		sq_getstackobj(vm, index, &obj);
 
		sq_pushobject(vm, obj);
 
		sq_pushnull(vm);
 

	
 
		SmallVector<int32, 2> data;
 
		std::vector<int32> data;
 

	
 
		while (SQ_SUCCEEDED(sq_next(vm, -2))) {
 
			SQInteger tmp;
 
			if (SQ_SUCCEEDED(sq_getinteger(vm, -1, &tmp))) {
 
				data.push_back((int32)tmp);
 
			} else {
 
				sq_pop(vm, 4);
 
				throw sq_throwerror(vm, "a member of an array used as parameter to a function is not numeric");
 
			}
 

	
 
			sq_pop(vm, 2);
 
		}