6
#include "kscript_typecode.h"
7
#include "kscript_interface.h"
8
#include "kscript_struct.h"
10
KSTypeCode::KSTypeCode()
12
m_typecode = new CORBA::TypeCode();
15
KSTypeCode::KSTypeCode( void* tc )
17
m_typecode = (CORBA::TypeCode*)tc;
21
KSTypeCode::KSTypeCode( const QString& stringified )
23
m_typecode = new CORBA::TypeCode( stringified.ascii() );
26
KSTypeCode::~KSTypeCode()
31
bool KSTypeCode::fromString( const QString& stringified )
33
return m_typecode->from_string( stringified.ascii() );
36
void* KSTypeCode::tc()
41
bool KSTypeCode::convertToTypeCode( KSContext& context, KSValue* v )
43
if ( v->type() == KSValue::TypeCodeType )
46
if ( v->type() != KSValue::StringType )
49
QString tc = v->stringValue();
50
v->setValue( new KSTypeCode() );
51
if ( !v->typeCodeValue()->fromString( tc ) )
53
context.setException( new KSException( "InvalidTypeCode", tc, -1 ) );
59
KSTypeCode::Ptr KSTypeCode::typeCode( KSContext& context, KSValue* v )
61
if( v->type() == KSValue::TypeCodeType )
63
v->typeCodeValue()->ref();
64
return v->typeCodeValue();
66
else if( v->type() == KSValue::StringType )
68
if ( !convertToTypeCode( context, v ) )
70
KSTypeCode* tc = v->typeCodeValue();
74
else if( v->type() == KSValue::StructClassType )
76
KSValue::Ptr p = v->structClassValue()->member( context, "typecode" );
79
if ( !convertToTypeCode( context, p ) )
81
KSTypeCode* tc = p->typeCodeValue();
85
else if( v->type() == KSValue::InterfaceType )
87
KSValue::Ptr p = v->interfaceValue()->member( context, "typecode" );
90
printf(" tc=%s\n",p->toString().ascii());
91
if ( !convertToTypeCode( context, p ) )
93
KSTypeCode* tc = p->typeCodeValue();
98
context.setException( new KSException( "InvalidTypeCode", v->toString(), -1 ) );