Improved Squirrel Bindings
Added AddCommand / BindCommand for Squirrel Plugins git-svn-id: http://mc-server.googlecode.com/svn/trunk@652 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
81a41c25fc
commit
d82e2449a0
@ -1737,6 +1737,14 @@
|
||||
RelativePath="..\source\cPluginManager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\cSquirrelCommandBinder.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\cSquirrelCommandBinder.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\cStringMap.cpp"
|
||||
>
|
||||
@ -1784,6 +1792,10 @@
|
||||
RelativePath="..\source\squirrelbindings\cSquirrelBaseClass.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\squirrelbindings\SquirrelArray.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\squirrelbindings\SquirrelBindings.cpp"
|
||||
>
|
||||
|
@ -378,6 +378,7 @@
|
||||
<ClCompile Include="..\source\cSocketThreads.cpp" />
|
||||
<ClCompile Include="..\source\cSpider.cpp" />
|
||||
<ClCompile Include="..\source\cSquid.cpp" />
|
||||
<ClCompile Include="..\source\cSquirrelCommandBinder.cpp" />
|
||||
<ClCompile Include="..\source\cStringMap.cpp" />
|
||||
<ClCompile Include="..\source\cSurvivalInventory.cpp" />
|
||||
<ClCompile Include="..\Source\cTCPLink.cpp" />
|
||||
@ -527,6 +528,7 @@
|
||||
<ClInclude Include="..\source\cIsThread.h" />
|
||||
<ClInclude Include="..\Source\cLadder.h" />
|
||||
<ClInclude Include="..\source\cPlugin_Squirrel.h" />
|
||||
<ClInclude Include="..\source\cSquirrelCommandBinder.h" />
|
||||
<ClInclude Include="..\Source\cVine.h" />
|
||||
<ClInclude Include="..\source\cLavaSimulator.h" />
|
||||
<ClInclude Include="..\Source\cLuaCommandBinder.h" />
|
||||
@ -666,6 +668,7 @@
|
||||
<ClInclude Include="..\source\packets\cPacket_WindowClose.h" />
|
||||
<ClInclude Include="..\source\packets\cPacket_WindowOpen.h" />
|
||||
<ClInclude Include="..\source\squirrelbindings\cSquirrelBaseClass.h" />
|
||||
<ClInclude Include="..\source\squirrelbindings\SquirrelArray.h" />
|
||||
<ClInclude Include="..\source\squirrelbindings\SquirrelBindings.h" />
|
||||
<ClInclude Include="..\source\squirrelbindings\SquirrelFunctions.h" />
|
||||
<ClInclude Include="..\source\squirrelbindings\SquirrelObject.h" />
|
||||
|
@ -436,6 +436,9 @@
|
||||
<Filter Include="HandyStuff\Generating">
|
||||
<UniqueIdentifier>{833e49bd-848d-42de-ac60-6cd7656474e3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="cPluginManager\cSquirrelCommandBinder">
|
||||
<UniqueIdentifier>{0a0b9b8e-ac72-4755-98e5-87cbc835016a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\source\cServer.cpp">
|
||||
@ -914,6 +917,9 @@
|
||||
<Filter>LuaBindings\SquirrelBindings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\source\BlockArea.cpp" />
|
||||
<ClCompile Include="..\source\cSquirrelCommandBinder.cpp">
|
||||
<Filter>cPluginManager\cSquirrelCommandBinder</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\source\cServer.h">
|
||||
@ -1437,6 +1443,12 @@
|
||||
<Filter>LuaBindings\SquirrelBindings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\source\BlockArea.h" />
|
||||
<ClInclude Include="..\source\cSquirrelCommandBinder.h">
|
||||
<Filter>cPluginManager\cSquirrelCommandBinder</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\source\squirrelbindings\SquirrelArray.h">
|
||||
<Filter>LuaBindings\SquirrelBindings</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\source\AllToLua.pkg">
|
||||
|
@ -280,6 +280,7 @@ MCServer : \
|
||||
build/sqvm.o\
|
||||
build/squirrelbindings/SquirrelBindings.o\
|
||||
build/squirrelbindings/SquirrelFunctions.o\
|
||||
build/cSquirrelCommandBinder.o\
|
||||
build/cPlugin_Squirrel.o\
|
||||
build/CraftingRecipes.o
|
||||
|
||||
@ -528,6 +529,7 @@ MCServer : \
|
||||
build/sqvm.o\
|
||||
build/squirrelbindings/SquirrelBindings.o\
|
||||
build/squirrelbindings/SquirrelFunctions.o\
|
||||
build/cSquirrelCommandBinder.o\
|
||||
build/cPlugin_Squirrel.o\
|
||||
-o MCServer
|
||||
|
||||
@ -771,6 +773,7 @@ clean :
|
||||
build/sqvm.o\
|
||||
build/squirrelbindings/SquirrelBindings.o\
|
||||
build/squirrelbindings/SquirrelFunctions.o\
|
||||
build/cSquirrelCommandBinder.o\
|
||||
build/cPlugin_Squirrel.o\
|
||||
MCServer
|
||||
|
||||
@ -1686,6 +1689,9 @@ build/CraftingRecipes.o : source/CraftingRecipes.cpp
|
||||
build/squirrelbindings/SquirrelBindings.o : source/squirrelbindings/SquirrelBindings.cpp
|
||||
$(CC) $(CC_OPTIONS) source/squirrelbindings/SquirrelBindings.cpp -c $(INCLUDE) -o build/squirrelbindings/SquirrelBindings.o
|
||||
|
||||
build/cSquirrelCommandBinder.o : source/cSquirrelCommandBinder.cpp
|
||||
$(CC) $(CC_OPTIONS) source/cSquirrelCommandBinder.cpp -c $(INCLUDE) -o build/cSquirrelCommandBinder.o
|
||||
|
||||
build/squirrelbindings/SquirrelFunctions.o : source/squirrelbindings/SquirrelFunctions.cpp
|
||||
$(CC) $(CC_OPTIONS) source/squirrelbindings/SquirrelFunctions.cpp -c $(INCLUDE) -o build/squirrelbindings/SquirrelFunctions.o
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 07/08/12 16:56:12.
|
||||
** Generated automatically by tolua++-1.0.92 on 07/09/12 09:01:54.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 07/08/12 16:56:13.
|
||||
** Generated automatically by tolua++-1.0.92 on 07/09/12 09:01:55.
|
||||
*/
|
||||
|
||||
/* Exported function */
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "cPluginManager.h"
|
||||
@ -10,6 +9,7 @@
|
||||
#include "cItem.h"
|
||||
#include "cRoot.h"
|
||||
#include "cLuaCommandBinder.h"
|
||||
#include "cSquirrelCommandBinder.h"
|
||||
#include "../iniFile/iniFile.h"
|
||||
#include "tolua++.h"
|
||||
|
||||
@ -38,6 +38,7 @@ cPluginManager* cPluginManager::GetPluginManager()
|
||||
|
||||
cPluginManager::cPluginManager()
|
||||
: m_LuaCommandBinder( new cLuaCommandBinder() )
|
||||
, m_SquirrelCommandBinder( new cSquirrelCommandBinder() )
|
||||
, m_bReloadPlugins(false)
|
||||
{
|
||||
}
|
||||
@ -51,6 +52,7 @@ cPluginManager::~cPluginManager()
|
||||
UnloadPluginsNow();
|
||||
|
||||
delete m_LuaCommandBinder;
|
||||
delete m_SquirrelCommandBinder;
|
||||
}
|
||||
|
||||
|
||||
@ -130,7 +132,12 @@ void cPluginManager::ReloadPluginsNow()
|
||||
{
|
||||
LOGINFO("Loading Squirrel plugin: %s", PluginFile.c_str() );
|
||||
|
||||
this->AddPlugin(new cPlugin_Squirrel(PluginFile.c_str()));
|
||||
cPlugin_Squirrel *Plugin = new cPlugin_Squirrel(PluginFile.c_str());
|
||||
|
||||
if( !AddPlugin( Plugin ) )
|
||||
{
|
||||
delete Plugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_SQUIRREL
|
||||
@ -189,6 +196,11 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...)
|
||||
cPlayer * Player = va_arg(argptr, cPlayer * );
|
||||
va_end (argptr);
|
||||
|
||||
if (m_SquirrelCommandBinder->HandleCommand( std::string( Message ), Player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_LuaCommandBinder->HandleCommand( std::string( Message ), Player))
|
||||
{
|
||||
return true;
|
||||
@ -644,13 +656,12 @@ void cPluginManager::RemovePlugin( cPlugin* a_Plugin, bool a_bDelete /* = false
|
||||
if( a_bDelete )
|
||||
{
|
||||
m_LuaCommandBinder->RemoveBindingsForPlugin( a_Plugin );
|
||||
m_SquirrelCommandBinder->RemoveBindingsForPlugin( a_Plugin );
|
||||
m_Plugins.remove( a_Plugin );
|
||||
RemoveHooks( a_Plugin );
|
||||
a_Plugin->OnDisable();
|
||||
if( a_Plugin->GetLanguage() != cPlugin::E_SQUIRREL ) // Squirrel needs to clean it up himself!
|
||||
{
|
||||
delete a_Plugin;
|
||||
}
|
||||
|
||||
delete a_Plugin;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
struct lua_State;
|
||||
class cLuaCommandBinder;
|
||||
class cSquirrelCommandBinder;
|
||||
class cPlugin;
|
||||
class cPlugin_Lua;
|
||||
|
||||
@ -109,8 +110,10 @@ public: //tolua_export
|
||||
void RemovePlugin( cPlugin* a_Plugin, bool a_bDelete = false ); //tolua_export
|
||||
void RemoveLuaPlugin( std::string a_FileName ); //tolua_export
|
||||
cPlugin_Lua* GetLuaPlugin( lua_State* a_State ); //tolua_export
|
||||
|
||||
|
||||
cLuaCommandBinder* GetLuaCommandBinder() const { return m_LuaCommandBinder; }
|
||||
|
||||
cSquirrelCommandBinder* GetSquirrelCommandBinder() { return m_SquirrelCommandBinder; }
|
||||
|
||||
bool HasPlugin( cPlugin* a_Plugin ) const;
|
||||
private:
|
||||
@ -127,8 +130,9 @@ private:
|
||||
|
||||
void ReloadPluginsNow();
|
||||
void UnloadPluginsNow();
|
||||
|
||||
|
||||
cLuaCommandBinder* m_LuaCommandBinder;
|
||||
cSquirrelCommandBinder* m_SquirrelCommandBinder;
|
||||
|
||||
bool m_bReloadPlugins;
|
||||
}; //tolua_export
|
||||
|
@ -13,7 +13,6 @@ cPlugin_Squirrel::cPlugin_Squirrel( const char* a_PluginName )
|
||||
|
||||
cPlugin_Squirrel::~cPlugin_Squirrel()
|
||||
{
|
||||
delete m_PluginName;
|
||||
delete m_Plugin;
|
||||
}
|
||||
|
||||
|
98
source/cSquirrelCommandBinder.cpp
Normal file
98
source/cSquirrelCommandBinder.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "cSquirrelCommandBinder.h"
|
||||
#include "cPlayer.h"
|
||||
#include "cPlugin.h"
|
||||
#include "cPlugin_Squirrel.h"
|
||||
#include "squirrelbindings/SquirrelArray.h"
|
||||
|
||||
|
||||
cSquirrelCommandBinder::cSquirrelCommandBinder()
|
||||
{
|
||||
}
|
||||
|
||||
cSquirrelCommandBinder::~cSquirrelCommandBinder()
|
||||
{
|
||||
}
|
||||
|
||||
void cSquirrelCommandBinder::ClearBindings()
|
||||
{
|
||||
m_BoundCommands.clear();
|
||||
}
|
||||
|
||||
void cSquirrelCommandBinder::RemoveBindingsForPlugin( cPlugin* a_Plugin )
|
||||
{
|
||||
for( CommandMap::iterator itr = m_BoundCommands.begin(); itr != m_BoundCommands.end(); )
|
||||
{
|
||||
if( itr->second.Plugin == a_Plugin )
|
||||
{
|
||||
LOGINFO("Unbinding %s ", itr->first.c_str( ) );
|
||||
CommandMap::iterator eraseme = itr;
|
||||
++itr;
|
||||
m_BoundCommands.erase( eraseme );
|
||||
continue;
|
||||
}
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
bool cSquirrelCommandBinder::BindCommand( const std::string & a_Command, const std::string & a_Permission, cPlugin* a_Plugin, Sqrat::Function a_Callback )
|
||||
{
|
||||
if( !a_Plugin->CanBindCommands() )
|
||||
{
|
||||
LOGERROR("ERROR: Trying to bind command \"%s\" to a plugin that is not initialized.", a_Command.c_str() );
|
||||
return false;
|
||||
}
|
||||
if( m_BoundCommands.find( a_Command ) != m_BoundCommands.end() )
|
||||
{
|
||||
LOGERROR("ERROR: Trying to bind command \"%s\" that has already been bound.", a_Command.c_str() );
|
||||
return false;
|
||||
}
|
||||
LOGINFO("Binding %s (%s)", a_Command.c_str(), a_Permission.c_str() );
|
||||
|
||||
BoundFunction Callback;
|
||||
Callback.Callback = a_Callback;
|
||||
Callback.Plugin = a_Plugin;
|
||||
Callback.Permission = a_Permission;
|
||||
|
||||
m_BoundCommands[ a_Command ] = Callback;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cSquirrelCommandBinder::HandleCommand( const std::string & a_Command, cPlayer* a_Player )
|
||||
{
|
||||
AStringVector Split = StringSplit(a_Command, " ");
|
||||
if (Split.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CommandMap::iterator FoundCommand = m_BoundCommands.find( Split[0] );
|
||||
if( FoundCommand != m_BoundCommands.end() )
|
||||
{
|
||||
const BoundFunction & func = FoundCommand->second;
|
||||
if( func.Permission.size() > 0 )
|
||||
{
|
||||
if( !a_Player->HasPermission( func.Permission.c_str() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Push the split
|
||||
SquirrelStringArray SplitData;
|
||||
|
||||
std::vector<std::string>::const_iterator iter = Split.begin();
|
||||
while(iter != Split.end()) {
|
||||
SplitData.Add(*iter);
|
||||
++iter;
|
||||
}
|
||||
|
||||
// Push player
|
||||
Sqrat::Function callback = func.Callback;
|
||||
return callback.Evaluate<bool>(&SplitData, a_Player);
|
||||
}
|
||||
return false;
|
||||
}
|
35
source/cSquirrelCommandBinder.h
Normal file
35
source/cSquirrelCommandBinder.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <sqrat.h>
|
||||
|
||||
class cPlugin;
|
||||
class cPlayer;
|
||||
|
||||
class cSquirrelCommandBinder
|
||||
{
|
||||
public:
|
||||
cSquirrelCommandBinder();
|
||||
~cSquirrelCommandBinder();
|
||||
|
||||
bool HandleCommand( const std::string & a_Command, cPlayer* a_Player );
|
||||
|
||||
bool BindCommand( const std::string & a_Command, const std::string & a_Permission, cPlugin* a_Plugin, Sqrat::Function a_Callback);
|
||||
|
||||
void ClearBindings();
|
||||
void RemoveBindingsForPlugin( cPlugin* a_Plugin );
|
||||
private:
|
||||
struct BoundFunction
|
||||
{
|
||||
Sqrat::Function Callback;
|
||||
cPlugin *Plugin;
|
||||
std::string Permission;
|
||||
};
|
||||
|
||||
typedef std::map< std::string, BoundFunction > CommandMap;
|
||||
CommandMap m_BoundCommands;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
36
source/squirrelbindings/SquirrelArray.h
Normal file
36
source/squirrelbindings/SquirrelArray.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
template <typename T>
|
||||
class SquirrelArray
|
||||
{
|
||||
public:
|
||||
SquirrelArray()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int Size()
|
||||
{
|
||||
return m_Values.size();
|
||||
}
|
||||
|
||||
T Get(unsigned int a_Index)
|
||||
{
|
||||
if(m_Values.size() < a_Index)
|
||||
{
|
||||
return T();
|
||||
}
|
||||
return m_Values.at(a_Index);
|
||||
}
|
||||
|
||||
void Add(T a_Value)
|
||||
{
|
||||
m_Values.push_back(a_Value);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<T> m_Values;
|
||||
|
||||
};
|
||||
|
||||
class SquirrelStringArray : public SquirrelArray<std::string> { };
|
@ -3,6 +3,7 @@
|
||||
#include "SquirrelFunctions.h"
|
||||
|
||||
#include "cSquirrelBaseClass.h"
|
||||
#include "SquirrelArray.h"
|
||||
|
||||
#include "../cPlayer.h"
|
||||
|
||||
@ -15,9 +16,135 @@ void BindSquirrel(HSQUIRRELVM vm)
|
||||
RootTable()
|
||||
.Bind("Plugin", Class<cSquirrelBaseClass>()
|
||||
.Func("AddHook", &cSquirrelBaseClass::AddHook)
|
||||
.Func("AddCommand", &cSquirrelBaseClass::AddCommand)
|
||||
.Func("BindCommand", &cSquirrelBaseClass::BindCommand)
|
||||
);
|
||||
RootTable().Bind("cPlayer", Class<cPlayer, NoConstructor>()
|
||||
|
||||
RootTable().Bind("Vector3f", Class<Vector3f, NoConstructor>()
|
||||
.Func("Set", &Vector3f::Set)
|
||||
.Func("Normalize", &Vector3f::Normalize)
|
||||
.Func("Length", &Vector3f::Length)
|
||||
.Func("SqrLength", &Vector3f::SqrLength)
|
||||
.Var("x", &Vector3f::x)
|
||||
.Var("y", &Vector3f::y)
|
||||
.Var("z", &Vector3f::z)
|
||||
);
|
||||
|
||||
RootTable().Bind("Vector3d", Class<Vector3d, NoConstructor>()
|
||||
.Func("Set", &Vector3d::Set)
|
||||
.Func("Normalize", &Vector3d::Normalize)
|
||||
.Func("Length", &Vector3d::Length)
|
||||
.Func("SqrLength", &Vector3d::SqrLength)
|
||||
.Var("x", &Vector3d::x)
|
||||
.Var("y", &Vector3d::y)
|
||||
.Var("z", &Vector3d::z)
|
||||
);
|
||||
|
||||
RootTable().Bind("cEntity", Class<cEntity, NoConstructor>()
|
||||
.Func("GetEntityType", &cEntity::GetEntityType)
|
||||
.Func("IsA", &cEntity::IsA)
|
||||
.Func("GetWorld", &cEntity::GetWorld)
|
||||
.Func("GetPosition", &cEntity::GetPosition)
|
||||
.Func("GetPosX", &cEntity::GetPosX)
|
||||
.Func("GetPosY", &cEntity::GetPosY)
|
||||
.Func("GetPosZ", &cEntity::GetPosZ)
|
||||
.Func("GetRot", &cEntity::GetRot)
|
||||
.Func("GetRotation", &cEntity::GetRotation)
|
||||
.Func("GetPitch", &cEntity::GetPitch)
|
||||
.Func("GetRoll", &cEntity::GetRoll)
|
||||
.Func("SetRotation", &cEntity::SetRotation)
|
||||
.Func("SetPitch", &cEntity::SetPitch)
|
||||
.Func("SetRoll", &cEntity::SetRoll)
|
||||
.Func("GetLookVector", &cEntity::GetLookVector)
|
||||
.Func("GetChunkX", &cEntity::GetChunkX)
|
||||
.Func("GetChunkY", &cEntity::GetChunkY)
|
||||
.Func("GetChunkZ", &cEntity::GetChunkZ)
|
||||
.Func("SetPosX", &cEntity::SetPosX)
|
||||
.Func("SetPosY", &cEntity::SetPosY)
|
||||
.Func("SetPosZ", &cEntity::SetPosZ)
|
||||
.Func<void (cEntity::*) (const double &, const double &, const double &)>("SetPosition", &cEntity::SetPosition)
|
||||
.Func("GetUniqueID", &cEntity::GetUniqueID)
|
||||
.Func("IsDestroyed", &cEntity::IsDestroyed)
|
||||
.Func("Destroy", &cEntity::Destroy)
|
||||
.Func("SpawnOn", &cEntity::SpawnOn)
|
||||
|
||||
);
|
||||
|
||||
ConstTable().Enum("MetaData", Enumeration()
|
||||
.Const("Normal", cPawn::NORMAL)
|
||||
.Const("Burning", cPawn::BURNING)
|
||||
.Const("Crouched", cPawn::CROUCHED)
|
||||
.Const("Riding", cPawn::RIDING)
|
||||
.Const("Sprinting", cPawn::SPRINTING)
|
||||
.Const("Eating", cPawn::EATING)
|
||||
.Const("Blocking", cPawn::BLOCKING)
|
||||
);
|
||||
|
||||
RootTable().Bind("cPawn", DerivedClass<cPawn, cEntity, NoConstructor>()
|
||||
.Func("TeleportToEntity", &cPawn::TeleportToEntity)
|
||||
.Func("TeleportTo", &cPawn::TeleportTo)
|
||||
.Func("Heal", &cPawn::Heal)
|
||||
.Func("TakeDamage", &cPawn::TakeDamage)
|
||||
.Func("KilledBy", &cPawn::KilledBy)
|
||||
.Func("GetHealth", &cPawn::GetHealth)
|
||||
.Func("SetMetaData", &cPawn::SetMetaData)
|
||||
.Func("GetMetaData", &cPawn::GetMetaData)
|
||||
.Func("SetMaxHealth", &cPawn::SetMaxHealth)
|
||||
.Func("GetMaxHealth", &cPawn::GetMaxHealth)
|
||||
.Func("GetMaxFood", &cPawn::GetMaxFood)
|
||||
.Func("GetFood", &cPawn::GetFood)
|
||||
.Func("GetMaxFoodSaturation", &cPawn::GetMaxFoodSaturation)
|
||||
.Func("GetFoodSaturation", &cPawn::GetFoodSaturation)
|
||||
.Func("SetMaxFoodLevel", &cPawn::SetMaxFoodLevel)
|
||||
.Func("GetMaxFoodLevel", &cPawn::SetMaxFoodLevel)
|
||||
);
|
||||
|
||||
RootTable().Bind("cPlayer", DerivedClass<cPlayer, cPawn, NoConstructor>()
|
||||
.Func("GetName", &cPlayer::GetName)
|
||||
.Func("SetTouchGround", &cPlayer::SetTouchGround)
|
||||
.Func("SetStance", &cPlayer::SetStance)
|
||||
.Func("GetEyeHeight", &cPlayer::GetEyeHeight)
|
||||
.Func("GetEyePosition", &cPlayer::GetEyePosition)
|
||||
.Func("GetFlying", &cPlayer::GetFlying)
|
||||
.Func("GetStance", &cPlayer::GetStance)
|
||||
//TODO .Func("GetInventory", &cPlayer::GetInventory)
|
||||
.Func("TeleportTo", &cPlayer::TeleportTo)
|
||||
.Func("GetGameMode", &cPlayer::GetGameMode)
|
||||
.Func("GetIP", &cPlayer::GetIP)
|
||||
.Func("GetLastBlockActionTime", &cPlayer::GetLastBlockActionTime)
|
||||
.Func("GetLastBlockActionCnt", &cPlayer::GetLastBlockActionCnt)
|
||||
.Func("SetLastBlockActionCnt", &cPlayer::SetLastBlockActionCnt)
|
||||
.Func("SetLastBlockActionTime", &cPlayer::SetLastBlockActionTime)
|
||||
.Func("SetGameMode", &cPlayer::SetGameMode)
|
||||
.Func("LoginSetGameMode", &cPlayer::LoginSetGameMode)
|
||||
.Func("SetIP", &cPlayer::SetIP)
|
||||
.Func("MoveTo", &cPlayer::MoveTo)
|
||||
.Func("GetClientHandle", &cPlayer::GetClientHandle)
|
||||
.Func("SendMessage", &cPlayer::SendMessage)
|
||||
.Func("AddToGroup", &cPlayer::AddToGroup)
|
||||
.Func("CanUseCommand", &cPlayer::CanUseCommand)
|
||||
.Func("HasPermission", &cPlayer::HasPermission)
|
||||
.Func("IsInGroup", &cPlayer::IsInGroup)
|
||||
.Func("GetColor", &cPlayer::GetColor)
|
||||
.Func("TossItem", &cPlayer::TossItem)
|
||||
.Func("Heal", &cPlayer::Heal)
|
||||
.Func("Feed", &cPlayer::Feed)
|
||||
.Func("TakeDamage", &cPlayer::TakeDamage)
|
||||
.Func("KilledBy", &cPlayer::KilledBy)
|
||||
.Func("Respawn", &cPlayer::Respawn)
|
||||
.Func("SetVisible", &cPlayer::SetVisible)
|
||||
.Func("IsVisible", &cPlayer::IsVisible)
|
||||
.Func("MoveToWorld", &cPlayer::MoveToWorld)
|
||||
.Func("GetLoadedWorldName", &cPlayer::GetLoadedWorldName)
|
||||
.Func("UseEquippedItem", &cPlayer::UseEquippedItem)
|
||||
.Func("EatItem", &cPlayer::EatItem)
|
||||
|
||||
);
|
||||
|
||||
RootTable().Bind("StringArray", Class<SquirrelStringArray>()
|
||||
.Func("Get", &SquirrelStringArray::Get)
|
||||
.Func("Add", &SquirrelStringArray::Add)
|
||||
.Func("Size", &SquirrelStringArray::Size)
|
||||
);
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "../cPlugin_Squirrel.h"
|
||||
#include "../cPluginManager.h"
|
||||
#include "../cRoot.h"
|
||||
#include "../cSquirrelCommandBinder.h"
|
||||
|
||||
//The baseclass for squirrel plugins
|
||||
class cSquirrelBaseClass
|
||||
@ -24,6 +25,17 @@ public:
|
||||
cRoot::Get()->GetPluginManager()->AddHook(m_Instance, (cPluginManager::PluginHook) a_Hook);
|
||||
}
|
||||
|
||||
void AddCommand( std::string a_Command, std::string a_Description, std::string a_Permission )
|
||||
{
|
||||
if(m_Instance) m_Instance->AddCommand(a_Command, a_Description, a_Permission);
|
||||
}
|
||||
|
||||
bool BindCommand( const std::string a_Command, const std::string a_Permission, Sqrat::Function a_Callback)
|
||||
{
|
||||
if(!m_Instance) return false;
|
||||
return cRoot::Get()->GetPluginManager()->GetSquirrelCommandBinder()->BindCommand(a_Command, a_Permission, m_Instance, a_Callback);
|
||||
}
|
||||
|
||||
protected:
|
||||
cPlugin_Squirrel *m_Instance;
|
||||
};
|
@ -1,18 +0,0 @@
|
||||
SQUIRREL= ..
|
||||
|
||||
OUT= $(SQUIRREL)/lib/libsqplus.a
|
||||
INCDIRS= -I$(SQUIRREL)/include -I. -Iinclude
|
||||
|
||||
ALLSRCS = $(wildcard *.cpp)
|
||||
WIN32SRCS = $(wildcard *Win32*)
|
||||
SRCS = $(filter-out $(WIN32SRCS),$(ALLSRCS))
|
||||
|
||||
sqplus:
|
||||
# g++ -fno-rtti -c $(SRCS) $(INCDIRS)
|
||||
g++ -O3 -fno-rtti -Os -c $(SRCS) $(INCDIRS)
|
||||
ar rc $(OUT) *.o
|
||||
rm *.o
|
||||
|
||||
|
||||
#g++ -O3 -fno-rtti -Os -c $(SRCS) $(INCDIRS)
|
||||
#g++ -ggdb -fno-rtti -c $(SRCS) $(INCDIRS)
|
@ -1,382 +0,0 @@
|
||||
#include "sqplus.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_OPT
|
||||
#define SQPLUS_SMARTPOINTER_CPP_DECLARATION
|
||||
#include "SqPlusSmartPointer.h"
|
||||
#endif
|
||||
|
||||
namespace SqPlus {
|
||||
|
||||
static int getVarInfo(StackHandler & sa,VarRefPtr & vr) {
|
||||
HSQOBJECT htable = sa.GetObjectHandle(1);
|
||||
SquirrelObject table(htable);
|
||||
const SQChar * el = sa.GetString(2);
|
||||
ScriptStringVar256 varNameTag;
|
||||
getVarNameTag(varNameTag,sizeof(varNameTag),el);
|
||||
SQUserPointer data=0;
|
||||
if (!table.RawGetUserData(varNameTag,&data)) {
|
||||
return sa.ThrowError(_SC("getVarInfo: Could not retrieve UserData")); // Results in variable not being found error.
|
||||
}
|
||||
vr = (VarRefPtr)data;
|
||||
return SQ_OK;
|
||||
} // getVarInfo
|
||||
|
||||
static int getInstanceVarInfo(StackHandler & sa,VarRefPtr & vr,SQUserPointer & data) {
|
||||
HSQOBJECT ho = sa.GetObjectHandle(1);
|
||||
SquirrelObject instance(ho);
|
||||
const SQChar * el = sa.GetString(2);
|
||||
ScriptStringVar256 varNameTag;
|
||||
getVarNameTag(varNameTag,sizeof(varNameTag),el);
|
||||
SQUserPointer ivrData=0;
|
||||
if (!instance.RawGetUserData(varNameTag,&ivrData)) {
|
||||
return sa.ThrowError(_SC("getInstanceVarInfo: Could not retrieve UserData")); // Results in variable not being found error.
|
||||
}
|
||||
vr = (VarRefPtr)ivrData;
|
||||
|
||||
char * up;
|
||||
if (!(vr->m_access & (VAR_ACCESS_STATIC|VAR_ACCESS_CONSTANT))) {
|
||||
SQUserPointer typetag;
|
||||
instance.GetTypeTag(&typetag);
|
||||
|
||||
#if defined(SQ_USE_CLASS_INHERITANCE)
|
||||
if (typetag != vr->instanceType) {
|
||||
SquirrelObject typeTable = instance.GetValue(SQ_CLASS_OBJECT_TABLE_NAME);
|
||||
up = (char *)typeTable.GetUserPointer(INT((size_t)vr->instanceType)); // <TODO> 64-bit compatible version.
|
||||
if (!up) {
|
||||
throw SquirrelError(_SC("Invalid Instance Type"));
|
||||
}
|
||||
} else {
|
||||
up = (char *)instance.GetInstanceUP(0);
|
||||
} // if
|
||||
|
||||
#elif defined(SQ_USE_CLASS_INHERITANCE_SIMPLE)
|
||||
ClassTypeBase *ctb = (ClassTypeBase*)vr->instanceType;
|
||||
up = (char *)instance.GetInstanceUP(0);
|
||||
// Walk base classes until type tag match, adjust for inheritence offset
|
||||
while(ctb && typetag!=ctb) {
|
||||
up = (char*)up - ctb->m_offset;
|
||||
ctb = ctb->m_pbase;
|
||||
}
|
||||
if (!ctb) {
|
||||
throw SquirrelError(_SC("Invalid Instance Type"));
|
||||
}
|
||||
#else
|
||||
up = (char *)instance.GetInstanceUP(0);
|
||||
#endif
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_OPT
|
||||
#define SQPLUS_SMARTPOINTER_INSTANCE_VARINFO
|
||||
#include "SqPlusSmartPointer.h"
|
||||
#endif
|
||||
|
||||
up += (size_t)vr->offsetOrAddrOrConst; // Offset
|
||||
} else {
|
||||
up = (char *)vr->offsetOrAddrOrConst; // Address
|
||||
} // if
|
||||
data = up;
|
||||
return SQ_OK;
|
||||
} // getInstanceVarInfo
|
||||
|
||||
|
||||
// If not static/global, message can (and will) disappear before arriving at catch (G++)
|
||||
static ScriptStringVar256 g_msg_throw;
|
||||
|
||||
static int setVar(StackHandler & sa,VarRef * vr,void * data) {
|
||||
if (vr->m_access & (VAR_ACCESS_READ_ONLY|VAR_ACCESS_CONSTANT)) {
|
||||
const SQChar * el = sa.GetString(2);
|
||||
SCSNPRINTF(g_msg_throw.s,sizeof(g_msg_throw),_SC("setVar(): Cannot write to constant: %s"),el);
|
||||
throw SquirrelError(g_msg_throw.s);
|
||||
} // if
|
||||
switch (vr->m_type) {
|
||||
case TypeInfo<INT>::TypeID: {
|
||||
INT * val = (INT *)data; // Address
|
||||
if (val) {
|
||||
INT v = sa.GetInt(3);
|
||||
// Support for different int sizes
|
||||
switch( vr->m_size ) {
|
||||
case 1: v = (*(char*)val = (char)v); break;
|
||||
case 2: v = (*(short*)val = (short)v); break;
|
||||
#ifdef _SQ64
|
||||
case 4: v = (*(int*)val = (int)v); break;
|
||||
#endif
|
||||
default: *val = v;
|
||||
}
|
||||
return sa.Return(v);
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
case TypeInfo<unsigned>::TypeID: {
|
||||
unsigned * val = (unsigned *)data; // Address
|
||||
if (val) {
|
||||
*val = sa.GetInt(3);
|
||||
return sa.Return(static_cast<INT>(*val));
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
case TypeInfo<FLOAT>::TypeID: {
|
||||
FLOAT * val = (FLOAT *)data; // Address
|
||||
if (val) {
|
||||
*val = sa.GetFloat(3);
|
||||
return sa.Return(*val);
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
case TypeInfo<bool>::TypeID: {
|
||||
bool * val = (bool *)data; // Address
|
||||
if (val) {
|
||||
*val = sa.GetBool(3) ? true : false;
|
||||
return sa.Return(*val);
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
case VAR_TYPE_INSTANCE: {
|
||||
HSQUIRRELVM v = sa.GetVMPtr();
|
||||
SQUserPointer src = sa.GetInstanceUp(3,(SQUserPointer)vr->varType); // Effectively performs: ClassType<>::type() == ClassType<>().
|
||||
if (!src) {
|
||||
throw SquirrelError(_SC("INSTANCE type assignment mismatch"));
|
||||
}
|
||||
vr->varType->vgetCopyFunc()(data,src);
|
||||
return 0;
|
||||
}
|
||||
case TypeInfo<SQUserPointer>::TypeID: {
|
||||
const SQChar * el = sa.GetString(2);
|
||||
SCSNPRINTF(g_msg_throw.s,sizeof(g_msg_throw),_SC("setVar(): Cannot write to an SQUserPointer: %s"),el);
|
||||
throw SquirrelError(g_msg_throw.s);
|
||||
} // case
|
||||
case TypeInfo<ScriptStringVarBase>::TypeID: {
|
||||
ScriptStringVarBase * val = (ScriptStringVarBase *)data; // Address
|
||||
if (val) {
|
||||
const SQChar * strVal = sa.GetString(3);
|
||||
if (strVal) {
|
||||
*val = strVal;
|
||||
return sa.Return(val->s);
|
||||
} // if
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
#if defined(SQPLUS_SUPPORT_STD_STRING) && !defined(SQUNICODE)
|
||||
case TypeInfo<std::string>::TypeID: {
|
||||
std::string *val = (std::string*)data; // Address
|
||||
if (val) {
|
||||
const SQChar *strVal = sa.GetString(3);
|
||||
if (strVal) {
|
||||
*val = strVal;
|
||||
return sa.Return(val->c_str());
|
||||
} // if
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
#endif
|
||||
} // switch
|
||||
return SQ_ERROR;
|
||||
} // setVar
|
||||
|
||||
static int getVar(StackHandler & sa,VarRef * vr,void * data) {
|
||||
switch (vr->m_type) {
|
||||
case TypeInfo<INT>::TypeID: {
|
||||
if (!(vr->m_access & VAR_ACCESS_CONSTANT)) {
|
||||
if (data) {
|
||||
INT v;
|
||||
// Support for different int sizes
|
||||
switch( vr->m_size ){
|
||||
case 1: v = *(char*)data; break;
|
||||
case 2: v = *(short*)data; break;
|
||||
#ifdef _SQ64
|
||||
case 4: v = *(int*)data; break;
|
||||
#endif
|
||||
default: v = *(INT*)data;
|
||||
}
|
||||
return sa.Return(v);
|
||||
} // if
|
||||
} else {
|
||||
INT * val = (INT *)&data; // Constant value
|
||||
return sa.Return(*val);
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
case TypeInfo<unsigned>::TypeID: {
|
||||
if (!(vr->m_access & VAR_ACCESS_CONSTANT)) {
|
||||
unsigned * val = (unsigned *)data; // Address
|
||||
if (val){
|
||||
return sa.Return(static_cast<INT>(*val));
|
||||
}
|
||||
} else {
|
||||
unsigned * val = (unsigned *)&data; // Constant value
|
||||
return sa.Return(static_cast<INT>(*val));
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
case TypeInfo<FLOAT>::TypeID: {
|
||||
if (!(vr->m_access & VAR_ACCESS_CONSTANT)) {
|
||||
FLOAT * val = (FLOAT *)data; // Address
|
||||
if (val) {
|
||||
return sa.Return(*val);
|
||||
} // if
|
||||
} else {
|
||||
FLOAT * val = (FLOAT *)&data; // Constant value
|
||||
return sa.Return(*val);
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
case TypeInfo<bool>::TypeID: {
|
||||
if (!(vr->m_access & VAR_ACCESS_CONSTANT)) {
|
||||
bool * val = (bool *)data; // Address
|
||||
if (val) {
|
||||
return sa.Return(*val);
|
||||
} // if
|
||||
} else {
|
||||
bool * val = (bool *)&data; // Constant value
|
||||
return sa.Return(*val);
|
||||
} // if
|
||||
break;
|
||||
} // case
|
||||
case VAR_TYPE_INSTANCE:
|
||||
if (!CreateNativeClassInstance(sa.GetVMPtr(),vr->varType->GetTypeName(),data,0)) { // data = address. Allocates memory.
|
||||
SCSNPRINTF(g_msg_throw.s,sizeof(g_msg_throw),_SC("getVar(): Could not create instance: %s"),vr->varType->GetTypeName());
|
||||
throw SquirrelError(g_msg_throw.s);
|
||||
} // if
|
||||
return 1;
|
||||
case TypeInfo<SQUserPointer>::TypeID:
|
||||
return sa.Return(data); // The address of member variable, not the variable itself.
|
||||
case TypeInfo<ScriptStringVarBase>::TypeID: {
|
||||
if (!(vr->m_access & VAR_ACCESS_CONSTANT)) {
|
||||
ScriptStringVarBase * val = (ScriptStringVarBase *)data; // Address
|
||||
if (val) {
|
||||
return sa.Return(val->s);
|
||||
} // if
|
||||
} else {
|
||||
throw SquirrelError(_SC("getVar(): Invalid type+access: 'ScriptStringVarBase' with VAR_ACCESS_CONSTANT (use VAR_ACCESS_READ_ONLY instead)"));
|
||||
}
|
||||
break;
|
||||
} // case
|
||||
case TypeInfo<const SQChar *>::TypeID: {
|
||||
if (!(vr->m_access & VAR_ACCESS_CONSTANT)) {
|
||||
if( vr->m_access==VAR_ACCESS_READ_WRITE )
|
||||
throw SquirrelError(_SC("getVar(): Invalid type+access: 'const SQChar *' without VAR_ACCESS_CONSTANT"));
|
||||
// It is OK to read from a SQChar* if requested
|
||||
return sa.Return(*(const SQChar **)data); // Address
|
||||
} else {
|
||||
return sa.Return((const SQChar *)data); // Address
|
||||
}
|
||||
break;
|
||||
} // case
|
||||
#ifdef SQPLUS_SUPPORT_STD_STRING
|
||||
case TypeInfo<std::string>::TypeID: {
|
||||
if (!(vr->m_access & VAR_ACCESS_CONSTANT)) {
|
||||
std::string *val = (std::string *)data; // Address
|
||||
if (val) {
|
||||
return sa.Return(val->c_str());
|
||||
}
|
||||
} else {
|
||||
throw SquirrelError(_SC("getVar(): Invalid type+access: 'std::string' with VAR_ACCESS_CONSTANT (use VAR_ACCESS_READ_ONLY instead)"));
|
||||
}
|
||||
break;
|
||||
} // case
|
||||
#endif
|
||||
} // switch
|
||||
return SQ_ERROR;
|
||||
} // getVar
|
||||
|
||||
// === Global Vars ===
|
||||
|
||||
int setVarFunc(HSQUIRRELVM v) {
|
||||
SquirrelVM::Init(v); // For handling multi-VM setting right
|
||||
StackHandler sa(v);
|
||||
if (sa.GetType(1) == OT_TABLE) {
|
||||
VarRefPtr vr;
|
||||
int res = getVarInfo(sa,vr);
|
||||
if (res != SQ_OK) return res;
|
||||
return setVar(sa,vr,vr->offsetOrAddrOrConst);
|
||||
} // if
|
||||
return SQ_ERROR;
|
||||
} // setVarFunc
|
||||
|
||||
int getVarFunc(HSQUIRRELVM v) {
|
||||
SquirrelVM::Init(v); // For handling multi-VM setting right
|
||||
StackHandler sa(v);
|
||||
if (sa.GetType(1) == OT_TABLE) {
|
||||
VarRefPtr vr;
|
||||
int res = getVarInfo(sa,vr);
|
||||
if (res != SQ_OK) return res;
|
||||
return getVar(sa,vr,vr->offsetOrAddrOrConst);
|
||||
} // if
|
||||
return SQ_ERROR;
|
||||
} // getVarFunc
|
||||
|
||||
// === Instance Vars ===
|
||||
|
||||
int setInstanceVarFunc(HSQUIRRELVM v) {
|
||||
SquirrelVM::Init(v); // For handling multi-VM setting right
|
||||
StackHandler sa(v);
|
||||
if (sa.GetType(1) == OT_INSTANCE) {
|
||||
VarRefPtr vr;
|
||||
void * data;
|
||||
int res = getInstanceVarInfo(sa,vr,data);
|
||||
if (res != SQ_OK) return res;
|
||||
return setVar(sa,vr,data);
|
||||
} // if
|
||||
return SQ_ERROR;
|
||||
} // setInstanceVarFunc
|
||||
|
||||
int getInstanceVarFunc(HSQUIRRELVM v) {
|
||||
SquirrelVM::Init(v); // For handling multi-VM setting right
|
||||
StackHandler sa(v);
|
||||
if (sa.GetType(1) == OT_INSTANCE) {
|
||||
VarRefPtr vr;
|
||||
void * data;
|
||||
int res = getInstanceVarInfo(sa,vr,data);
|
||||
if (res != SQ_OK) return res;
|
||||
return getVar(sa,vr,data);
|
||||
} // if
|
||||
return SQ_ERROR;
|
||||
} // getInstanceVarFunc
|
||||
|
||||
// === Classes ===
|
||||
|
||||
BOOL CreateClass(HSQUIRRELVM v,SquirrelObject & newClass,SQUserPointer classType,const SQChar * name,const SQChar * baseName) {
|
||||
int n = 0;
|
||||
int oldtop = sq_gettop(v);
|
||||
sq_pushroottable(v);
|
||||
sq_pushstring(v,name,-1);
|
||||
if (baseName) {
|
||||
sq_pushstring(v,baseName,-1);
|
||||
if (SQ_FAILED(sq_get(v,-3))) { // Make sure the base exists if specified by baseName.
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
} // if
|
||||
} // if
|
||||
if (SQ_FAILED(sq_newclass(v,baseName ? 1 : 0))) { // Will inherit from base class on stack from sq_get() above.
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
} // if
|
||||
newClass.AttachToStackObject(-1);
|
||||
sq_settypetag(v,-1,classType);
|
||||
sq_createslot(v,-3);
|
||||
sq_pop(v,1);
|
||||
return TRUE;
|
||||
} // CreateClass
|
||||
|
||||
SquirrelObject RegisterClassType(HSQUIRRELVM v,const SQChar * scriptClassName,SQUserPointer classType,SQFUNCTION constructor) {
|
||||
SquirrelVM::Init(v); // For handling multi-VM setting right
|
||||
int top = sq_gettop(v);
|
||||
SquirrelObject newClass;
|
||||
if (CreateClass(v,newClass,classType,scriptClassName)) {
|
||||
SquirrelVM::CreateFunction(newClass,constructor,_SC("constructor"));
|
||||
} // if
|
||||
sq_settop(v,top);
|
||||
return newClass;
|
||||
} // RegisterClassType
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GCC sometimes has problems with finding inline functions at link time
|
||||
// (that also have a template definition). To solve the problem,
|
||||
// non-inlines goes here.
|
||||
#ifdef GCC_INLINE_WORKAROUND
|
||||
# include "SqPlusFunctionCallImpl.h"
|
||||
#endif // GCC_INLINE_WORKAROUND
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace SqPlus
|
||||
|
@ -1,337 +0,0 @@
|
||||
|
||||
// This file is included multiple times, with varying options - No header guard.
|
||||
|
||||
// Include this file to generate Call templates with or without these options:
|
||||
// - SQPLUS_APPLY_CONST - const qualifier after functions signature (const func / member func)
|
||||
// - SQPLUS_APPLY_CDECL - qualifier before class name (MSVC specific calling convention)
|
||||
|
||||
#undef CONST_QUAL
|
||||
#undef CALL_QUAL
|
||||
|
||||
#ifdef SQPLUS_APPLY_CONST
|
||||
#define CONST_QUAL const
|
||||
#else
|
||||
#define CONST_QUAL
|
||||
#endif
|
||||
|
||||
#ifdef SQPLUS_APPLY_CDECL
|
||||
#define CALL_QUAL __cdecl
|
||||
#else
|
||||
#define CALL_QUAL
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SQPLUS_CALL_MFUNC_RET0
|
||||
|
||||
// Include this file again, with __cdecl also (Visual C++ specific)
|
||||
#if defined(SQPLUS_ENABLE_CDECL_MEMBER_FUNCTIONS) && !defined(SQPLUS_APPLY_CDECL)
|
||||
#define SQPLUS_APPLY_CDECL
|
||||
#include "SqPlusCallTemplates.h"
|
||||
#undef CALL_QUAL
|
||||
#define CALL_QUAL
|
||||
#endif
|
||||
|
||||
template <typename Callee>
|
||||
static int Call(Callee & callee,RT (CALL_QUAL Callee::*func)() CONST_QUAL,HSQUIRRELVM v,int /*index*/) {
|
||||
RT ret = (callee.*func)();
|
||||
Push(v,ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename Callee,typename P1>
|
||||
static int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1) CONST_QUAL,HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
RT ret = (callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0)
|
||||
);
|
||||
Push(v,ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2>
|
||||
static int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2) CONST_QUAL,HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
RT ret = (callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1)
|
||||
);
|
||||
Push(v,ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3>
|
||||
static int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3) CONST_QUAL,HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
RT ret = (callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2)
|
||||
);
|
||||
Push(v,ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3,typename P4>
|
||||
static int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3,P4) CONST_QUAL,HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
sq_argassert(4,index + 3);
|
||||
RT ret = (callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2),
|
||||
Get(TypeWrapper<P4>(),v,index + 3)
|
||||
);
|
||||
Push(v,ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5>
|
||||
static int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5) CONST_QUAL,HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
sq_argassert(4,index + 3);
|
||||
sq_argassert(5,index + 4);
|
||||
RT ret = (callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2),
|
||||
Get(TypeWrapper<P4>(),v,index + 3),
|
||||
Get(TypeWrapper<P5>(),v,index + 4)
|
||||
);
|
||||
Push(v,ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6>
|
||||
static int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5,P6) CONST_QUAL,HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
sq_argassert(4,index + 3);
|
||||
sq_argassert(5,index + 4);
|
||||
sq_argassert(6,index + 5);
|
||||
RT ret = (callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2),
|
||||
Get(TypeWrapper<P4>(),v,index + 3),
|
||||
Get(TypeWrapper<P5>(),v,index + 4),
|
||||
Get(TypeWrapper<P6>(),v,index + 5)
|
||||
);
|
||||
Push(v,ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7>
|
||||
static int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5,P6,P7) CONST_QUAL,HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
sq_argassert(4,index + 3);
|
||||
sq_argassert(5,index + 4);
|
||||
sq_argassert(6,index + 5);
|
||||
sq_argassert(7,index + 6);
|
||||
RT ret = (callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2),
|
||||
Get(TypeWrapper<P4>(),v,index + 3),
|
||||
Get(TypeWrapper<P5>(),v,index + 4),
|
||||
Get(TypeWrapper<P6>(),v,index + 5),
|
||||
Get(TypeWrapper<P7>(),v,index + 6)
|
||||
);
|
||||
Push(v,ret);
|
||||
return 1;
|
||||
}
|
||||
#undef SQPLUS_CALL_MFUNC_RET0
|
||||
#endif // SQPLUS_CALL_MFUNC_RET0
|
||||
|
||||
|
||||
#ifdef SQPLUS_CALL_MFUNC_NORET
|
||||
|
||||
// Include this very same thing with __cdecl also
|
||||
#if defined(SQPLUS_ENABLE_CDECL_MEMBER_FUNCTIONS) && !defined(SQPLUS_APPLY_CDECL)
|
||||
#define SQPLUS_APPLY_CDECL
|
||||
#include "SqPlusCallTemplates.h"
|
||||
#undef CALL_QUAL
|
||||
#define CALL_QUAL
|
||||
#endif
|
||||
|
||||
// === Member function calls ===
|
||||
|
||||
template<typename Callee>
|
||||
static int Call(Callee & callee,void (CALL_QUAL Callee::*func)() CONST_QUAL, HSQUIRRELVM,int /*index*/) {
|
||||
(callee.*func)();
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1>
|
||||
static int Call(Callee & callee,void (CALL_QUAL Callee::*func)(P1) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
(callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2>
|
||||
static int Call(Callee & callee,void (CALL_QUAL Callee::*func)(P1,P2) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
(callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3>
|
||||
static int Call(Callee & callee,void (CALL_QUAL Callee::*func)(P1,P2,P3) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
(callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3,typename P4>
|
||||
static int Call(Callee & callee,void (CALL_QUAL Callee::*func)(P1,P2,P3,P4) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
sq_argassert(4,index + 3);
|
||||
(callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2),
|
||||
Get(TypeWrapper<P4>(),v,index + 3)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5>
|
||||
static int Call(Callee & callee,void (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
sq_argassert(4,index + 3);
|
||||
sq_argassert(5,index + 4);
|
||||
(callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2),
|
||||
Get(TypeWrapper<P4>(),v,index + 3),
|
||||
Get(TypeWrapper<P5>(),v,index + 4)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6>
|
||||
static int Call(Callee & callee,void (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5,P6) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
sq_argassert(4,index + 3);
|
||||
sq_argassert(5,index + 4);
|
||||
sq_argassert(6,index + 5);
|
||||
(callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2),
|
||||
Get(TypeWrapper<P4>(),v,index + 3),
|
||||
Get(TypeWrapper<P5>(),v,index + 4),
|
||||
Get(TypeWrapper<P6>(),v,index + 5)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7>
|
||||
static int Call(Callee & callee,void (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5,P6,P7) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
sq_argassert(1,index + 0);
|
||||
sq_argassert(2,index + 1);
|
||||
sq_argassert(3,index + 2);
|
||||
sq_argassert(4,index + 3);
|
||||
sq_argassert(5,index + 4);
|
||||
sq_argassert(6,index + 5);
|
||||
sq_argassert(7,index + 6);
|
||||
(callee.*func)(
|
||||
Get(TypeWrapper<P1>(),v,index + 0),
|
||||
Get(TypeWrapper<P2>(),v,index + 1),
|
||||
Get(TypeWrapper<P3>(),v,index + 2),
|
||||
Get(TypeWrapper<P4>(),v,index + 3),
|
||||
Get(TypeWrapper<P5>(),v,index + 4),
|
||||
Get(TypeWrapper<P6>(),v,index + 5),
|
||||
Get(TypeWrapper<P7>(),v,index + 6)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
#undef SQPLUS_CALL_MFUNC_NORET
|
||||
#endif // SQPLUS_CALL_MFUNC_NORET
|
||||
|
||||
|
||||
#ifdef SQPLUS_CALL_MFUNC_RET1
|
||||
|
||||
// Include this very same thing with __cdecl also
|
||||
#if defined(SQPLUS_ENABLE_CDECL_MEMBER_FUNCTIONS) && !defined(SQPLUS_APPLY_CDECL)
|
||||
#define SQPLUS_APPLY_CDECL
|
||||
#include "SqPlusCallTemplates.h"
|
||||
#undef CALL_QUAL
|
||||
#define CALL_QUAL
|
||||
#endif
|
||||
|
||||
template<typename Callee,typename RT>
|
||||
int Call(Callee & callee, RT (CALL_QUAL Callee::*func)() CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
return ReturnSpecialization<RT>::Call(callee,func,v,index);
|
||||
}
|
||||
|
||||
template<typename Callee,typename RT,typename P1>
|
||||
int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
return ReturnSpecialization<RT>::Call(callee,func,v,index);
|
||||
}
|
||||
|
||||
template<typename Callee,typename RT,typename P1,typename P2>
|
||||
int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
return ReturnSpecialization<RT>::Call(callee,func,v,index);
|
||||
}
|
||||
|
||||
template<typename Callee,typename RT,typename P1,typename P2,typename P3>
|
||||
int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
return ReturnSpecialization<RT>::Call(callee,func,v,index);
|
||||
}
|
||||
|
||||
template<typename Callee,typename RT,typename P1,typename P2,typename P3,typename P4>
|
||||
int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3,P4) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
return ReturnSpecialization<RT>::Call(callee,func,v,index);
|
||||
}
|
||||
|
||||
template<typename Callee,typename RT,typename P1,typename P2,typename P3,typename P4,typename P5>
|
||||
int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
return ReturnSpecialization<RT>::Call(callee,func,v,index);
|
||||
}
|
||||
|
||||
template<typename Callee,typename RT,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6>
|
||||
int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5,P6) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
return ReturnSpecialization<RT>::Call(callee,func,v,index);
|
||||
}
|
||||
|
||||
template<typename Callee,typename RT,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7>
|
||||
int Call(Callee & callee,RT (CALL_QUAL Callee::*func)(P1,P2,P3,P4,P5,P6,P7) CONST_QUAL, HSQUIRRELVM v,int index) {
|
||||
return ReturnSpecialization<RT>::Call(callee,func,v,index);
|
||||
}
|
||||
|
||||
#undef SQPLUS_CALL_MFUNC_RET1
|
||||
#endif // SQPLUS_CALL_MFUNC_RET1
|
||||
|
||||
// We will be reusing these symbols later
|
||||
#undef SQPLUS_APPLY_CDECL
|
||||
#undef SQPLUS_APPLY_CONST
|
@ -1,74 +0,0 @@
|
||||
// SqPlusConst.h
|
||||
// SqPlus constant type and constant member function support created by Simon Michelmore.
|
||||
// Modular integration 11/14/05 jcs.
|
||||
|
||||
#ifdef SQPLUS_DECLARE_INSTANCE_TYPE_CONST
|
||||
#undef SQPLUS_DECLARE_INSTANCE_TYPE_CONST
|
||||
|
||||
// Kamaitati's NULL_INSTANCE support. 5/28/06 jcs
|
||||
|
||||
#ifdef SQPLUS_SUPPORT_NULL_INSTANCES
|
||||
|
||||
#define DECLARE_INSTANCE_TYPE_NAME_CONST_BASE(TYPE,NAME) \
|
||||
inline bool Match(TypeWrapper<const TYPE &>,HSQUIRRELVM v,int idx) { return GetInstance<TYPE,false>(v,idx) != NULL; } \
|
||||
inline const TYPE & Get(TypeWrapper<const TYPE &>,HSQUIRRELVM v,int idx) { return *GetInstance<TYPE,true>(v,idx); }
|
||||
|
||||
// Ordinary case
|
||||
#define DECLARE_INSTANCE_TYPE_NAME_CONST(TYPE,NAME) \
|
||||
DECLARE_INSTANCE_TYPE_NAME_(TYPE,NAME) \
|
||||
namespace SqPlus { \
|
||||
DECLARE_INSTANCE_TYPE_NAME_CONST_BASE(TYPE,NAME) \
|
||||
template<> inline void Push(HSQUIRRELVM v,const TYPE * value) { \
|
||||
if (!value) sq_pushnull(v); \
|
||||
else if (!CreateNativeClassInstance(v,GetTypeName(*value),(TYPE*)value,0)) \
|
||||
throw SquirrelError(_SC("Push(): could not create INSTANCE (check registration name)")); } \
|
||||
template<> inline void Push(HSQUIRRELVM v,const TYPE & value) { if (!CreateCopyInstance(v,GetTypeName(value),value)) throw SquirrelError(_SC("Push(): could not create INSTANCE copy (check registration name)")); } \
|
||||
} // nameSpace SqPlus
|
||||
|
||||
// Case for custom Push implementation (covariant return type)
|
||||
#define DECLARE_INSTANCE_TYPE_NAME_CONST_CUSTOM(TYPE,NAME) \
|
||||
DECLARE_INSTANCE_TYPE_NAME_CUSTOM_(TYPE,NAME) \
|
||||
namespace SqPlus { \
|
||||
DECLARE_INSTANCE_TYPE_NAME_CONST_BASE(TYPE,NAME) \
|
||||
template<> void Push(HSQUIRRELVM v,const TYPE * value); \
|
||||
template<> void Push(HSQUIRRELVM v,const TYPE & value); \
|
||||
} // nameSpace SqPlus
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#define DECLARE_INSTANCE_TYPE_NAME_CONST(TYPE,NAME) \
|
||||
DECLARE_INSTANCE_TYPE_NAME_(TYPE,NAME) \
|
||||
namespace SqPlus { \
|
||||
template<> inline void Push(HSQUIRRELVM v,const TYPE * value) { if (!CreateNativeClassInstance(v,GetTypeName(*value),(TYPE*)value,0)) throw SquirrelError(_SC("Push(): could not create INSTANCE (check registration name)")); } \
|
||||
template<> inline void Push(HSQUIRRELVM v,const TYPE & value) { if (!CreateCopyInstance(v,GetTypeName(value),value)) throw SquirrelError(_SC("Push(): could not create INSTANCE copy (check registration name)")); } \
|
||||
template<> inline bool Match(TypeWrapper<const TYPE &>,HSQUIRRELVM v,int idx) { return GetInstance<TYPE,false>(v,idx) != NULL; } \
|
||||
template<> inline const TYPE & Get(TypeWrapper<const TYPE &>,HSQUIRRELVM v,int idx) { return *GetInstance<TYPE,true>(v,idx); } \
|
||||
} // nameSpace SqPlus
|
||||
|
||||
#endif
|
||||
|
||||
#define DECLARE_INSTANCE_TYPE(TYPE) DECLARE_INSTANCE_TYPE_NAME_CONST(TYPE,TYPE)
|
||||
#define DECLARE_INSTANCE_TYPE_NAME(TYPE,NAME) DECLARE_INSTANCE_TYPE_NAME_CONST(TYPE,NAME)
|
||||
#define DECLARE_INSTANCE_TYPE_CUSTOM(TYPE) DECLARE_INSTANCE_TYPE_NAME_CONST_CUSTOM(TYPE,TYPE)
|
||||
#define DECLARE_INSTANCE_TYPE_NAME_CUSTOM(TYPE,NAME) DECLARE_INSTANCE_TYPE_NAME_CONST_CUSTOM(TYPE,NAME)
|
||||
#endif
|
||||
|
||||
#define SQPLUS_APPLY_CONST
|
||||
#include "SqPlusCallTemplates.h"
|
||||
|
||||
|
||||
#ifdef SQ_REG_CONST_STATIC_VAR
|
||||
#undef SQ_REG_CONST_STATIC_VAR
|
||||
template<typename VarType>
|
||||
SQClassDefBase & staticVar(const VarType * pvar,const SQChar * name,VarAccessType access=VAR_ACCESS_READ_ONLY) {
|
||||
struct CV {
|
||||
const VarType * var;
|
||||
} cv; // Cast Variable helper.
|
||||
cv.var = pvar;
|
||||
RegisterInstanceVariable(newClass,ClassType<TClassType>::type(),*(VarType **)&cv,name,VarAccessType(access|VAR_ACCESS_STATIC));
|
||||
return *this;
|
||||
} // staticVar
|
||||
#endif
|
||||
|
||||
// SqPlusConst.h
|
@ -1,114 +0,0 @@
|
||||
#ifndef _SQPLUS_FUNCTION_CALL_IMPL_H_
|
||||
#define _SQPLUS_FUNCTION_CALL_IMPL_H_
|
||||
|
||||
#ifdef GCC_INLINE_WORKAROUND
|
||||
# define SQINLINE
|
||||
#else
|
||||
# define SQINLINE inline
|
||||
#endif
|
||||
|
||||
SQINLINE void Push(HSQUIRRELVM v,char value) { sq_pushinteger(v,value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,unsigned char value) { sq_pushinteger(v,value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,short value) { sq_pushinteger(v,value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,unsigned short value) { sq_pushinteger(v,value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,int value) { sq_pushinteger(v,value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,unsigned int value) { sq_pushinteger(v,value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,long value) { sq_pushinteger(v,value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,unsigned long value) { sq_pushinteger(v,value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,double value) { sq_pushfloat(v,(FLOAT)value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,float value) { sq_pushfloat(v,(FLOAT)value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,const SQChar * value) { sq_pushstring(v,value,-1); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,SQChar * value) { sq_pushstring(v,value,-1); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,const SquirrelNull &) { sq_pushnull(v); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,SQFUNCTION value) { sq_pushuserpointer(v,(void*)value); }
|
||||
SQINLINE void Push(HSQUIRRELVM v,SQAnythingPtr value) { sq_pushuserpointer(v,(void*)value); } // Cast to SQAnythingPtr instead of void * if USE_ARGUMENT_DEPENDANT_OVERLOADS can't be used by your compiler.
|
||||
SQINLINE void Push(HSQUIRRELVM v,SquirrelObject & so) { sq_pushobject(v,so.GetObjectHandle()); }
|
||||
|
||||
#ifdef USE_ARGUMENT_DEPENDANT_OVERLOADS
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable:4675) // Disable warning: "resolved overload was found by argument-dependent lookup" when class/struct pointers are used as function arguments.
|
||||
#endif
|
||||
// === BEGIN Argument Dependent Overloads ===
|
||||
SQINLINE void Push(HSQUIRRELVM v,bool value) { sq_pushbool(v,value); } // Pass bool as int if USE_ARGUMENT_DEPENDANT_OVERLOADS can't be used by your compiler.
|
||||
SQINLINE void Push(HSQUIRRELVM v,const void * value) { sq_pushuserpointer(v,(void*)value); } // Pass SQAnythingPtr instead of void * " "
|
||||
SQINLINE void Push(HSQUIRRELVM v,const SQUserPointer & value) { sq_pushuserpointer(v,(void*)value); }
|
||||
// === END Argument Dependent Overloads ===
|
||||
#endif
|
||||
|
||||
#define SQPLUS_CHECK_GET(res) if (!SQ_SUCCEEDED(res)) throw SquirrelError(_SC("sq_get*() failed (type error)"))
|
||||
|
||||
//SQINLINE bool Match(TypeWrapper<bool>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_BOOL; }
|
||||
SQINLINE bool Match(TypeWrapper<bool>,HSQUIRRELVM v,int idx) { return true; } // All types can be cast to bool
|
||||
SQINLINE bool Match(TypeWrapper<char>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_INTEGER; }
|
||||
SQINLINE bool Match(TypeWrapper<unsigned char>,HSQUIRRELVM v, int idx) { return sq_gettype(v,idx) == OT_INTEGER; }
|
||||
SQINLINE bool Match(TypeWrapper<short>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_INTEGER; }
|
||||
SQINLINE bool Match(TypeWrapper<unsigned short>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_INTEGER; }
|
||||
SQINLINE bool Match(TypeWrapper<int>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_INTEGER; }
|
||||
SQINLINE bool Match(TypeWrapper<unsigned int>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_INTEGER; }
|
||||
SQINLINE bool Match(TypeWrapper<long>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_INTEGER; }
|
||||
SQINLINE bool Match(TypeWrapper<unsigned long>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_INTEGER; }
|
||||
SQINLINE bool Match(TypeWrapper<float>,HSQUIRRELVM v,int idx) { int type = sq_gettype(v,idx); return type == OT_FLOAT; }
|
||||
SQINLINE bool Match(TypeWrapper<double>,HSQUIRRELVM v,int idx) { int type = sq_gettype(v,idx); return type == OT_FLOAT; }
|
||||
SQINLINE bool Match(TypeWrapper<const SQChar *>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_STRING; }
|
||||
SQINLINE bool Match(TypeWrapper<SQChar *>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_STRING; }
|
||||
SQINLINE bool Match(TypeWrapper<HSQUIRRELVM>,HSQUIRRELVM v,int idx) { return true; } // See Get() for HSQUIRRELVM below (v is always present).
|
||||
SQINLINE bool Match(TypeWrapper<void*>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_USERPOINTER; }
|
||||
SQINLINE bool Match(TypeWrapper<SquirrelObject>,HSQUIRRELVM v,int idx) { return true; } // See sq_getstackobj(): always returns true.
|
||||
|
||||
SQINLINE void Get(TypeWrapper<void>,HSQUIRRELVM v,int) {}
|
||||
//SQINLINE bool Get(TypeWrapper<bool>,HSQUIRRELVM v,int idx) { SQBool b; SQPLUS_CHECK_GET(sq_getbool(v,idx,&b)); return b != 0; }
|
||||
SQINLINE char Get(TypeWrapper<char>,HSQUIRRELVM v,int idx) { INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return static_cast<char>(i); }
|
||||
SQINLINE unsigned char Get(TypeWrapper<unsigned char>,HSQUIRRELVM v,int idx) { INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return static_cast<unsigned char>(i); }
|
||||
SQINLINE short Get(TypeWrapper<short>,HSQUIRRELVM v,int idx) { INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return static_cast<short>(i); }
|
||||
SQINLINE unsigned short Get(TypeWrapper<unsigned short>,HSQUIRRELVM v,int idx) { INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return static_cast<unsigned short>(i); }
|
||||
SQINLINE int Get(TypeWrapper<int>,HSQUIRRELVM v,int idx) { INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return i; }
|
||||
SQINLINE unsigned int Get(TypeWrapper<unsigned int>,HSQUIRRELVM v,int idx) { INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return static_cast<unsigned int>(i); }
|
||||
SQINLINE long Get(TypeWrapper<long>,HSQUIRRELVM v,int idx) { INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return static_cast<long>(i); }
|
||||
SQINLINE unsigned long Get(TypeWrapper<unsigned long>,HSQUIRRELVM v,int idx) { INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return static_cast<unsigned long>(i); }
|
||||
SQINLINE float Get(TypeWrapper<float>,HSQUIRRELVM v,int idx) { FLOAT f; SQPLUS_CHECK_GET(sq_getfloat(v,idx,&f)); return f; }
|
||||
SQINLINE double Get(TypeWrapper<double>,HSQUIRRELVM v,int idx) { FLOAT f; SQPLUS_CHECK_GET(sq_getfloat(v,idx,&f)); return static_cast<double>(f); }
|
||||
SQINLINE const SQChar * Get(TypeWrapper<const SQChar *>,HSQUIRRELVM v,int idx) { const SQChar * s; SQPLUS_CHECK_GET(sq_getstring(v,idx,&s)); return s; }
|
||||
SQINLINE SquirrelNull Get(TypeWrapper<SquirrelNull>,HSQUIRRELVM v,int idx) { (void)v, (void)idx; return SquirrelNull(); }
|
||||
SQINLINE void * Get(TypeWrapper<void *>,HSQUIRRELVM v,int idx) { SQUserPointer p; SQPLUS_CHECK_GET(sq_getuserpointer(v,idx,&p)); return p; }
|
||||
SQINLINE HSQUIRRELVM Get(TypeWrapper<HSQUIRRELVM>,HSQUIRRELVM v,int /*idx*/) { sq_poptop(v); return v; } // sq_poptop(v): remove UserData from stack so GetParamCount() matches normal behavior.
|
||||
SQINLINE SquirrelObject Get(TypeWrapper<SquirrelObject>,HSQUIRRELVM v,int idx) { HSQOBJECT o; SQPLUS_CHECK_GET(sq_getstackobj(v,idx,&o)); return SquirrelObject(o); }
|
||||
|
||||
SQINLINE bool Get(TypeWrapper<bool>,HSQUIRRELVM v,int idx){
|
||||
switch( sq_gettype(v,idx) ){
|
||||
case OT_NULL:{ return false; }
|
||||
case OT_BOOL:{ SQBool b; SQPLUS_CHECK_GET(sq_getbool(v,idx,&b)); return b != 0; }
|
||||
case OT_INTEGER:{ INT i; SQPLUS_CHECK_GET(sq_getinteger(v,idx,&i)); return i != 0; }
|
||||
case OT_FLOAT:{ FLOAT f; SQPLUS_CHECK_GET(sq_getfloat(v,idx,&f)); return f != (FLOAT)0.0; }
|
||||
default: return true; } }
|
||||
|
||||
#ifdef SQPLUS_AUTOCONVERT_OTHER_CHAR
|
||||
SQINLINE void Push(HSQUIRRELVM v, const SQOtherChar *value){ SQDefCharBuf cb(value); sq_pushstring(v,(const SQChar*)cb,-1); }
|
||||
SQINLINE void Push(HSQUIRRELVM v, SQOtherChar *value){ SQDefCharBuf cb(value); sq_pushstring(v,(const SQChar*)cb,-1); }
|
||||
SQINLINE bool Match(TypeWrapper<const SQOtherChar *>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_STRING; }
|
||||
SQINLINE bool Match(TypeWrapper<SQOtherChar *>,HSQUIRRELVM v,int idx) { return sq_gettype(v,idx) == OT_STRING; }
|
||||
/*SQINLINE SQOtherChar* Get(TypeWrapper<const SQOtherChar *>,HSQUIRRELVM v,int idx) {
|
||||
const SQChar *s; SQPLUS_CHECK_GET(sq_getstring(v,idx,&s));
|
||||
static SQOthCharBuf ocb[SQPLUS_AUTOCONVERT_MAX_INSTANCES]; static int st_buf_cnt;
|
||||
return ocb[st_buf_cnt++%SQPLUS_AUTOCONVERT_MAX_INSTANCES].Set(s); }*/
|
||||
SQINLINE SQOthCharBuf Get(TypeWrapper<const SQOtherChar *>,HSQUIRRELVM v,int idx) { const SQChar * s; SQPLUS_CHECK_GET(sq_getstring(v,idx,&s)); return SQOthCharBuf(s); }
|
||||
#endif // SQPLUS_AUTOCONVERT_OTHER_CHAR
|
||||
|
||||
#if defined(SQPLUS_SUPPORT_STD_STRING) && !defined(SQUNICODE)
|
||||
SQINLINE void Push(HSQUIRRELVM v,const std::string& value) { sq_pushstring(v,value.c_str(),-1); }
|
||||
SQINLINE bool Match(TypeWrapper<const std::string&>, HSQUIRRELVM v, int idx) { return sq_gettype(v,idx) == OT_STRING; }
|
||||
SQINLINE std::string Get(TypeWrapper<const std::string&>,HSQUIRRELVM v,int idx) { const SQChar * s; SQPLUS_CHECK_GET(sq_getstring(v,idx,&s)); return std::string(s); }
|
||||
#endif // defined(SQPLUS_SUPPORT_STD_STRING) && !defined(SQUNICODE)
|
||||
|
||||
// Added jflanglois suggestion, 8/20/06. jcs
|
||||
#ifdef SQPLUS_SUPPORT_SQ_STD_STRING
|
||||
typedef std::basic_string<SQChar> sq_std_string;
|
||||
SQINLINE void Push(HSQUIRRELVM v,const sq_std_string & value) { sq_pushstring(v,value.c_str(),-1); }
|
||||
SQINLINE bool Match(TypeWrapper<const sq_std_string &>, HSQUIRRELVM v, int idx) { return sq_gettype(v,idx) == OT_STRING; }
|
||||
SQINLINE sq_std_string Get(TypeWrapper<const sq_std_string &>,HSQUIRRELVM v,int idx) { const SQChar * s; SQPLUS_CHECK_GET(sq_getstring(v,idx,&s)); return sq_std_string(s); }
|
||||
#endif
|
||||
|
||||
// Specialization to support void return type.
|
||||
SQINLINE void GetRet(TypeWrapper<void>,HSQUIRRELVM v,int idx) { sq_pop(v,2); }
|
||||
|
||||
#endif // _SQPLUS_FUNCTION_CALL_IMPL_H_
|
||||
|
@ -1,61 +0,0 @@
|
||||
|
||||
#include "sqplus.h"
|
||||
#include "SqPlusOCharBuf.h"
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
// Conversion functions, between char* string and wchar_t* strings.
|
||||
|
||||
int ol_strlen(const wchar_t* pwc){ return (int)wcslen(pwc); }
|
||||
int ol_buflen(const wchar_t* pwc){ return (int)wcslen(pwc); }
|
||||
int ol_charlen(const wchar_t* pwc){ return 1; }
|
||||
//int ol_charlen(const wchar_t pwc){ return 1; }
|
||||
int ol_char(const wchar_t* pwc){ return (int)*pwc; }
|
||||
bool ol_writechar(wchar_t*& pwc, int ch){ *pwc=(wchar_t)ch; pwc++; return true; }
|
||||
|
||||
int ol_buflen(const char* pc){ return (int)strlen(pc); }
|
||||
|
||||
#if SQPLUS_USE_LATIN1==1
|
||||
// Convert to 8-bit LATIN1 char set. The only thing to do is convert chars out of range to '?'
|
||||
int ol_strlen(const char* pc){ return (int)strlen(pc); }
|
||||
int ol_charlen(const char* pc){ return 1; }
|
||||
//int ol_charlen(int pc){ return 1; }
|
||||
int ol_char(const char* pc){ return (int)*(unsigned char*)pc; }
|
||||
bool ol_writechar(char*& pc, int ch){ *pc=(char)(ch>255?'?':ch); pc++; return true; }
|
||||
#else
|
||||
#include "SqPlusUtf8.h"
|
||||
// Convert to 8-Bit UTF8 encoding. Some more work here.
|
||||
int ol_strlen(const char* pc){ return sqplus_utf8_strlen(pc); }
|
||||
int ol_charlen(const char* pc){ return sqplus_utf8_len_first(pc); }
|
||||
//int ol_charlen(int ch){ char buf[8]; return sqplus_wchar_to_utf8(buf,ch,8); }
|
||||
int ol_char(const char* pc){ int chr=-1; sqplus_utf8_to_wchar(&chr,pc); return chr; }
|
||||
bool ol_writechar(char*& pc, int ch) {
|
||||
int l=sqplus_wchar_to_utf8(pc,ch,8);
|
||||
if(l>0){
|
||||
pc += l;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SQUNICODE
|
||||
// SQChar is wchar_t, convert to/from to either Latin1 or UTF8
|
||||
SQDefCharBuf CH2SQ( const char* ps ){
|
||||
return SQDefCharBuf(ps);
|
||||
}
|
||||
SQOthCharBuf SQ2CH( const wchar_t* pws ){
|
||||
return SQOthCharBuf(pws);
|
||||
}
|
||||
#else
|
||||
// SQChar is char, convert to/from wchar_t
|
||||
SQDefCharBuf WC2SQ( const wchar_t* pws ){
|
||||
return SQDefCharBuf(pws);
|
||||
}
|
||||
SQOthCharBuf SQ2WC( const char* ps ){
|
||||
return SQOthCharBuf(ps);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,193 +0,0 @@
|
||||
|
||||
#ifndef SQPLUS_OCHARBUF_H
|
||||
#define SQPLUS_OCHARBUF_H
|
||||
|
||||
// Conversion routines between different character encodings, to be used in
|
||||
// Push/Get/Match handlers of SqPlus. It enables using both of char* and
|
||||
// wchar_t* as function arguments.
|
||||
//
|
||||
// When converting from wchar_t to char, the choice is between using a Latin1
|
||||
// or a UTF8 representation in 8-bit mode. This is probably most useful if
|
||||
// Squirrel is compiled in ANSI mode and the app uses some wchar_t strings
|
||||
// (UNICODE mode on Win32).
|
||||
//
|
||||
|
||||
// A char is either
|
||||
// - A Latin1 character (first code page, coincides with Unicode points 0..255)
|
||||
// - Part of an UTF8 character
|
||||
//
|
||||
// Note: SQUTF8 requires Squirrel sources that have been patched for UTF8 strings
|
||||
// internally (when converting function arguments).
|
||||
|
||||
#ifndef SQUTF8
|
||||
// Default to Latin1 conversion
|
||||
//#undef SQPLUS_USE_LATIN1
|
||||
#ifndef SQPLUS_USE_LATIN1
|
||||
#define SQPLUS_USE_LATIN1 1
|
||||
#endif
|
||||
#else
|
||||
// Using Squirrel with internal UTF8 string encoding
|
||||
//#undef SQPLUS_USE_LATIN1
|
||||
#ifndef SQPLUS_USE_LATIN1
|
||||
#define SQPLUS_USE_LATIN1 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// The various ol_... functions sets up for a conversion scheme
|
||||
// that can be used in both wchar_t => char and char => wchar_t.
|
||||
int ol_strlen(const wchar_t* pwc);
|
||||
int ol_buflen(const wchar_t* pwc);
|
||||
int ol_charlen(const wchar_t* pwc);
|
||||
int ol_char(const wchar_t* pwc);
|
||||
bool ol_writechar(wchar_t*& pwc, int ch);
|
||||
|
||||
int ol_strlen(const char* pc);
|
||||
int ol_buflen(const char* pc);
|
||||
int ol_charlen(const char* pc);
|
||||
int ol_char(const char* pc);
|
||||
bool ol_writechar(char*& pc, int ch);
|
||||
|
||||
#ifdef SQUNICODE
|
||||
// SQChar is wchar_t, convert to/from either Latin1 or UTF8
|
||||
typedef char SQOtherChar;
|
||||
#else
|
||||
// SQChar is char, convert to/from wchar_t
|
||||
typedef wchar_t SQOtherChar;
|
||||
#endif
|
||||
|
||||
|
||||
// Buffer to hold a string and release it in destructor.
|
||||
// SQT is input character type
|
||||
// SQOT is the opposite type of SQChar
|
||||
// If 'try_borrow' is set, it will not allocate a new buffer when no
|
||||
// conversion is done, it will just keep the input pointer (beware).
|
||||
template<class SQT, class SQOT, bool use_latin1>
|
||||
struct SQCharBufImpl {
|
||||
|
||||
// Allocate a buffer from string of same type
|
||||
SQCharBufImpl(const SQT *poc=NULL, bool try_borrow=true ) : m_poc(0), m_own(false) {
|
||||
Init( poc, try_borrow );
|
||||
}
|
||||
|
||||
// This does conversion from other char type
|
||||
SQCharBufImpl(const SQOT *ps, bool try_borrow=false ) : m_poc(0), m_own(false) {
|
||||
Init( ps ); // Cannot borrow pointer when doing conversion
|
||||
}
|
||||
|
||||
void Init( const SQT *poc, bool try_borrow ){
|
||||
m_own = !try_borrow;
|
||||
if( try_borrow ){
|
||||
m_poc = (SQT*)poc;
|
||||
}
|
||||
else {
|
||||
int sl = poc ? ol_buflen(poc) : 0;
|
||||
if( poc ){
|
||||
m_poc = poc ? new SQT[sl+1] : NULL;
|
||||
if( m_poc ) memcpy( m_poc, poc, (sl+1)*sizeof(SQT) );
|
||||
}
|
||||
else
|
||||
m_poc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Init( const SQOT *ps ){
|
||||
m_own = true;
|
||||
if( ps ){
|
||||
int sl = ps ? ol_strlen(ps) : 0; // Length of string in characters (not bytes)
|
||||
int scl = 0; // Length of converted string in char/wchar_t count
|
||||
// How much storage needed?
|
||||
if( !use_latin1 && sizeof(SQT)<sizeof(SQOT) ){
|
||||
// Converting wchar_t => UTF8
|
||||
const SQOT *ps1 = ps; // It is wchar_t* here
|
||||
SQT tmp_buf[8];
|
||||
SQT *ptmp;
|
||||
while( *ps1 ){
|
||||
ptmp = tmp_buf;
|
||||
if( ol_writechar(ptmp,*ps1++) )
|
||||
scl += ol_charlen(tmp_buf);
|
||||
else
|
||||
scl++;
|
||||
}
|
||||
}
|
||||
else scl = sl; // Converting to wchar_t or Latin1, keep length
|
||||
|
||||
m_poc = new SQT[scl+1];
|
||||
if( !m_poc ) return;
|
||||
|
||||
// Convert
|
||||
SQT *poc = m_poc;
|
||||
while( *ps ){
|
||||
ol_writechar( poc, ol_char(ps) );
|
||||
ps += ol_charlen(ps);
|
||||
}
|
||||
*poc = 0; // Terminating zero
|
||||
}
|
||||
else
|
||||
m_poc = NULL;
|
||||
}
|
||||
|
||||
~SQCharBufImpl(){ Release(); }
|
||||
|
||||
void Release( ){
|
||||
if(m_poc && m_own )
|
||||
delete [] m_poc;
|
||||
m_poc = NULL;
|
||||
}
|
||||
|
||||
SQT* Set( const SQOT *ps ){
|
||||
Release( );
|
||||
Init( ps );
|
||||
return m_poc;
|
||||
}
|
||||
|
||||
operator SQT*() const { return m_poc; }
|
||||
|
||||
SQCharBufImpl<SQT,SQOT,use_latin1>& operator = (const SQT *ps){
|
||||
Release();
|
||||
Init( ps, false );
|
||||
return *this;
|
||||
}
|
||||
|
||||
SQCharBufImpl<SQT,SQOT,use_latin1>& operator = (const SQOT *ps){
|
||||
Release();
|
||||
Init( ps );
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Move string from other here - Note: Empties the input argument (other)
|
||||
SQCharBufImpl<SQT,SQOT,use_latin1>& operator = (const SQCharBufImpl<SQT,SQOT,use_latin1>& other){
|
||||
Release();
|
||||
m_poc = other.m_poc;
|
||||
m_own = other.m_own;
|
||||
SQT **psqt = (SQT**)&other.m_poc;
|
||||
*psqt = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
SQT *m_poc;
|
||||
bool m_own;
|
||||
};
|
||||
|
||||
typedef SQCharBufImpl<SQOtherChar, SQChar, bool(SQPLUS_USE_LATIN1)> SQOthCharBuf;
|
||||
typedef SQCharBufImpl<SQChar, SQOtherChar, bool(SQPLUS_USE_LATIN1)> SQDefCharBuf;
|
||||
typedef SQCharBufImpl<wchar_t, char, bool(SQPLUS_USE_LATIN1)> SQWCharBuf;
|
||||
typedef SQCharBufImpl<char, wchar_t, bool(SQPLUS_USE_LATIN1)> SQACharBuf;
|
||||
|
||||
#ifdef SQUNICODE
|
||||
// SQChar is wchar_t, convert to/from to either Latin1 or UTF8
|
||||
#define WC2SQ(s) s
|
||||
#define SQ2WC(s) s
|
||||
SQDefCharBuf CH2SQ( const char* ps );
|
||||
SQOthCharBuf SQ2CH( const wchar_t* pws );
|
||||
#else
|
||||
// SQChar is char, convert to/from wchar_t
|
||||
SQDefCharBuf WC2SQ( const wchar_t* pws );
|
||||
SQOthCharBuf SQ2WC( const char* pws );
|
||||
#define CH2SQ(s) s
|
||||
#define SQ2CH(s) s
|
||||
#endif
|
||||
|
||||
#endif // SQPLUS_CHARBUF_H
|
||||
|
@ -1,819 +0,0 @@
|
||||
// SqPlusOverload.h
|
||||
// SqPlus function overloading support created by Katsuaki Kawachi.
|
||||
//
|
||||
// Const member function fixed Tegan
|
||||
// from http://squirrel-lang.org/forums/thread/2160.aspx
|
||||
|
||||
#ifdef SQPLUS_OVERLOAD_RELEASE_HOOK
|
||||
#undef SQPLUS_OVERLOAD_RELEASE_HOOK
|
||||
|
||||
// These end up int ClassType<T> now
|
||||
static inline int destruct(SQUserPointer up, SQInteger size) {
|
||||
if (up) {
|
||||
static_cast<T*>(up)->~T();
|
||||
sq_free(up, size);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline SQRELEASEHOOK &release(void) {
|
||||
static SQRELEASEHOOK hook = ClassType<T>::destruct;
|
||||
return hook;
|
||||
}
|
||||
|
||||
void releaseHook(SQRELEASEHOOK releaseHook) {
|
||||
release() = releaseHook;
|
||||
//return *this;
|
||||
}
|
||||
|
||||
static inline SQRELEASEHOOK &getReleaseHook(void) {
|
||||
return release();
|
||||
}
|
||||
|
||||
#endif // SQPLUS_OVERLOAD_RELEASE_HOOK
|
||||
|
||||
|
||||
#ifdef SQPLUS_OVERLOAD_DECLARATION
|
||||
#undef SQPLUS_OVERLOAD_DECLARATION
|
||||
|
||||
template<typename Func> struct Arg;
|
||||
|
||||
#endif // SQPLUS_OVERLOAD_DECLARATION
|
||||
|
||||
|
||||
#ifdef SQPLUS_OVERLOAD_IMPLEMENTATION
|
||||
#undef SQPLUS_OVERLOAD_IMPLEMENTATION
|
||||
private:
|
||||
class SQFuncHolder {
|
||||
private:
|
||||
template<typename T>
|
||||
class FlexArray {
|
||||
protected:
|
||||
SquirrelObject array;
|
||||
public:
|
||||
FlexArray(int size = 0) {
|
||||
this->resize(size);
|
||||
}
|
||||
int size(void) const {
|
||||
return array.Len();
|
||||
}
|
||||
void resize(int newSize) {
|
||||
if (this->size() == 0) {
|
||||
array = SquirrelVM::CreateArray(newSize);
|
||||
} else {
|
||||
array.ArrayResize(newSize);
|
||||
}
|
||||
}
|
||||
void push_back(const T &t) {
|
||||
this->set(this->size(), t);
|
||||
}
|
||||
void set(int index, const T &t) {
|
||||
get(index) = t;
|
||||
}
|
||||
T &get(int index) {
|
||||
if (index >= array.Len()) {
|
||||
resize(index + 1);
|
||||
}
|
||||
SQUserPointer up = array.GetUserPointer(index);
|
||||
if (!up) {
|
||||
up = sq_newuserdata(SquirrelVM::GetVMPtr(), sizeof(T));
|
||||
new(static_cast<T*>(up)) T;
|
||||
array.SetUserPointer(index, up);
|
||||
}
|
||||
return *static_cast<T*>(up);
|
||||
}
|
||||
};
|
||||
/*
|
||||
storage of wrapped C++ functions
|
||||
*/
|
||||
typedef SQInteger(*WrappedFunction)(HSQUIRRELVM, bool, int);
|
||||
typedef FlexArray<WrappedFunction> SQWrappedFuncArray;
|
||||
typedef FlexArray<SQWrappedFuncArray> SQWrappedFuncArray2 ;
|
||||
typedef FlexArray<SQWrappedFuncArray2> SQWrappedFuncArray3 ;
|
||||
|
||||
struct MemberHolder {
|
||||
static SQWrappedFuncArray &funcs(int functionIndex,
|
||||
int paramCount) {
|
||||
static SQWrappedFuncArray3 funcs;
|
||||
return funcs.get(paramCount).get(functionIndex);
|
||||
}
|
||||
};
|
||||
struct StaticHolder {
|
||||
static SQWrappedFuncArray &funcs(int functionIndex,
|
||||
int paramCount) {
|
||||
static SQWrappedFuncArray3 funcs;
|
||||
return funcs.get(paramCount).get(functionIndex);
|
||||
}
|
||||
};
|
||||
struct ConstructorHolder {
|
||||
static SQWrappedFuncArray &funcs(int paramCount) {
|
||||
static SQWrappedFuncArray2 funcs;
|
||||
return funcs.get(paramCount);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
wrapper for C++ functions
|
||||
*/
|
||||
template<typename Mfunc> struct MemberDispatcher {
|
||||
static inline FlexArray<Mfunc> &mfunc(void) {
|
||||
static FlexArray<Mfunc> mfunc;
|
||||
return mfunc;
|
||||
}
|
||||
static inline SQInteger
|
||||
dispatch(HSQUIRRELVM v, bool execute, int functionIndex) {
|
||||
return execute ?
|
||||
Call(*GetInstance<TClassType, true>(v, 1),
|
||||
mfunc().get(functionIndex), v, 2) :
|
||||
Arg<Mfunc>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
template<typename Sfunc> struct StaticDispatcher {
|
||||
static inline FlexArray<Sfunc> &sfunc(void) {
|
||||
static FlexArray<Sfunc> sfunc;
|
||||
return sfunc;
|
||||
}
|
||||
static inline SQInteger
|
||||
dispatch(HSQUIRRELVM v, bool execute, int functionIndex) {
|
||||
return execute ?
|
||||
Call(sfunc().get(functionIndex), v, 2) :
|
||||
Arg<Sfunc>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
template<typename Cfunc> struct Constructor {
|
||||
static inline Cfunc &cfunc(void) {
|
||||
static Cfunc cfunc = 0;
|
||||
return cfunc;
|
||||
}
|
||||
static inline SQInteger
|
||||
construct(HSQUIRRELVM v, bool execute, int) {
|
||||
return execute ?
|
||||
Call(cfunc(), v, 2) :
|
||||
Arg<Cfunc>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
// search and call an overloaded function on runtime
|
||||
static inline SQInteger
|
||||
call(SQWrappedFuncArray &funcs, HSQUIRRELVM v, int functionIndex = 0) {
|
||||
bool ambiguous = false;
|
||||
int imin = -1;
|
||||
int dmin = INT_MAX;
|
||||
for (int i = 0, size = funcs.size(); i < size; ++i) {
|
||||
// FIXME: to be refactored
|
||||
const int d = (**funcs.get(i))(v, false, functionIndex);
|
||||
if (d == 0) { // complete match
|
||||
imin = i;
|
||||
ambiguous = false;
|
||||
goto SQPLUS_OVERLOAD_CALL_IMMEDIATE_EXECUTION;
|
||||
} else if (0 < d && d < dmin) {
|
||||
dmin = d;
|
||||
imin = i;
|
||||
ambiguous = false;
|
||||
} else if (d == dmin) {
|
||||
ambiguous = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ambiguous) {
|
||||
return sq_throwerror(
|
||||
v, _SC("Call of overloaded function is ambiguous")
|
||||
);
|
||||
} else if (imin == -1) {
|
||||
return sq_throwerror(
|
||||
v, _SC("No match for given arguments")
|
||||
);
|
||||
}
|
||||
|
||||
SQPLUS_OVERLOAD_CALL_IMMEDIATE_EXECUTION:
|
||||
// FIXME: to be refactored
|
||||
return (**funcs.get(imin))(v, true, functionIndex);
|
||||
}
|
||||
|
||||
public:
|
||||
template<typename Mfunc> static inline void
|
||||
addMemberFunc(int functionIndex, Mfunc mfunc) {
|
||||
MemberHolder::funcs(functionIndex, Arg<Mfunc>::num()).push_back(
|
||||
&MemberDispatcher<Mfunc>::dispatch
|
||||
);
|
||||
MemberDispatcher<Mfunc>::mfunc().set(functionIndex, mfunc);
|
||||
}
|
||||
template<typename Sfunc> static inline void
|
||||
addStaticFunc(int functionIndex, Sfunc sfunc) {
|
||||
StaticHolder::funcs(functionIndex, Arg<Sfunc>::num()).push_back(
|
||||
&StaticDispatcher<Sfunc>::dispatch
|
||||
);
|
||||
StaticDispatcher<Sfunc>::sfunc().set(functionIndex, sfunc);
|
||||
}
|
||||
template<typename Cfunc> static inline void
|
||||
addConstructor(Cfunc cfunc) {
|
||||
ConstructorHolder::funcs(Arg<Cfunc>::num()).push_back(
|
||||
&Constructor<Cfunc>::construct
|
||||
);
|
||||
Constructor<Cfunc>::cfunc() = cfunc;
|
||||
}
|
||||
|
||||
static inline SQInteger
|
||||
memberCall(int paramCount, HSQUIRRELVM v, int functionIndex) {
|
||||
return call(MemberHolder::funcs(functionIndex, paramCount),
|
||||
v, functionIndex);
|
||||
}
|
||||
static inline SQInteger
|
||||
staticCall(int paramCount, HSQUIRRELVM v, int functionIndex) {
|
||||
return call(StaticHolder::funcs(functionIndex, paramCount),
|
||||
v, functionIndex);
|
||||
}
|
||||
static inline SQInteger
|
||||
constructorCall(int paramCount, HSQUIRRELVM v, int) {
|
||||
return call(ConstructorHolder::funcs(paramCount), v);
|
||||
}
|
||||
}; // class SQFuncHolder
|
||||
|
||||
|
||||
struct FunctionNameEnumerator {
|
||||
SquirrelObject names;
|
||||
FunctionNameEnumerator(void) : names(SquirrelVM::CreateTable()) {}
|
||||
int index(const SQChar *n) {
|
||||
int i;
|
||||
SquirrelObject v = names.GetValue(n);
|
||||
if (v.IsNull()) {
|
||||
i = names.Len();
|
||||
names.SetValue(n, i);
|
||||
} else {
|
||||
i = v.ToInteger();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
};
|
||||
|
||||
FunctionNameEnumerator overloadedMemberNames;
|
||||
FunctionNameEnumerator overloadedStaticMemberNames;
|
||||
|
||||
static SquirrelObject &
|
||||
functionIndexHolders(HSQUIRRELVM v) {
|
||||
static SquirrelObject indexHolders;
|
||||
if (indexHolders.IsNull()) {
|
||||
sq_newtable(v);
|
||||
indexHolders.AttachToStackObject(-1);
|
||||
sq_pop(v, 1);
|
||||
}
|
||||
return indexHolders;
|
||||
}
|
||||
|
||||
template<int N>
|
||||
static SquirrelObject &
|
||||
indexHolder(HSQUIRRELVM v) {
|
||||
static SquirrelObject holder;
|
||||
if (holder.IsNull()) {
|
||||
sq_pushobject(v, functionIndexHolders(v).GetObjectHandle());
|
||||
sq_pushinteger(v, N);
|
||||
if (SQ_OK == sq_rawget(v, -2)) {
|
||||
holder.AttachToStackObject(-1);
|
||||
sq_pop(v, 3);
|
||||
} else {
|
||||
sq_pushinteger(v, N);
|
||||
sq_newtable(v);
|
||||
holder.AttachToStackObject(-1);
|
||||
sq_rawset(v, -3);
|
||||
sq_pop(v, 1);
|
||||
}
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
template<typename Func>
|
||||
class SQOverloader {
|
||||
private:
|
||||
static inline SQInteger switcher(HSQUIRRELVM v,
|
||||
int(*caller)(int, HSQUIRRELVM, int),
|
||||
int fidx) {
|
||||
return (*caller)(StackHandler(v).GetParamCount() - 1,
|
||||
v,
|
||||
fidx);
|
||||
}
|
||||
|
||||
static inline SQInteger memberSwitcher(HSQUIRRELVM v) {
|
||||
SQInteger fidx;
|
||||
sq_pushobject(v, indexHolder<0>(v).GetObjectHandle());
|
||||
sq_push(v, 0); // native closure
|
||||
sq_rawget(v, -2);
|
||||
sq_getinteger(v, -1, &fidx);
|
||||
sq_pop(v, 2);
|
||||
return switcher(v, SQFuncHolder::memberCall, fidx);
|
||||
}
|
||||
static inline SQInteger staticSwitcher(HSQUIRRELVM v) {
|
||||
SQInteger fidx;
|
||||
sq_pushobject(v, indexHolder<1>(v).GetObjectHandle());
|
||||
sq_push(v, 0); // native closure
|
||||
sq_rawget(v, -2);
|
||||
sq_getinteger(v, -1, &fidx);
|
||||
sq_pop(v, 2);
|
||||
return switcher(v, SQFuncHolder::staticCall, fidx);
|
||||
}
|
||||
static inline SQInteger constructorSwitcher(HSQUIRRELVM v) {
|
||||
return switcher(v, SQFuncHolder::constructorCall, 0);
|
||||
}
|
||||
|
||||
public:
|
||||
static inline void addMemberFunc(SQClassDefBase<TClassType,TClassBase> *def,
|
||||
Func mfunc,
|
||||
const SQChar *name) {
|
||||
const int fidx = def->overloadedMemberNames.index(name);
|
||||
SQFuncHolder::addMemberFunc(fidx, mfunc);
|
||||
def->staticFuncVarArgs(memberSwitcher, name);
|
||||
|
||||
HSQUIRRELVM v = def->v;
|
||||
// get closure
|
||||
sq_pushobject(v, def->newClass.GetObjectHandle());
|
||||
sq_pushstring(v, name, -1);
|
||||
sq_rawget(v, -2);
|
||||
// holder[closure] = fidx
|
||||
sq_pushobject(v, indexHolder<0>(v).GetObjectHandle());
|
||||
sq_push(v, -2);
|
||||
sq_pushinteger(v, fidx);
|
||||
sq_rawset(v, -3);
|
||||
//
|
||||
sq_pop(v, 3);
|
||||
}
|
||||
|
||||
static inline void addOperatorFunc(SQClassDefBase<TClassType,TClassBase> *def,
|
||||
Func ofunc,
|
||||
const SQChar *name) {
|
||||
if (Arg<Func>::num() != 1) {
|
||||
//assert(false &&
|
||||
// "Cannot add this function as operator (argc != 1)");
|
||||
abort();
|
||||
}
|
||||
SQChar proxy[256];
|
||||
scsprintf(proxy, _SC("overloaded%s"), name);
|
||||
|
||||
addMemberFunc(def, ofunc, proxy);
|
||||
|
||||
SQChar script[512];
|
||||
scsprintf(script, _SC("%s.%s<-function(o){return %s.%s(o);}"),
|
||||
def->name, name, def->name, proxy);
|
||||
SquirrelVM::RunScript(SquirrelVM::CompileBuffer(script));
|
||||
}
|
||||
|
||||
static inline void addStaticFunc(SQClassDefBase<TClassType,TClassBase> *def,
|
||||
Func sfunc,
|
||||
const SQChar *name) {
|
||||
const int fidx = def->overloadedStaticMemberNames.index(name);
|
||||
SQFuncHolder::addStaticFunc(fidx, sfunc);
|
||||
def->staticFuncVarArgs(staticSwitcher, name);
|
||||
|
||||
HSQUIRRELVM v = def->v;
|
||||
// get closure
|
||||
sq_pushobject(v, def->newClass.GetObjectHandle());
|
||||
sq_pushstring(v, name, -1);
|
||||
sq_rawget(v, -2);
|
||||
|
||||
// holder[closure] = fidx
|
||||
sq_pushobject(v, indexHolder<1>(v).GetObjectHandle());
|
||||
sq_push(v, -2);
|
||||
sq_pushinteger(v, fidx);
|
||||
sq_rawset(v, -3);
|
||||
//
|
||||
sq_pop(v, 3);
|
||||
}
|
||||
template<typename Cfunc>
|
||||
static inline void addConstructor(SQClassDefBase<TClassType,TClassBase> *def,
|
||||
Cfunc cfunc) {
|
||||
SQFuncHolder::addConstructor(cfunc);
|
||||
def->staticFuncVarArgs(constructorSwitcher, _SC("constructor"));
|
||||
}
|
||||
static inline void addGlobalFunc(SQClassDefBase<TClassType,TClassBase> *def,
|
||||
Func gfunc,
|
||||
const SQChar *name) {
|
||||
const int fidx = def->overloadedStaticMemberNames.index(name);
|
||||
SQFuncHolder::addStaticFunc(fidx, gfunc);
|
||||
SquirrelVM::CreateFunctionGlobal(staticSwitcher, name, _SC("*"));
|
||||
|
||||
HSQUIRRELVM v = def->v;
|
||||
// get closure
|
||||
sq_pushroottable(v);
|
||||
sq_pushstring(v, name, -1);
|
||||
sq_rawget(v, -2);
|
||||
|
||||
// holder[closure] = fidx
|
||||
sq_pushobject(v, indexHolder<1>(v).GetObjectHandle());
|
||||
sq_push(v, -2);
|
||||
sq_pushinteger(v, fidx);
|
||||
sq_rawset(v, -3);
|
||||
//
|
||||
sq_pop(v, 3);
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
template<typename Mfunc>
|
||||
SQClassDefBase<TClassType,TClassBase> &overloadFunc(Mfunc mfunc, const SQChar *n) {
|
||||
SQOverloader<Mfunc>::addMemberFunc(this, mfunc, n);
|
||||
return *this;
|
||||
}
|
||||
template<typename Ofunc>
|
||||
SQClassDefBase<TClassType,TClassBase> &overloadOperator(Ofunc ofunc, const SQChar *n){
|
||||
SQOverloader<Ofunc>::addOperatorFunc(this, ofunc, n);
|
||||
return *this;
|
||||
}
|
||||
template<typename Sfunc>
|
||||
SQClassDefBase<TClassType,TClassBase> &overloadStaticFunc(Sfunc sfunc,
|
||||
const SQChar *n) {
|
||||
SQOverloader<Sfunc>::addStaticFunc(this, sfunc, n);
|
||||
return *this;
|
||||
}
|
||||
template<typename Cmetafunc>
|
||||
SQClassDefBase<TClassType,TClassBase> &overloadConstructor(void) {
|
||||
SQOverloader<Cmetafunc>::addConstructor(this, &Arg<Cmetafunc>::create);
|
||||
return *this;
|
||||
}
|
||||
template<typename Cfunc>
|
||||
SQClassDefBase<TClassType,TClassBase> &overloadConstructor(Cfunc cfunc) {
|
||||
SQOverloader<Cfunc>::addConstructor(this, cfunc);
|
||||
return *this;
|
||||
}
|
||||
template<typename Gfunc>
|
||||
SQClassDefBase<TClassType,TClassBase> &overloadGlobalFunc(Gfunc gfunc,
|
||||
const SQChar *n) {
|
||||
SQOverloader<Gfunc>::addGlobalFunc(this, gfunc, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#endif // SQPLUS_OVERLOAD_IMPLEMENTATION
|
||||
|
||||
|
||||
|
||||
#ifdef SQPLUS_OVERLOAD_FUNCTIONS
|
||||
#undef SQPLUS_OVERLOAD_FUNCTIONS
|
||||
|
||||
struct GlobalFuncOverloader {};
|
||||
static inline SQClassDefBase<GlobalFuncOverloader,SQNoBaseClass> &globalFuncOverloader(void)
|
||||
{
|
||||
static SQClassDefBase<GlobalFuncOverloader,SQNoBaseClass> fo(_SC("GlobalFuncOverloader"));
|
||||
return fo;
|
||||
}
|
||||
|
||||
template<typename Gfunc> void
|
||||
OverloadGlobal(Gfunc gfunc, const SQChar *n)
|
||||
{
|
||||
globalFuncOverloader().overloadGlobalFunc(gfunc, n);
|
||||
}
|
||||
|
||||
template<typename TYPE> struct CheckInstance {
|
||||
template<typename T> struct unref {typedef T type;};
|
||||
template<typename T> struct unref<T&> {typedef T type;};
|
||||
template<typename T> struct unref<T*> {typedef T type;};
|
||||
template<typename T> struct unref<const T&> {typedef T type;};
|
||||
template<typename T> struct unref<const T*> {typedef T type;};
|
||||
|
||||
/*
|
||||
d = -1 : not in hierarchy
|
||||
d = 0 : same
|
||||
d > 0 : similar (o is d-th subclass of TYPE)
|
||||
*/
|
||||
static inline int distance(HSQUIRRELVM v, int index) {
|
||||
HSQOBJECT o;
|
||||
sq_resetobject(&o);
|
||||
sq_getstackobj(v, index, &o);
|
||||
|
||||
const int top = sq_gettop(v);
|
||||
sq_pushroottable(v);
|
||||
|
||||
// Check plain object type
|
||||
int d = -1;
|
||||
if (Match(TypeWrapper<TYPE>(), v, index)) {
|
||||
d = 0;
|
||||
|
||||
// Check instance type hierarchy
|
||||
if (sq_type(o) == OT_INSTANCE) {
|
||||
SQUserPointer dsttype =
|
||||
ClassType<typename unref<TYPE>::type>::type();
|
||||
|
||||
SQUserPointer argtype;
|
||||
for (sq_getclass(v, index);
|
||||
sq_gettypetag(v, -1, &argtype) == SQ_OK;
|
||||
sq_getbase(v, -1)) {
|
||||
if (argtype == dsttype) {
|
||||
goto SQPLUS_OVERLOAD_DISTANCE_IMMEDIATE_RETURN;
|
||||
}
|
||||
++d;
|
||||
}
|
||||
d = -1; // no matching type found
|
||||
}
|
||||
}
|
||||
SQPLUS_OVERLOAD_DISTANCE_IMMEDIATE_RETURN:
|
||||
sq_settop(v, top);
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename T, typename R>
|
||||
struct Arg<R(T::*)(void)> {
|
||||
static inline int num(void) {return 0;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1>
|
||||
struct Arg<R(T::*)(A1)> {
|
||||
static inline int num(void) {return 1;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2>
|
||||
struct Arg<R(T::*)(A1, A2)> {
|
||||
static inline int num(void) {return 2;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3>
|
||||
struct Arg<R(T::*)(A1, A2, A3)> {
|
||||
static inline int num(void) {return 3;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3, typename A4>
|
||||
struct Arg<R(T::*)(A1, A2, A3, A4)> {
|
||||
static inline int num(void) {return 4;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3, A4)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
struct Arg<R(T::*)(A1, A2, A3, A4, A5)> {
|
||||
static inline int num(void) {return 5;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3, A4, A5)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
struct Arg<R(T::*)(A1, A2, A3, A4, A5, A6)> {
|
||||
static inline int num(void) {return 6;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3, A4, A5, A6)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
struct Arg<R(T::*)(A1, A2, A3, A4, A5, A6, A7)> {
|
||||
static inline int num(void) {return 7;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3, A4, A5, A6, A7)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef SQPLUS_CONST_OPT
|
||||
template<typename T, typename R>
|
||||
struct Arg<R(T::*)(void) const> {
|
||||
static inline int num(void) {return 0;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1>
|
||||
struct Arg<R(T::*)(A1) const> {
|
||||
static inline int num(void) {return 1;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2>
|
||||
struct Arg<R(T::*)(A1, A2) const> {
|
||||
static inline int num(void) {return 2;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3>
|
||||
struct Arg<R(T::*)(A1, A2, A3) const> {
|
||||
static inline int num(void) {return 3;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3, typename A4>
|
||||
struct Arg<R(T::*)(A1, A2, A3, A4) const> {
|
||||
static inline int num(void) {return 4;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3, A4)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
struct Arg<R(T::*)(A1, A2, A3, A4, A5) const> {
|
||||
static inline int num(void) {return 5;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3, A4, A5)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
struct Arg<R(T::*)(A1, A2, A3, A4, A5, A6) const> {
|
||||
static inline int num(void) {return 6;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3, A4, A5, A6)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
struct Arg<R(T::*)(A1, A2, A3, A4, A5, A6, A7) const> {
|
||||
static inline int num(void) {return 7;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
return Arg<R(*)(A1, A2, A3, A4, A5, A6, A7)>::argTypeDistance(v);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
static inline int classAllocationError(HSQUIRRELVM v) {
|
||||
return sq_throwerror(v, _SC("Failed to allocate memory"));
|
||||
}
|
||||
|
||||
template<typename R>
|
||||
struct Arg<R(*)(void)> {
|
||||
static inline int num(void) {return 0;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM) {return 0;}
|
||||
static inline int create(void) {
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
R *r = static_cast<R*>(sq_malloc(sizeof(R)));
|
||||
return r ?
|
||||
PostConstruct<R>(v, new(r) R,
|
||||
ClassType<R>::getReleaseHook()) :
|
||||
classAllocationError(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename R, typename A1>
|
||||
struct Arg<R(*)(A1)> {
|
||||
static inline int num(void) {return 1;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
int s, r;
|
||||
r = 0;
|
||||
s = CheckInstance<A1>::distance(v, 2); if (s < 0) {return -1;} r += s;
|
||||
return r;
|
||||
}
|
||||
static inline int create(A1 a1) {
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
R *r = static_cast<R*>(sq_malloc(sizeof(R)));
|
||||
return r ?
|
||||
PostConstruct<R>(v, new(r) R(a1),
|
||||
ClassType<R>::getReleaseHook()) :
|
||||
classAllocationError(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename R, typename A1, typename A2>
|
||||
struct Arg<R(*)(A1, A2)> {
|
||||
static inline int num(void) {return 2;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
int s, r;
|
||||
r = 0;
|
||||
s = CheckInstance<A1>::distance(v, 2); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A2>::distance(v, 3); if (s < 0) {return -1;} r += s;
|
||||
return r;
|
||||
}
|
||||
static inline int create(A1 a1, A2 a2) {
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
R *r = static_cast<R*>(sq_malloc(sizeof(R)));
|
||||
return r ?
|
||||
PostConstruct<R>(v, new(r) R(a1, a2),
|
||||
ClassType<R>::getReleaseHook()) :
|
||||
classAllocationError(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename R, typename A1, typename A2, typename A3>
|
||||
struct Arg<R(*)(A1, A2, A3)> {
|
||||
static inline int num(void) {return 3;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
int s, r;
|
||||
r = 0;
|
||||
s = CheckInstance<A1>::distance(v, 2); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A2>::distance(v, 3); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A3>::distance(v, 4); if (s < 0) {return -1;} r += s;
|
||||
return r;
|
||||
}
|
||||
static inline int create(A1 a1, A2 a2, A3 a3) {
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
R *r = static_cast<R*>(sq_malloc(sizeof(R)));
|
||||
return r ?
|
||||
PostConstruct<R>(v, new(r) R(a1, a2, a3),
|
||||
ClassType<R>::getReleaseHook()) :
|
||||
classAllocationError(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename R, typename A1, typename A2, typename A3, typename A4>
|
||||
struct Arg<R(*)(A1, A2, A3, A4)> {
|
||||
static inline int num(void) {return 4;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
int s, r;
|
||||
r = 0;
|
||||
s = CheckInstance<A1>::distance(v, 2); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A2>::distance(v, 3); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A3>::distance(v, 4); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A4>::distance(v, 5); if (s < 0) {return -1;} r += s;
|
||||
return r;
|
||||
}
|
||||
static inline int create(A1 a1, A2 a2, A3 a3, A4 a4) {
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
R *r = static_cast<R*>(sq_malloc(sizeof(R)));
|
||||
return r ?
|
||||
PostConstruct<R>(v, new(r) R(a1, a2, a3, a4),
|
||||
ClassType<R>::getReleaseHook()) :
|
||||
classAllocationError(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename R, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
struct Arg<R(*)(A1, A2, A3, A4, A5)> {
|
||||
static inline int num(void) {return 5;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
int s, r;
|
||||
r = 0;
|
||||
s = CheckInstance<A1>::distance(v, 2); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A2>::distance(v, 3); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A3>::distance(v, 4); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A4>::distance(v, 5); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A5>::distance(v, 6); if (s < 0) {return -1;} r += s;
|
||||
return r;
|
||||
}
|
||||
static inline int create(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
R *r = static_cast<R*>(sq_malloc(sizeof(R)));
|
||||
return r ?
|
||||
PostConstruct<R>(v, new(r) R(a1, a2, a3, a4, a5),
|
||||
ClassType<R>::getReleaseHook()) :
|
||||
classAllocationError(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
struct Arg<R(*)(A1, A2, A3, A4, A5, A6)> {
|
||||
static inline int num(void) {return 6;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
int s, r;
|
||||
r = 0;
|
||||
s = CheckInstance<A1>::distance(v, 2); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A2>::distance(v, 3); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A3>::distance(v, 4); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A4>::distance(v, 5); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A5>::distance(v, 6); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A6>::distance(v, 7); if (s < 0) {return -1;} r += s;
|
||||
return r;
|
||||
}
|
||||
static inline int create(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
R *r = static_cast<R*>(sq_malloc(sizeof(R)));
|
||||
return r ?
|
||||
PostConstruct<R>(v, new(r) R(a1, a2, a3, a4, a5, a6),
|
||||
ClassType<R>::getReleaseHook()) :
|
||||
classAllocationError(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename R, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
struct Arg<R(*)(A1, A2, A3, A4, A5, A6, A7)> {
|
||||
static inline int num(void) {return 7;}
|
||||
static inline int argTypeDistance(HSQUIRRELVM v) {
|
||||
int s, r;
|
||||
r = 0;
|
||||
s = CheckInstance<A1>::distance(v, 2); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A2>::distance(v, 3); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A3>::distance(v, 4); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A4>::distance(v, 5); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A5>::distance(v, 6); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A6>::distance(v, 7); if (s < 0) {return -1;} r += s;
|
||||
s = CheckInstance<A7>::distance(v, 8); if (s < 0) {return -1;} r += s;
|
||||
return r;
|
||||
}
|
||||
static inline int create(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
R *r = static_cast<R*>(sq_malloc(sizeof(R)));
|
||||
return r ?
|
||||
PostConstruct<R>(v, new(r) R(a1, a2, a3, a4, a5, a6, a7),
|
||||
ClassType<R>::getReleaseHook()) :
|
||||
classAllocationError(v);
|
||||
}
|
||||
};
|
||||
#endif // SQPLUS_OVERLOAD_FUNCTIONS
|
||||
|
||||
// SqPlusOverload.h
|
||||
|
||||
// Local Variables:
|
||||
// mode: c++
|
||||
// End:
|
@ -1,129 +0,0 @@
|
||||
#ifndef SQPLUSSETUP_H
|
||||
#define SQPLUSSETUP_H
|
||||
|
||||
// Setup file for SqPlus.
|
||||
// Comment / uncomment / define options below.
|
||||
|
||||
|
||||
// Inheritance in Squirrel allows one class to inherit a base class's
|
||||
// functions and variables.
|
||||
//
|
||||
// Variables are merged: if Derived has a var name 'val' and Base has
|
||||
// a var of the same name, the resulting var 'val' will take Derived's
|
||||
// initialization value.
|
||||
//
|
||||
// Functions are not merged, and can be called via Squirrel scoping rules.
|
||||
//
|
||||
// Define SQ_USE_CLASS_INHERITANCE to enable class inheritance support
|
||||
// (requires slightly more memory and adds some CPU overhead).
|
||||
//
|
||||
// Can also be useful for debugging, as class type information is
|
||||
// checked before dispatching instance function calls and before
|
||||
// accessing instance member variables.
|
||||
#define SQ_USE_CLASS_INHERITANCE
|
||||
|
||||
|
||||
// This is a new C++ template based inheritence scheme that uses no
|
||||
// additional memory per instance. To support offset between "this"
|
||||
// pointer in base and derived class, use a second class in:
|
||||
// SQClassDef< MyClass, MyBaseClass >.
|
||||
// NOTE: For new code SQ_USE_CLASS_INHERITANCE_SIMPLE is more
|
||||
// efficient than above method.
|
||||
//#define SQ_USE_CLASS_INHERITANCE_SIMPLE
|
||||
|
||||
// === Instance type info support ===
|
||||
#define SQ_SUPPORT_INSTANCE_TYPE_INFO
|
||||
|
||||
// === Constant argument and constant member function support ===
|
||||
// Define SQPLUS_CONST_OPT before including SqPlus.h for constant
|
||||
// argument + constant member function support.
|
||||
#define SQPLUS_CONST_OPT
|
||||
|
||||
|
||||
// === Uncomment to support smart pointer ===
|
||||
// Define SQPLUS_SMARTPOINTER_OPT before including SqPlus.h for
|
||||
// smartpointer member function + variable support
|
||||
//#define SQPLUS_SMARTPOINTER_OPT
|
||||
|
||||
|
||||
// === Function overloading support ===
|
||||
#define SQPLUS_OVERLOAD_OPT
|
||||
|
||||
// === Uncomment to support std::string ===
|
||||
// Requires that Squirrel is compiled with SQChar == char
|
||||
//#define SQPLUS_SUPPORT_STD_STRING
|
||||
|
||||
// === Uncomment to support typedef std::basic_string<SQChar> sq_std_string ===
|
||||
#define SQPLUS_SUPPORT_SQ_STD_STRING
|
||||
|
||||
// === Uncomment to support NULL INSTANCE arguments ===
|
||||
#define SQPLUS_SUPPORT_NULL_INSTANCES
|
||||
|
||||
// === Uncomment to disable copying of class instances ===
|
||||
// If classes being exposed have private or protected constructors
|
||||
// one cannot do assign (=) in template functions.
|
||||
//#define SQPLUS_DISABLE_COPY_INSTANCES
|
||||
|
||||
|
||||
// === Auto generating typemasks for registered functions ===
|
||||
// This is useful when using Squirrel interactively
|
||||
//#define SQPLUS_ENABLE_AUTO_TYPEMASK
|
||||
|
||||
// === Uncomment to generate a typeof function for each class ===
|
||||
// This is mostly for displaying function help from inside a Squirrel prompt
|
||||
//#define SQPLUS_ENABLE_TYPEOF
|
||||
|
||||
// === Uncomment to skip sq_argassert() ===
|
||||
//#define SQ_SKIP_ARG_ASSERT
|
||||
|
||||
// === GCC Inline template fix ===
|
||||
// Can solve problems when linking if GCC has problems with inline functions
|
||||
//#define GCC_INLINE_WORKAROUND
|
||||
|
||||
|
||||
// === MSVC cdecl member functions ===
|
||||
// Enable binding member functions with __cdecl calling convention under MSVC.
|
||||
// Mostly useful when linking with binaries from other compilers.
|
||||
#ifdef _MSC_VER
|
||||
//#define SQPLUS_ENABLE_CDECL_MEMBER_FUNCTIONS
|
||||
#endif
|
||||
|
||||
|
||||
// === Generic Push/Pop/Match handlers ===
|
||||
// This enables using a 'fallback' set of Push/Get/Match that operates
|
||||
// on class level (not on template level). This opens for handling all
|
||||
// members of a certain class hierarchy using the same function
|
||||
// GenPush/GenGet/GenMatch overrides (provided the hierarchy has some
|
||||
// run-time type mechanism to use). They are used whenever an exact
|
||||
// template match is not found.
|
||||
//#define SQPLUS_USE_GENERIC_HANDLERS
|
||||
|
||||
|
||||
// === Sandbox VM ===
|
||||
// This enables giving one VM the role of 'sandbox' VM where scripts
|
||||
// of unknown origin may execute and not have access to any SqPlus
|
||||
// registered functions. All normal VMs have full access to script
|
||||
// functions, but the one given in SetSandboxVm() can only use std
|
||||
// Squirrel functions.
|
||||
//#define SQPLUS_USE_SANDBOX_VM
|
||||
|
||||
|
||||
#if defined(SQPLUS_SUPPORT_STD_STRING) || defined(SQPLUS_SUPPORT_SQ_STD_STRING)
|
||||
# include <string>
|
||||
#endif
|
||||
|
||||
|
||||
// === Conversion of arguments from opposite char type ( char <=> wchar_t ) ===
|
||||
// Converts strings to opposite encoding in Push/Get handlers (UTF8 / Latin1)
|
||||
#define SQPLUS_AUTOCONVERT_OTHER_CHAR
|
||||
|
||||
// === Whether 8 bit chars are treated as Latin1(1) or UTF8(0) ===
|
||||
// (leave undefined for undefined for automatic handling)
|
||||
#define SQPLUS_USE_LATIN1 1
|
||||
|
||||
// === Include system library bindings when creating VM:s in SquirrelVM::Init() ===
|
||||
// Define to bind to system lib when VM:s are created automatically in
|
||||
// SquirrelVM::Init()
|
||||
//#define SQPLUS_SQUIRRELVM_WITH_SYSTEMLIB
|
||||
|
||||
#endif // SQPLUSSETUP_H
|
@ -1,141 +0,0 @@
|
||||
// SqPlusSmartPointer.h
|
||||
// SqPlus smart pointer member function support created by James Whitworth.
|
||||
// Modular integration 07/11/07 James Whitworth.
|
||||
// you must define the function:
|
||||
// unsigned char* getSmartPointerPointee(unsigned char*) {
|
||||
// return &(MySmartPointer->pointee);
|
||||
// }
|
||||
// somewhere in your program so it can correctly lookup member variables on the class pointed to
|
||||
// by your smart pointer.
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_ACCESSTYPE
|
||||
#undef SQPLUS_SMARTPOINTER_ACCESSTYPE
|
||||
enum VarAccessType {VAR_ACCESS_READ_WRITE=0,VAR_ACCESS_READ_ONLY=1<<0,VAR_ACCESS_CONSTANT=1<<1,VAR_ACCESS_STATIC=1<<2,VAR_ACCESS_SMARTPOINTER=1<<3};
|
||||
#endif // #ifdef SQPLUS_SMARTPOINTER_ACCESSTYPE
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_REGISTER_VARIABLE
|
||||
#undef SQPLUS_SMARTPOINTER_REGISTER_VARIABLE
|
||||
// classType is the type of the member variable's containing class.
|
||||
template<typename T>
|
||||
void
|
||||
RegisterSmartInstanceVariable(SquirrelObject & so,
|
||||
ClassTypeBase *classType,
|
||||
T *var,
|
||||
const SQChar *scriptVarName,
|
||||
VarAccessType access = VAR_ACCESS_READ_WRITE)
|
||||
{
|
||||
VarRef *pvr = createVarRef(so,scriptVarName);
|
||||
|
||||
// var must be passed in as &obj->var, where obj = 0
|
||||
// (the address is the offset), or as static/global address.
|
||||
void *offsetOrAddrOrConst = static_cast<void*>(var);
|
||||
*pvr = VarRef(offsetOrAddrOrConst,
|
||||
TypeInfo<T>(),
|
||||
classType,
|
||||
ClassType<T>::type(),
|
||||
sizeof(*var),
|
||||
access);
|
||||
pvr->m_access |= VAR_ACCESS_SMARTPOINTER;
|
||||
createInstanceSetGetHandlers(so);
|
||||
}
|
||||
#endif // #ifdef SQPLUS_SMARTPOINTER_REGISTER_VARIABLE
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_DISPATCH
|
||||
#undef SQPLUS_SMARTPOINTER_DISPATCH
|
||||
template<typename Callee,typename Pointee,typename Func>
|
||||
class DirectCallSmartInstanceMemberFunction {
|
||||
public:
|
||||
static inline int Dispatch(HSQUIRRELVM v) {
|
||||
DirectCallInstanceFuncPicker<Callee, Func> p(v);
|
||||
if (!p.instance || !p.func) {
|
||||
sq_throwerror(v, _SC("Invalid Instance Type"));
|
||||
}
|
||||
Pointee *pointeeInstance = static_cast<Pointee*>(p.instance->get());
|
||||
return
|
||||
!pointeeInstance ? sq_throwerror(v, _SC("SmartPointer Pointee NULL")) :
|
||||
Call(*pointeeInstance, *(p.func), v, 2);
|
||||
}
|
||||
};
|
||||
#endif // #ifdef SQPLUS_SMARTPOINTER_DISPATCH
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_DIRECT_CLOSURE
|
||||
#undef SQPLUS_SMARTPOINTER_DIRECT_CLOSURE
|
||||
|
||||
template<typename Callee,typename Pointee,typename Func>
|
||||
inline void sq_pushdirectsmartinstanceclosure(HSQUIRRELVM v,const Callee & callee,const Pointee & pointee,Func func,SQUnsignedInteger nupvalues) {
|
||||
unsigned char * up = (unsigned char *)sq_newuserdata(v,sizeof(func)); // Also pushed on stack.
|
||||
memcpy(up,&func,sizeof(func));
|
||||
sq_newclosure(v,DirectCallSmartInstanceMemberFunction<Callee,Pointee,Func>::Dispatch,nupvalues+1);
|
||||
} // sq_pushdirectinstanceclosure
|
||||
|
||||
#endif // #ifdef SQPLUS_SMARTPOINTER_DIRECT_CLOSURE
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_REGISTER_INSTANCE
|
||||
#undef SQPLUS_SMARTPOINTER_REGISTER_INSTANCE
|
||||
|
||||
template<typename Callee, typename Pointee, typename Func>
|
||||
inline void RegisterSmartInstance(HSQUIRRELVM v,HSQOBJECT hclass,Callee & callee,Pointee & pointee,Func func,const SQChar * name) {
|
||||
sq_pushobject(v,hclass);
|
||||
sq_pushstring(v,name,-1);
|
||||
sq_pushdirectsmartinstanceclosure(v,callee,pointee,func,0);
|
||||
sq_createslot(v,-3);
|
||||
sq_poptop(v); // Remove hclass.
|
||||
} // RegisterInstance
|
||||
|
||||
#endif // #ifdef SQPLUS_SMARTPOINTER_REGISTER_INSTANCE
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_CLASS_DEF_FUNC
|
||||
#undef SQPLUS_SMARTPOINTER_CLASS_DEF_FUNC
|
||||
|
||||
// Register a smartpointer member function.
|
||||
template<typename Pointee, typename Func>
|
||||
SQClassDefBase & smartFunc(Func pfunc,const SQChar * name) {
|
||||
RegisterSmartInstance(v,newClass.GetObjectHandle(),*(TClassType *)0,*(Pointee *)0,pfunc,name);
|
||||
return *this;
|
||||
} // func
|
||||
|
||||
#endif // #ifdef SQPLUS_SMARTPOINTER_CLASS_DEF_FUNC
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_CLASS_DEF_VAR
|
||||
#undef SQPLUS_SMARTPOINTER_CLASS_DEF_VAR
|
||||
|
||||
// Register a member variable.
|
||||
template<typename Pointee, typename VarType>
|
||||
SQClassDefBase & smartVar(VarType Pointee::* pvar,const SQChar * name,VarAccessType access=VAR_ACCESS_READ_WRITE) {
|
||||
struct CV {
|
||||
VarType Pointee::* var;
|
||||
} cv; // Cast Variable helper.
|
||||
cv.var = pvar;
|
||||
RegisterSmartInstanceVariable(newClass,ClassType<TClassType>::type(),*(VarType **)&cv,name,access);
|
||||
return *this;
|
||||
} // var
|
||||
|
||||
// Register a member variable as a UserPointer (read only).
|
||||
template<typename Pointee, typename VarType>
|
||||
SQClassDefBase & smartVarAsUserPointer(VarType Pointee::* pvar,const SQChar * name) {
|
||||
struct CV {
|
||||
VarType Pointee::* var;
|
||||
} cv; // Cast Variable helper.
|
||||
cv.var = pvar;
|
||||
RegisterSmartInstanceVariable(newClass,ClassType<TClassType>::type(),*(SQAnything **)&cv,name,VAR_ACCESS_READ_ONLY);
|
||||
return *this;
|
||||
} // varAsUserPointer
|
||||
|
||||
#endif // #ifdef SQPLUS_SMARTPOINTER_CLASS_DEF_VAR
|
||||
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_CPP_DECLARATION
|
||||
#undef SQPLUS_SMARTPOINTER_CPP_DECLARATION
|
||||
extern unsigned char* getSmartPointerPointee(unsigned char*);
|
||||
#endif
|
||||
|
||||
#ifdef SQPLUS_SMARTPOINTER_INSTANCE_VARINFO
|
||||
#undef SQPLUS_SMARTPOINTER_INSTANCE_VARINFO
|
||||
if(vr->m_access & VAR_ACCESS_SMARTPOINTER) {
|
||||
up = reinterpret_cast<char*>(
|
||||
getSmartPointerPointee(reinterpret_cast<unsigned char*>(up))
|
||||
);
|
||||
}
|
||||
#endif // #ifdef SQPLUS_SMARTPOINTER_CPP_DECLARATION
|
||||
|
||||
// SqPlusSmartPointer.h
|
@ -1,169 +0,0 @@
|
||||
|
||||
// File to automatically generate a typemask for a function
|
||||
|
||||
// Will generate type masks that accepts Instance pointer or null
|
||||
#ifndef SQPLUS_ACCEPT_NULL_INSTANCE
|
||||
#define SQPLUS_ACCEPT_NULL_INSTANCE
|
||||
#endif
|
||||
|
||||
// Macros to reduce typing: (P1), (P1,P2), (P1,P2,P3), ...
|
||||
#define P_0
|
||||
#define P_1 P1
|
||||
#define P_2 P_1,P2
|
||||
#define P_3 P_2,P3
|
||||
#define P_4 P_3,P4
|
||||
#define P_5 P_4,P5
|
||||
#define P_6 P_5,P6
|
||||
#define P_7 P_6,P7
|
||||
|
||||
// Macros to reduce typing: (typename P1), (typename P1,typename P2), ...
|
||||
#define PTN_0
|
||||
#define PTN_1 typename P1
|
||||
#define PTN_2 PTN_1,typename P2
|
||||
#define PTN_3 PTN_2,typename P3
|
||||
#define PTN_4 PTN_3,typename P4
|
||||
#define PTN_5 PTN_4,typename P5
|
||||
#define PTN_6 PTN_5,typename P6
|
||||
#define PTN_7 PTN_6,typename P7
|
||||
|
||||
// Include a comma first in list: ,typename P1,typename P2
|
||||
#define PTNC_0
|
||||
#define PTNC_1 ,PTN_1
|
||||
#define PTNC_2 ,PTN_2
|
||||
#define PTNC_3 ,PTN_3
|
||||
#define PTNC_4 ,PTN_4
|
||||
#define PTNC_5 ,PTN_5
|
||||
#define PTNC_6 ,PTN_6
|
||||
#define PTNC_7 ,PTN_7
|
||||
|
||||
#ifdef SQUNICODE
|
||||
#define scstrcpy wcscpy
|
||||
#else
|
||||
#define scstrcpy strcpy
|
||||
#endif
|
||||
|
||||
inline const SQChar* strappchar(SQChar *buf, SQChar *in, SQChar ch){
|
||||
int l=scstrlen(in);
|
||||
scstrcpy(buf,in);
|
||||
buf[l] = ch;
|
||||
#ifdef SQPLUS_ACCEPT_NULL_INSTANCE
|
||||
if( ch=='x' ){
|
||||
buf[++l] = '|'; // Also accept NULL pointers
|
||||
buf[++l] = 'o';
|
||||
}
|
||||
#endif
|
||||
buf[l+1] = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
struct sqTypeMask { };
|
||||
|
||||
|
||||
// Return type not included in type mask, delegate to void case
|
||||
|
||||
// Base case, no arguments
|
||||
template<typename RT>
|
||||
struct sqTypeMask<RT(*)()> {
|
||||
static const SQChar *Get(){
|
||||
static SQChar buf[64];
|
||||
//buf[0] = _SC('t');
|
||||
//buf[1] = 0;
|
||||
//strcpy(buf,"t|x"); // Accept both instance and table, we don't use param anyway
|
||||
buf[0] = _SC('.'); // Accept anything (not used)
|
||||
buf[1] = 0;
|
||||
return buf;
|
||||
}
|
||||
};
|
||||
|
||||
// Recursive case, peel of one arg at each level
|
||||
#define DECLARE_RT_SQTYPEMASK(N,M) \
|
||||
template<typename RT PTNC_##N> \
|
||||
struct sqTypeMask<RT(*)(P_##N)> { \
|
||||
static const SQChar *Get(){ \
|
||||
static SQChar buf[10]; \
|
||||
return strappchar(buf, (SQChar*)sqTypeMask<RT(*)(P_##M)>::Get(), \
|
||||
(SQChar)TypeInfo<P##N>::TypeMask); \
|
||||
} \
|
||||
};
|
||||
|
||||
DECLARE_RT_SQTYPEMASK(1,0)
|
||||
DECLARE_RT_SQTYPEMASK(2,1)
|
||||
DECLARE_RT_SQTYPEMASK(3,2)
|
||||
DECLARE_RT_SQTYPEMASK(4,3)
|
||||
DECLARE_RT_SQTYPEMASK(5,4)
|
||||
DECLARE_RT_SQTYPEMASK(6,5)
|
||||
DECLARE_RT_SQTYPEMASK(7,6)
|
||||
|
||||
|
||||
// Difference to above is that 1st param is instance instead of table
|
||||
|
||||
#define DECLARE_RT_MEMBER_SQTYPEMASK(N,QUAL) \
|
||||
template<typename Callee, typename RT PTNC_##N> \
|
||||
struct sqTypeMask<RT(Callee::*)(P_##N) QUAL> { \
|
||||
static const SQChar *Get(){ \
|
||||
SQChar *buf = (SQChar*)sqTypeMask<RT(*)(P_##N)>::Get(); \
|
||||
buf[0] = _SC('x'); \
|
||||
return buf; \
|
||||
} \
|
||||
};
|
||||
|
||||
// buf[1] = 0; \
|
||||
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(0,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(1,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(2,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(3,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(4,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(5,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(6,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(7,)
|
||||
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(0,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(1,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(2,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(3,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(4,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(5,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(6,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK(7,const)
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
// Difference to above is we're using __cdecl calling convention here
|
||||
// Only makes sense for MSVC where member functions can have different
|
||||
// calling conventions (__cdecl or __thiscall)
|
||||
|
||||
#define DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(N,QUAL) \
|
||||
template<typename Callee, typename RT PTNC_##N> \
|
||||
struct sqTypeMask<RT(__cdecl Callee::*)(P_##N) QUAL> { \
|
||||
static const SQChar *Get(){ \
|
||||
SQChar *buf = (SQChar*)sqTypeMask<RT(*)(P_##N)>::Get(); \
|
||||
buf[0] = _SC('x'); \
|
||||
return buf; \
|
||||
} \
|
||||
};
|
||||
|
||||
// buf[1] = 0; \
|
||||
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(0,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(1,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(2,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(3,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(4,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(5,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(6,)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(7,)
|
||||
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(0,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(1,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(2,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(3,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(4,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(5,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(6,const)
|
||||
DECLARE_RT_MEMBER_SQTYPEMASK_CDECL(7,const)
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
@ -1,133 +0,0 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Simple conversion routines, to, from UTF8 and full Unicode character
|
||||
// (using int).
|
||||
//
|
||||
|
||||
// Only when needed
|
||||
#if !defined(SQPLUS_USE_LATIN1) || SQPLUS_USE_LATIN1==0
|
||||
|
||||
static char g_utf8_length[256];
|
||||
static int g_did_init_length;
|
||||
|
||||
void sqplus_init_utf8_lengths() {
|
||||
// Fill in lengths in array above
|
||||
for( int lb=0; lb<256; lb++ ){
|
||||
int l = -1;
|
||||
if( !(lb&0x80) ) l=1;
|
||||
else if( (lb&0xE0)==0xC0 ) l=2;
|
||||
else if( (lb&0xF0)==0xE0 ) l=3;
|
||||
else if( (lb&0xF8)==0xF0 ) l=4;
|
||||
else if( (lb&0xFC)==0xF8 ) l=5;
|
||||
else if( (lb&0xFE)==0xFC ) l=6;
|
||||
g_utf8_length[lb] = l;
|
||||
}
|
||||
g_did_init_length = 1;
|
||||
}
|
||||
|
||||
// Length of a UTF8 encoded Unicode character
|
||||
int sqplus_utf8_len(int lead_byte){
|
||||
if( !(lead_byte&0x80) ) return 1; // Special case, make faster
|
||||
if( !g_did_init_length )
|
||||
sqplus_init_utf8_lengths();
|
||||
|
||||
return g_utf8_length[(unsigned char)lead_byte];
|
||||
}
|
||||
|
||||
int sqplus_utf8_len_first(const char* pc){
|
||||
int lb = *(unsigned char*)pc;
|
||||
if( !(lb&0x80) ) return 1; // Special case, make faster
|
||||
if( !g_did_init_length )
|
||||
sqplus_init_utf8_lengths();
|
||||
|
||||
int l = g_utf8_length[(unsigned char)lb];
|
||||
if( l>0 ) return l;
|
||||
|
||||
// Invalid UTF8 lead byte. Look for next valid character.
|
||||
const char *pc1 = pc+1;
|
||||
while( ((*pc1)&0xC0)==0x80 )
|
||||
pc1++;
|
||||
return int(pc1 - pc);
|
||||
}
|
||||
|
||||
|
||||
// Length of a UTF8 encoded Unicode string (number of Unicode characters)
|
||||
int sqplus_utf8_strlen(const char *str) {
|
||||
if( !str ) return 0;
|
||||
int l, tl=0;
|
||||
while( *str ){
|
||||
l = sqplus_utf8_len_first(str);
|
||||
str += l;
|
||||
tl++;
|
||||
}
|
||||
return tl;
|
||||
}
|
||||
|
||||
// Convert one UTF8 encoded character to Unicode point
|
||||
int sqplus_utf8_to_wchar(int *result, const char *string){
|
||||
int res=-1;
|
||||
|
||||
// Assume argument pointers to be OK
|
||||
unsigned char ch = *string;
|
||||
int l = sqplus_utf8_len(ch);
|
||||
|
||||
if( l<1 ) return -1;
|
||||
int wc = l>1 ? (ch&(0x7F>>l)) : ch;
|
||||
while( l>1 ){
|
||||
wc = (wc<<6) + (*++string & 0x3F);
|
||||
l--;
|
||||
}
|
||||
*result = wc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Convert one Unicode point to UTF8 encoded version.
|
||||
// Checks if output fits in 1/4/6 bytes buffer.
|
||||
int sqplus_wchar_to_utf8(char *s, int wc, int size){
|
||||
if( size<1 ) return -1;
|
||||
if( (unsigned int)wc>=0x80000000 ) return -2;
|
||||
|
||||
// Single byte case
|
||||
if( wc<0x80 ){
|
||||
*s = (char)wc;
|
||||
//*s = (char)wc&0x7F;
|
||||
return 1;
|
||||
}
|
||||
if( size<4 ) return -3;
|
||||
|
||||
// Two or more UTF8 bytes
|
||||
int p = 1; // Index of last UTF8 byte
|
||||
if( wc>0x7FF ){ // 11 bits
|
||||
// Three or more UTF8 bytes
|
||||
p++; // p>=2
|
||||
if( wc>0xFFFF ){ // 16 bits
|
||||
// Four or more UTF8 bytes
|
||||
p++; // p>=3
|
||||
if( wc>0x1FFFFF ){ // 21 bits
|
||||
// Five or more UTF8 bytes
|
||||
if( size<6 ) return -3;
|
||||
p++; // p>=4 UTF8 bytes
|
||||
if( wc>0x3FFFFFF ){ // 26 bits
|
||||
// Six UTF8 bytes
|
||||
p++; // p>=5
|
||||
if( (unsigned int)wc>(unsigned int)0x7FFFFFF ){ // 31 bits
|
||||
// Would need 7 UTF8 bytes. Not supported.
|
||||
return -10;
|
||||
}
|
||||
s[p-4] = 0x80 | ((wc>>24)&0x3F); // Bit 24..29
|
||||
}
|
||||
s[p-3] = 0x80 | ((wc>>18)&0x3F); // Bit 18..23
|
||||
}
|
||||
s[p-2] = 0x80 | ((wc>>12)&0x3F); // Bit 12..17
|
||||
}
|
||||
s[p-1] = 0x80 | ((wc>>6)&0x3F); // Bit 6..11
|
||||
}
|
||||
s[p] = 0x80 | (wc&0x3F); // Bit 0..5
|
||||
s[0] = (0xFC << (5-p)) | (wc>>(p*6));
|
||||
|
||||
return p+1;
|
||||
}
|
||||
|
||||
#endif // #if !defined(SQPLUS_USE_LATIN1) || SQPLUS_USE_LATIN1==0
|
||||
|
@ -1,15 +0,0 @@
|
||||
#ifndef SQPLUSUTF8_H
|
||||
#define SQPLUSUTF8_H
|
||||
|
||||
#if defined(SQUTF8) || SQPLUS_USE_LATIN1!=1
|
||||
|
||||
// Simple Unicode <-> UTF8 conversion routines
|
||||
//int sqplus_utf8_len(char lead_byte);
|
||||
int sqplus_utf8_len_first(const char *str);
|
||||
int sqplus_utf8_strlen(const char *str);
|
||||
int sqplus_utf8_to_wchar(int *result, const char *string);
|
||||
int sqplus_wchar_to_utf8(char *s, int wc, int size);
|
||||
|
||||
#endif // defined(SQUTF8) || SQPLUS_USE_LATIN1!=1
|
||||
|
||||
#endif // SQPLUSUTF8_H
|
@ -1,161 +0,0 @@
|
||||
#include "sqplus.h"
|
||||
|
||||
BOOL CreateStaticNamespace(HSQUIRRELVM v,ScriptNamespaceDecl *sn)
|
||||
{
|
||||
int n = 0;
|
||||
sq_pushroottable(v);
|
||||
sq_pushstring(v,sn->name,-1);
|
||||
sq_newtable(v);
|
||||
const ScriptClassMemberDecl *members = sn->members;
|
||||
const ScriptClassMemberDecl *m = NULL;
|
||||
while(members[n].name) {
|
||||
m = &members[n];
|
||||
sq_pushstring(v,m->name,-1);
|
||||
sq_newclosure(v,m->func,0);
|
||||
sq_setparamscheck(v,m->params,m->typemask);
|
||||
sq_setnativeclosurename(v,-1,m->name);
|
||||
sq_createslot(v,-3);
|
||||
n++;
|
||||
}
|
||||
const ScriptConstantDecl *consts = sn->constants;
|
||||
const ScriptConstantDecl *c = NULL;
|
||||
n = 0;
|
||||
while(consts[n].name) {
|
||||
c = &consts[n];
|
||||
sq_pushstring(v,c->name,-1);
|
||||
switch(c->type) {
|
||||
case OT_STRING: sq_pushstring(v,c->val.s,-1);break;
|
||||
case OT_INTEGER: sq_pushinteger(v,c->val.i);break;
|
||||
case OT_FLOAT: sq_pushfloat(v,c->val.f);break;
|
||||
}
|
||||
sq_createslot(v,-3);
|
||||
n++;
|
||||
}
|
||||
if(sn->delegate) {
|
||||
const ScriptClassMemberDecl *members = sn->delegate;
|
||||
const ScriptClassMemberDecl *m = NULL;
|
||||
sq_newtable(v);
|
||||
while(members[n].name) {
|
||||
m = &members[n];
|
||||
sq_pushstring(v,m->name,-1);
|
||||
sq_newclosure(v,m->func,0);
|
||||
sq_setparamscheck(v,m->params,m->typemask);
|
||||
sq_setnativeclosurename(v,-1,m->name);
|
||||
sq_createslot(v,-3);
|
||||
n++;
|
||||
}
|
||||
sq_setdelegate(v,-2);
|
||||
}
|
||||
sq_createslot(v,-3);
|
||||
sq_pop(v,1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CreateClass(HSQUIRRELVM v,SquirrelClassDecl *cd)
|
||||
{
|
||||
int n = 0;
|
||||
int oldtop = sq_gettop(v);
|
||||
sq_pushroottable(v);
|
||||
sq_pushstring(v,cd->name,-1);
|
||||
if(cd->base) {
|
||||
sq_pushstring(v,cd->base,-1);
|
||||
if(SQ_FAILED(sq_get(v,-3))) { // Make sure the base exists if specified by cd->base name.
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if(SQ_FAILED(sq_newclass(v,cd->base?1:0))) { // Will inherit from base class on stack from sq_get() above.
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
}
|
||||
// sq_settypetag(v,-1,(unsigned int)cd);
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable : 4311)
|
||||
#endif
|
||||
sq_settypetag(v,-1,reinterpret_cast<SQUserPointer>(cd));
|
||||
const ScriptClassMemberDecl *members = cd->members;
|
||||
const ScriptClassMemberDecl *m = NULL;
|
||||
if (members) {
|
||||
while(members[n].name) {
|
||||
m = &members[n];
|
||||
sq_pushstring(v,m->name,-1);
|
||||
sq_newclosure(v,m->func,0);
|
||||
sq_setparamscheck(v,m->params,m->typemask);
|
||||
sq_setnativeclosurename(v,-1,m->name);
|
||||
sq_createslot(v,-3);
|
||||
n++;
|
||||
}
|
||||
} // if
|
||||
sq_createslot(v,-3);
|
||||
sq_pop(v,1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CreateNativeClassInstance(HSQUIRRELVM v,
|
||||
const SQChar *classname,
|
||||
SQUserPointer ud,
|
||||
SQRELEASEHOOK hook)
|
||||
{
|
||||
// If we don't do this, SquirrelVM keeps an old pointer around and this
|
||||
// will be used by SquirrelObject. That crashes when using several VMs.
|
||||
SquirrelVM::Init( v );
|
||||
|
||||
int oldtop = sq_gettop(v);
|
||||
sq_pushroottable(v);
|
||||
sq_pushstring(v,classname,-1);
|
||||
if(SQ_FAILED(sq_rawget(v,-2))){ //Get the class (created with sq_newclass()).
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
}
|
||||
//sq_pushroottable(v);
|
||||
if(SQ_FAILED(sq_createinstance(v,-1))) {
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef SQ_USE_CLASS_INHERITANCE
|
||||
HSQOBJECT ho;
|
||||
sq_getstackobj(v, -1, &ho); // OT_INSTANCE
|
||||
SquirrelObject instance(ho);
|
||||
SqPlus::PopulateAncestry(v, instance, ud);
|
||||
#endif
|
||||
|
||||
sq_remove(v,-3); //removes the root table
|
||||
sq_remove(v,-2); //removes the class
|
||||
if(SQ_FAILED(sq_setinstanceup(v,-1,ud))) {
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
}
|
||||
sq_setreleasehook(v,-1,hook);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Create native class instance and leave on stack.
|
||||
BOOL CreateConstructNativeClassInstance(HSQUIRRELVM v,const SQChar * className) {
|
||||
int oldtop = sq_gettop(v);
|
||||
sq_pushroottable(v);
|
||||
sq_pushstring(v,className,-1);
|
||||
if (SQ_FAILED(sq_rawget(v,-2))) { // Get the class (created with sq_newclass()).
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
} // if
|
||||
#if 0
|
||||
sq_remove(v,-3); // Remove the root table.
|
||||
sq_push(v,1); // Push the 'this'.
|
||||
#else // Kamaitati's change. 5/28/06 jcs.
|
||||
sq_remove(v,-2); // Remove the root table.
|
||||
sq_pushroottable(v); // Push the 'this'.
|
||||
#endif
|
||||
if (SQ_FAILED(sq_call(v,1,SQTrue,SQ_CALL_RAISE_ERROR))) { // Call ClassName(): creates new instance and calls constructor (instead of sq_createinstance() where constructor is not called).
|
||||
sq_settop(v,oldtop);
|
||||
return FALSE;
|
||||
} // if
|
||||
sq_remove(v,-2); // Remove the class.
|
||||
// int newtop = sq_gettop(v);
|
||||
return TRUE;
|
||||
} // CreateConstructNativeClassInstance
|
||||
|
||||
|
@ -1,152 +0,0 @@
|
||||
#ifndef SQUIRREL_BINDINGS_UTILS_H
|
||||
#define SQUIRREL_BINDINGS_UTILS_H
|
||||
|
||||
struct ScriptClassMemberDecl {
|
||||
const SQChar *name;
|
||||
SQFUNCTION func;
|
||||
int params;
|
||||
const SQChar *typemask;
|
||||
};
|
||||
|
||||
struct SquirrelClassDecl {
|
||||
const SQChar *name;
|
||||
const SQChar *base;
|
||||
const ScriptClassMemberDecl *members;
|
||||
};
|
||||
|
||||
struct ScriptConstantDecl {
|
||||
const SQChar *name;
|
||||
SQObjectType type;
|
||||
union value {
|
||||
value(float v){ f = v; }
|
||||
value(int v){ i = v; }
|
||||
value(long int v){ li = v; }
|
||||
value(const SQChar *v){ s = v; }
|
||||
float f;
|
||||
int i;
|
||||
long int li;
|
||||
const SQChar *s;
|
||||
} val;
|
||||
};
|
||||
|
||||
struct ScriptNamespaceDecl {
|
||||
const SQChar *name;
|
||||
const ScriptClassMemberDecl *members;
|
||||
const ScriptConstantDecl *constants;
|
||||
const ScriptClassMemberDecl *delegate;
|
||||
};
|
||||
|
||||
#define _BEGIN_CLASS(classname) \
|
||||
int __##classname##__typeof(HSQUIRRELVM v) \
|
||||
{ \
|
||||
sq_pushstring(v,_SC(#classname),-1); \
|
||||
return 1; \
|
||||
} \
|
||||
struct ScriptClassMemberDecl __##classname##_members[] = { \
|
||||
{_SC("_typeof"),__##classname##__typeof,1,NULL},
|
||||
|
||||
#define _BEGIN_NAMESPACE(xnamespace) struct ScriptClassMemberDecl __##xnamespace##_members[] = {
|
||||
#define _BEGIN_NAMESPACE_CONSTANTS(xnamespace) {NULL,NULL,0,NULL}}; \
|
||||
struct ScriptConstantDecl __##xnamespace##_constants[] = {
|
||||
|
||||
#define _BEGIN_DELEGATE(xnamespace) struct ScriptClassMemberDecl __##xnamespace##_delegate[] = {
|
||||
#define _DELEGATE(xnamespace) __##xnamespace##_delegate
|
||||
#define _END_DELEGATE(classname) {NULL,NULL,NULL,NULL}};
|
||||
|
||||
#define _CONSTANT(name,type,val) {_SC(#name),type,val},
|
||||
#define _CONSTANT_IMPL(name,type) {_SC(#name),type,name},
|
||||
|
||||
#define _MEMBER_FUNCTION(classname,name,nparams,typemask) \
|
||||
{_SC(#name),__##classname##_##name,nparams,typemask},
|
||||
|
||||
#define _END_NAMESPACE(classname,delegate) {NULL,OT_NULL,0}}; \
|
||||
struct ScriptNamespaceDecl __##classname##_decl = { \
|
||||
_SC(#classname), __##classname##_members,__##classname##_constants,delegate };
|
||||
|
||||
#define _END_CLASS(classname) {NULL,NULL,0,NULL}}; \
|
||||
struct SquirrelClassDecl __##classname##_decl = { \
|
||||
_SC(#classname), NULL, __##classname##_members };
|
||||
|
||||
|
||||
#define _END_CLASS_INHERITANCE(classname,base) {NULL,NULL,NULL,NULL}}; \
|
||||
struct SquirrelClassDecl __##classname##_decl = { \
|
||||
_SC(#classname), _SC(#base), __##classname##_members };
|
||||
|
||||
#define _MEMBER_FUNCTION_IMPL(classname,name) \
|
||||
int __##classname##_##name(HSQUIRRELVM v)
|
||||
|
||||
#define _INIT_STATIC_NAMESPACE(classname) CreateStaticNamespace(SquirrelVM::GetVMPtr(),&__##classname##_decl);
|
||||
#define _INIT_CLASS(classname)CreateClass(SquirrelVM::GetVMPtr(),&__##classname##_decl);
|
||||
|
||||
#define _DECL_STATIC_NAMESPACE(xnamespace) extern struct ScriptNamespaceDecl __##xnamespace##_decl;
|
||||
#define _DECL_CLASS(classname) extern struct SquirrelClassDecl __##classname##_decl;
|
||||
|
||||
#define _CHECK_SELF(cppclass,scriptclass) \
|
||||
cppclass *self = NULL; \
|
||||
if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)&__##scriptclass##_decl))) { \
|
||||
return sq_throwerror(v,_SC("invalid instance type"));\
|
||||
}
|
||||
|
||||
#define _CHECK_INST_PARAM(pname,idx,cppclass,scriptclass) \
|
||||
cppclass *pname = NULL; \
|
||||
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer*)&pname,(SQUserPointer)&__##scriptclass##_decl))) { \
|
||||
return sq_throwerror(v,_SC("invalid instance type"));\
|
||||
} \
|
||||
|
||||
#define _CHECK_INST_PARAM_BREAK(pname,idx,cppclass,scriptclass) \
|
||||
cppclass *pname = NULL; \
|
||||
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer*)&pname,(SQUserPointer)&__##scriptclass##_decl))) { \
|
||||
break; \
|
||||
} \
|
||||
|
||||
#define _CLASS_TAG(classname) ((unsigned int)&__##classname##_decl)
|
||||
|
||||
|
||||
#define _DECL_NATIVE_CONSTRUCTION(classname,cppclass) \
|
||||
BOOL push_##classname(cppclass &quat); \
|
||||
SquirrelObject new_##classname(cppclass &quat);
|
||||
|
||||
#define _IMPL_NATIVE_CONSTRUCTION(classname,cppclass) \
|
||||
static int classname##_release_hook(SQUserPointer p, int size) \
|
||||
{ \
|
||||
if(p) { \
|
||||
cppclass *pv = (cppclass *)p; \
|
||||
delete pv; \
|
||||
} \
|
||||
return 0; \
|
||||
} \
|
||||
BOOL push_##classname(cppclass &quat) \
|
||||
{ \
|
||||
cppclass *newquat = new cppclass; \
|
||||
*newquat = quat; \
|
||||
if(!CreateNativeClassInstance(SquirrelVM::GetVMPtr(),_SC(#classname),newquat,classname##_release_hook)) { \
|
||||
delete newquat; \
|
||||
return FALSE; \
|
||||
} \
|
||||
return TRUE; \
|
||||
} \
|
||||
SquirrelObject new_##classname(cppclass &quat) \
|
||||
{ \
|
||||
SquirrelObject ret; \
|
||||
if(push_##classname(quat)) { \
|
||||
ret.AttachToStackObject(-1); \
|
||||
sq_pop(SquirrelVM::GetVMPtr(),1); \
|
||||
} \
|
||||
return ret; \
|
||||
} \
|
||||
int construct_##classname(cppclass *p) \
|
||||
{ \
|
||||
sq_setinstanceup(SquirrelVM::GetVMPtr(),1,p); \
|
||||
sq_setreleasehook(SquirrelVM::GetVMPtr(),1,classname##_release_hook); \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
BOOL CreateStaticClass(HSQUIRRELVM v,SquirrelClassDecl *cd);
|
||||
BOOL CreateStaticNamespace(HSQUIRRELVM v,ScriptNamespaceDecl *sn);
|
||||
BOOL CreateClass(HSQUIRRELVM v,SquirrelClassDecl *cd);
|
||||
BOOL InitScriptClasses(HSQUIRRELVM v);
|
||||
BOOL CreateNativeClassInstance(HSQUIRRELVM v,const SQChar *classname,SQUserPointer ud,SQRELEASEHOOK hook);
|
||||
BOOL CreateConstructNativeClassInstance(HSQUIRRELVM v,const SQChar * className);
|
||||
|
||||
#endif // SQUIRREL_BINDINGS_UTILS_H
|
||||
|
@ -1,31 +0,0 @@
|
||||
#include "sqplus.h"
|
||||
|
||||
//#include "SquirrelObject.h"
|
||||
//#include "SquirrelVM.h"
|
||||
#include "SquirrelBindingsUtilsWin32.h"
|
||||
|
||||
int refcounted_release_hook(SQUserPointer p, int size)
|
||||
{
|
||||
IUnknown *pRC = (IUnknown*)p;
|
||||
pRC->Release();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL __CreateRefCountedInstance(HSQUIRRELVM v,const SQChar *classname,IUnknown *pRC,SQRELEASEHOOK hook)
|
||||
{
|
||||
if(!CreateNativeClassInstance(v,classname,pRC,hook)) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int construct_RefCounted(IUnknown *p)
|
||||
{
|
||||
sq_setinstanceup(SquirrelVM::GetVMPtr(),1,p);
|
||||
sq_setreleasehook(SquirrelVM::GetVMPtr(),1,refcounted_release_hook);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
BOOL CreateRefCountedInstance(HSQUIRRELVM v,const SQChar *classname,IUnknown *pRC)
|
||||
{
|
||||
return __CreateRefCountedInstance(v,classname,pRC,refcounted_release_hook);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#ifndef SQUIRREL_BINDINGS_UTILS_WIN32_H
|
||||
#define SQUIRREL_BINDINGS_UTILS_WIN32_H
|
||||
|
||||
#ifndef _INC_WINDOWS
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifndef __IUnknown_INTERFACE_DEFINED__
|
||||
#include <unknwn.h>
|
||||
#endif
|
||||
|
||||
#ifndef SQUIRREL_BINDINGS_UTILS_H
|
||||
#include "SquirrelBindingsUtils.h"
|
||||
#endif
|
||||
|
||||
#define _DECLARE_REFCOUNTED_NEW(cppclass,classname) \
|
||||
SquirrelObject new_##classname(cppclass *ptr) { \
|
||||
if(CreateRefCountedInstance(SquirrelVM::GetVMPtr(),_SC(#classname),ptr)) { \
|
||||
HSQOBJECT o; \
|
||||
sq_getstackobj(SquirrelVM::GetVMPtr(),-1,&o); \
|
||||
SquirrelObject tmp = o; \
|
||||
sq_pop(SquirrelVM::GetVMPtr(),1); \
|
||||
return tmp; \
|
||||
} \
|
||||
return SquirrelObject() ; \
|
||||
}
|
||||
|
||||
#define _RETURN_REFCOUNTED_INSTANCE(classname,ptr) \
|
||||
if(!CreateRefCountedInstance(SquirrelVM::GetVMPtr(),_SC(#classname),ptr)) { \
|
||||
return sa.ThrowError(_SC("cannot create the class instance")); \
|
||||
} \
|
||||
return 1;
|
||||
|
||||
BOOL CreateRefCountedInstance(HSQUIRRELVM v,const SQChar *classname,IUnknown *pRC);
|
||||
BOOL CreateRefCountedInstanceChached(HSQUIRRELVM v,const SQChar *classname,IUnknown *pRC);
|
||||
int refcounted_release_hook(SQUserPointer p, int size);
|
||||
int construct_RefCounted(IUnknown *p);
|
||||
|
||||
#endif // SQUIRREL_BINDINGS_UTILS_WIN32_H
|
||||
|
@ -1,702 +0,0 @@
|
||||
#include "sqplus.h"
|
||||
|
||||
SquirrelObject::SquirrelObject(void)
|
||||
{
|
||||
sq_resetobject(&_o);
|
||||
}
|
||||
|
||||
SquirrelObject::~SquirrelObject()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
SquirrelObject::SquirrelObject(const SquirrelObject &o)
|
||||
{
|
||||
_o = o._o;
|
||||
sq_addref(SquirrelVM::_VM,&_o);
|
||||
}
|
||||
|
||||
SquirrelObject::SquirrelObject(HSQOBJECT o)
|
||||
{
|
||||
_o = o;
|
||||
sq_addref(SquirrelVM::_VM,&_o);
|
||||
}
|
||||
|
||||
void SquirrelObject::Reset(void) {
|
||||
if(SquirrelVM::_VM)
|
||||
sq_release(SquirrelVM::_VM,&_o);
|
||||
else if( _o._type!=OT_NULL && _o._unVal.pRefCounted )
|
||||
printf( "SquirrelObject::~SquirrelObject - Cannot release\n" );
|
||||
sq_resetobject(&_o);
|
||||
} // SquirrelObject::Reset
|
||||
|
||||
SquirrelObject SquirrelObject::Clone()
|
||||
{
|
||||
SquirrelObject ret;
|
||||
if(GetType() == OT_TABLE || GetType() == OT_ARRAY)
|
||||
{
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_clone(SquirrelVM::_VM,-1);
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(SquirrelVM::_VM,2);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
SquirrelObject & SquirrelObject::operator =(const SquirrelObject &o)
|
||||
{
|
||||
//HSQOBJECT t;
|
||||
//t = o._o;
|
||||
//sq_addref(SquirrelVM::_VM,&t);
|
||||
sq_addref(SquirrelVM::_VM, (HSQOBJECT*)&o._o);
|
||||
sq_release(SquirrelVM::_VM,&_o);
|
||||
//_o = t;
|
||||
_o = o._o;
|
||||
return *this;
|
||||
}
|
||||
|
||||
SquirrelObject & SquirrelObject::operator =(HSQOBJECT ho)
|
||||
{
|
||||
sq_addref(SquirrelVM::_VM,&ho);
|
||||
sq_release(SquirrelVM::_VM,&_o);
|
||||
_o = ho;
|
||||
return *this;
|
||||
}
|
||||
|
||||
SquirrelObject & SquirrelObject::operator =(int n)
|
||||
{
|
||||
sq_pushinteger(SquirrelVM::_VM,n);
|
||||
AttachToStackObject(-1);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#include <assert.h>
|
||||
#include "../squirrel/sqstate.h"
|
||||
#include "../squirrel/sqvm.h"
|
||||
|
||||
SquirrelObject & SquirrelObject::operator =(HSQUIRRELVM v)
|
||||
{
|
||||
if( v && SquirrelVM::_VM ){
|
||||
SquirrelVM::_VM->Push(v);
|
||||
AttachToStackObject(-1);
|
||||
sq_poptop(SquirrelVM::_VM);
|
||||
}
|
||||
else Reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool SquirrelObject::operator == (const SquirrelObject &o)
|
||||
{
|
||||
bool cmp = false;
|
||||
HSQUIRRELVM v = SquirrelVM::GetVMPtr();
|
||||
int oldtop = sq_gettop(v);
|
||||
|
||||
sq_pushobject(v, GetObjectHandle());
|
||||
sq_pushobject(v, o.GetObjectHandle());
|
||||
if(sq_cmp(v) == 0)
|
||||
cmp = true;
|
||||
|
||||
sq_settop(v, oldtop);
|
||||
return cmp;
|
||||
}
|
||||
|
||||
bool SquirrelObject::CompareUserPointer( const SquirrelObject &o )
|
||||
{
|
||||
if( _o._type == o.GetObjectHandle()._type )
|
||||
if( _o._unVal.pUserPointer == o.GetObjectHandle()._unVal.pUserPointer )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SquirrelObject::ArrayAppend(const SquirrelObject &o)
|
||||
{
|
||||
if(sq_isarray(_o)) {
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_pushobject(SquirrelVM::_VM,o._o);
|
||||
sq_arrayappend(SquirrelVM::_VM,-2);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
}
|
||||
|
||||
void SquirrelObject::AttachToStackObject(int idx)
|
||||
{
|
||||
HSQOBJECT t;
|
||||
sq_getstackobj(SquirrelVM::_VM,idx,&t);
|
||||
sq_addref(SquirrelVM::_VM,&t);
|
||||
sq_release(SquirrelVM::_VM,&_o);
|
||||
_o = t;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetDelegate(SquirrelObject &obj)
|
||||
{
|
||||
if(obj.GetType() == OT_TABLE ||
|
||||
obj.GetType() == OT_NULL) {
|
||||
switch(_o._type) {
|
||||
case OT_USERDATA:
|
||||
case OT_TABLE:
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_pushobject(SquirrelVM::_VM,obj._o);
|
||||
if(SQ_SUCCEEDED(sq_setdelegate(SquirrelVM::_VM,-2))) {
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return TRUE;
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelObject::GetDelegate()
|
||||
{
|
||||
SquirrelObject ret;
|
||||
if(_o._type == OT_TABLE || _o._type == OT_USERDATA)
|
||||
{
|
||||
int top = sq_gettop(SquirrelVM::_VM);
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_getdelegate(SquirrelVM::_VM,-1);
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_settop(SquirrelVM::_VM,top);
|
||||
// sq_pop(SquirrelVM::_VM,2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::IsNull() const
|
||||
{
|
||||
return sq_isnull(_o);
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::IsNumeric() const
|
||||
{
|
||||
return sq_isnumeric(_o);
|
||||
}
|
||||
|
||||
int SquirrelObject::Len() const
|
||||
{
|
||||
int ret = 0;
|
||||
if(sq_isarray(_o) || sq_istable(_o) || sq_isstring(_o)) {
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
ret = sq_getsize(SquirrelVM::_VM,-1);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define _SETVALUE_INT_BEGIN \
|
||||
BOOL ret = FALSE; \
|
||||
int top = sq_gettop(SquirrelVM::_VM); \
|
||||
sq_pushobject(SquirrelVM::_VM,_o); \
|
||||
sq_pushinteger(SquirrelVM::_VM,key);
|
||||
|
||||
#define _SETVALUE_INT_END \
|
||||
if(SQ_SUCCEEDED(sq_rawset(SquirrelVM::_VM,-3))) { \
|
||||
ret = TRUE; \
|
||||
} \
|
||||
sq_settop(SquirrelVM::_VM,top); \
|
||||
return ret;
|
||||
|
||||
BOOL SquirrelObject::SetValue(INT key,const SquirrelObject &val)
|
||||
{
|
||||
_SETVALUE_INT_BEGIN
|
||||
sq_pushobject(SquirrelVM::_VM,val._o);
|
||||
_SETVALUE_INT_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(INT key,INT n)
|
||||
{
|
||||
_SETVALUE_INT_BEGIN
|
||||
sq_pushinteger(SquirrelVM::_VM,n);
|
||||
_SETVALUE_INT_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(INT key,FLOAT f)
|
||||
{
|
||||
_SETVALUE_INT_BEGIN
|
||||
sq_pushfloat(SquirrelVM::_VM,f);
|
||||
_SETVALUE_INT_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(INT key,const SQChar *s)
|
||||
{
|
||||
_SETVALUE_INT_BEGIN
|
||||
sq_pushstring(SquirrelVM::_VM,s,-1);
|
||||
_SETVALUE_INT_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(INT key,bool b)
|
||||
{
|
||||
_SETVALUE_INT_BEGIN
|
||||
sq_pushbool(SquirrelVM::_VM,b);
|
||||
_SETVALUE_INT_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(const SquirrelObject &key,const SquirrelObject &val)
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
int top = sq_gettop(SquirrelVM::_VM);
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_pushobject(SquirrelVM::_VM,key._o);
|
||||
sq_pushobject(SquirrelVM::_VM,val._o);
|
||||
if(SQ_SUCCEEDED(sq_rawset(SquirrelVM::_VM,-3))) {
|
||||
ret = TRUE;
|
||||
}
|
||||
sq_settop(SquirrelVM::_VM,top);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define _SETVALUE_STR_BEGIN \
|
||||
BOOL ret = FALSE; \
|
||||
int top = sq_gettop(SquirrelVM::_VM); \
|
||||
sq_pushobject(SquirrelVM::_VM,_o); \
|
||||
sq_pushstring(SquirrelVM::_VM,key,-1);
|
||||
|
||||
#define _SETVALUE_STR_END \
|
||||
if(SQ_SUCCEEDED(sq_rawset(SquirrelVM::_VM,-3))) { \
|
||||
ret = TRUE; \
|
||||
} \
|
||||
sq_settop(SquirrelVM::_VM,top); \
|
||||
return ret;
|
||||
|
||||
BOOL SquirrelObject::SetValue(const SQChar *key,const SquirrelObject &val)
|
||||
{
|
||||
_SETVALUE_STR_BEGIN
|
||||
sq_pushobject(SquirrelVM::_VM,val._o);
|
||||
_SETVALUE_STR_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(const SQChar *key,INT n)
|
||||
{
|
||||
_SETVALUE_STR_BEGIN
|
||||
sq_pushinteger(SquirrelVM::_VM,n);
|
||||
_SETVALUE_STR_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(const SQChar *key,FLOAT f)
|
||||
{
|
||||
_SETVALUE_STR_BEGIN
|
||||
sq_pushfloat(SquirrelVM::_VM,f);
|
||||
_SETVALUE_STR_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(const SQChar *key,const SQChar *s)
|
||||
{
|
||||
_SETVALUE_STR_BEGIN
|
||||
sq_pushstring(SquirrelVM::_VM,s,-1);
|
||||
_SETVALUE_STR_END
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetValue(const SQChar *key,bool b)
|
||||
{
|
||||
_SETVALUE_STR_BEGIN
|
||||
sq_pushbool(SquirrelVM::_VM,b);
|
||||
_SETVALUE_STR_END
|
||||
}
|
||||
|
||||
// === BEGIN User Pointer, User Data ===
|
||||
|
||||
BOOL SquirrelObject::SetUserPointer(const SQChar * key,SQUserPointer up) {
|
||||
_SETVALUE_STR_BEGIN
|
||||
sq_pushuserpointer(SquirrelVM::_VM,up);
|
||||
_SETVALUE_STR_END
|
||||
} // SquirrelObject::SetUserPointer
|
||||
|
||||
SQUserPointer SquirrelObject::GetUserPointer(const SQChar * key) {
|
||||
SQUserPointer ret = NULL;
|
||||
if (GetSlot(key)) {
|
||||
sq_getuserpointer(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
} // if
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
} // SquirrelObject::GetUserPointer
|
||||
|
||||
BOOL SquirrelObject::SetUserPointer(INT key,SQUserPointer up) {
|
||||
_SETVALUE_INT_BEGIN
|
||||
sq_pushuserpointer(SquirrelVM::_VM,up);
|
||||
_SETVALUE_INT_END
|
||||
} // SquirrelObject::SetUserPointer
|
||||
|
||||
SQUserPointer SquirrelObject::GetUserPointer(INT key) {
|
||||
SQUserPointer ret = NULL;
|
||||
if (GetSlot(key)) {
|
||||
sq_getuserpointer(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
} // if
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
} // SquirrelObject::GetUserPointer
|
||||
|
||||
// === User Data ===
|
||||
|
||||
BOOL SquirrelObject::NewUserData(const SQChar * key,INT size,SQUserPointer * typetag) {
|
||||
_SETVALUE_STR_BEGIN
|
||||
sq_newuserdata(SquirrelVM::_VM,size);
|
||||
if (typetag) {
|
||||
sq_settypetag(SquirrelVM::_VM,-1,typetag);
|
||||
} // if
|
||||
_SETVALUE_STR_END
|
||||
} // SquirrelObject::NewUserData
|
||||
|
||||
BOOL SquirrelObject::GetUserData(const SQChar * key,SQUserPointer * data,SQUserPointer * typetag) {
|
||||
BOOL ret = false;
|
||||
if (GetSlot(key)) {
|
||||
sq_getuserdata(SquirrelVM::_VM,-1,data,typetag);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
ret = true;
|
||||
} // if
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
} // SquirrelObject::GetUserData
|
||||
|
||||
BOOL SquirrelObject::RawGetUserData(const SQChar * key,SQUserPointer * data,SQUserPointer * typetag) {
|
||||
BOOL ret = false;
|
||||
if (RawGetSlot(key)) {
|
||||
sq_getuserdata(SquirrelVM::_VM,-1,data,typetag);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
ret = true;
|
||||
} // if
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
} // SquirrelObject::RawGetUserData
|
||||
|
||||
// === END User Pointer ===
|
||||
|
||||
// === BEGIN Arrays ===
|
||||
|
||||
BOOL SquirrelObject::ArrayResize(INT newSize) {
|
||||
// int top = sq_gettop(SquirrelVM::_VM);
|
||||
sq_pushobject(SquirrelVM::_VM,GetObjectHandle());
|
||||
BOOL res = sq_arrayresize(SquirrelVM::_VM,-1,newSize) == SQ_OK;
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
// sq_settop(SquirrelVM::_VM,top);
|
||||
return res;
|
||||
} // SquirrelObject::ArrayResize
|
||||
|
||||
BOOL SquirrelObject::ArrayExtend(INT amount) {
|
||||
int newLen = Len()+amount;
|
||||
return ArrayResize(newLen);
|
||||
} // SquirrelObject::ArrayExtend
|
||||
|
||||
BOOL SquirrelObject::ArrayReverse(void) {
|
||||
sq_pushobject(SquirrelVM::_VM,GetObjectHandle());
|
||||
BOOL res = sq_arrayreverse(SquirrelVM::_VM,-1) == SQ_OK;
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return res;
|
||||
} // SquirrelObject::ArrayReverse
|
||||
|
||||
SquirrelObject SquirrelObject::ArrayPop(SQBool returnPoppedVal) {
|
||||
SquirrelObject ret;
|
||||
int top = sq_gettop(SquirrelVM::_VM);
|
||||
sq_pushobject(SquirrelVM::_VM,GetObjectHandle());
|
||||
if (sq_arraypop(SquirrelVM::_VM,-1,returnPoppedVal) == SQ_OK) {
|
||||
if (returnPoppedVal) {
|
||||
ret.AttachToStackObject(-1);
|
||||
} // if
|
||||
} // if
|
||||
sq_settop(SquirrelVM::_VM,top);
|
||||
return ret;
|
||||
} // SquirrelObject::ArrayPop
|
||||
|
||||
// === END Arrays ===
|
||||
|
||||
SQObjectType SquirrelObject::GetType()
|
||||
{
|
||||
return _o._type;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::GetSlot(INT key) const
|
||||
{
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_pushinteger(SquirrelVM::_VM,key);
|
||||
if(SQ_SUCCEEDED(sq_get(SquirrelVM::_VM,-2))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
SquirrelObject SquirrelObject::GetValue(INT key)const
|
||||
{
|
||||
SquirrelObject ret;
|
||||
if(GetSlot(key)) {
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
FLOAT SquirrelObject::GetFloat(INT key) const
|
||||
{
|
||||
FLOAT ret = 0.0f;
|
||||
if(GetSlot(key)) {
|
||||
sq_getfloat(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
INT SquirrelObject::GetInt(INT key) const
|
||||
{
|
||||
INT ret = 0;
|
||||
if(GetSlot(key)) {
|
||||
sq_getinteger(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const SQChar *SquirrelObject::GetString(INT key) const
|
||||
{
|
||||
const SQChar *ret = NULL;
|
||||
if(GetSlot(key)) {
|
||||
sq_getstring(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SquirrelObject::GetBool(INT key) const
|
||||
{
|
||||
SQBool ret = FALSE;
|
||||
if(GetSlot(key)) {
|
||||
sq_getbool(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret?true:false;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::Exists(const SQChar *key) const
|
||||
{
|
||||
if(GetSlot(key)) {
|
||||
sq_pop(SquirrelVM::_VM,2);
|
||||
return TRUE;
|
||||
} else {
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL SquirrelObject::GetSlot(const SQChar *name) const
|
||||
{
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_pushstring(SquirrelVM::_VM,name,-1);
|
||||
if(SQ_SUCCEEDED(sq_get(SquirrelVM::_VM,-2))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::RawGetSlot(const SQChar *name) const {
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_pushstring(SquirrelVM::_VM,name,-1);
|
||||
if(SQ_SUCCEEDED(sq_rawget(SquirrelVM::_VM,-2))) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
} // SquirrelObject::RawGetSlot
|
||||
|
||||
SquirrelObject SquirrelObject::GetValue(const SQChar *key)const
|
||||
{
|
||||
SquirrelObject ret;
|
||||
if(GetSlot(key)) {
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
FLOAT SquirrelObject::GetFloat(const SQChar *key) const
|
||||
{
|
||||
FLOAT ret = 0.0f;
|
||||
if(GetSlot(key)) {
|
||||
sq_getfloat(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
INT SquirrelObject::GetInt(const SQChar *key) const
|
||||
{
|
||||
INT ret = 0;
|
||||
if(GetSlot(key)) {
|
||||
sq_getinteger(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const SQChar *SquirrelObject::GetString(const SQChar *key) const
|
||||
{
|
||||
const SQChar *ret = NULL;
|
||||
if(GetSlot(key)) {
|
||||
sq_getstring(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SquirrelObject::GetBool(const SQChar *key) const
|
||||
{
|
||||
SQBool ret = FALSE;
|
||||
if(GetSlot(key)) {
|
||||
sq_getbool(SquirrelVM::_VM,-1,&ret);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
}
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return ret?true:false;
|
||||
}
|
||||
|
||||
SQUserPointer SquirrelObject::GetInstanceUP(SQUserPointer tag) const
|
||||
{
|
||||
SQUserPointer up;
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
if (SQ_FAILED(sq_getinstanceup(SquirrelVM::_VM,-1,(SQUserPointer*)&up,tag))) {
|
||||
sq_reseterror(SquirrelVM::_VM);
|
||||
up = NULL;
|
||||
} // if
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return up;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::SetInstanceUP(SQUserPointer up)
|
||||
{
|
||||
if(!sq_isinstance(_o)) return FALSE;
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_setinstanceup(SquirrelVM::_VM,-1,up);
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelObject::GetAttributes(const SQChar *key)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
int top = sq_gettop(SquirrelVM::_VM);
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
if(key)
|
||||
sq_pushstring(SquirrelVM::_VM,key,-1);
|
||||
else
|
||||
sq_pushnull(SquirrelVM::_VM);
|
||||
if(SQ_SUCCEEDED(sq_getattributes(SquirrelVM::_VM,-2))) {
|
||||
ret.AttachToStackObject(-1);
|
||||
}
|
||||
sq_settop(SquirrelVM::_VM,top);
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::BeginIteration()
|
||||
{
|
||||
if(!sq_istable(_o) && !sq_isarray(_o) && !sq_isclass(_o))
|
||||
return FALSE;
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_pushnull(SquirrelVM::_VM);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::Next(SquirrelObject &key,SquirrelObject &val)
|
||||
{
|
||||
if(SQ_SUCCEEDED(sq_next(SquirrelVM::_VM,-2))) {
|
||||
key.AttachToStackObject(-2);
|
||||
val.AttachToStackObject(-1);
|
||||
sq_pop(SquirrelVM::_VM,2);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL SquirrelObject::GetTypeTag(SQUserPointer * typeTag) {
|
||||
if (SQ_SUCCEEDED(sq_getobjtypetag(&_o,typeTag))) {
|
||||
return TRUE;
|
||||
} // if
|
||||
return FALSE;
|
||||
} // SquirrelObject::GetTypeTag
|
||||
|
||||
const SQChar * SquirrelObject::GetTypeName(const SQChar * key) {
|
||||
#if 1
|
||||
// This version will work even if SQ_SUPPORT_INSTANCE_TYPE_INFO is not enabled.
|
||||
SqPlus::ScriptStringVar256 varNameTag;
|
||||
SqPlus::getVarNameTag(varNameTag,sizeof(varNameTag),key);
|
||||
SQUserPointer data=0;
|
||||
if (!RawGetUserData(varNameTag,&data)) {
|
||||
return NULL;
|
||||
} // if
|
||||
SqPlus::VarRefPtr vr = (SqPlus::VarRefPtr)data;
|
||||
return vr->varType->GetTypeName();
|
||||
#else // This version will only work if SQ_SUPPORT_INSTANCE_TYPE_INFO is enabled.
|
||||
SquirrelObject so = GetValue(key);
|
||||
if (so.IsNull()) return NULL;
|
||||
return so.GetTypeName();
|
||||
#endif
|
||||
} // SquirrelObject::GetTypeName
|
||||
|
||||
const SQChar * SquirrelObject::GetTypeName(INT key) {
|
||||
SquirrelObject so = GetValue(key);
|
||||
if (so.IsNull()) return NULL;
|
||||
return so.GetTypeName();
|
||||
} // SquirrelObject::GetTypeName
|
||||
|
||||
const SQChar * SquirrelObject::GetTypeName(void) {
|
||||
SQUserPointer typeTag=NULL;
|
||||
if (SQ_SUCCEEDED(sq_getobjtypetag(&_o,&typeTag))) {
|
||||
SquirrelObject typeTable = SquirrelVM::GetRootTable().GetValue(SQ_PLUS_TYPE_TABLE);
|
||||
if (typeTable.IsNull()) {
|
||||
return NULL; // Not compiled with SQ_SUPPORT_INSTANCE_TYPE_INFO enabled.
|
||||
} // if
|
||||
return typeTable.GetString(INT((size_t)typeTag));
|
||||
} // if
|
||||
return NULL;
|
||||
} // SquirrelObject::GetTypeName
|
||||
|
||||
SquirrelObject SquirrelObject::GetBase(void)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
sq_pushobject(SquirrelVM::_VM,_o);
|
||||
sq_getbase(SquirrelVM::_VM,-1);
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(SquirrelVM::_VM,2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const SQChar* SquirrelObject::ToString()
|
||||
{
|
||||
return sq_objtostring(&_o);
|
||||
}
|
||||
|
||||
SQInteger SquirrelObject::ToInteger()
|
||||
{
|
||||
return sq_objtointeger(&_o);
|
||||
}
|
||||
|
||||
SQFloat SquirrelObject::ToFloat()
|
||||
{
|
||||
return sq_objtofloat(&_o);
|
||||
}
|
||||
|
||||
bool SquirrelObject::ToBool()
|
||||
{
|
||||
//<<FIXME>>
|
||||
return _o._unVal.nInteger?true:false;
|
||||
}
|
||||
|
||||
void SquirrelObject::EndIteration()
|
||||
{
|
||||
sq_pop(SquirrelVM::_VM,2);
|
||||
}
|
||||
|
@ -1,256 +0,0 @@
|
||||
#ifndef _SQUIRREL_OBJECT_H_
|
||||
#define _SQUIRREL_OBJECT_H_
|
||||
|
||||
class SquirrelObject
|
||||
{
|
||||
friend class SquirrelVM;
|
||||
|
||||
public:
|
||||
SquirrelObject();
|
||||
virtual ~SquirrelObject();
|
||||
SquirrelObject(const SquirrelObject & o);
|
||||
SquirrelObject(HSQOBJECT o);
|
||||
|
||||
#if 1
|
||||
template <typename _ty>
|
||||
SquirrelObject(const _ty & val) { sq_resetobject(&_o); Set((_ty &)val); } // Cast away const to avoid compiler SqPlus::Push() match issue.
|
||||
template <typename _ty>
|
||||
SquirrelObject(_ty & val) { sq_resetobject(&_o); Set(val); }
|
||||
template <typename _ty>
|
||||
SquirrelObject(_ty * val) { sq_resetobject(&_o); SetByValue(val); } // Set() would also be OK here. SetByValue() to save potential compiler overhead.
|
||||
#endif
|
||||
|
||||
SquirrelObject & operator = (HSQOBJECT ho);
|
||||
SquirrelObject & operator = (const SquirrelObject &o);
|
||||
SquirrelObject & operator = (int n);
|
||||
SquirrelObject & operator = (HSQUIRRELVM v);
|
||||
|
||||
operator HSQOBJECT& (){ return _o; }
|
||||
bool operator ==(const SquirrelObject& o);
|
||||
bool CompareUserPointer(const SquirrelObject& o);
|
||||
|
||||
void AttachToStackObject(int idx);
|
||||
void Reset(void); // Release (any) reference and reset _o.
|
||||
SquirrelObject Clone();
|
||||
BOOL SetValue(const SquirrelObject &key,const SquirrelObject &val);
|
||||
|
||||
BOOL SetValue(SQInteger key,const SquirrelObject &val);
|
||||
BOOL SetValue(INT key,bool b); // Compiler treats SQBool as INT.
|
||||
BOOL SetValue(INT key,INT n);
|
||||
BOOL SetValue(INT key,FLOAT f);
|
||||
BOOL SetValue(INT key,const SQChar *s);
|
||||
|
||||
BOOL SetValue(const SQChar *key,const SquirrelObject &val);
|
||||
BOOL SetValue(const SQChar *key,bool b);
|
||||
BOOL SetValue(const SQChar *key,INT n);
|
||||
BOOL SetValue(const SQChar *key,FLOAT f);
|
||||
BOOL SetValue(const SQChar *key,const SQChar *s);
|
||||
|
||||
BOOL SetUserPointer(const SQChar * key,SQUserPointer up);
|
||||
SQUserPointer GetUserPointer(const SQChar * key);
|
||||
BOOL SetUserPointer(INT key,SQUserPointer up);
|
||||
SQUserPointer GetUserPointer(INT key);
|
||||
|
||||
BOOL NewUserData(const SQChar * key,INT size,SQUserPointer * typetag=0);
|
||||
BOOL GetUserData(const SQChar * key,SQUserPointer * data,SQUserPointer * typetag=0);
|
||||
BOOL RawGetUserData(const SQChar * key,SQUserPointer * data,SQUserPointer * typetag=0);
|
||||
|
||||
// === BEGIN Arrays ===
|
||||
|
||||
BOOL ArrayResize(INT newSize);
|
||||
BOOL ArrayExtend(INT amount);
|
||||
BOOL ArrayReverse(void);
|
||||
SquirrelObject ArrayPop(SQBool returnPoppedVal=SQTrue);
|
||||
|
||||
void ArrayAppend(const SquirrelObject &o);
|
||||
|
||||
template<typename T>
|
||||
BOOL ArrayAppend(T item);
|
||||
|
||||
// === END Arrays ===
|
||||
|
||||
BOOL SetInstanceUP(SQUserPointer up);
|
||||
BOOL IsNull() const;
|
||||
int IsNumeric() const;
|
||||
int Len() const;
|
||||
BOOL SetDelegate(SquirrelObject &obj);
|
||||
SquirrelObject GetDelegate();
|
||||
const SQChar* ToString();
|
||||
bool ToBool();
|
||||
SQInteger ToInteger();
|
||||
SQFloat ToFloat();
|
||||
SQUserPointer GetInstanceUP(SQUserPointer tag) const;
|
||||
SquirrelObject GetValue(const SQChar *key) const;
|
||||
BOOL Exists(const SQChar *key) const;
|
||||
FLOAT GetFloat(const SQChar *key) const;
|
||||
INT GetInt(const SQChar *key) const;
|
||||
const SQChar *GetString(const SQChar *key) const;
|
||||
bool GetBool(const SQChar *key) const;
|
||||
SquirrelObject GetValue(INT key) const;
|
||||
FLOAT GetFloat(INT key) const;
|
||||
INT GetInt(INT key) const;
|
||||
const SQChar *GetString(INT key) const;
|
||||
bool GetBool(INT key) const;
|
||||
SquirrelObject GetAttributes(const SQChar *key = NULL);
|
||||
SQObjectType GetType();
|
||||
HSQOBJECT & GetObjectHandle() const {return *(HSQOBJECT*)&_o;}
|
||||
BOOL BeginIteration();
|
||||
BOOL Next(SquirrelObject &key,SquirrelObject &value);
|
||||
void EndIteration();
|
||||
|
||||
BOOL GetTypeTag(SQUserPointer * typeTag);
|
||||
|
||||
// === Get the type name of item/object through string key in a table or class. Returns NULL if the type name is not set (not an SqPlus registered type).
|
||||
const SQChar * GetTypeName(const SQChar * key);
|
||||
// === Get the type name of item/object through INT key in a table or class. Returns NULL if the type name is not set (not an SqPlus registered type).
|
||||
const SQChar * GetTypeName(INT key);
|
||||
// === Get the type name of this object, else return NULL if not an SqPlus registered type.
|
||||
const SQChar * GetTypeName(void);
|
||||
|
||||
// === Return base class of object using sq_getbase() ===
|
||||
SquirrelObject GetBase();
|
||||
|
||||
// === BEGIN code suggestion from the Wiki ===
|
||||
// Get any bound type from this SquirrelObject. Note that Squirrel's handling of references and pointers still holds here.
|
||||
template<typename _ty>
|
||||
_ty Get(void);
|
||||
|
||||
// Set any bound type to this SquirrelObject. Note that Squirrel's handling of references and pointers still holds here.
|
||||
template<typename _ty>
|
||||
SquirrelObject SetByValue(_ty val); // classes/structs should be passed by ref (below) to avoid an extra copy.
|
||||
|
||||
// Set any bound type to this SquirrelObject. Note that Squirrel's handling of references and pointers still holds here.
|
||||
template<typename _ty>
|
||||
SquirrelObject &Set(_ty & val);
|
||||
|
||||
// === END code suggestion from the Wiki ===
|
||||
|
||||
private:
|
||||
BOOL GetSlot(const SQChar *name) const;
|
||||
BOOL RawGetSlot(const SQChar *name) const;
|
||||
BOOL GetSlot(INT key) const;
|
||||
HSQOBJECT _o;
|
||||
};
|
||||
|
||||
struct StackHandler {
|
||||
StackHandler(HSQUIRRELVM v) {
|
||||
_top = sq_gettop(v);
|
||||
this->v = v;
|
||||
}
|
||||
SQFloat GetFloat(int idx) {
|
||||
SQFloat x = 0.0f;
|
||||
if(idx > 0 && idx <= _top) {
|
||||
sq_getfloat(v,idx,&x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
SQInteger GetInt(int idx) {
|
||||
SQInteger x = 0;
|
||||
if(idx > 0 && idx <= _top) {
|
||||
sq_getinteger(v,idx,&x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
HSQOBJECT GetObjectHandle(int idx) {
|
||||
HSQOBJECT x;
|
||||
if(idx > 0 && idx <= _top) {
|
||||
sq_resetobject(&x);
|
||||
sq_getstackobj(v,idx,&x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
const SQChar *GetString(int idx)
|
||||
{
|
||||
const SQChar *x = NULL;
|
||||
if(idx > 0 && idx <= _top) {
|
||||
sq_getstring(v,idx,&x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
SQUserPointer GetUserPointer(int idx)
|
||||
{
|
||||
SQUserPointer x = 0;
|
||||
if(idx > 0 && idx <= _top) {
|
||||
sq_getuserpointer(v,idx,&x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
SQUserPointer GetInstanceUp(int idx,SQUserPointer tag)
|
||||
{
|
||||
SQUserPointer self;
|
||||
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer*)&self,tag)))
|
||||
return NULL;
|
||||
return self;
|
||||
}
|
||||
SQUserPointer GetUserData(int idx,SQUserPointer tag=0)
|
||||
{
|
||||
SQUserPointer otag;
|
||||
SQUserPointer up;
|
||||
if(idx > 0 && idx <= _top) {
|
||||
if(SQ_SUCCEEDED(sq_getuserdata(v,idx,&up,&otag))) {
|
||||
if(tag == otag)
|
||||
return up;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
BOOL GetBool(int idx)
|
||||
{
|
||||
SQBool ret;
|
||||
if(idx > 0 && idx <= _top) {
|
||||
if(SQ_SUCCEEDED(sq_getbool(v,idx,&ret)))
|
||||
return ret;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
int GetType(int idx)
|
||||
{
|
||||
if(idx > 0 && idx <= _top) {
|
||||
return sq_gettype(v,idx);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int GetParamCount() {
|
||||
return _top;
|
||||
}
|
||||
int Return(const SQChar *s)
|
||||
{
|
||||
sq_pushstring(v,s,-1);
|
||||
return 1;
|
||||
}
|
||||
int Return(FLOAT f)
|
||||
{
|
||||
sq_pushfloat(v,f);
|
||||
return 1;
|
||||
}
|
||||
int Return(INT i)
|
||||
{
|
||||
sq_pushinteger(v,i);
|
||||
return 1;
|
||||
}
|
||||
int Return(bool b)
|
||||
{
|
||||
sq_pushbool(v,b);
|
||||
return 1;
|
||||
}
|
||||
int Return(SQUserPointer p) {
|
||||
sq_pushuserpointer(v,p);
|
||||
return 1;
|
||||
}
|
||||
int Return(SquirrelObject &o)
|
||||
{
|
||||
sq_pushobject(v,o.GetObjectHandle());
|
||||
return 1;
|
||||
}
|
||||
int Return() { return 0; }
|
||||
int ThrowError(const SQChar *error) {
|
||||
return sq_throwerror(v,error);
|
||||
}
|
||||
HSQUIRRELVM GetVMPtr() { return v; }
|
||||
private:
|
||||
int _top;
|
||||
HSQUIRRELVM v;
|
||||
};
|
||||
|
||||
#endif //_SQUIRREL_OBJECT_H_
|
@ -1,505 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define _DEBUG_DUMP
|
||||
|
||||
#include "sqplus.h"
|
||||
|
||||
#include <sqstdio.h>
|
||||
#include <sqstdmath.h>
|
||||
#include <sqstdstring.h>
|
||||
#include <sqstdaux.h>
|
||||
#include <sqstdblob.h>
|
||||
#include <sqstdsystem.h>
|
||||
|
||||
|
||||
HSQUIRRELVM SquirrelVM::_VM;
|
||||
bool SquirrelVM::_no_vm_ref;
|
||||
int SquirrelVM::_CallState = -1;
|
||||
SquirrelObject* SquirrelVM::_root;
|
||||
HSQUIRRELVM SquirrelVM::_sandboxVM;
|
||||
SquirrelObject SquirrelVM::_vm;
|
||||
|
||||
|
||||
// Helper struct to keep track of all SQSharedState:s created by SquirrelVM.
|
||||
#include "../squirrel/sqpcheader.h"
|
||||
#include "../squirrel/sqvm.h"
|
||||
struct SQSharedStateNode {
|
||||
SQSharedStateNode( SQSharedState* ps );
|
||||
~SQSharedStateNode( );
|
||||
SQSharedState* m_ps;
|
||||
SQSharedStateNode* m_nxt;
|
||||
};
|
||||
|
||||
// Linked list of shared states
|
||||
static SQSharedStateNode* g_sqss_fst;
|
||||
|
||||
SQSharedStateNode::SQSharedStateNode( SQSharedState* ps ) : m_ps(ps), m_nxt(g_sqss_fst) {
|
||||
g_sqss_fst = this;
|
||||
}
|
||||
|
||||
SQSharedStateNode::~SQSharedStateNode() {
|
||||
if(m_ps) sq_delete(m_ps,SQSharedState);
|
||||
delete m_nxt;
|
||||
}
|
||||
|
||||
static struct SquirrelVM_ModConstr {
|
||||
~SquirrelVM_ModConstr(){
|
||||
// Delete any shared states we created
|
||||
delete g_sqss_fst;
|
||||
g_sqss_fst = NULL;
|
||||
}
|
||||
} g_squirrelvm_mod_constr;
|
||||
|
||||
|
||||
|
||||
SquirrelError::SquirrelError()
|
||||
{
|
||||
const SQChar *s;
|
||||
sq_getlasterror(SquirrelVM::_VM);
|
||||
sq_getstring(SquirrelVM::_VM,-1,&s);
|
||||
if(s) {
|
||||
desc = s;
|
||||
}
|
||||
else {
|
||||
desc = _SC("unknown error");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SquirrelVMSys::~SquirrelVMSys() {
|
||||
// Must take care to release object with the 'ref' VM
|
||||
PushRefVM( _vm.GetObjectHandle()._unVal.pThread );
|
||||
_vm.Reset();
|
||||
PopRefVM();
|
||||
}
|
||||
|
||||
void SquirrelVMSys::Set( HSQUIRRELVM v ){
|
||||
// Must take care to release object with the 'ref' VM
|
||||
PushRefVM( v );
|
||||
_vm = v;
|
||||
PopRefVM( );
|
||||
}
|
||||
|
||||
void SquirrelVMSys::Set( const SquirrelObject& ov ){
|
||||
assert( ov.GetObjectHandle()._type==OT_THREAD );
|
||||
// Must take care to release object with the 'ref' VM
|
||||
PushRefVM( ov.GetObjectHandle()._unVal.pThread );
|
||||
_vm = ov;
|
||||
PopRefVM( );
|
||||
}
|
||||
|
||||
SquirrelVMSys::operator HSQUIRRELVM () const {
|
||||
// Avoid const madness
|
||||
SquirrelObject *pvm = (SquirrelObject*)&_vm;
|
||||
assert( pvm->GetObjectHandle()._type==OT_THREAD );
|
||||
return pvm->GetObjectHandle()._unVal.pThread;
|
||||
}
|
||||
|
||||
|
||||
// When doing a SquirrelObject assignment, a reference using the current
|
||||
// VM is done.
|
||||
HSQUIRRELVM g_VM_pushed;
|
||||
void SquirrelVMSys::PushRefVM( HSQUIRRELVM v ){
|
||||
assert( !g_VM_pushed );
|
||||
g_VM_pushed = SquirrelVM::_VM;
|
||||
SquirrelVM::_VM = v;
|
||||
}
|
||||
|
||||
void SquirrelVMSys::PopRefVM( ){
|
||||
SquirrelVM::_VM = g_VM_pushed;
|
||||
g_VM_pushed = NULL;
|
||||
}
|
||||
|
||||
|
||||
bool SquirrelVM::Init( HSQUIRRELVM v ){
|
||||
if( v && v==_VM )
|
||||
return true;
|
||||
|
||||
// Do we have a previous state?
|
||||
Release( );
|
||||
|
||||
bool created_new = false;
|
||||
if( !v ){
|
||||
// Create a new VM - a root VM with new SharedState.
|
||||
v = sq_open(1024);
|
||||
if( !v ) return false;
|
||||
// Store the associated shared state in a linked list. The state will only
|
||||
// be destroyed at app shutdown. Often that is fine, but if using many
|
||||
// VM:s briefly, this allocation is not optimal.
|
||||
new SQSharedStateNode( _ss(v) );
|
||||
created_new = true;
|
||||
sq_setprintfunc(v,SquirrelVM::PrintFunc, SquirrelVM::PrintFunc);
|
||||
sq_pushroottable(v);
|
||||
sqstd_register_iolib(v);
|
||||
sqstd_register_bloblib(v);
|
||||
sqstd_register_mathlib(v);
|
||||
sqstd_register_stringlib(v);
|
||||
#ifdef SQPLUS_SQUIRRELVM_WITH_SYSTEMLIB
|
||||
sqstd_register_systemlib(v);
|
||||
#endif
|
||||
sqstd_seterrorhandlers(v);
|
||||
//TODO error handler, compiler error handler
|
||||
sq_pop(v,1);
|
||||
}
|
||||
|
||||
// After this we hold a ref
|
||||
_no_vm_ref = false;
|
||||
_VM = v;
|
||||
_vm = v;
|
||||
|
||||
// In the case where Squirrel is ref counted we currently
|
||||
// hold two references to the VM (since it is created with
|
||||
// a ref count of 1). In the GC case, it is outside of the
|
||||
// chain of valid objects, so it is not referenced. Compensate
|
||||
// in ref counted case.
|
||||
if( created_new )
|
||||
DropVMRefIfRefCounted( v );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SquirrelVM::InitNoRef( HSQUIRRELVM v ){
|
||||
if( v && v==_VM )
|
||||
return true;
|
||||
|
||||
// Do we have a previous state?
|
||||
Release( );
|
||||
|
||||
// Set pointer to this VM, without referencing it
|
||||
_no_vm_ref = true;
|
||||
_VM = v;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void SquirrelVM::Init( HSQUIRRELVM v )
|
||||
{
|
||||
if( v && v==_VM ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do we have a previous state?
|
||||
Release();
|
||||
|
||||
if( !v ){
|
||||
// Create a new VM and own it
|
||||
_VM = sq_open(1024);
|
||||
sq_setprintfunc(_VM,SquirrelVM::PrintFunc);
|
||||
sq_pushroottable(_VM);
|
||||
sqstd_register_iolib(_VM);
|
||||
sqstd_register_bloblib(_VM);
|
||||
sqstd_register_mathlib(_VM);
|
||||
sqstd_register_stringlib(_VM);
|
||||
sqstd_seterrorhandlers(_VM);
|
||||
//TODO error handler, compiler error handler
|
||||
sq_pop(_VM,1);
|
||||
}
|
||||
else {
|
||||
_VM = v;
|
||||
}
|
||||
// After this we hold a ref
|
||||
_vm = _VM;
|
||||
}
|
||||
*/
|
||||
|
||||
void SquirrelVM::Release() {
|
||||
// Release root table object if we have one
|
||||
if( _root ){
|
||||
delete _root;
|
||||
_root = NULL;
|
||||
}
|
||||
|
||||
// Release our ref on VM - if we should
|
||||
if( !_no_vm_ref )
|
||||
_vm.Reset();
|
||||
|
||||
_VM = NULL;
|
||||
}
|
||||
|
||||
void SquirrelVM::DropVMRefIfRefCounted( HSQUIRRELVM v ){
|
||||
#ifdef NO_GARBAGE_COLLECTOR
|
||||
if( v ){
|
||||
SQObject t;
|
||||
t._unVal.pThread = v;
|
||||
t._type = OT_THREAD;
|
||||
sq_release( v, &t );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL SquirrelVM::Update()
|
||||
{
|
||||
//update remote debugger
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void SquirrelVM::PrintFunc(HSQUIRRELVM v,const SQChar* s,...)
|
||||
{
|
||||
static SQChar temp[2048];
|
||||
va_list vl;
|
||||
va_start(vl, s);
|
||||
scvsprintf( temp,s, vl);
|
||||
SCPUTS(temp);
|
||||
va_end(vl);
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::CompileScript(const SQChar *s)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
if(SQ_SUCCEEDED(sqstd_loadfile(_VM,s,1))) {
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,1);
|
||||
return ret;
|
||||
}
|
||||
throw SquirrelError();
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::CompileBuffer(const SQChar *s,const SQChar * debugInfo)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
if(SQ_SUCCEEDED(sq_compilebuffer(_VM,s,(int)scstrlen(s)*sizeof(SQChar),debugInfo,1))) {
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,1);
|
||||
return ret;
|
||||
}
|
||||
throw SquirrelError();
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::RunScript(const SquirrelObject &o,SquirrelObject *_this)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
sq_pushobject(_VM,o._o);
|
||||
if(_this) {
|
||||
sq_pushobject(_VM,_this->_o);
|
||||
}
|
||||
else {
|
||||
sq_pushroottable(_VM);
|
||||
}
|
||||
if(SQ_SUCCEEDED(sq_call(_VM,1,SQTrue,SQ_CALL_RAISE_ERROR))) {
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,2);
|
||||
return ret;
|
||||
}
|
||||
sq_pop(_VM,1);
|
||||
throw SquirrelError();
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL SquirrelVM::BeginCall(const SquirrelObject &func)
|
||||
{
|
||||
if(_CallState != -1)
|
||||
return FALSE;
|
||||
_CallState = 1;
|
||||
sq_pushobject(_VM,func._o);
|
||||
sq_pushroottable(_VM);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL SquirrelVM::BeginCall(const SquirrelObject &func,SquirrelObject &_this)
|
||||
{
|
||||
if(_CallState != -1)
|
||||
throw SquirrelError(_SC("call already initialized"));
|
||||
_CallState = 1;
|
||||
sq_pushobject(_VM,func._o);
|
||||
sq_pushobject(_VM,_this._o);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define _CHECK_CALL_STATE \
|
||||
if(_CallState == -1) \
|
||||
throw SquirrelError(_SC("call not initialized"));
|
||||
|
||||
void SquirrelVM::PushParam(const SquirrelObject &o)
|
||||
{
|
||||
_CHECK_CALL_STATE
|
||||
sq_pushobject(_VM,o._o);
|
||||
_CallState++;
|
||||
}
|
||||
|
||||
void SquirrelVM::PushParam(const SQChar *s)
|
||||
{
|
||||
_CHECK_CALL_STATE
|
||||
sq_pushstring(_VM,s,-1);
|
||||
_CallState++;
|
||||
}
|
||||
|
||||
void SquirrelVM::PushParam(SQInteger n)
|
||||
{
|
||||
_CHECK_CALL_STATE
|
||||
sq_pushinteger(_VM,n);
|
||||
_CallState++;
|
||||
}
|
||||
|
||||
void SquirrelVM::PushParam(SQFloat f)
|
||||
{
|
||||
_CHECK_CALL_STATE
|
||||
sq_pushfloat(_VM,f);
|
||||
_CallState++;
|
||||
}
|
||||
|
||||
void SquirrelVM::PushParamNull()
|
||||
{
|
||||
_CHECK_CALL_STATE
|
||||
sq_pushnull(_VM);
|
||||
_CallState++;
|
||||
}
|
||||
|
||||
void SquirrelVM::PushParam(SQUserPointer up)
|
||||
{
|
||||
_CHECK_CALL_STATE
|
||||
sq_pushuserpointer(_VM,up);
|
||||
_CallState++;
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::EndCall()
|
||||
{
|
||||
SquirrelObject ret;
|
||||
if(_CallState >= 0) {
|
||||
int oldtop = sq_gettop(_VM);
|
||||
int nparams = _CallState;
|
||||
_CallState = -1;
|
||||
if(SQ_SUCCEEDED(sq_call(_VM,nparams,SQTrue,SQ_CALL_RAISE_ERROR))) {
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,2);
|
||||
}else {
|
||||
sq_settop(_VM,oldtop-(nparams+1));
|
||||
throw SquirrelError();
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::CreateInstance(SquirrelObject &oclass)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
int oldtop = sq_gettop(_VM);
|
||||
sq_pushobject(_VM,oclass._o);
|
||||
if(SQ_FAILED(sq_createinstance(_VM,-1))) {
|
||||
sq_settop(_VM,oldtop);
|
||||
throw SquirrelError();
|
||||
}
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::CreateTable()
|
||||
{
|
||||
SquirrelObject ret;
|
||||
sq_newtable(_VM);
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::CreateString(const SQChar *s)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
sq_pushstring(_VM,s,-1);
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
SquirrelObject SquirrelVM::CreateArray(int size)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
sq_newarray(_VM,size);
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::CreateFunction(SQFUNCTION func)
|
||||
{
|
||||
SquirrelObject ret;
|
||||
sq_newclosure(_VM,func,0);
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SquirrelObject SquirrelVM::CreateUserData(int size) {
|
||||
SquirrelObject ret;
|
||||
sq_newuserdata(_VM,size);
|
||||
ret.AttachToStackObject(-1);
|
||||
sq_pop(_VM,1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const SquirrelObject &SquirrelVM::GetRootTable()
|
||||
{
|
||||
if( !_root ){
|
||||
sq_pushroottable(_VM);
|
||||
_root = new SquirrelObject();
|
||||
_root->AttachToStackObject(-1);
|
||||
sq_pop(_VM,1);
|
||||
}
|
||||
return *_root;
|
||||
}
|
||||
|
||||
void SquirrelVM::PushRootTable(void) {
|
||||
sq_pushroottable(_VM);
|
||||
} // SquirrelVM::PushRootTable
|
||||
|
||||
// Creates a function in the table or class currently on the stack.
|
||||
//void CreateFunction(HSQUIRRELVM v,const SQChar * scriptFuncName,SQFUNCTION func,int numParams=0,const SQChar * typeMask=0) {
|
||||
SquirrelObject SquirrelVM::CreateFunction(SQFUNCTION func,const SQChar * scriptFuncName,const SQChar * typeMask) {
|
||||
sq_pushstring(_VM,scriptFuncName,-1);
|
||||
sq_newclosure(_VM,func,0);
|
||||
SquirrelObject ret;
|
||||
ret.AttachToStackObject(-1);
|
||||
SQChar tm[64];
|
||||
SQChar * ptm = tm;
|
||||
int numParams = SQ_MATCHTYPEMASKSTRING;
|
||||
if (typeMask) {
|
||||
if (typeMask[0] == '*') {
|
||||
ptm = 0; // Variable args: don't check parameters.
|
||||
numParams = 0; // Clear SQ_MATCHTYPEMASKSTRING (does not mean match 0 params. See sq_setparamscheck()).
|
||||
} else {
|
||||
if (SCSNPRINTF(tm,sizeof(tm),_SC("t|y|x%s"),typeMask) < 0) {
|
||||
// sq_throwerror(_VM,_SC("CreateFunction: typeMask string too long."));
|
||||
throw SquirrelError(_SC("CreateFunction: typeMask string too long."));
|
||||
} // if
|
||||
} // if
|
||||
} else { // <TODO> Need to check object type on stack: table, class, instance, etc.
|
||||
SCSNPRINTF(tm,sizeof(tm),_SC("%s"),_SC("t|y|x")); // table, class, instance.
|
||||
// tm[0] = 't';
|
||||
// tm[1] = 0;
|
||||
} // if
|
||||
#if 0
|
||||
sq_setparamscheck(_VM,numParams+1,ptm); // Parameters are table+args (thus, the +1).
|
||||
#else
|
||||
if (ptm) {
|
||||
sq_setparamscheck(_VM,numParams,ptm); // Determine arg count from type string.
|
||||
} // if
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
sq_setnativeclosurename(_VM,-1,scriptFuncName); // For debugging only.
|
||||
#endif
|
||||
sq_createslot(_VM,-3); // Create slot in table or class (assigning function to slot at scriptNameFunc).
|
||||
return ret;
|
||||
} // SquirrelVM::CreateFunction
|
||||
|
||||
SquirrelObject SquirrelVM::CreateFunction(SquirrelObject & so,SQFUNCTION func,const SQChar * scriptFuncName,const SQChar * typeMask) {
|
||||
PushObject(so);
|
||||
SquirrelObject ret = CreateFunction(func,scriptFuncName,typeMask);
|
||||
Pop(1);
|
||||
return ret;
|
||||
} // SquirrelVM::CreateFunction
|
||||
|
||||
// Create a Global function on the root table.
|
||||
//void CreateFunctionGlobal(HSQUIRRELVM v,const SQChar * scriptFuncName,SQFUNCTION func,int numParams=0,const SQChar * typeMask=0) {
|
||||
SquirrelObject SquirrelVM::CreateFunctionGlobal(SQFUNCTION func,const SQChar * scriptFuncName,const SQChar * typeMask) {
|
||||
PushRootTable(); // Push root table.
|
||||
// CreateFunction(scriptFuncName,func,numParams,typeMask);
|
||||
SquirrelObject ret = CreateFunction(func,scriptFuncName,typeMask);
|
||||
Pop(1); // Pop root table.
|
||||
return ret;
|
||||
} // SquirrelVM::CreateFunctionGlobal
|
@ -1,179 +0,0 @@
|
||||
#ifndef _SQUIRREL_VM_H_
|
||||
#define _SQUIRREL_VM_H_
|
||||
|
||||
#include "SquirrelObject.h"
|
||||
|
||||
struct SquirrelError {
|
||||
SquirrelError();
|
||||
SquirrelError(const SQChar* s):desc(s){}
|
||||
const SQChar *desc;
|
||||
};
|
||||
|
||||
// This class can hold a reference to a SquirrelVM. It keeps a Squirrel ref
|
||||
// to the VM to protect it from being deleted while held.
|
||||
struct SquirrelVMSys {
|
||||
SquirrelVMSys() { }
|
||||
~SquirrelVMSys();
|
||||
|
||||
void Set( HSQUIRRELVM v );
|
||||
void Set( const SquirrelObject& ov );
|
||||
void Reset( ){ _vm.Reset(); }
|
||||
|
||||
SquirrelVMSys& operator = (HSQUIRRELVM v){ Set(v); return *this; }
|
||||
operator HSQUIRRELVM () const;
|
||||
|
||||
protected:
|
||||
void PushRefVM(HSQUIRRELVM v);
|
||||
void PopRefVM();
|
||||
SquirrelObject _vm;
|
||||
friend class SquirrelVM;
|
||||
};
|
||||
|
||||
// Notes on creating / destroying SquirrelVM:s:
|
||||
//
|
||||
// VM:s created through sq_open are special since they create a new
|
||||
// SQSharedState. That shared state is later shared by any new thread
|
||||
// or friend VM. sq_close can be used for closing VM:s created through
|
||||
// sq_open (but not for friend VMs).
|
||||
//
|
||||
// Using squirrel references in SquirrelVMSys and SquirrelVM, one must
|
||||
// make sure that these are all reset if one calls sq_close manually.
|
||||
//
|
||||
// When there are no more references to a VM, it is destroyed automatically,
|
||||
// but the shared state is not! For VM:s created by SquirrelVM, it keeps
|
||||
// a list of shared states it has created and will destroy them all on
|
||||
// app shutdown.
|
||||
|
||||
class SquirrelVM {
|
||||
friend class SquirrelObject;
|
||||
friend struct SquirrelError;
|
||||
friend struct SquirrelVMSys;
|
||||
|
||||
public:
|
||||
// If a VM is passed as arg here, Init will not alter it. Otherwise
|
||||
// a new VM is created and initialized. A squirrel reference is kept
|
||||
// while it is the current VM.
|
||||
static bool Init( HSQUIRRELVM v=NULL );
|
||||
|
||||
// Initialize with an externally created VM, without adding a ref
|
||||
// on it. NOTE: This may not be compatible with Set/GetVMSys as
|
||||
// we're just working with raw pointers here.
|
||||
static bool InitNoRef( HSQUIRRELVM v );
|
||||
static BOOL IsInitialized(){return _VM == NULL?FALSE:TRUE;}
|
||||
|
||||
static void Release(); // Release ref on VM and reset VM pointer
|
||||
static void Shutdown(){ Release(); }
|
||||
static void AppFinalShutdown(); // Call when finally shutting down app
|
||||
|
||||
static BOOL Update(); //debugger and maybe GC later
|
||||
|
||||
static SquirrelObject CompileScript(const SQChar *s);
|
||||
static SquirrelObject CompileBuffer(const SQChar *s,const SQChar * debugInfo=_SC("console_buffer"));
|
||||
static SquirrelObject RunScript(const SquirrelObject &o,SquirrelObject *_this = NULL);
|
||||
|
||||
static void PrintFunc(HSQUIRRELVM v,const SQChar* s,...);
|
||||
|
||||
static BOOL BeginCall(const SquirrelObject &func);
|
||||
static BOOL BeginCall(const SquirrelObject &func,SquirrelObject &_this);
|
||||
|
||||
static void PushParam(const SquirrelObject &o);
|
||||
static void PushParam(const SQChar *s);
|
||||
static void PushParam(SQInteger n);
|
||||
static void PushParam(SQFloat f);
|
||||
static void PushParam(SQUserPointer up);
|
||||
static void PushParamNull();
|
||||
|
||||
static SquirrelObject EndCall();
|
||||
static SquirrelObject CreateString(const SQChar *s);
|
||||
static SquirrelObject CreateTable();
|
||||
static SquirrelObject CreateArray(int size);
|
||||
static SquirrelObject CreateInstance(SquirrelObject &oclass); // oclass is an existing class. Create an 'instance' (OT_INSTANCE) of oclass.
|
||||
static SquirrelObject CreateFunction(SQFUNCTION func);
|
||||
static SquirrelObject CreateUserData(int size);
|
||||
|
||||
static const SquirrelObject &GetRootTable();
|
||||
static HSQUIRRELVM GetVMPtr() { return _VM; }
|
||||
|
||||
// The sandbox VM ptr is one which cannot access functions bound with
|
||||
// SqPlus. It is suitable for running non-trusted scripts that can only
|
||||
// access basic functionality.
|
||||
static void SetSandboxVMPtr(HSQUIRRELVM v) {
|
||||
_sandboxVM = v;
|
||||
} // SetSandboxVMPtr
|
||||
|
||||
static HSQUIRRELVM GetSandboxVMPtr() {
|
||||
return _sandboxVM;
|
||||
} // GetSandboxVMPtr
|
||||
|
||||
static void GetVMSys(SquirrelVMSys & vmSys) {
|
||||
vmSys.Set( _vm );
|
||||
} // GetVMSys
|
||||
|
||||
static void SetVMSys(const SquirrelVMSys & vmSys) {
|
||||
Release();
|
||||
HSQUIRRELVM v = (HSQUIRRELVM)vmSys;
|
||||
if( v )
|
||||
Init( v );
|
||||
} // SetVMSys
|
||||
|
||||
static void PushValue(INT val) {
|
||||
sq_pushinteger(_VM,val);
|
||||
} // PushValue
|
||||
static void PushValue(FLOAT val) {
|
||||
sq_pushfloat(_VM,val);
|
||||
} // PushValue
|
||||
static void PushValue(bool val) { // Compiler treats SQBool as INT.
|
||||
sq_pushbool(_VM,val);
|
||||
} // PushValue
|
||||
static void PushValue(SQChar * val) {
|
||||
sq_pushstring(_VM,val,-1);
|
||||
} // PushValue
|
||||
static void PushValue(SQUserPointer val) {
|
||||
sq_pushuserpointer(_VM,val);
|
||||
} // PushValue
|
||||
static void PushValue(const SQChar * val) {
|
||||
sq_pushstring(_VM,val,-1);
|
||||
} // PushValue
|
||||
static void PushObject(SquirrelObject & so) {
|
||||
sq_pushobject(_VM,so._o);
|
||||
} // PushObject
|
||||
static void Pop(SQInteger nelemstopop) {
|
||||
sq_pop(_VM,nelemstopop);
|
||||
} // Pop
|
||||
|
||||
static void PushRootTable(void);
|
||||
|
||||
// Create/bind a function on the table currently on the stack.
|
||||
static SquirrelObject CreateFunction(SQFUNCTION func,const SQChar * scriptFuncName,const SQChar * typeMask=0);
|
||||
// Create/bind a function on the table so. typeMask: standard Squirrel types plus: no typemask means no args, "*" means any type of args.
|
||||
static SquirrelObject CreateFunction(SquirrelObject & so,SQFUNCTION func,const SQChar * scriptFuncName,const SQChar * typeMask=0);
|
||||
// Create/bind a function to the root table. typeMask: standard Squirrel types plus: no typemask means no args, "*" means any type of args.
|
||||
static SquirrelObject CreateFunctionGlobal(SQFUNCTION func,const SQChar * scriptFuncName,const SQChar * typeMask=0);
|
||||
|
||||
// This is a helper to correct a difference in referncing new VM:s in
|
||||
// ref counted versus garbage collected modes. NOTE: Only use after creating
|
||||
// a VM with: 1 - sq_open() 2 - Creating a ref to the VM (SquirrelObject)
|
||||
static void DropVMRefIfRefCounted( HSQUIRRELVM v );
|
||||
|
||||
|
||||
private:
|
||||
static SquirrelObject _vm; // This is a Squirrel reference to the VM
|
||||
static HSQUIRRELVM _VM; // The raw C++ pointer
|
||||
static bool _no_vm_ref; // Set if we only keep the raw C++ pointer and no ref
|
||||
static int _CallState;
|
||||
static SquirrelObject * _root; // Cached root table if non NULL
|
||||
static HSQUIRRELVM _sandboxVM; // The sandbox VM (that cannot use bound functions)
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline BOOL SquirrelObject::ArrayAppend(T item) {
|
||||
sq_pushobject(SquirrelVM::_VM,GetObjectHandle());
|
||||
SquirrelVM::PushValue(item);
|
||||
BOOL res = sq_arrayappend(SquirrelVM::_VM,-2) == SQ_OK;
|
||||
sq_pop(SquirrelVM::_VM,1);
|
||||
return res;
|
||||
} // ArrayAppend
|
||||
|
||||
#endif //_SQUIRREL_VM_H_
|
||||
|
@ -1,359 +0,0 @@
|
||||
2008-07-13 "SQUIRREL2_1_1_sqplus_snapshot_20080713"
|
||||
|
||||
* Released as a snapshot
|
||||
|
||||
|
||||
2008-07-06 kawachi
|
||||
|
||||
* Removed testSqPlus2
|
||||
|
||||
|
||||
2008-06-26 arst@users.sf.net
|
||||
|
||||
* SquirrelVM.cpp / SqPlusSetup.h
|
||||
- Added a new define SQPLUS_SQUIRRELVM_WITH_SYSTEMLIB
|
||||
(Juggernaut, http://squirrel-lang.org/forums/2585/ShowThread.aspx#2585)
|
||||
|
||||
- Added a new function:
|
||||
SQClassDefBase::scriptVar(const SQChar* name, int ival,
|
||||
SQBool static_var=SQFalse)
|
||||
|
||||
It allows for creating either static or ordinary Squirrel class
|
||||
members from C++ source code. Versions for int/double/const
|
||||
SQChar*.
|
||||
|
||||
- SquirrelObject::GetBase() - retrieve base class.
|
||||
(Juggernaut, http://squirrel-lang.org/forums/2585/ShowThread.aspx#2585)
|
||||
|
||||
|
||||
2008-06-14 Kazei
|
||||
|
||||
* Fixed memory leak in overloadConstructor
|
||||
(http://squirrel-lang.org/forums/thread/2516.aspx)
|
||||
|
||||
|
||||
2008-05-10 Neimod
|
||||
|
||||
* Fixed for typesafe scripting
|
||||
(http://squirrel-lang.org/forums/thread/2478.aspx)
|
||||
|
||||
|
||||
2008-05-08 arst@users.sf.net
|
||||
|
||||
* sqplus.h/.cpp
|
||||
|
||||
- SQ_USE_CLASS_INHERITANCE_SIMPLE is a new way of handling class
|
||||
inheritence in SqPlus, relying on a template scheme (see ClassTypeBase
|
||||
and ClassType<T>). It doesn't use any memory per instance and should
|
||||
be a bit faster than previous scheme. SqClassDef has been given
|
||||
a second template argument to account for this:
|
||||
|
||||
struct SQClassDef<MyClass, TheBaseClass> ...
|
||||
|
||||
- The name of the class (in SqClassDef) can be filled in by SqPlus now,
|
||||
if Squirrel class name is same as C++ class name:
|
||||
|
||||
SQClasDef<Troll, Creature>("Troll", "Creature").func(...) =>
|
||||
SQClasDef<Troll, Creature>().func(...)
|
||||
|
||||
- Code to handle class types (names, copy funcs, ID tag, ...) has been
|
||||
collected in ClassTypeBase and ClassType<T>.
|
||||
|
||||
- A new macro to specify that classes should not be copied with default
|
||||
C++ method: DECLARE_NONCOPY_TYPE(ClassThatCannotBeCopied).
|
||||
|
||||
- Reworked body of repetetive template functions, Moved to
|
||||
SqPlusCallTemplates.h. Can be included with different qualifiers
|
||||
(const, cdecl).
|
||||
|
||||
- Support for cdecl member functions (MSVC specific) through:
|
||||
|
||||
SQPLUS_ENABLE_CDECL_MEMBER_FUNCTIONS
|
||||
|
||||
cdecl functions are compatible across compilers, while thiscall
|
||||
is not.
|
||||
|
||||
- Generic Push/Pop/Match handlers: SQPLUS_USE_GENERIC_HANDLERS
|
||||
By default, Push/Get/Match handlers are for a single type. This
|
||||
adds a fallback level, so that `hierarchy wide' handlers can
|
||||
be used (define for base class and let all derived classes use
|
||||
just that).
|
||||
|
||||
- For functions that return a pointer to a temporarary (such as
|
||||
returning a SQDefCharBuf, a template mapper class:
|
||||
|
||||
Temporary<T>::type
|
||||
|
||||
was added. It can hold a temporary value while finishing a
|
||||
SquirrelFunction call (before returning to C++).
|
||||
|
||||
- Suppressing horrible warnings from Visual C++ about sprintf and related
|
||||
functions (_CRT_SECURE_NO_DEPRECATE).
|
||||
|
||||
|
||||
* SquirrelVM.h/.cpp
|
||||
|
||||
- Changed SquirrelVM and SquirrelVMSys to make them hold a reference
|
||||
on a SQVM so that ownership can be shared in a defined way.
|
||||
|
||||
- SquirrelVMSys can be used as before to swap the `active' VM.
|
||||
Now it holds a ref to a VM so that a VM is closed automatically
|
||||
when switched out and there are no refs to any longer. (To hold a
|
||||
VM ref in the application, simply use an instance of SquirrelVMSys).
|
||||
|
||||
- NOTE: A VM created through sq_open() comes out with a reference
|
||||
count of 1. A VM created with sq_newthread() arrives with a ref
|
||||
count of 0. SquirrelVM will compensate for this.
|
||||
|
||||
- Possibility to store a `sandbox VM'. This VM is not allowed to
|
||||
access functions / classes bound with SqPlus and so can run more
|
||||
untrusted scripts.
|
||||
|
||||
- Hopefully these changes will not break current apps. (Note: creating
|
||||
and keeping correct refs on SQVM involved some difficulties (with ref-
|
||||
counting and garbage collected Squirrel). The scheme provided here is
|
||||
(I hope) a working solution.)
|
||||
|
||||
* SquirrelObject.h/.cpp
|
||||
|
||||
- Added: operator = (HSQOBJECT)
|
||||
|
||||
- From forum: (http://squirrel-lang.org/forums/thread/2506.aspx)
|
||||
(suggested by auron0)
|
||||
- Added: operator == (const SquirrelObject& o)
|
||||
- Added: CompareUserPointer(const SquirrelObject& o)
|
||||
|
||||
* SqPlusUTF8.h / .cpp
|
||||
|
||||
- New files for converting strings in arguments (UTF8 <-> wchar_t)
|
||||
|
||||
- Fix for conversion of UTF8 sequence of length 3+ bytes
|
||||
|
||||
|
||||
|
||||
2008-02-17 PallavNawani
|
||||
|
||||
* BindVariable of std::string
|
||||
(http://squirrel-lang.org/forums/2370/ShowThread.aspx)
|
||||
|
||||
|
||||
2007-10-14 "SQUIRREL2_1_1_sqplus_snapshot_20071014"
|
||||
|
||||
* Fixed const member function overloading by Tegan
|
||||
(http://squirrel-lang.org/forums/thread/2160.aspx)
|
||||
|
||||
* Updates for missing inline in DECLARE_INSTANCE_TYPE_NAME
|
||||
(http://squirrel-lang.org/forums/thread/2156.aspx)
|
||||
|
||||
* Fixed resolution in function overloading
|
||||
(http://squirrel-lang.org/forums/thread/2179.aspx)
|
||||
|
||||
* Added support for operator overloading suggested by Tegan
|
||||
(http://squirrel-lang.org/forums/thread/2160.aspx)
|
||||
|
||||
|
||||
2007-09-27 "SQUIRREL2_1_1_sqplus_snapshot_20070927"
|
||||
|
||||
* Added ats's extensions :
|
||||
http://squirrel-lang.org/forums/1/2153/ShowThread.aspx
|
||||
|
||||
- GCC_INLINE_WORKAROUND (problems with inline functions with gcc)
|
||||
- Set/get for short/char members
|
||||
- Get for const SQChar*
|
||||
- DECLARE_ENUM_TYPE - Allows enums to be used as arguments
|
||||
- Support for more customized Push handlers
|
||||
- SQPLUS_DISABLE_COPY_INSTANCES (disabling automatic use of copy
|
||||
constructors)
|
||||
- Support for automatically generate TypeMasks (a template
|
||||
solution) on function registration
|
||||
|
||||
|
||||
2007-08-25 "SQUIRREL2_1_1_sqplus_snapshot_20070825"
|
||||
|
||||
* Added m0pey's smart pointer support :
|
||||
http://squirrel-lang.org/forums/thread/1982.aspx
|
||||
|
||||
|
||||
2007-01-07 "SQUIRREL2_1_1_sqplus_snapshot_20070701"
|
||||
|
||||
* Fixed `returning a pointer of a derived class' problem with gcc
|
||||
(http://squirrel-lang.org/forums/thread/1875.aspx) based on
|
||||
http://wiki.squirrel-lang.org/default.aspx/SquirrelWiki/SqPlusNativeCreatedInstancesWithCorrectAncestry.html
|
||||
|
||||
|
||||
2007-06/02 "SQUIRREL2_1_1_sqplus_snapshot_20070602"
|
||||
|
||||
* Fix by Sebastien Frippiat:
|
||||
http://squirrel-lang.org/forums/thread/507.aspx
|
||||
|
||||
|
||||
2007-05-27 "SQUIRREL2_1_1_sqplus_snapshot_20070527"
|
||||
|
||||
* Added sqplus/SqPlusOverload.h for function overloading. See
|
||||
testSqPlus2unit/test_FunctionOverloading.cpp.
|
||||
|
||||
|
||||
2007-03-04 "SQUIRREL2_1_1_sqplus_snapshot_20070304"
|
||||
|
||||
* Fixed compilation problem on g++-3.4.4 (cygwin):
|
||||
http://squirrel-lang.org/forums/thread/1753.aspx
|
||||
|
||||
|
||||
2007-02-25 "SQUIRREL2_1_1_sqplus_snapshot_20070225"
|
||||
|
||||
* Fix by Kamaitati: http://squirrel-lang.org/forums/thread/1748.aspx
|
||||
|
||||
* Modified sqplu.h (SquirrelObject::Set<>()) for gcc
|
||||
|
||||
* Added testSqPlus2unit directory for unit testing
|
||||
|
||||
|
||||
2006-10-09- "SQUIRREL2_1_1_sqplus_25"
|
||||
|
||||
* Fixed SqPlusConst.h:
|
||||
http://squirrel-lang.org/forums/thread/1314.aspx, changed
|
||||
SquirrelObject Get/Set to default to pass-by-reference, where
|
||||
pass-by-copy requires extra parameter
|
||||
|
||||
|
||||
2006-10-08 "SQUIRREL2_1_1_sqplus_24"
|
||||
|
||||
* Added SQClassDefNoConstructor<>:
|
||||
http://wiki.squirrel-lang.org/default.aspx/SquirrelWiki/SqPlusWithoutAutoDefaultConstructor.html
|
||||
(allows binding abstract base classes/pure-virtual-interfaces)
|
||||
|
||||
* Added "Squirrel Set/Get objects"
|
||||
http://wiki.squirrel-lang.org/default.aspx/SquirrelWiki/SqPlusGetSetObjects.html
|
||||
|
||||
|
||||
2006-09-30 "SQUIRREL2_1_1_sqplus_23"
|
||||
|
||||
* Fixed return type for sq_std_string Get()
|
||||
|
||||
|
||||
2006-08-21 "SQUIRREL2_1_0_sqplus_22"
|
||||
|
||||
* Merged in Squirrel 2.1.1 Stable
|
||||
|
||||
|
||||
2006-08-20 "SQUIRREL2_1_0_sqplus_21"
|
||||
|
||||
* Changed code order to be compatible with GCC 4.1.x.
|
||||
|
||||
* Added jflanglois' suggestion for std::basic_string<SQChar>
|
||||
|
||||
|
||||
2006-06-27 "SQUIRREL2_1_0_sqplus_20"
|
||||
|
||||
* Added Katsuaki Kawachi's GetInstance()/Match() changes
|
||||
(http://www.squirrel-lang.org/forums/962/ShowPost.aspx)
|
||||
|
||||
|
||||
2006-02-06 "SQUIRREL2_1_0_sqplus_19"
|
||||
|
||||
* Added VS7.1 make/project files with 71 suffix: can be used
|
||||
alongside VS8 without directory changes
|
||||
|
||||
* Added optional debug string argument to SquirrelVM::CompileBuffer()
|
||||
|
||||
|
||||
2006-05-28 "SQUIRREL2_1_0_sqplus_18"
|
||||
|
||||
* Added Kamaitati's changes: bug fix, C++ style inheritance support,
|
||||
null instance argument support
|
||||
|
||||
|
||||
2006-04-25 "SQUIRREL2_1_0_sqplus_17"
|
||||
|
||||
* Changed SquirrelObject::GetInstanceUP() to return NULL and
|
||||
clear internal error state on invalid instance type request
|
||||
|
||||
* Added SquirrelObject::GetTypeName(const "SQChar" * key),
|
||||
SquirrelObject::GetTypeName("INT" key) and
|
||||
SquirrelObject::GetTypeName().
|
||||
|
||||
* Added SQ_SUPPORT_INSTANCE_TYPE_INFO compile time option
|
||||
|
||||
* Added missing template arguments (7 argument case)
|
||||
|
||||
* Source changes to support VS7.1 and VS8 compilation (standard and
|
||||
UNICODE builds)
|
||||
|
||||
* Added Code::Blocks project files
|
||||
|
||||
|
||||
2006-03-26 "SQUIRREL2_1_0_sqplus_11"
|
||||
|
||||
* Updated make/build files to VS8 (http://msdn.microsoft.com/vstudio/)
|
||||
|
||||
* Source changes for VS8 compilation
|
||||
|
||||
|
||||
2006-03-19 "SQUIRREL2_1_0_sqplus_10"
|
||||
|
||||
* Updated to Squirrel 2.1
|
||||
|
||||
|
||||
2006-02-27 "SQUIRREL2_0_5_sqplus_9"
|
||||
|
||||
* Added Ben's changes to implement DECLARE_INSTANCE_TYPE_NAME
|
||||
(http://www.squirrel-lang.org/forums/635/ShowPost.aspx)
|
||||
|
||||
|
||||
2005-12-22 "SQUIRREL2_0_5_sqplus_8"
|
||||
|
||||
* Added GetVMSys() and SetVMSys() to better support multiple VM's
|
||||
|
||||
|
||||
2005-11-21 "SQUIRREL2_0_5_sqplus_7"
|
||||
|
||||
* Added modular support for const member functions. Defining
|
||||
SQPLUS_CONST_OPT before including sqplus.h enables the added
|
||||
functionality
|
||||
|
||||
* SqPlus tested on Mac OS-X
|
||||
|
||||
|
||||
2005-11-03 "SQUIRREL2_0_5_sqplus_6"
|
||||
|
||||
* Fixed inheritance issue: tables added to classes are not newly
|
||||
created upon instantiation- they must be cloned during
|
||||
construction (language design)
|
||||
|
||||
* Reworked projects build settings to better allow building all
|
||||
projects types: Debug, Release, Debug - Unicode, Release - Unicode
|
||||
|
||||
|
||||
2005-11-01 "SQUIRREL2_0_5_sqplus_5"
|
||||
|
||||
* Added Unicode support
|
||||
|
||||
|
||||
2005-10-23 "SQUIRREL2_0_5_sqplus_4"
|
||||
|
||||
* Added gcc support:
|
||||
- Added simple GNU Makefiles for gcc
|
||||
- Minor code changes for gcc compilation
|
||||
- Tested on RH Linux gcc 3.2.3, Cygwin gcc 3.4.4, and gcc on Sony PSP
|
||||
(http://www.squirrel-lang.org/forums/420/ShowPost.aspx#420)
|
||||
|
||||
* Added ClassDef::enumInt() for registering enums as ints
|
||||
(to replace ClassDef::constant((int)myEnum))
|
||||
|
||||
|
||||
2005-10-14 "SQUIRREL2_0_5_sqplus_3"
|
||||
|
||||
* Added support for SquirrelObject as a function argument and return
|
||||
value. Tables and arrays can be directly accessed without using
|
||||
the stack. This also makes it possible to return tables, arrays,
|
||||
classes, and closures for later use at runtime, saving look-up
|
||||
overhead
|
||||
|
||||
* Added GetRet() for SquirrelFunction<> to ensure proper stack
|
||||
behavior
|
||||
|
||||
* Added additional error return info to help with debugging
|
||||
|
||||
* Removed unused code
|
||||
|
||||
|
@ -1,190 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE CodeBlocks_project_file>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="1"/>
|
||||
<Project>
|
||||
<Option title="sqplus"/>
|
||||
<Option makefile="Makefile"/>
|
||||
<Option makefile_is_custom="0"/>
|
||||
<Option default_target="-1"/>
|
||||
<Option compiler="0"/>
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="..\lib\libsqplusD.a"/>
|
||||
<Option working_dir=""/>
|
||||
<Option object_output="Debug"/>
|
||||
<Option deps_output=".deps"/>
|
||||
<Option type="2"/>
|
||||
<Option compiler="0"/>
|
||||
<Option createDefFile="1"/>
|
||||
<Option projectResourceIncludeDirsRelation="2"/>
|
||||
<Compiler>
|
||||
<Add option="-DWIN32"/>
|
||||
<Add option="-D_DEBUG"/>
|
||||
<Add option="-D_LIB"/>
|
||||
<Add option="-D_CRT_SECURE_NO_DEPRECATE"/>
|
||||
<Add option="-W"/>
|
||||
<Add option="-O0"/>
|
||||
<Add directory="..\include"/>
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="..\lib\libsqplus.a"/>
|
||||
<Option working_dir=""/>
|
||||
<Option object_output="Release"/>
|
||||
<Option deps_output=".deps"/>
|
||||
<Option type="2"/>
|
||||
<Option compiler="0"/>
|
||||
<Option createDefFile="1"/>
|
||||
<Option projectResourceIncludeDirsRelation="2"/>
|
||||
<Compiler>
|
||||
<Add option="-DWIN32"/>
|
||||
<Add option="-DNDEBUG"/>
|
||||
<Add option="-D_LIB"/>
|
||||
<Add option="-D_CRT_SECURE_NO_DEPRECATE"/>
|
||||
<Add option="-W"/>
|
||||
<Add option="-g"/>
|
||||
<Add directory="..\include"/>
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Debug - Unicode">
|
||||
<Option output="..\lib\libsqplusDU.a"/>
|
||||
<Option working_dir=""/>
|
||||
<Option object_output="Debug - Unicode"/>
|
||||
<Option deps_output=".deps"/>
|
||||
<Option type="2"/>
|
||||
<Option compiler="0"/>
|
||||
<Option createDefFile="1"/>
|
||||
<Option projectResourceIncludeDirsRelation="2"/>
|
||||
<Compiler>
|
||||
<Add option="-DWIN32"/>
|
||||
<Add option="-D_DEBUG"/>
|
||||
<Add option="-D_LIB"/>
|
||||
<Add option="-D_CRT_SECURE_NO_DEPRECATE"/>
|
||||
<Add option="-D_CRT_NON_CONFORMING_SWPRINTFS"/>
|
||||
<Add option="-W"/>
|
||||
<Add option="-O0"/>
|
||||
<Add directory="..\include"/>
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release - Unicode">
|
||||
<Option output="..\lib\libsqplusU.a"/>
|
||||
<Option working_dir=""/>
|
||||
<Option object_output="Release - Unicode"/>
|
||||
<Option deps_output=".deps"/>
|
||||
<Option type="2"/>
|
||||
<Option compiler="0"/>
|
||||
<Option createDefFile="1"/>
|
||||
<Option projectResourceIncludeDirsRelation="2"/>
|
||||
<Compiler>
|
||||
<Add option="-DWIN32"/>
|
||||
<Add option="-DNDEBUG"/>
|
||||
<Add option="-D_LIB"/>
|
||||
<Add option="-D_CRT_SECURE_NO_DEPRECATE"/>
|
||||
<Add option="-D_CRT_NON_CONFORMING_SWPRINTFS"/>
|
||||
<Add option="-W"/>
|
||||
<Add option="-g"/>
|
||||
<Add directory="..\include"/>
|
||||
</Compiler>
|
||||
</Target>
|
||||
</Build>
|
||||
<Unit filename="SqPlus.cpp">
|
||||
<Option compilerVar="CPP"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SqPlusConst.h">
|
||||
<Option compilerVar=""/>
|
||||
<Option compile="0"/>
|
||||
<Option link="0"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SquirrelBindingsUtils.cpp">
|
||||
<Option compilerVar="CPP"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SquirrelBindingsUtils.h">
|
||||
<Option compilerVar=""/>
|
||||
<Option compile="0"/>
|
||||
<Option link="0"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SquirrelBindingsUtilsWin32.cpp">
|
||||
<Option compilerVar="CPP"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SquirrelBindingsUtilsWin32.h">
|
||||
<Option compilerVar=""/>
|
||||
<Option compile="0"/>
|
||||
<Option link="0"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SquirrelObject.cpp">
|
||||
<Option compilerVar="CPP"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SquirrelObject.h">
|
||||
<Option compilerVar=""/>
|
||||
<Option compile="0"/>
|
||||
<Option link="0"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SquirrelVM.cpp">
|
||||
<Option compilerVar="CPP"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="SquirrelVM.h">
|
||||
<Option compilerVar=""/>
|
||||
<Option compile="0"/>
|
||||
<Option link="0"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="sqplus.h">
|
||||
<Option compilerVar=""/>
|
||||
<Option compile="0"/>
|
||||
<Option link="0"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
<Unit filename="sqplusWin32.h">
|
||||
<Option compilerVar=""/>
|
||||
<Option compile="0"/>
|
||||
<Option link="0"/>
|
||||
<Option target="Debug"/>
|
||||
<Option target="Release"/>
|
||||
<Option target="Debug - Unicode"/>
|
||||
<Option target="Release - Unicode"/>
|
||||
</Unit>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
File diff suppressed because it is too large
Load Diff
@ -1,355 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="sqplus"
|
||||
ProjectGUID="{F9811314-C694-49A4-BD87-BA2E7F30D358}"
|
||||
RootNamespace="sqplus"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="../lib/sqplusD.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="../lib/sqplus.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug - Unicode|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="../lib/sqplusDU.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release - Unicode|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="../lib/sqplusU.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\SqPlus.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SqPlusOCharBuf.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SqPlusUtf8.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelBindingsUtils.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelBindingsUtilsWin32.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelObject.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelVM.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\sqplus.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SqPlusConst.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SqPlusOCharBuf.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SqPlusSetup.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\sqplusWin32.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelBindingsUtils.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelBindingsUtilsWin32.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelObject.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelVM.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
@ -1,159 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug - Unicode|Win32">
|
||||
<Configuration>Debug - Unicode</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release - Unicode|Win32">
|
||||
<Configuration>Release - Unicode</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{F9811314-C694-49A4-BD87-BA2E7F30D358}</ProjectGuid>
|
||||
<RootNamespace>sqplus</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>../lib/sqplusD.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>../lib/sqplus.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>../lib/sqplusDU.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>../lib/sqplusU.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SqPlus.cpp" />
|
||||
<ClCompile Include="SqPlusOCharBuf.cpp" />
|
||||
<ClCompile Include="SqPlusUtf8.cpp" />
|
||||
<ClCompile Include="SquirrelBindingsUtils.cpp" />
|
||||
<ClCompile Include="SquirrelBindingsUtilsWin32.cpp" />
|
||||
<ClCompile Include="SquirrelObject.cpp" />
|
||||
<ClCompile Include="SquirrelVM.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="sqplus.h" />
|
||||
<ClInclude Include="SqPlusConst.h" />
|
||||
<ClInclude Include="SqPlusOCharBuf.h" />
|
||||
<ClInclude Include="SqPlusSetup.h" />
|
||||
<ClInclude Include="sqplusWin32.h" />
|
||||
<ClInclude Include="SquirrelBindingsUtils.h" />
|
||||
<ClInclude Include="SquirrelBindingsUtilsWin32.h" />
|
||||
<ClInclude Include="SquirrelObject.h" />
|
||||
<ClInclude Include="SquirrelVM.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SqPlus.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SqPlusOCharBuf.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SqPlusUtf8.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SquirrelBindingsUtils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SquirrelBindingsUtilsWin32.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SquirrelObject.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SquirrelVM.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="sqplus.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SqPlusConst.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SqPlusOCharBuf.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SqPlusSetup.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sqplusWin32.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SquirrelBindingsUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SquirrelBindingsUtilsWin32.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SquirrelObject.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SquirrelVM.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
@ -1,235 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="sqplus"
|
||||
ProjectGUID="{F9811314-C694-49A4-BD87-BA2E7F30D358}"
|
||||
RootNamespace="sqplus"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="../lib/sqplusD.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="../lib/sqplus.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug - Unicode|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="../lib/sqplusDU.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release - Unicode|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="../lib/sqplusU.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\SqPlus.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SqPlusOCharBuf.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SqPlusUtf8.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelBindingsUtils.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelBindingsUtilsWin32.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelObject.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelVM.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\sqplus.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SqPlusConst.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\sqplusWin32.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelBindingsUtils.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelBindingsUtilsWin32.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelObject.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SquirrelVM.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
@ -1,7 +0,0 @@
|
||||
#ifndef _SQ_PLUS_WIN32_H_
|
||||
#define _SQ_PLUS_WIN32_H_
|
||||
|
||||
#include "sqplus.h"
|
||||
#include "SquirrelBindingsUtilsWin32.h"
|
||||
|
||||
#endif //_SQ_PLUS_WIN32_H_
|
Loading…
Reference in New Issue
Block a user