mirror of
				https://github.com/VCMP-SqMod/SqMod.git
				synced 2025-11-04 00:07:19 +01:00 
			
		
		
		
	Expand the host plug-in API and not just the Squirrel API.
Extend the host plug-in API with a few more date/time functions. Update some of the plugins to use the expanded functions of the host plug-in API.
This commit is contained in:
		@@ -43,8 +43,10 @@ void OnSquirrelInitialize()
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Expand the Squirrel plug-in API into global functions
 | 
			
		||||
        sqmod_api_expand(_SqMod);
 | 
			
		||||
        // Obtain the Squirrel API
 | 
			
		||||
        _SqAPI = _SqMod->GetSquirrelAPI();
 | 
			
		||||
        _SqAPI = SqMod_GetSquirrelAPI();
 | 
			
		||||
        // Expand the Squirrel API into global functions
 | 
			
		||||
        sq_api_expand(_SqAPI);
 | 
			
		||||
    }
 | 
			
		||||
@@ -61,7 +63,7 @@ void OnSquirrelLoad()
 | 
			
		||||
        return; // Unable to proceed!
 | 
			
		||||
    }
 | 
			
		||||
    // Obtain the Squirrel API and VM
 | 
			
		||||
    _SqVM = _SqMod->GetSquirrelVM();
 | 
			
		||||
    _SqVM = SqMod_GetSquirrelVM();
 | 
			
		||||
    // Make sure that a valid virtual machine exists
 | 
			
		||||
    if (!_SqVM)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -111,12 +111,12 @@ void Session::Update()
 | 
			
		||||
    else if (!irc_is_connected(m_Session))
 | 
			
		||||
    {
 | 
			
		||||
        // Do we meet the condition to attempt to reconnect?
 | 
			
		||||
        if (m_Reconnect && (m_LeftTries != 0) && (m_NextTry <= _SqMod->GetEpochTimeMicro()))
 | 
			
		||||
        if (m_Reconnect && (m_LeftTries != 0) && (m_NextTry <= SqMod_GetEpochTimeMicro()))
 | 
			
		||||
        {
 | 
			
		||||
            // Take out one try
 | 
			
		||||
            --m_LeftTries;
 | 
			
		||||
            // Update the time-point for the next try
 | 
			
		||||
            m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
            m_NextTry = (SqMod_GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
            // Attempt to reconnect
 | 
			
		||||
            if (m_IPv6)
 | 
			
		||||
            {
 | 
			
		||||
@@ -155,13 +155,13 @@ void Session::Update()
 | 
			
		||||
    // Call select()
 | 
			
		||||
    if (select(maxfd + 1, &in_set, &out_set, 0, &tv) < 0)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->LogErr("Unable to select() on IRC session");
 | 
			
		||||
        SqMod_LogErr("Unable to select() on IRC session");
 | 
			
		||||
    }
 | 
			
		||||
    // Call irc_process_select_descriptors() for the session
 | 
			
		||||
    if (irc_process_select_descriptors (m_Session, &in_set, &out_set))
 | 
			
		||||
    {
 | 
			
		||||
        // @TODO: The connection failed, or the server disconnected. Handle it!
 | 
			
		||||
        _SqMod->LogWrn("The IRC connection failed, or the server disconnected.");
 | 
			
		||||
        SqMod_LogWrn("The IRC connection failed, or the server disconnected.");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -256,7 +256,7 @@ bool Session::ValidateEventSession(Session * ptr)
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    // We can't throw an error here so we simply log it
 | 
			
		||||
    _SqMod->LogErr("Cannot forward IRC event without a session instance");
 | 
			
		||||
    SqMod_LogErr("Cannot forward IRC event without a session instance");
 | 
			
		||||
    // Invalid session instance
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
@@ -442,7 +442,7 @@ Object Session::GetNextTry() const
 | 
			
		||||
    // Obtain the initial stack size
 | 
			
		||||
    const StackGuard sg(_SqVM);
 | 
			
		||||
    // Attempt to push a time-stamp instance on the stack
 | 
			
		||||
    _SqMod->PushTimestamp(_SqVM, m_NextTry);
 | 
			
		||||
    SqMod_PushTimestamp(_SqVM, m_NextTry);
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -457,7 +457,7 @@ void Session::SetNextTry(Object & tm)
 | 
			
		||||
    // The resulted times-tamp value
 | 
			
		||||
    Int64 microseconds = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetTimestamp(_SqVM, -1, µseconds)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetTimestamp(_SqVM, -1, µseconds)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid time-stamp specified");
 | 
			
		||||
    }
 | 
			
		||||
@@ -473,12 +473,12 @@ Object Session::GetSessionTime() const
 | 
			
		||||
    // Attempt to push a time-stamp instance on the stack
 | 
			
		||||
    if (m_SessionTime)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->PushTimestamp(_SqVM, _SqMod->GetEpochTimeMicro() - m_SessionTime);
 | 
			
		||||
        SqMod_PushTimestamp(_SqVM, SqMod_GetEpochTimeMicro() - m_SessionTime);
 | 
			
		||||
    }
 | 
			
		||||
    // This session was not connected yet
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->PushTimestamp(_SqVM, 0);
 | 
			
		||||
        SqMod_PushTimestamp(_SqVM, 0);
 | 
			
		||||
    }
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
@@ -506,7 +506,7 @@ Int32 Session::Connect()
 | 
			
		||||
    // Reset the number of tries
 | 
			
		||||
    m_LeftTries = m_Tries;
 | 
			
		||||
    // Set the time-point for the next try
 | 
			
		||||
    m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
    m_NextTry = (SqMod_GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
    // This is not an IPv6 connection
 | 
			
		||||
    m_IPv6 = false;
 | 
			
		||||
    // Attempt to connect the session and return the result
 | 
			
		||||
@@ -557,7 +557,7 @@ Int32 Session::Connect(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSSt
 | 
			
		||||
    // Reset the number of tries
 | 
			
		||||
    m_LeftTries = m_Tries;
 | 
			
		||||
    // Set the time-point for the next connection try
 | 
			
		||||
    m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
    m_NextTry = (SqMod_GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
    // This is not an IPv6 connection
 | 
			
		||||
    m_IPv6 = false;
 | 
			
		||||
    // Attempt to connect the session and return the result
 | 
			
		||||
@@ -591,7 +591,7 @@ Int32 Session::Connect6()
 | 
			
		||||
    // Reset the number of tries
 | 
			
		||||
    m_LeftTries = m_Tries;
 | 
			
		||||
    // Set the time-point for the next try
 | 
			
		||||
    m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
    m_NextTry = (SqMod_GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
    // This is an IPv6 connection
 | 
			
		||||
    m_IPv6 = true;
 | 
			
		||||
    // Attempt to connect the session and return the result
 | 
			
		||||
@@ -642,7 +642,7 @@ Int32 Session::Connect6(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSS
 | 
			
		||||
    // Reset the number of tries
 | 
			
		||||
    m_LeftTries = m_Tries;
 | 
			
		||||
    // Set the time-point for the next connection try
 | 
			
		||||
    m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
    m_NextTry = (SqMod_GetEpochTimeMicro() + (m_Wait * 1000LL));
 | 
			
		||||
    // This is an IPv6 connection
 | 
			
		||||
    m_IPv6 = true;
 | 
			
		||||
    // Attempt to connect the session and return the result
 | 
			
		||||
@@ -699,15 +699,15 @@ void Session::ForwardEvent(Function & listener, CCStr event, CCStr origin, CCStr
 | 
			
		||||
    }
 | 
			
		||||
    catch (const Sqrat::Exception & e)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->LogErr("IRC event [%s] => Squirrel error [%s]", event, e.Message().c_str());
 | 
			
		||||
        SqMod_LogErr("IRC event [%s] => Squirrel error [%s]", event, e.Message().c_str());
 | 
			
		||||
    }
 | 
			
		||||
    catch (const std::exception & e)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->LogErr("IRC event [%s] => Program error [%s]", event, e.what());
 | 
			
		||||
        SqMod_LogErr("IRC event [%s] => Program error [%s]", event, e.what());
 | 
			
		||||
    }
 | 
			
		||||
    catch (...)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->LogErr("IRC event [%s] => Unknown error", event);
 | 
			
		||||
        SqMod_LogErr("IRC event [%s] => Unknown error", event);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -743,15 +743,15 @@ void Session::ForwardEvent(Function & listener, Uint32 event,
 | 
			
		||||
    }
 | 
			
		||||
    catch (const Sqrat::Exception & e)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->LogErr("IRC event [%s] => Squirrel error [%s]", event, e.Message().c_str());
 | 
			
		||||
        SqMod_LogErr("IRC event [%s] => Squirrel error [%s]", event, e.Message().c_str());
 | 
			
		||||
    }
 | 
			
		||||
    catch (const std::exception & e)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->LogErr("IRC event [%s] => Program error [%s]", event, e.what());
 | 
			
		||||
        SqMod_LogErr("IRC event [%s] => Program error [%s]", event, e.what());
 | 
			
		||||
    }
 | 
			
		||||
    catch (...)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->LogErr("IRC event [%s] => Unknown error", event);
 | 
			
		||||
        SqMod_LogErr("IRC event [%s] => Unknown error", event);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -778,7 +778,7 @@ void Session::OnConnect(irc_session_t * session, CCStr event, CCStr origin, CCSt
 | 
			
		||||
        // Prevent any attempts to reconnect now
 | 
			
		||||
        inst->m_Reconnect = false;
 | 
			
		||||
        // Save the connection time-stamp to calculate session uptime
 | 
			
		||||
        inst->m_SessionTime = _SqMod->GetEpochTimeMicro();
 | 
			
		||||
        inst->m_SessionTime = SqMod_GetEpochTimeMicro();
 | 
			
		||||
        // Now forward event
 | 
			
		||||
        ForwardEvent(inst->m_OnConnect, event, origin, params, count);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -37,8 +37,10 @@ void OnSquirrelInitialize()
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Expand the Squirrel plug-in API into global functions
 | 
			
		||||
        sqmod_api_expand(_SqMod);
 | 
			
		||||
        // Obtain the Squirrel API
 | 
			
		||||
        _SqAPI = _SqMod->GetSquirrelAPI();
 | 
			
		||||
        _SqAPI = SqMod_GetSquirrelAPI();
 | 
			
		||||
        // Expand the Squirrel API into global functions
 | 
			
		||||
        sq_api_expand(_SqAPI);
 | 
			
		||||
    }
 | 
			
		||||
@@ -55,7 +57,7 @@ void OnSquirrelLoad()
 | 
			
		||||
        return; // Unable to proceed.
 | 
			
		||||
    }
 | 
			
		||||
    // Obtain the Squirrel API and VM
 | 
			
		||||
    _SqVM = _SqMod->GetSquirrelVM();
 | 
			
		||||
    _SqVM = SqMod_GetSquirrelVM();
 | 
			
		||||
    // Make sure that a valid virtual machine exists
 | 
			
		||||
    if (!_SqVM)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ void ConnectionHnd::EvFwd(Pointer nc, Int32 ev_type, void * ev_data)
 | 
			
		||||
{
 | 
			
		||||
    if (!nc->user_data)
 | 
			
		||||
    {
 | 
			
		||||
        _SqMod->LogErr("Event dispatched without valid instance");
 | 
			
		||||
        SqMod_LogErr("Event dispatched without valid instance");
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -39,8 +39,10 @@ void OnSquirrelInitialize()
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Expand the Squirrel plug-in API into global functions
 | 
			
		||||
        sqmod_api_expand(_SqMod);
 | 
			
		||||
        // Obtain the Squirrel API
 | 
			
		||||
        _SqAPI = _SqMod->GetSquirrelAPI();
 | 
			
		||||
        _SqAPI = SqMod_GetSquirrelAPI();
 | 
			
		||||
        // Expand the Squirrel API into global functions
 | 
			
		||||
        sq_api_expand(_SqAPI);
 | 
			
		||||
    }
 | 
			
		||||
@@ -57,7 +59,7 @@ void OnSquirrelLoad()
 | 
			
		||||
        return; // Unable to proceed.
 | 
			
		||||
    }
 | 
			
		||||
    // Obtain the Squirrel API and VM
 | 
			
		||||
    _SqVM = _SqMod->GetSquirrelVM();
 | 
			
		||||
    _SqVM = SqMod_GetSquirrelVM();
 | 
			
		||||
    // Make sure that a valid virtual machine exists
 | 
			
		||||
    if (!_SqVM)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -316,7 +316,7 @@ Object EntryDataList::GetLong() const
 | 
			
		||||
    // Obtain the initial stack size
 | 
			
		||||
    const StackGuard sg(_SqVM);
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushULongObject(_SqVM, longint);
 | 
			
		||||
    SqMod_PushULongObject(_SqVM, longint);
 | 
			
		||||
    // Get the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -37,8 +37,10 @@ void OnSquirrelInitialize()
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Expand the Squirrel plug-in API into global functions
 | 
			
		||||
        sqmod_api_expand(_SqMod);
 | 
			
		||||
        // Obtain the Squirrel API
 | 
			
		||||
        _SqAPI = _SqMod->GetSquirrelAPI();
 | 
			
		||||
        _SqAPI = SqMod_GetSquirrelAPI();
 | 
			
		||||
        // Expand the Squirrel API into global functions
 | 
			
		||||
        sq_api_expand(_SqAPI);
 | 
			
		||||
    }
 | 
			
		||||
@@ -55,7 +57,7 @@ void OnSquirrelLoad()
 | 
			
		||||
        return; // Unable to proceed.
 | 
			
		||||
    }
 | 
			
		||||
    // Obtain the Squirrel API and VM
 | 
			
		||||
    _SqVM = _SqMod->GetSquirrelVM();
 | 
			
		||||
    _SqVM = SqMod_GetSquirrelVM();
 | 
			
		||||
    // Make sure that a valid virtual machine exists
 | 
			
		||||
    if (!_SqVM)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -37,8 +37,10 @@ void OnSquirrelInitialize()
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Expand the Squirrel plug-in API into global functions
 | 
			
		||||
        sqmod_api_expand(_SqMod);
 | 
			
		||||
        // Obtain the Squirrel API
 | 
			
		||||
        _SqAPI = _SqMod->GetSquirrelAPI();
 | 
			
		||||
        _SqAPI = SqMod_GetSquirrelAPI();
 | 
			
		||||
        // Expand the Squirrel API into global functions
 | 
			
		||||
        sq_api_expand(_SqAPI);
 | 
			
		||||
    }
 | 
			
		||||
@@ -55,7 +57,7 @@ void OnSquirrelLoad()
 | 
			
		||||
        return; // Unable to proceed.
 | 
			
		||||
    }
 | 
			
		||||
    // Obtain the Squirrel API and VM
 | 
			
		||||
    _SqVM = _SqMod->GetSquirrelVM();
 | 
			
		||||
    _SqVM = SqMod_GetSquirrelVM();
 | 
			
		||||
    // Make sure that a valid virtual machine exists
 | 
			
		||||
    if (!_SqVM)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -195,7 +195,7 @@ Object Column::GetValue() const
 | 
			
		||||
            // Retrieve the the actual blob data that must be returned
 | 
			
		||||
            CCStr data = reinterpret_cast< CCStr >(sqlite3_column_blob(m_Handle->mPtr, m_Index));
 | 
			
		||||
            // Attempt to create a buffer with the blob data on the stack
 | 
			
		||||
            if (SQ_FAILED(_SqMod->PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
            if (SQ_FAILED(SqMod_PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
            {
 | 
			
		||||
                STHROWF("Unable to allocate buffer of at least (%d) bytes", size);
 | 
			
		||||
            }
 | 
			
		||||
@@ -325,7 +325,7 @@ Object Column::GetBuffer() const
 | 
			
		||||
    // Retrieve the the actual blob data that must be returned
 | 
			
		||||
    CCStr data = reinterpret_cast< CCStr >(sqlite3_column_blob(m_Handle->mPtr, m_Index));
 | 
			
		||||
    // Attempt to create a buffer with the blob data on the stack
 | 
			
		||||
    if (SQ_FAILED(_SqMod->PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Unable to allocate buffer of at least (%d) bytes", size);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@ Object GetMemoryUsage()
 | 
			
		||||
    // Obtain the initial stack size
 | 
			
		||||
    const StackGuard sg(_SqVM);
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushSLongObject(_SqVM, sqlite3_memory_used());
 | 
			
		||||
    SqMod_PushSLongObject(_SqVM, sqlite3_memory_used());
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -82,7 +82,7 @@ Object GetMemoryHighwaterMark(bool reset)
 | 
			
		||||
    // Obtain the initial stack size
 | 
			
		||||
    const StackGuard sg(_SqVM);
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushSLongObject(_SqVM, sqlite3_memory_highwater(reset));
 | 
			
		||||
    SqMod_PushSLongObject(_SqVM, sqlite3_memory_highwater(reset));
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,13 +16,13 @@ SQInteger Connection::Typename(HSQUIRRELVM vm)
 | 
			
		||||
// ------------------------------------------------------------------------------------------------
 | 
			
		||||
void Connection::TraceOutput(void * /*ptr*/, CCStr sql)
 | 
			
		||||
{
 | 
			
		||||
    _SqMod->LogInf("SQLite Trace: %s", sql);
 | 
			
		||||
    SqMod_LogInf("SQLite Trace: %s", sql);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------------------------------
 | 
			
		||||
void Connection::ProfileOutput(void * /*ptr*/, CCStr sql, sqlite3_uint64 time)
 | 
			
		||||
{
 | 
			
		||||
    _SqMod->LogInf("SQLite profile (time: %llu): %s", time, sql);
 | 
			
		||||
    SqMod_LogInf("SQLite profile (time: %llu): %s", time, sql);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ ConnHnd::~ConnHnd()
 | 
			
		||||
        // Attempt to close the database
 | 
			
		||||
        if ((sqlite3_close(mPtr)) != SQLITE_OK)
 | 
			
		||||
        {
 | 
			
		||||
            _SqMod->LogErr("Unable to close SQLite connection [%s]", sqlite3_errmsg(mPtr));
 | 
			
		||||
            SqMod_LogErr("Unable to close SQLite connection [%s]", sqlite3_errmsg(mPtr));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -127,15 +127,15 @@ Int32 ConnHnd::Flush(Uint32 num, Object & env, Function & func)
 | 
			
		||||
            }
 | 
			
		||||
            catch (const Sqrat::Exception & e)
 | 
			
		||||
            {
 | 
			
		||||
                _SqMod->LogErr("Squirrel error caught in flush handler [%s]", e.Message().c_str());
 | 
			
		||||
                SqMod_LogErr("Squirrel error caught in flush handler [%s]", e.Message().c_str());
 | 
			
		||||
            }
 | 
			
		||||
            catch (const std::exception & e)
 | 
			
		||||
            {
 | 
			
		||||
                _SqMod->LogErr("Program error caught in flush handler [%s]", e.what());
 | 
			
		||||
                SqMod_LogErr("Program error caught in flush handler [%s]", e.what());
 | 
			
		||||
            }
 | 
			
		||||
            catch (...)
 | 
			
		||||
            {
 | 
			
		||||
                _SqMod->LogErr("Unknown error caught in flush handler");
 | 
			
		||||
                SqMod_LogErr("Unknown error caught in flush handler");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ StmtHnd::~StmtHnd()
 | 
			
		||||
        // Attempt to finalize the statement
 | 
			
		||||
        if ((sqlite3_finalize(mPtr)) != SQLITE_OK)
 | 
			
		||||
        {
 | 
			
		||||
            _SqMod->LogErr("Unable to finalize SQLite statement [%s]", mConn->ErrMsg());
 | 
			
		||||
            SqMod_LogErr("Unable to finalize SQLite statement [%s]", mConn->ErrMsg());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -37,8 +37,10 @@ void OnSquirrelInitialize()
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Expand the Squirrel plug-in API into global functions
 | 
			
		||||
        sqmod_api_expand(_SqMod);
 | 
			
		||||
        // Obtain the Squirrel API
 | 
			
		||||
        _SqAPI = _SqMod->GetSquirrelAPI();
 | 
			
		||||
        _SqAPI = SqMod_GetSquirrelAPI();
 | 
			
		||||
        // Expand the Squirrel API into global functions
 | 
			
		||||
        sq_api_expand(_SqAPI);
 | 
			
		||||
    }
 | 
			
		||||
@@ -55,7 +57,7 @@ void OnSquirrelLoad()
 | 
			
		||||
        return; // Unable to proceed!
 | 
			
		||||
    }
 | 
			
		||||
    // Obtain the Squirrel API and VM
 | 
			
		||||
    _SqVM = _SqMod->GetSquirrelVM();
 | 
			
		||||
    _SqVM = SqMod_GetSquirrelVM();
 | 
			
		||||
    // Make sure that a valid virtual machine exists
 | 
			
		||||
    if (!_SqVM)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -756,7 +756,7 @@ Object Statement::FetchColumnIndex(Int32 idx) const
 | 
			
		||||
            // Retrieve the the actual blob data that must be returned
 | 
			
		||||
            CCStr data = reinterpret_cast< CCStr >(sqlite3_column_blob(m_Handle->mPtr, idx));
 | 
			
		||||
            // Attempt to create a buffer with the blob data on the stack
 | 
			
		||||
            if (SQ_FAILED(_SqMod->PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
            if (SQ_FAILED(SqMod_PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
            {
 | 
			
		||||
                STHROWF("Unable to allocate buffer of at least (%d) bytes", size);
 | 
			
		||||
            }
 | 
			
		||||
@@ -874,7 +874,7 @@ Array Statement::FetchArray(Int32 min, Int32 max) const
 | 
			
		||||
                // Retrieve the the actual blob data that must be returned
 | 
			
		||||
                CCStr data = reinterpret_cast< CCStr >(sqlite3_column_blob(m_Handle->mPtr, idx));
 | 
			
		||||
                // Attempt to create a buffer with the blob data on the stack
 | 
			
		||||
                if (SQ_FAILED(_SqMod->PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
                if (SQ_FAILED(SqMod_PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
                {
 | 
			
		||||
                    STHROWF("Unable to allocate buffer of at least (%d) bytes", size);
 | 
			
		||||
                }
 | 
			
		||||
@@ -981,7 +981,7 @@ Table Statement::FetchTable(Int32 min, Int32 max) const
 | 
			
		||||
                // Retrieve the the actual blob data that must be returned
 | 
			
		||||
                CCStr data = reinterpret_cast< CCStr >(sqlite3_column_blob(m_Handle->mPtr, idx));
 | 
			
		||||
                // Attempt to create a buffer with the blob data on the stack
 | 
			
		||||
                if (SQ_FAILED(_SqMod->PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
                if (SQ_FAILED(SqMod_PushBufferData(DefaultVM::Get(), data, size, size)))
 | 
			
		||||
                {
 | 
			
		||||
                    STHROWF("Unable to allocate buffer of at least (%d) bytes", size);
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -22,12 +22,12 @@ Object Attribute::AsLong(Object & def) const
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Int64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushSLongObject(_SqVM, m_Attr.as_llong(longint));
 | 
			
		||||
    SqMod_PushSLongObject(_SqVM, m_Attr.as_llong(longint));
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -42,12 +42,12 @@ Object Attribute::AsUlong(Object & def) const
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Uint64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushULongObject(_SqVM, m_Attr.as_ullong(longint));
 | 
			
		||||
    SqMod_PushULongObject(_SqVM, m_Attr.as_ullong(longint));
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -62,7 +62,7 @@ bool Attribute::ApplyLong(Object & value)
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Int64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
@@ -80,7 +80,7 @@ bool Attribute::ApplyUlong(Object & value)
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Uint64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
@@ -94,7 +94,7 @@ Object Attribute::GetLong() const
 | 
			
		||||
    // Obtain the initial stack size
 | 
			
		||||
    const StackGuard sg(_SqVM);
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushSLongObject(_SqVM, m_Attr.as_llong());
 | 
			
		||||
    SqMod_PushSLongObject(_SqVM, m_Attr.as_llong());
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -109,7 +109,7 @@ void Attribute::SetLong(Object & value)
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Int64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
@@ -123,7 +123,7 @@ Object Attribute::GetUlong() const
 | 
			
		||||
    // Obtain the initial stack size
 | 
			
		||||
    const StackGuard sg(_SqVM);
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushULongObject(_SqVM, m_Attr.as_ullong());
 | 
			
		||||
    SqMod_PushULongObject(_SqVM, m_Attr.as_ullong());
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -138,7 +138,7 @@ void Attribute::SetUlong(Object & value)
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Uint64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -42,8 +42,10 @@ void OnSquirrelInitialize()
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Expand the Squirrel plug-in API into global functions
 | 
			
		||||
        sqmod_api_expand(_SqMod);
 | 
			
		||||
        // Obtain the Squirrel API
 | 
			
		||||
        _SqAPI = _SqMod->GetSquirrelAPI();
 | 
			
		||||
        _SqAPI = SqMod_GetSquirrelAPI();
 | 
			
		||||
        // Expand the Squirrel API into global functions
 | 
			
		||||
        sq_api_expand(_SqAPI);
 | 
			
		||||
    }
 | 
			
		||||
@@ -60,7 +62,7 @@ void OnSquirrelLoad()
 | 
			
		||||
        return; // Unable to proceed!
 | 
			
		||||
    }
 | 
			
		||||
    // Obtain the Squirrel API and VM
 | 
			
		||||
    _SqVM = _SqMod->GetSquirrelVM();
 | 
			
		||||
    _SqVM = SqMod_GetSquirrelVM();
 | 
			
		||||
    // Make sure that a valid virtual machine exists
 | 
			
		||||
    if (!_SqVM)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -43,12 +43,12 @@ Object Text::AsLong(Object & def) const
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Int64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushSLongObject(_SqVM, m_Text.as_llong(longint));
 | 
			
		||||
    SqMod_PushSLongObject(_SqVM, m_Text.as_llong(longint));
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -63,12 +63,12 @@ Object Text::AsUlong(Object & def) const
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Uint64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushULongObject(_SqVM, m_Text.as_ullong(longint));
 | 
			
		||||
    SqMod_PushULongObject(_SqVM, m_Text.as_ullong(longint));
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -83,7 +83,7 @@ bool Text::ApplyLong(Object & value)
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Int64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
@@ -101,7 +101,7 @@ bool Text::ApplyUlong(Object & value)
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Uint64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
@@ -115,7 +115,7 @@ Object Text::GetLong() const
 | 
			
		||||
    // Obtain the initial stack size
 | 
			
		||||
    const StackGuard sg(_SqVM);
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushSLongObject(_SqVM, m_Text.as_llong());
 | 
			
		||||
    SqMod_PushSLongObject(_SqVM, m_Text.as_llong());
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -130,7 +130,7 @@ void Text::SetLong(Object & value)
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Int64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
@@ -144,7 +144,7 @@ Object Text::GetUlong() const
 | 
			
		||||
    // Obtain the initial stack size
 | 
			
		||||
    const StackGuard sg(_SqVM);
 | 
			
		||||
    // Push a long integer instance with the requested value on the stack
 | 
			
		||||
    _SqMod->PushULongObject(_SqVM, m_Text.as_ullong());
 | 
			
		||||
    SqMod_PushULongObject(_SqVM, m_Text.as_ullong());
 | 
			
		||||
    // Obtain the object from the stack and return it
 | 
			
		||||
    return Var< Object >(_SqVM, -1).value;
 | 
			
		||||
}
 | 
			
		||||
@@ -159,7 +159,7 @@ void Text::SetUlong(Object & value)
 | 
			
		||||
    // The resulted long integer value
 | 
			
		||||
    Uint64 longint = 0;
 | 
			
		||||
    // Attempt to get the numeric value inside the specified object
 | 
			
		||||
    if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
 | 
			
		||||
    {
 | 
			
		||||
        STHROWF("Invalid long integer specified");
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user