#include <windows.h>

#include "typbrows.h"

/* free using the task allocator */


void GetFuncTypeName (INVOKEKIND ik, LPTSTR cp, int length)
{
	if (ik == DISPATCH_METHOD)
	{
		lstrcpyn (cp, TEXT("DISPATCH_METHOD"), length) ;  
	}
	else if (ik == DISPATCH_PROPERTYPUT)
	{
		lstrcpyn (cp, TEXT("DISPATCH_PROPERTYSET"), length) ;  	
	}
	else if (ik == DISPATCH_PROPERTYGET)
	{
		lstrcpyn (cp, TEXT("DISPATCH_PROPERTYGET"), length) ;  	
	}
	else if (ik == DISPATCH_PROPERTYPUTREF)
	{
		lstrcpyn (cp, TEXT("DISPATCH_PROPERTYPUTREF"), length) ;  	
	}

}                                             

TCHAR *VarNames[] = {

	TEXT("nothing"),                    
    TEXT("SQL style Null"),               
    TEXT("2 byte signed int"),             
    TEXT("4 byte signed int"), 
    TEXT("4 byte real"),                  
    TEXT("8 byte real"),                  
    TEXT("currency"),                    
    TEXT("date"),                        
    TEXT("binary string"),               
    TEXT("IDispatch"),             
    
    TEXT("SCODE"),                        
    TEXT("BOOL"),             
    TEXT("VARIANT"),                
    TEXT("IUnknown"),
    TEXT("reserved (14)"),
    TEXT("reserved (15)"),                 
	TEXT("signed char"),                  
    TEXT("unsigned char"),                
    TEXT("2 byte unsigned int"),  
    TEXT("4 byte unsigned int"),               
    
    TEXT("signed 64-bit int"),             
    TEXT("unsigned 64-bit int"),          
    TEXT("signed machine int"),          
    TEXT("unsigned machine int"),         
    TEXT("C style void"),                
    TEXT("HRESULT"),                               
    TEXT("pointer type"),                  
    TEXT("safe array (use VT_ARRAY in VARIANT)"),     
    TEXT("C style array"),                 
    TEXT("user defined type"),  	       
    
    TEXT("null terminated string"), 
    TEXT("null terminated wide string")  } ;
    
void GetVarTypeName (TYPEDESC td, LPTSTR cp)
{
	if (td.vt & VT_BYREF)
	{
		lstrcpy (cp, TEXT("pointer to ")) ;
		GetVarTypeName (*(td.lptdesc), cp + lstrlen(cp)) ;
	}
	else if (td.vt & VT_ARRAY)
	{
		int length = wsprintf (cp, TEXT("array [%d] of "), td.lpadesc->cDims) ;
		GetVarTypeName (td.lpadesc->tdescElem, cp + length) ; 
	}
	else
	{
		lstrcpy (cp, VarNames [td.vt]) ;
	}
}
