core/systems/ForwardSys.cpp
changeset 192 dee91851dcd4
parent 188 8951baf7cb3c
child 211 4c77142eaf36
     1.1 --- a/core/systems/ForwardSys.cpp	Wed Dec 06 00:53:34 2006 +0000
     1.2 +++ b/core/systems/ForwardSys.cpp	Wed Dec 06 14:52:11 2006 +0000
     1.3 @@ -20,12 +20,12 @@
     1.4   * X Push strings (copyback tested = yes)
     1.5   * VARARG FUNCTIONS:
     1.6   * - Pushing no varargs
     1.7 - * - Push vararg cells (copyback should be verified to not happen = ??)
     1.8 - * - Push vararg cells byref (copyback tested = ??)
     1.9 - * - Push vararg floats (copyback should be verified to not happen = ??)
    1.10 - * - Push vararg floats byref (copyback tested = ??)
    1.11 - * - Push vararg arrays  (copyback tested = ??)
    1.12 - * - Push vararg strings (copyback tested = ??)
    1.13 + * X Push vararg cells (copyback should be verified to not happen = didnt happen)
    1.14 + * X Push vararg cells byref (copyback tested = yes)
    1.15 + * X Push vararg floats (copyback should be verified to not happen = didnt happen)
    1.16 + * X Push vararg floats byref (copyback tested = yes)
    1.17 + * X Push vararg arrays  (copyback tested = yes)
    1.18 + * X Push vararg strings (copyback tested = :TODO:)
    1.19   */
    1.20  
    1.21  IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned int num_params, ParamType *types, ...)
    1.22 @@ -227,9 +227,9 @@
    1.23  				/* If we're byref or we're vararg, we always push everything by ref.
    1.24  				 * Even if they're byval, we must push them byref.
    1.25  				 */
    1.26 -				if (type == Param_String) 
    1.27 +				if (type == Param_String)
    1.28  				{
    1.29 -					func->PushStringEx((char *)param->byref.orig_addr, param->byref.flags);
    1.30 +					func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags);
    1.31  				} else if (type == Param_Float || type == Param_Cell) {
    1.32  					func->PushCellByRef(&param->val, 0); 
    1.33  				} else {
    1.34 @@ -365,8 +365,10 @@
    1.35  {
    1.36  	if (m_curparam < m_numparams)
    1.37  	{
    1.38 -		if (m_types[m_curparam] != Param_CellByRef && m_types[m_curparam] != Param_Any)
    1.39 +		if (m_types[m_curparam] == Param_Any)
    1.40  		{
    1.41 +			m_params[m_curparam].pushedas = Param_CellByRef;
    1.42 +		} else if (m_types[m_curparam] != Param_CellByRef) {
    1.43  			return SetError(SP_ERROR_PARAM);
    1.44  		}
    1.45  	} else {
    1.46 @@ -374,6 +376,7 @@
    1.47  		{
    1.48  			return SetError(SP_ERROR_PARAMS_MAX);
    1.49  		}
    1.50 +		m_params[m_curparam].pushedas = Param_CellByRef;
    1.51  	}
    1.52  
    1.53  	_Int_PushArray(cell, 1, flags);
    1.54 @@ -386,8 +389,10 @@
    1.55  {
    1.56  	if (m_curparam < m_numparams)
    1.57  	{
    1.58 -		if (m_types[m_curparam] != Param_FloatByRef && m_types[m_curparam] != Param_Any)
    1.59 +		if (m_types[m_curparam] == Param_Any)
    1.60  		{
    1.61 +			m_params[m_curparam].pushedas = Param_FloatByRef;
    1.62 +		} else if (m_types[m_curparam] != Param_FloatByRef) {
    1.63  			return SetError(SP_ERROR_PARAM);
    1.64  		}
    1.65  	} else {
    1.66 @@ -395,6 +400,7 @@
    1.67  		{
    1.68  			return SetError(SP_ERROR_PARAMS_MAX);
    1.69  		}
    1.70 +		m_params[m_curparam].pushedas = Param_FloatByRef;
    1.71  	}
    1.72  
    1.73  	_Int_PushArray((cell_t *)num, 1, flags);
    1.74 @@ -446,6 +452,14 @@
    1.75  	return SP_ERROR_NONE;
    1.76  }
    1.77  
    1.78 +void CForward::_Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags)
    1.79 +{
    1.80 +	m_params[m_curparam].byref.cells = cells;	/* Notice this contains the char count not cell count */
    1.81 +	m_params[m_curparam].byref.flags = cp_flags;
    1.82 +	m_params[m_curparam].byref.orig_addr = inarray;
    1.83 +	m_params[m_curparam].byref.sz_flags = sz_flags;
    1.84 +}
    1.85 +
    1.86  int CForward::PushString(const char *string)
    1.87  {
    1.88  	if (m_curparam < m_numparams)
    1.89 @@ -464,13 +478,13 @@
    1.90  		m_params[m_curparam].pushedas = Param_String;
    1.91  	}
    1.92  
    1.93 -	_Int_PushArray((cell_t *)string, 0, 0);
    1.94 +	_Int_PushString((cell_t *)string, strlen(string)+1, SP_STRING_COPY, 0);
    1.95  	m_curparam++;
    1.96  
    1.97  	return SP_ERROR_NONE;
    1.98  }
    1.99  
   1.100 -int CForward::PushStringEx(char *string, int flags)
   1.101 +int CForward::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags)
   1.102  {
   1.103  	if (m_curparam < m_numparams)
   1.104  	{
   1.105 @@ -488,7 +502,7 @@
   1.106  		m_params[m_curparam].pushedas = Param_String;
   1.107  	}
   1.108  
   1.109 -	_Int_PushArray((cell_t *)string, 0, flags);
   1.110 +	_Int_PushString((cell_t *)buffer, length, sz_flags, cp_flags);
   1.111  	m_curparam++;
   1.112  
   1.113  	return SP_ERROR_NONE;