1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
/*
FALCON - The Falcon Programming Language.
FILE: vmmsg.cpp
Asynchronous message for the Virtual Machine.
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: Sun, 08 Feb 2009 16:08:50 +0100
-------------------------------------------------------------------
(C) Copyright 2009: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
/** \file
Asynchronous message for the Virtual Machine - Implementation.
*/
#include <falcon/vmmsg.h>
#include <falcon/globals.h>
#include <falcon/vm.h>
#include <falcon/garbagelock.h>
#define PARAMS_GROWTH 8
namespace Falcon {
VMMessage::VMMessage( const String &msgName ):
m_msg( msgName ),
m_params(0),
m_allocated(0),
m_pcount(0),
m_next(0),
m_error(0)
{
}
VMMessage::~VMMessage()
{
if( m_params != 0 )
{
for(uint32 i = 0; i < m_pcount; ++i )
{
memPool->markItem( m_params[i] );
}
memFree( m_params );
}
if ( m_error != 0 )
m_error->decref();
}
void VMMessage::addParam( const SafeItem &itm )
{
if ( m_params == 0 )
{
m_params = (SafeItem *) memAlloc( sizeof( SafeItem ) * PARAMS_GROWTH );
m_allocated = PARAMS_GROWTH;
}
else if( m_pcount == m_allocated ) {
m_allocated += PARAMS_GROWTH;
m_params = (SafeItem *) memRealloc( m_params, sizeof( SafeItem ) * m_allocated );
}
m_params[ m_pcount++ ].copy( itm );
}
SafeItem *VMMessage::param( uint32 p ) const
{
return p < m_pcount ? &m_params[p] : 0;
}
void VMMessage::onMsgComplete( bool )
{
}
}
/* end of vmmsg.cpp */
|