mirror of
				https://github.com/VCMP-SqMod/SqMod.git
				synced 2025-11-04 08:17:19 +01:00 
			
		
		
		
	Improve debug message and value gen.
This commit is contained in:
		@@ -63,6 +63,7 @@ static void Register_Vector(HSQUIRRELVM vm, Table & ns, const SQChar * name)
 | 
				
			|||||||
        .Func(_SC("Generate"), &Container::Generate)
 | 
					        .Func(_SC("Generate"), &Container::Generate)
 | 
				
			||||||
        .Func(_SC("GenerateSome"), &Container::GenerateSome)
 | 
					        .Func(_SC("GenerateSome"), &Container::GenerateSome)
 | 
				
			||||||
        .Func(_SC("GenerateFrom"), &Container::GenerateFrom)
 | 
					        .Func(_SC("GenerateFrom"), &Container::GenerateFrom)
 | 
				
			||||||
 | 
					        .Func(_SC("GenerateBetween"), &Container::GenerateBetween)
 | 
				
			||||||
        .Func(_SC("Sort"), &Container::Sort)
 | 
					        .Func(_SC("Sort"), &Container::Sort)
 | 
				
			||||||
        .Func(_SC("Shuffle"), &Container::Shuffle)
 | 
					        .Func(_SC("Shuffle"), &Container::Shuffle)
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -204,7 +204,7 @@ template < class T > struct SqVector
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if (static_cast< size_t >(i) >= mC->size())
 | 
					        if (static_cast< size_t >(i) >= mC->size())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            STHROWF("Invalid vector container index");
 | 
					            STHROWF("Invalid vector container index(" PRINT_INT_FMT ")", i);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return *mC;
 | 
					        return *mC;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -580,7 +580,7 @@ template < class T > struct SqVector
 | 
				
			|||||||
        Validate();
 | 
					        Validate();
 | 
				
			||||||
        if (static_cast< size_t >(p) >= mC->size())
 | 
					        if (static_cast< size_t >(p) >= mC->size())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            STHROWF("Invalid container index");
 | 
					            STHROWF("Invalid container index (" PRINT_INT_FMT ")", p);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        for (auto i = static_cast< size_t >(p); n--; ++i)
 | 
					        for (auto i = static_cast< size_t >(p); n--; ++i)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -591,6 +591,29 @@ template < class T > struct SqVector
 | 
				
			|||||||
        return *this;
 | 
					        return *this;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Generate new elements at specified position.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    SqVector & GenerateBetween(SQInteger p, SQInteger n, LightObj & ctx, Function & fn)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Validate();
 | 
				
			||||||
 | 
					        if (static_cast< size_t >(p) >= mC->size())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            STHROWF("Invalid container index (" PRINT_INT_FMT ")", p);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (static_cast< size_t >(p + n) >= mC->size())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            STHROWF("Invalid container index (" PRINT_INT_FMT ")", p + n);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        for (n = (p + n); p <= n; ++p)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            auto ret = fn.Eval(ctx);
 | 
				
			||||||
 | 
					            // Extract the value from object and assign it
 | 
				
			||||||
 | 
					            mC->at(static_cast< size_t >(p)) = ret.Cast< T >();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* --------------------------------------------------------------------------------------------
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
     * Sort the elements from the container.
 | 
					     * Sort the elements from the container.
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user