void ParticleEditor::refresh_state_ui()
  {
    per_state_info_.clear();
    TwRemoveAllVars(state_window_);
    TwAddVarCB(state_window_,
               "State Index",
               TW_TYPE_INT32,
               TweakBarParticleSetState,
               TweakBarParticleGetState,
               nullptr,
               "");
    TwAddButton(state_window_, 
                "Remove State", 
                TweakBarRemoveState, 
                &state_index_, 
                "");

    Reflection::Metadata* stateMeta = FindType(ParticleDescription);
    ParticleCallbackInfo stateInfo;
    stateInfo.baseData = FindType(ParticleDescription);
    stateInfo.type = ParticleUiType::State;
    //once for particle

    for(auto& it : stateMeta->GetMembers())
    {
      add_members(stateInfo, &it.second, state_window_, "state");
    }
    //once for variance
    stateInfo.type = ParticleUiType::Variance;
    for(auto& it : stateMeta->GetMembers())
    {
      add_members(stateInfo, &it.second, state_window_, "variance");
    }
  }
Example #2
0
boolean set_solver_types(void) {
  boolean nerr = 0;
  if( (g_solver_var_type = FindType(AddSymbol(SOLVER_VAR_STR))) == NULL ) {
    ERROR_REPORTER_HERE(ASC_PROG_FATAL,"'solver_var' not defined");
    nerr++;
  }
  if( (g_solver_int_type = FindType(AddSymbol(SOLVER_INT_STR))) == NULL ) {
    ERROR_REPORTER_HERE(ASC_PROG_ERROR,"'solver_int' not defined: MPS will not work");
    nerr++;
  }
  g_solver_binary_type = FindType(AddSymbol(SOLVER_BINARY_STR));
  if( g_solver_binary_type == NULL) {
    ERROR_REPORTER_HERE(ASC_PROG_FATAL,"'solver_binary' not defined: MPS will not work");
    nerr++;
  }
  if( (g_solver_semi_type = FindType(AddSymbol(SOLVER_SEMI_STR))) == NULL ) {
    ERROR_REPORTER_HERE(ASC_PROG_FATAL,"'solver_semi' not defined: MPS will not work");
    nerr++;
  }

  LOWER_V = AddSymbol("lower_bound");
  UPPER_V = AddSymbol("upper_bound");
  RELAXED_V = AddSymbol("relaxed");
  NOMINAL_V = AddSymbol("nominal");
  FIXED_V = AddSymbol("fixed");
  INTERFACE_V = AddSymbol("interface");
  ODEATOL_V = AddSymbol("ode_atol");
  return nerr;
}
  void ParticleEditor::refresh_emitter_ui()
  {
    per_emitter_info_.clear();
    indices_for_tweakbar_.clear();
    TwRemoveAllVars(emitter_window_);
    TwAddVarCB(emitter_window_,
               "Emitter Index",
               TW_TYPE_INT32,
               TweakBarParticleSetEmitter,
               TweakBarParticleGetEmitter,
               nullptr,
               "");
    TwAddButton(emitter_window_,
                "Remove Emitter",
                TweakBarRemoveEmitter,
                &emitter_index_,
                "");
    TwAddButton(emitter_window_,
                "Add State",
                TweakBarAddState,
                nullptr,
                "");
    Reflection::Metadata* emitterMeta = FindType(ParticleEmitter);
    ParticleCallbackInfo emitterInfo;
    emitterInfo.baseData = emitterMeta;
    emitterInfo.type = ParticleUiType::Emitter;
    //first typical bullshit
    for(auto& it : emitterMeta->GetMembers())
    {
      add_members(emitterInfo, &it.second, emitter_window_);
    }
    //so here we have to add controls to toggle interpolation
    //either something interpolates or it doesn't no selective interpolation for certain states
    Reflection::Metadata* stateMeta = FindType(ParticleDescription);
    ParticleCallbackInfo stateInfo;
    stateInfo.baseData = FindType(ParticleDescription);
    stateInfo.type = ParticleUiType::State;
    
    
    per_emitter_info_.push_back(stateInfo);
    void* dataToSend = &per_emitter_info_.back();
    int index = 0;
    for(auto& it : stateMeta->GetMembers())
    {
      indices_for_tweakbar_.push_back(index);
      ++index;
      TwAddVarCB(emitter_window_,
                 it.second.GetName().c_str(),
                 TW_TYPE_STDSTRING,
                 TweakBarParticleSetRegistered,
                 TweakBarParticleGetRegistered,
                 &indices_for_tweakbar_.back(),
                 "group = 'registered vars'");
    }

    refresh_state_ui();
  }
Example #4
0
// allocate a object given the classname by string
RTRoot* NewType(const char *typeName)
{
TypeInfo *t = FindType(typeName);
if (!t) return(NULL);
if (t->New == 0) return(NULL);		// abstract type
return t->New();
}
Example #5
0
File: main.cpp Project: EQ4/axLib
void DirectoryNavigation::SetDestinationPath(const string& path)
{
	_currentDirectory = path;

	_dirName.clear();

	DIR *d = opendir(path.c_str());
	dirent* dir;

	if(d)
	{
		while((dir = readdir(d)) != NULL)
		{
			IconType icon = FindType(dir);
			_dirName.push_back(FileInfo(dir->d_name, icon));
		}

		closedir(d);
	}

	_dirName.pop_front();
	_dirName.pop_front();

	std::sort(_dirName.begin(), _dirName.end());
}
Example #6
0
void Typedef(Member *td_names, Type *decl)
{
    Member *m, *t;


    m = ApplyMemberType(td_names, decl);
    while (m)
    {
        t = m->next;
        if (FindType(m->name))
        {
            int i;

            for (i = 0; i < EXTENDED_TYPES; i++)
                if (!strcmp(m->name, extended_types[i]))
                    break;
#ifdef REDEF_ERROR
            if (i == EXTENDED_TYPES)
                LexError("'%s' redefinition ignored", m->name);
#endif
            FreeMember(m);
        }
        else
        {
            AddType(NewTypedefType(m->name, m->type));
            /* Can't use FreeMember since we want to keep the name */
            free(m);
        }
        m = t;
    }
}
Example #7
0
DI_HID_Object * DI_HID_DeviceBase::FetchEvent( ) {

	DI_HID_Object * objPtr;
	DI_HID_MouseEvent mouseEvent;

	while( 1 ) {

		if( !WrapperSystem::eventList.size( ) ) return NULL;

		mouseEvent = WrapperSystem::eventList.front( );
		WrapperSystem::eventList.pop_front( );

		if( objPtr = FindType( mouseEvent.GetType( ) ) ) break;
	}

	switch( objPtr->GetType( ) ) {

		case type_axis_x:	objPtr->SetData( mouseEvent.lLastX );														break;
		case type_axis_y:	objPtr->SetData( mouseEvent.lLastY );														break;
		case type_axis_z:	objPtr->SetData( ( *( short * )&mouseEvent.usButtonData ) > 0 ? 1 : -1 );					break;
		case type_button_1:	objPtr->SetData( ( mouseEvent.usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN ) ? 0x80 : 0 );		break;
		case type_button_2:	objPtr->SetData( ( mouseEvent.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN ) ? 0x80 : 0 );	break;
		case type_button_3:	objPtr->SetData( ( mouseEvent.usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN ) ? 0x80 : 0 );	break;
		case type_button_4:	objPtr->SetData( ( mouseEvent.usButtonFlags & RI_MOUSE_BUTTON_4_DOWN ) ? 0x80 : 0 );		break;
		case type_button_5:	objPtr->SetData( ( mouseEvent.usButtonFlags & RI_MOUSE_BUTTON_5_DOWN ) ? 0x80 : 0 );		break;
		case type_button_6:	objPtr->SetData( mouseEvent.usButtonData ? 0x80 : 0 );										break;
		case type_button_7:	objPtr->SetData( mouseEvent.usButtonData ? 0x80 : 0 );										break;
	}

	objPtr->SetTime( mouseEvent.GetTime( ) - initTime );

	return objPtr;
}
Example #8
0
int CXGseScd::FindDAType(const std::string &ln_type, const std::string &do_name, const std::string &da_name, std::string &data_type)
{
    TiXmlNode *pXmlNodeType = m_pDatTypeNode->FirstChild("LNodeType");
    while (pXmlNodeType != NULL)
    {
        if (pXmlNodeType->ToElement()->Attribute("id") == ln_type)
        {
            TiXmlNode *pXmlDOType =  pXmlNodeType->FirstChild("DO");
            while (pXmlDOType != NULL)
            {
                if (pXmlDOType->ToElement()->Attribute("name") == do_name)
                {
                    std::string do_type = pXmlDOType->ToElement()->Attribute("type");
                    if (FindType(do_type, da_name, data_type) != J_OK)
                    {
                        //未找到类型
                        assert(false);
                    }
                    return J_OK;
                }
                pXmlDOType = pXmlDOType->NextSibling();
            }
        }
        pXmlNodeType = pXmlNodeType->NextSibling("LNodeType");
    }
    return J_NOT_FOUND;
}
Example #9
0
Type *FindTypeErr(char *name)
{
    Type *t;

    t = FindType(name);
    if (t == NULL)
        LexError("Unknown type: '%s'", name);
    return t;
}
bool
IsAutobinderType(const sptr<IDLType> &type)
{
	sptr<IDLType> st=FindType(type);
	uint32_t code = st->GetCode();
	//printf("Type %s: attrs=%08lx\n", st->GetName().String(), st->GetAttributes());
	return (code != B_WILD_TYPE && code != B_VARIABLE_ARRAY_TYPE && code != B_MESSAGE_TYPE)
		 || ((st->GetAttributes()&kAutoMarshal) != 0);
}
 //----------------------------------------------------------------------------
 bool MediaFoundationVideoDevice::SetupDevice(unsigned int streamIndex, unsigned int w, unsigned int h, unsigned int idealFramerate, GUID subtype)
 {
   unsigned int formatIndex = 0;
   if(!FindType(formatIndex, streamIndex, w, h, idealFramerate, subtype))
   {
     LOG_ERROR("MediaFoundationVideoDevice::SetupDevice failed: device " << this->DeviceIndex << ": Cannot find the requested type");
     return false;
   }
   return SetupDevice(streamIndex, formatIndex);
 }
bool
IsAutoMarshalType(const sptr<IDLType> &type)
{
	if (type->GetName() == "void") return false;

	//printf("Finding type for: %s\n", type->GetName().String());
	sptr<IDLType> st=FindType(type);
	//printf("The type found is: %s\n", st->GetName().String());
	return (st->GetAttributes()&kAutoMarshal) != 0;
}
Example #13
0
// Adds a type of the given name (or return the existing type with this name).
FCDEType* FCDExtra::AddType(const char* name)
{
	FCDEType* type = FindType(name);
	if (type == NULL)
	{
		type = new FCDEType(GetDocument(), this, emptyCharString);
		types.push_back(type);
		type->SetName(name);
		SetNewChildFlag();
	}
	return type;
}
Example #14
0
afs_int32
bnode_Create(char *atype, char *ainstance, struct bnode ** abp, char *ap1,
	     char *ap2, char *ap3, char *ap4, char *ap5, char *notifier,
	     int fileGoal, int rewritefile)
{
    struct bnode_type *type;
    struct bnode *tb;
    char *notifierpath = NULL;
    struct stat tstat;

    if (bnode_FindInstance(ainstance))
	return BZEXISTS;
    type = FindType(atype);
    if (!type)
	return BZBADTYPE;

    if (notifier && strcmp(notifier, NONOTIFIER)) {
	/* construct local path from canonical (wire-format) path */
	if (ConstructLocalBinPath(notifier, &notifierpath)) {
	    bozo_Log("BNODE-Create: Notifier program path invalid '%s'\n",
		     notifier);
	    return BZNOCREATE;
	}

	if (stat(notifierpath, &tstat)) {
	    bozo_Log("BNODE-Create: Notifier program '%s' not found\n",
		     notifierpath);
	    free(notifierpath);
	    return BZNOCREATE;
	}
    }
    tb = (*type->ops->create) (ainstance, ap1, ap2, ap3, ap4, ap5);
    if (!tb) {
	free(notifierpath);
	return BZNOCREATE;
    }
    tb->notifier = notifierpath;
    *abp = tb;
    tb->type = type;

    /* The fs_create above calls bnode_InitBnode() which always sets the
     ** fileGoal to BSTAT_NORMAL .... overwrite it with whatever is passed into
     ** this function as a parameter... */
    tb->fileGoal = fileGoal;

    bnode_SetStat(tb, tb->goal);	/* nudge it once */

    if (rewritefile != 0)
	WriteBozoFile(0);

    return 0;
}
void ChannelServer::FindCtors (const string& type, const string& keypat, std::set<ChannelCtor*>& ctors)
{
	ctors.clear();

	CtorTable::iterator c1 = find_if(chCtors.begin(),chCtors.end(),FindType(type));

	if(c1==chCtors.end())
	{
		return;
	}

	CtorTable::iterator c2 = find_if(c1,chCtors.end(),FindType(type,true));

	// Now find those ctors that match the key pattern
	StringPattern keyp(keypat);
	for(CtorTable::iterator ci = c1; ci!=c2; ci++)
	{
		if(keyp((ci->second)->GetKey()))
		{
			ctors.insert(ci->second);
		}
	}
}
  void ParticleEditor::refresh_system_ui()
  {
    per_system_info_.clear();
    TwRemoveAllVars(system_window_);
    TwAddVarCB(system_window_,
               "System Index",
               TW_TYPE_INT32,
               TweakBarParticleSetSystem,
               TweakBarParticleGetSystem,
               nullptr,
               "");
    TwAddButton(system_window_,
                "Remove System",
                TweakBarRemoveSystem,
                &system_index_,
                "");
    TwAddButton(system_window_,
                "Add Emitter",
                TweakBarAddEmitter,
                nullptr,
                "");
    Reflection::Metadata* systemMeta = FindType(ParticleSystem);
    ParticleCallbackInfo systemInfo;
    systemInfo.baseData = FindType(ParticleSystem);
    systemInfo.type = ParticleUiType::System;
    for(auto& it : systemMeta->GetMembers())
    {
      add_members(systemInfo, &it.second, system_window_);
    }


    

    refresh_emitter_ui();
    
  }
Example #17
0
static void ExtractIds(char *fname)
{
	strCollection *text = istrCollection.CreateFromFile(fname);
	Iterator *it = istrCollection.NewIterator(text);
	char *p;
	for (p = it->GetFirst(it); p != NULL; p = it->GetNext(it)) {
		char buf[512];
		if (strstr(p,"typedef") && strstr(p,"struct") &&
                    strchr(p,'{')) {
			char *q = strstr(p,"struct");
			char *name;
			q += 6;
			while (*q == ' ' || *q == '\t')
				q++;
			if (*q == 't' && q[1] == 'a' && q[2] == 'g')
				q += 3;
			if (*q == '{') {
				strcpy(buf,"ValArray");
				doFile(buf,it);
			}
			else {
			        int i = 0;
				while (*q != ' ' && *q != '{' && *q)
					buf[i++] = *q++;
				buf[i]=0;
				q = strstr(buf,"Interface");
				if (q) *q=0;
				if (FindType(buf) >= 0) {
					doFile(buf,it);
				}
				else if (strstr(buf,"WDictionary")) {
					strcpy(buf,"WDictionary");
					doFile(buf,it);
				}
				else if (strstr(buf,"HeapAllocator")) {
					strcpy(buf,"ContainerHeap");
					doFile(buf,it);
				}
			}
		}
	}
         for (p = it->GetFirst(it); p != NULL; p = it->GetNext(it)) {
                 int r = ScanOneLine(p);
        }

	istrCollection.DeleteIterator(it);
	istrCollection.Finalize(text);
}
Example #18
0
/*
	Testing for Franc Ivankovic's CNF conversion code, ongoing, Jan 2010 -- JP.
*/
static void test_boolrel(void){
	struct module_t *m;
	int status;

	Asc_CompilerInit(0); /* no simplification of expressions for this test */
	Asc_PutEnv(ASC_ENV_LIBRARY "=models");

	/* load the file */
#define TESTFILE "boolrel"
	m = Asc_OpenModule("test/compiler/" TESTFILE ".a4c",&status);
	CU_ASSERT(status == 0);

	/* parse it */
	CU_ASSERT(0 == zz_parse());

	/* find the model */
	CU_ASSERT(FindType(AddSymbol(TESTFILE))!=NULL);

	/* instantiate it */
	struct Instance *sim = SimsCreateInstance(AddSymbol(TESTFILE), AddSymbol("sim1"), e_normal, NULL);
	CU_ASSERT_FATAL(sim!=NULL);

	/* call the on_load method */
	struct Name *name = CreateIdName(AddSymbol("on_load"));
	CU_ASSERT(Proc_all_ok == Initialize(GetSimulationRoot(sim),name,"sim1", ASCERR, WP_STOPONERR, NULL, NULL));

	/* Check that x := 2 was NOT executed (after error statement) */
	struct Instance *inst;
	struct Instance *root = GetSimulationRoot(sim);
	CU_ASSERT(NULL != root);
	CU_ASSERT(NULL != (inst = ChildByChar(root,AddSymbol("rel1"))));
	CONSOLE_DEBUG("Instance kind = %d",InstanceKind(inst));
	CU_ASSERT(InstanceKind(inst)==LREL_INST);

	char *out = WriteLogRelToString(inst,root);
	CONSOLE_DEBUG("Relation: %s",out);


	ASC_FREE(out);

	/* clean up */
	sim_destroy(sim);
	Asc_CompilerDestroy();
#undef TESTFILE
}
void PrintTypeForValue(ParsingDefinitionType* _type, ParsingSymbol* _scope, ParsingSymbolManager* _manager, const WString& _codeClassPrefix, TextWriter& _writer)
{
	List<Ptr<ParsingError>> errors;
	ParsingSymbol* type=FindType(_type, _manager, _scope, errors);
	if(type->GetType()==ParsingSymbol::EnumType)
	{
		PrintType(_type, _scope, _manager, _codeClassPrefix, _writer);
	}
	else if(type->GetType()==ParsingSymbol::ClassType)
	{
		_writer.WriteString(L"vl::Ptr<");
		PrintType(_type, _scope, _manager, _codeClassPrefix, _writer);
		_writer.WriteString(L">");
	}
	else
	{
		PrintType(_type, _scope, _manager, _codeClassPrefix, _writer);
	}
}
void
AddFromSValueStatements(const InterfaceRec* rec,
						sptr<StatementList> statementList, 
						const sptr<IDLType>& vartype,
						const SString& varname,
						const SString& valuename)
{
	sptr<IDLType> storedtype = FindType(vartype);
	SString cpptype = TypeToCPPType(rec, vartype, false);
	if (storedtype->GetCode() != B_VARIABLE_ARRAY_TYPE) {
		// statements = MyType rv(value);
		statementList->AddItem(new Literal(true, "%s %s(%s)", cpptype.String(), varname.String(), valuename.String()));
	}
	else {
		// statements = MyType rv;
		//				rv.SetFromValue(value);
		statementList->AddItem(new Literal(true, "%s %s", cpptype.String(), varname.String()));
		statementList->AddItem(new Literal(true, "%s.SetFromValue(%s)", varname.String(), valuename.String()));
	}
}
Example #21
0
sBool ACDoc::_IsDecl()
{
  if(Scan.Token==sTOK_NAME)
  {
    if(FindType(Scan.Name)) return 1;
  }
  if(Scan.Token==AC_TOK_IN) return 1;
  if(Scan.Token==AC_TOK_OUT) return 1;
  if(Scan.Token==AC_TOK_INOUT) return 1;
  if(Scan.Token==AC_TOK_UNIFORM) return 1;
  if(Scan.Token==AC_TOK_ROWMAJOR) return 1;
  if(Scan.Token==AC_TOK_COLMAJOR) return 1;
  if(Scan.Token==AC_TOK_CONST) return 1;
  if(Scan.Token==AC_TOK_INLINE) return 1;
  if(Scan.Token==AC_TOK_STATIC) return 1;
  if(Scan.Token==AC_TOK_GROUPSHARED) return 1;

  if(Scan.Token==AC_TOK_STRUCT) return 1;
  return 0;
}
Example #22
0
TBNode<JSTypeInfo> *JSTypeTree::FindMemberInPrototype(CodeGenContext& context, TBNode<JSTypeInfo> *node, llvm::Type *member, const char *name, llvm::Value *nodeValueRef)
{
    JSTypeInfo *typeInfo;
    TBNode<JSTypeInfo> *nodeContainMember = node;

    if ((NULL == node) || (NULL == name))
    {
        return node;
    }

    /* find __proto__ first, two ways:JSTypeInfoFindInPredecessor+JSTypeInfoGetMemberValueOfBase, or suppose EJSObject(JSObject_01 actually) is the base of every type  */
    TBNode<JSTypeInfo> *jsObject_01Info;
#if 0
    jsObject_01Info= FindType(context.getTypeRef("struct.JSObject_01"));
#else
    jsObject_01Info= jsTypeTree->mRoot;
#endif
    llvm::Value *prototypeRef = GetMemberRef(context, node, jsObject_01Info, "__proto__", nodeValueRef);
    llvm::Value *valueRef = GetMemberRef(context, node, jsObject_01Info, "__proto__", prototypeRef);

    /* check predecessor of typeInfo to find name */
    for (nodeContainMember = node; NULL != nodeContainMember; nodeContainMember = nodeContainMember->data.baseTypeInfo)
    {
        typeInfo = &nodeContainMember->data;
        if (NULL == typeInfo->memberName)
        {
            continue;
        }
        if (0 == strcmp(typeInfo->memberName, name))
        {
            break;
        }
    }

    /* find name in the base, no need to create a new type for the property */
    return nodeContainMember;
}
SString
ToSValueConversion(const sptr<IDLType>& type, const SString &variable)
{
	SString s("SValue::");
	SString tn=type->GetName();

	sptr<IDLType> storedtype=FindType(type);
	if (storedtype->CountMembers()>0) {	
		sptr<jmember> toBV=storedtype->GetMemberAt(0); 

		if (tn=="SValue") {		
			s=variable; 
		}
		else if ((tn=="SMessage")) {		
			s =variable;
			s.Append(".AsValue()");
		}		
		else if (tn=="sptr") {		
			s.Append("Binder");
			s.Append("(");
			s.Append(variable);

			if (type->GetIface()!="IBinder") {
				if (type->HasAttribute(kWeak)) {
					s.Append(".promote() != NULL ? ");
					s.Append(variable);
					s.Append(".promote()->AsBinder() : sptr<IBinder>()");
				}
				else {
					s.Append("->AsBinder()");
				}
			}
			s.Append(")");
		}
		else if ((tn!=NULL) && (storedtype->GetCode()==B_WILD_TYPE)) {		
			//bout << "<----- outpututil.cpp -----> ToSValueConversion - " << tn << " is a custom type " << endl; 
			s=variable;
			s.Append(".");
			s.Append(toBV->ID());
			s.Append("()");
		}
		else if (storedtype->GetCode() == B_VARIABLE_ARRAY_TYPE) {
			// if we are dealing with a sequence, then
			// SVector provides an AsValue
			// the storedtype we are dealing with is the element
			// types, so we ignore the toBV since we want AsValue
			// for the entire array.
			s = variable;
			s.Append(".AsValue()");
		}
		else if (tn=="char*") {
			s.Append("String(");
			s.Append(variable);
			s.Append(")");
		}
		else {
			s.Append(toBV->ID());
			s.Append("(");
			s.Append(variable);
			s.Append(")");
		}

		return s;	
	}
	else {	
		bout << "<----- outpututil.cpp -----> there is no function to marshall type=" << tn << endl; 
		_exit(1);
	}
	return NULL;
}
  void ParticleEditor::add_members(ParticleCallbackInfo& info, 
                                   Reflection::Member* base, 
                                   TwBar* bar,
                                   const std::string& group)
  {
    
    info.members.push_back(base);
    if(base->GetType() != FindType(Vector4))
    {
      for(auto& it : base->GetType()->GetMembers())
      {
        add_members(info, &it.second, bar, group);
      }
    }
    
    void* dataToSend = nullptr;
    switch(info.type)
    {
      case ParticleUiType::Emitter:
        per_emitter_info_.push_back(info);
        dataToSend = &per_emitter_info_.back();
        break;
      case ParticleUiType::System:
        per_system_info_.push_back(info);
        dataToSend = &per_system_info_.back();
        break;
      case ParticleUiType::State:
      case ParticleUiType::Variance:
        per_state_info_.push_back(info);
        dataToSend = &per_state_info_.back();
        break;
      default:
        __debugbreak();
    }

    std::string fullName = group + " ";
    Reflection::Metadata* type = base->GetType();
    for(auto& it : info.members)
    {
      fullName.append(it->GetName() + " ");
    }
    TwType varType = FindTwType(type);
    std::string tweakVars = " group='" + group + "'";
    if(varType == TW_TYPE_FLOAT || varType == TW_TYPE_COLOR4F)
    {
      tweakVars += " step=0.05 ";
    }
    if(varType == TW_TYPE_STDSTRING)
    {
      TwAddVarCB(bar,
                 fullName.c_str(),
                 FindTwType(type),
                 TweakBarParticleSetString,
                 TweakBarParticleGetString,
                 dataToSend,
                 tweakVars.c_str());
    }
    else
    {

      TwAddVarCB(bar,
                 fullName.c_str(),
                 FindTwType(type),
                 TweakBarParticleSet,
                 TweakBarParticleGet,
                 dataToSend,
                 tweakVars.c_str());
    }
    info.members.pop_back();
  }
Example #25
0
/*
** Get the data from the debuggee, format it and then put it in a buffer.
*/
int CVGetValue(DebugModule *module, State *state)
{
UCHAR	   *data;
CVTypeData *cvType = state->typeData;
USHORT	    targetIndex;


    module;

    /*
    ** Get the data from the debuggee
    */
    data = calloc(state->elementSize + 4, 1);
    debugBuffer->Len	= state->elementSize;
    debugBuffer->Addr	= state->addr;
    debugBuffer->Buffer = (ULONG) data;
    if(DispatchCommand(DBG_C_ReadMemBuf) != DBG_N_Success) {
	free(data);
	return OUT_OF_CONTEXT;
    }
    if(state->value.typeValue == BYTE_INDEX_IN_LVAL)
	*(ULONG *) data = *(ULONG *)data + state->value.val.lVal;

    /*
    ** Check the type of the data.
    */
    targetIndex = cvType->typeIndex;
    if(targetIndex > 0x0200) {
	char *types;

	types = FindType(cvType, cvType->typeIndex);
	if(types == NULL) {
	    free(data);
	    return INTERNAL_ERROR;
	}

	/*
	** Pointers
	*/
	if(types[3] == 0x7a) {
	    USHORT  typeIndex;

	    state->value.typeValue = PTR_VAL;
	    state->value.val.lVal = *(ULONG *) data;
	    typeIndex = GetType(&types[5]);
	    state->isStruct = 0;
	    if(typeIndex >= 0x200) {
		types = FindType(cvType, typeIndex);
		if(types[3] == 0x79) {
		    state->isStruct = 1;
		    cvType->typeIndex = typeIndex;
		}
	    }
	    free(data);
	    return SUCCESS;
	}

	/*
	** Structures
	*/
	if(types[3] == 0x79) {
	    state->value.typeValue = PTR_VAL;
	    state->value.val.lVal  = state->addr;
	    state->isStruct	   = 1;
	    return SUCCESS;
	}

	/*
	** Arrays
	*/
	if(types[3] == 0x78) {
	    int     i;
	    ULONG   size;
	    USHORT  typeIndex;

	    state->value.typeValue = PTR_VAL;
	    state->value.val.lVal  = state->addr;
	    i = CVGetNumber(&types[4], &size) + 4;
	    typeIndex = GetType(&types[i]);
	    if((typeIndex == 0x80) || (typeIndex == 0x84)) {
		char   *ptr;

		size /= 8;
		ptr = malloc(size+1);
		ptr[size] = 0;
		state->value.typeValue = STR_VAL;
		state->value.val.sVal  = ptr;
		debugBuffer->Len       = size;
		debugBuffer->Addr      = state->addr;
		debugBuffer->Buffer    = (ULONG) ptr;
		if((i = DispatchCommand(DBG_C_ReadMemBuf)) == DBG_N_Success)
		    return SUCCESS;

		free(ptr);
		state->value.typeValue = PTR_VAL;
		state->value.val.lVal  = *(ULONG *) data;
		return OUT_OF_CONTEXT;
	    }
	    return SUCCESS;
	}

{
char buff[80];
hexdump(types, 16, buff);
fprintf(stderr, "Unknown type in GetValue\n");
fprintf(stderr, "%s\n", buff);
}
	free(data);
	return INVALID_NAME;
    }

    /*
    ** For predefined types, break it down.
    */
    switch((targetIndex & 0x01c) >> 2) {
	/* Real */
	case 2: switch(targetIndex & 0x03) {
		    case 0: /* Single */
			    state->value.val.dVal  = *(float *) data;
			    state->value.typeValue = DOUBLE_VAL;
                            free(data);
			    return SUCCESS;
		    case 1: /* Double */
			    state->value.val.dVal  = *(double *) data;
			    state->value.typeValue = DOUBLE_VAL;
                            free(data);
			    return SUCCESS;
		    case 2: /* Long double */
			    free(data);
			    return INVALID_VALUE;
		    case 3: /* Reserved */
			    free(data);
			    return INTERNAL_ERROR;
		} break;

	/* Complex */
	case 3: free(data);
		return INVALID_VALUE;

	/* Currency */
	case 6: free(data);
		return INVALID_VALUE;

	/* Other base c types. */
	case 0: /* SIGNED   */
	case 1: /* UNSIGNED */
	case 4: /* BOOLEAN  */
	case 5: /* ASCII    */
		if((targetIndex & 0x60) == 0) {
		    switch(targetIndex & 0x03) {
			case 0: /* Byte */
				state->value.val.lVal  = data[0];
				state->value.typeValue = CHAR_VAL;
                                free(data);
				return SUCCESS;;
			case 1: /* Word */
				state->value.val.lVal  = *(short *) data;
				state->value.typeValue = LONG_VAL;
                                free(data);
				return SUCCESS;;
			case 2: /* Long     */
				state->value.val.lVal  = *(long *) data;
				state->value.typeValue = LONG_VAL;
                                free(data);
				return SUCCESS;;
			case 3: /* Reserved */
				free(data);
				return INTERNAL_ERROR;
		    }
		} else {
		    debugBuffer->Addr	= *(ULONG *) data;
		    debugBuffer->Buffer = (ULONG) data;
		    debugBuffer->Len	= 4;
		    if(DispatchCommand(DBG_C_ReadMemBuf) != 0) {
			free(data);
			return OUT_OF_CONTEXT;
		    }
		    switch(targetIndex & 0x03) {
			case 0: /* Byte */
			    {
				ULONG	base, tmp;
				int	numBytes;

				tmp = base = *(ULONG *) data;
				numBytes = 0;
				do {
				    debugBuffer->Addr	= tmp;
				    debugBuffer->Buffer = (ULONG) data;
				    debugBuffer->Len	= 1;
				    if(DispatchCommand(DBG_C_ReadMemBuf) != 0) {
					free(data);
					return OUT_OF_CONTEXT;
				    }
				    numBytes++;
				    tmp++;
				} while(data[0] != 0);
				state->value.val.sVal  = malloc(numBytes);
				state->value.typeValue = STR_VAL;
				debugBuffer->Addr   = base;
				debugBuffer->Buffer = (ULONG) state->value.val.sVal;
				debugBuffer->Len    = numBytes;
				if(DispatchCommand(DBG_C_ReadMemBuf) != 0) {
				    free(data);
				    return OUT_OF_CONTEXT;
				}
				state->value.val.sVal[numBytes] = 0;
				free(data);
				return SUCCESS;
			    }
			case 1: /* Word */
				state->value.val.lVal  = *(short *) data;
				state->value.typeValue = LONG_VAL;
                                free(data);
				return SUCCESS;
			case 2: /* Long     */
				state->value.val.lVal  = *(long *) data;
				state->value.typeValue = LONG_VAL;
                                free(data);
				return SUCCESS;
			case 3: /* Reserved */
				free(data);
				return INTERNAL_ERROR;
		    }
		    return INVALID_VALUE;
		} break;
    }
    free(data);
    return INVALID_VALUE;
}
Example #26
0
/* Call the appropriate function, or return syntax error code.  Note: if
 * no opcode is specified, an initialization routine exists, and it has
 * NOT been called before, we invoke the special initialization opcode
 */
int
cmd_Parse(int argc, char **argv, struct cmd_syndesc **outsyntax)
{
    char *pname;
    struct cmd_syndesc *ts = NULL;
    struct cmd_parmdesc *tparm;
    int i;
    int curType;
    int positional;
    int ambig;
    int code = 0;
    char *param = NULL;
    char *embeddedvalue = NULL;
    static int initd = 0;	/*Is this the first time this routine has been called? */
    static int initcmdpossible = 1;	/*Should be consider parsing the initial command? */

    *outsyntax = NULL;

    if (!initd) {
	initd = 1;
	initSyntax();
    }

    /*Remember the program name */
    pname = argv[0];

    if (noOpcodes) {
	if (argc == 1) {
	    if (!NoParmsOK(allSyntax)) {
		printf("%s: Type '%s -help' for help\n", pname, pname);
		code = CMD_USAGE;
		goto out;
	    }
	}
    } else {
	if (argc < 2) {
	    /* if there is an initcmd, don't print an error message, just
	     * setup to use the initcmd below. */
	    if (!(initcmdpossible && FindSyntax(initcmd_opcode, NULL))) {
		printf("%s: Type '%s help' or '%s help <topic>' for help\n",
		       pname, pname, pname);
		code = CMD_USAGE;
		goto out;
	    }
	}
    }

    /* Find the syntax descriptor for this command, doing prefix matching properly */
    if (noOpcodes) {
	ts = allSyntax;
    } else {
	ts = (argc < 2 ? 0 : FindSyntax(argv[1], &ambig));
	if (!ts) {
	    /*First token doesn't match a syntax descriptor */
	    if (initcmdpossible) {
		/*If initial command line handling hasn't been done yet,
		 * see if there is a descriptor for the initialization opcode.
		 * Only try this once. */
		initcmdpossible = 0;
		ts = FindSyntax(initcmd_opcode, NULL);
		if (!ts) {
		    /*There is no initialization opcode available, so we declare
		     * an error */
		    if (ambig) {
			fprintf(stderr, "%s", NName(pname, ": "));
			fprintf(stderr,
				"Ambiguous operation '%s'; type '%shelp' for list\n",
				argv[1], NName(pname, " "));
		    } else {
			fprintf(stderr, "%s", NName(pname, ": "));
			fprintf(stderr,
				"Unrecognized operation '%s'; type '%shelp' for list\n",
				argv[1], NName(pname, " "));
		    }
		    code = CMD_UNKNOWNCMD;
		    goto out;
		} else {
		    /*Found syntax structure for an initialization opcode.  Fix
		     * up argv and argc to relect what the user
		     * ``should have'' typed */
		    if (!(argv = InsertInitOpcode(&argc, argv))) {
			fprintf(stderr,
				"%sCan't insert implicit init opcode into command line\n",
				NName(pname, ": "));
			code = CMD_INTERNALERROR;
			goto out;
		    }
		}
	    } /*Initial opcode not yet attempted */
	    else {
		/* init cmd already run and no syntax entry found */
		if (ambig) {
		    fprintf(stderr, "%s", NName(pname, ": "));
		    fprintf(stderr,
			    "Ambiguous operation '%s'; type '%shelp' for list\n",
			    argv[1], NName(pname, " "));
		} else {
		    fprintf(stderr, "%s", NName(pname, ": "));
		    fprintf(stderr,
			    "Unrecognized operation '%s'; type '%shelp' for list\n",
			    argv[1], NName(pname, " "));
		}
		code = CMD_UNKNOWNCMD;
		goto out;
	    }
	}			/*Argv[1] is not a valid opcode */
    }				/*Opcodes are defined */

    /* Found the descriptor; start parsing.  curType is the type we're
     * trying to parse */
    curType = 0;

    /* We start off parsing in "positional" mode, where tokens are put in
     * slots positionally.  If we find a name that takes args, we go
     * out of positional mode, and from that point on, expect a switch
     * before any particular token. */

    positional = enablePositional;	/* Accepting positional cmds ? */
    i = noOpcodes ? 1 : 2;
    SetupExpandsFlag(ts);
    for (; i < argc; i++) {
	if (param) {
	    free(param);
	    param = NULL;
	    embeddedvalue = NULL;
	}

	/* Only tokens that start with a hyphen and are not followed by a digit
	 * are considered switches.  This allow negative numbers. */

	if ((argv[i][0] == '-') && !isdigit(argv[i][1])) {
	    int j;

	    /* Find switch */
	    if (strrchr(argv[i], '=') != NULL) {
		param = strdup(argv[i]);
		embeddedvalue = strrchr(param, '=');
		*embeddedvalue = '\0';
		embeddedvalue ++;
	        j = FindType(ts, param);
	    } else {
	        j = FindType(ts, argv[i]);
	    }

	    if (j < 0) {
		fprintf(stderr,
			"%sUnrecognized or ambiguous switch '%s'; type ",
			NName(pname, ": "), argv[i]);
		if (noOpcodes)
		    fprintf(stderr, "'%s -help' for detailed help\n",
			    argv[0]);
		else
		    fprintf(stderr, "'%shelp %s' for detailed help\n",
			    NName(argv[0], " "), ts->name);
		code = CMD_UNKNOWNSWITCH;
		goto out;
	    }
	    if (j >= CMD_MAXPARMS) {
		fprintf(stderr, "%sInternal parsing error\n",
			NName(pname, ": "));
		code = CMD_INTERNALERROR;
		goto out;
	    }
	    if (ts->parms[j].type == CMD_FLAG) {
		ts->parms[j].items = &dummy;

		if (embeddedvalue) {
		    fprintf(stderr, "%sSwitch '%s' doesn't take an argument\n",
			    NName(pname, ": "), ts->parms[j].name);
		    code = CMD_TOOMANY;
		    goto out;
		}
	    } else {
		positional = 0;
		curType = j;
		ts->parms[j].flags |= CMD_PROCESSED;

		if (embeddedvalue) {
		    AddItem(&ts->parms[curType], embeddedvalue, pname);
		}
	    }
	} else {
	    /* Try to fit in this descr */
	    if (curType >= CMD_MAXPARMS) {
		fprintf(stderr, "%sToo many arguments\n", NName(pname, ": "));
		code = CMD_TOOMANY;
		goto out;
	    }
	    tparm = &ts->parms[curType];

	    if ((tparm->type == 0) ||	/* No option in this slot */
		(tparm->type == CMD_FLAG)) {	/* A flag (not an argument */
		/* skipped parm slot */
		curType++;	/* Skip this slot and reprocess this parm */
		i--;
		continue;
	    }

	    if (!(tparm->flags & CMD_PROCESSED) && (tparm->flags & CMD_HIDE)) {
		curType++;	/* Skip this slot and reprocess this parm */
		i--;
		continue;
	    }

	    if (tparm->type == CMD_SINGLE ||
	        tparm->type == CMD_SINGLE_OR_FLAG) {
		if (tparm->items) {
		    fprintf(stderr, "%sToo many values after switch %s\n",
		            NName(pname, ": "), tparm->name);
		    code = CMD_NOTLIST;
		    goto out;
		}
		AddItem(tparm, argv[i], pname);        /* Add to end of list */
	    } else if (tparm->type == CMD_LIST) {
		AddItem(tparm, argv[i], pname);        /* Add to end of list */
	    }

	    /* Now, if we're in positional mode, advance to the next item */
	    if (positional)
		curType = AdvanceType(ts, curType);
	}
    }

    /* keep track of this for messages */
    ts->a0name = argv[0];

    /* If we make it here, all the parameters are filled in.  Check to see if
     * this is a -help version.  Must do this before checking for all
     * required parms, otherwise it is a real nuisance */
    if (ts->parms[CMD_HELPPARM].items) {
	PrintSyntax(ts);
	/* Display full help syntax if we don't have subcommands */
	if (noOpcodes)
	    PrintFlagHelp(ts);
	code = CMD_HELP;
	goto out;
    }

    /* Parsing done, see if we have all of our required parameters */
    for (i = 0; i < CMD_MAXPARMS; i++) {
	tparm = &ts->parms[i];
	if (tparm->type == 0)
	    continue;		/* Skipped parm slot */
	if ((tparm->flags & CMD_PROCESSED) && tparm->items == 0) {
	    if (tparm->type == CMD_SINGLE_OR_FLAG) {
		tparm->items = &dummy;
	    } else {
	        fprintf(stderr, "%s The field '%s' isn't completed properly\n",
		    NName(pname, ": "), tparm->name);
	        code = CMD_TOOFEW;
	        goto out;
	    }
	}
	if (!(tparm->flags & CMD_OPTIONAL) && tparm->items == 0) {
	    fprintf(stderr, "%sMissing required parameter '%s'\n",
		    NName(pname, ": "), tparm->name);
	    code = CMD_TOOFEW;
	    goto out;
	}
	tparm->flags &= ~CMD_PROCESSED;
    }
    *outsyntax = ts;

out:
    if (code && ts != NULL)
	ResetSyntax(ts);

    return code;
}
SString
FromSValueConversion(const sptr<IDLType>& type, const SString &variable, bool setError)
{
	SString s(variable);
	s.Append(".");

	SString tn=type->GetName();

	sptr<IDLType> storedtype=FindType(type);
	if (storedtype->CountMembers()>1) {	
		sptr<jmember> fromBV=storedtype->GetMemberAt(1);

		if ((tn=="SValue") || (tn=="SMessage")) {
			// simple assignment
			s = variable; 
			return s;
		}
		if (tn=="sptr") {		
			//bout << "interface id=" << type->GetIface() << endl;
			if (type->GetIface() == "IBinder") {
				s=variable;
				if (setError) {
					s.Append(".AsBinder(&_pidgen_err)");
				}
				else {
					s.Append(".AsBinder()");
				}
			}
			else {
				InterfaceRec*	validiface=FindInterface(type->GetIface());
				s.Truncate(0);
				/* if (validiface->InNamespace()) {
					s.Append(validiface->Namespace());
					s.Append(':', 2);
				} */
				s.Append(validiface->ID());
				s.Append("::AsInterface(");
				s.Append(variable);
				if (setError) {
					s.Append(", &_pidgen_err)");
				}
				else {
					s.Append(")");
				}
			}
			return s;	
		}
		else if ((tn!=NULL) && (storedtype->GetCode() == B_WILD_TYPE)) {		
			// custom types which have Code==B_WILD_TYPE
			// all custom types use explicit constructor
			//bout << "<----- outpututil.cpp -----> FromSValueConversion - " << tn << " is a custom type " << endl; 

			s=fromBV->ID();
			s.Append("(");
			s.Append(variable);
			if (setError) {
				s.Append(", &_pidgen_err)");
			}
			else {
				s.Append(")");
			}
			//s.Prepend(".");	
			return s;
		}
		else if ((tn!=NULL) && storedtype->GetCode() == B_VARIABLE_ARRAY_TYPE) {
			// custom types which are sequences
			// if we are dealing with an array type, then we need to
			// use the SVector SetFromValue function
			s = "SetFromValue(";
			s.Append(variable);
			if (setError) {
				s.Append(", &_pidgen_err)");
			}
			else {
				s.Append(")");
			}
			return s;
		}
		else {
			s.Append(fromBV->ID());
			if (setError) {
				s.Append("(&_pidgen_err)");
			}
			else {
				s.Append("()");
			}
	
			if ((tn=="size_t") ||
					(tn=="char") ||
					(tn=="wchar32_t") ||
					(tn=="int8_t") ||
					(tn=="int16_t") ||
					(tn=="uint8_t") ||
					(tn=="uint16_t") ||
					(tn=="uint32_t") ||
					(tn=="uint64_t")) { 
				s.Prepend(")");
				s.Prepend(tn);
				s.Prepend("("); 
			}
			return s;
		}
	}
	else {	
		bout << "<----- outpututil.cpp -----> there is no function to marshall type=" << tn << endl; 
		_exit(1);
	}
	return NULL;

}
SString 
FromSValueExpression(const InterfaceRec* rec,
					 const sptr<IDLType>& vartype,
					 const SString& varname,
					 const SString& valuename,
					 ExpressionKind kind,
					 bool setError)
{
	// Create the appropriate expression for converting from an SValue
	// We do this here, so we don't have to special case the code all over OutputCPP.cpp
	// There are 8 different places where FromSValueConversion is called,
	// all just slightly different than the other.
	// However, they can be grouped into the following categories:
	//	INITIALIZE,				// BClass v = BClass(value, &err);
	//	ASSIGN,					// arg = BClass(value, &err);
	//	INDIRECT_ASSIGN,		// *arg = BClass(value, &err);
	//	RETURN					// return BClass(value, &err);

	//	sequences, which are handled in C++ as SVector must be treated differently.
	//	INITIALIZE,				// VectorClass v; v.SetFromValue(value, &err);
	//	ASSIGN,					// arg.SetFromValue(value, &err);
	//	INDIRECT_ASSIGN,		// arg->SetFromValue(value, &err);
	//	RETURN					// return VectorClass(value, &err);

	SString expr;
	sptr<IDLType> storedtype=FindType(vartype);
	if (storedtype->GetCode() != B_VARIABLE_ARRAY_TYPE) {
		switch (kind) {
			case INITIALIZE:
				{
				expr.Append(TypeToCPPType(rec, vartype, false));
				expr.Append(" ");
				expr.Append(varname);
				expr.Append(kAssignStr);
				break;
				}
			case ASSIGN:
				expr.Append(varname);
				expr.Append(kAssignStr);
				break;
			case INDIRECT_ASSIGN:
				expr.Append("*");
				expr.Append(varname);
				expr.Append(kAssignStr);
				break;
			case RETURN:
				expr.Append("return ");
				break;
		}
	}
	else {
		// The SFlattenable signature for SetFromValue doesn't set any errors, just returns them
		setError = false;
		switch (kind) {
			case INITIALIZE:
				// VectorClass v; v.SetFromValue(value, &err);
				expr.Append(TypeToCPPType(rec, vartype, false));
				expr.Append(" ");
				expr.Append(varname);
				expr.Append(";\n");
				expr.Append(varname);
				expr.Append(".");
				break;
			case ASSIGN:
				// arg.SetFromValue(value, &err);
				expr.Append(varname);
				expr.Append(".");
				break;
			case INDIRECT_ASSIGN:
				// arg->SetFromValue(value, &err);
				expr.Append(varname);
				expr.Append("->");
				break;
			case RETURN:
				// VectorClass rv; rv.SetFromValue(value, &err); return rv;
				expr.Append(TypeToCPPType(rec, vartype, false));
				expr.Append(" ");
				expr.Append(varname);
				expr.Append(";\n");
				expr.Append(varname);
				expr.Append(".");
				// ... to be continued after FromSValueConversion
				break;
		}
	}
	expr.Append(FromSValueConversion(vartype, valuename, setError));
	expr.Append(";");
	if (storedtype->GetCode() == B_VARIABLE_ARRAY_TYPE && kind == RETURN) {
		expr.Append("\nreturn ");
		expr.Append(varname);
		expr.Append(";");
	}
	return expr;
}
Example #29
0
void Program::CreateDefForEvent( Event *ev )
{
    type_t	   newtype;
    type_t	   *type;
    const char  *name;
    def_t		   *def;
    EventArgDef *arg;
    int         num;
    int         i;
    dfunction_t	*df;
    qboolean    hitoptional;

    num = ev->getNumArgDefs();
    if ( num > MAX_PARMS )
    {
        gi.WDPrintf( "Event '%s' has too many arguments for function call.\n", ev->getName() );
        return;
    }

    if ( numfunctions >= MAX_FUNCTIONS )
    {
        gi.Error( ERR_DROP, "Exceeded max functions while declaring events." );
    }

    df = &functions[ numfunctions ];
    df->parm_total = 0;
    df->parm_start = numpr_globals;

    memset( &newtype, 0, sizeof( newtype ) );
    newtype.type = ev_function;

    // set the return type
    arg = ev->getReturnType();
    if ( arg )
    {
        switch( arg->getType() )
        {
        case IS_STRING :
            newtype.aux_type = &type_string;
            break;

        case IS_VECTOR :
            newtype.aux_type = &type_vector;
            break;

        case IS_ENTITY :
            newtype.aux_type = &type_entity;
            break;

        case IS_BOOLEAN :
        case IS_INTEGER :
        case IS_FLOAT :
        default:
            newtype.aux_type = &type_float;
            break;
        }
    }
    else
    {
        newtype.aux_type = &type_void;
    }

    newtype.num_parms = 0;
    newtype.min_parms = 0;
    hitoptional = false;
    for( i = 1; i <= num; i++ )
    {
        arg = ev->getArgDef( i );

        if ( !hitoptional )
        {
            hitoptional = arg->isOptional();
            if ( !hitoptional )
            {
                newtype.min_parms++;
            }
        }

        switch( arg->getType() )
        {
        case IS_STRING :
            type = &type_string;
            break;

        case IS_VECTOR :
            type = &type_vector;
            break;

        case IS_ENTITY :
            type = &type_entity;
            break;

        case IS_BOOLEAN :
        case IS_INTEGER :
        case IS_FLOAT :
        default:
            type = &type_float;
            break;
        }

        df->parm_total += type_size[ type->type ];
        df->parm_size[ newtype.num_parms ] = type_size[ type->type ];
        df->parm_type[ newtype.num_parms ] = type->type;
        newtype.parm_types[ newtype.num_parms ] = type;
        newtype.num_parms++;
    }

    type = FindType( &newtype );
    name = ev->getName();
    def = GetDef( type, name, NULL, true, NULL );
    def->initialized = 1;
    def->caseSensitive = false;

    setFunction( def->ofs, numfunctions );

    // fill in the dfunction
    df->eventnum         = int( *ev );
    df->first_statement  = -1;
    df->s_name           = def->name;
    df->s_file           = s_file;
    df->numparms         = def->type->num_parms;
    df->minparms         = def->type->min_parms;
    df->locals           = 0;

    numfunctions++;
}
SString
TypeToCPPType(const InterfaceRec* rec, const sptr<IDLType>& obj, bool asConst)
{
	// Convert IDLType into a C++ type name
	// rec can be NULL if we are writing the type inside the class, otherwise
	// it must point to the owning class (for typedefs)

	SString	cpptype = obj->GetName();

	if (cpptype==NULL) {
		bout << "<----- outpututil.cpp -----> invalid type when converting to CPP;"  << endl;
		_exit(1);
	}
	else {		
		// Binder Types
		// IClass* -> sptr<IClass>
		// [weak] IClass* -> wptr<IClass>
		// (both of these types have the name of "sptr")
		if (cpptype=="sptr") {
			if (obj->HasAttribute(kWeak) == true) {
				cpptype = "wptr";
			}
			InterfaceRec* iface=FindInterface(obj->GetIface());				
			cpptype.Append("<");
			if (iface->ID()== "Binder") { cpptype.Append("I"); }
			cpptype.Append(iface->ID());
			cpptype.Append(">");
			if (asConst) {
				cpptype.Prepend("const ");
				cpptype.Append("&");
			}

		} 
		else if ((cpptype=="SString") || (cpptype=="SValue") || (cpptype=="SMessage")) {
			if (asConst) {
				cpptype.Prepend("const ");
				cpptype.Append("&");
			}
		} 
		else if (cpptype=="char*") {
			if (asConst) {			
				// in the rare case this is a const char*
				cpptype.Prepend("const ");
			}
			else {
				cpptype="SString";
			}
		} 
		else if (cpptype=="void") {
			;	// cpptype is fine as is
		} 
		else {

			// deal with typedefs...
			// If the stored type is different than the object type, then
			// we have a user defined typedef... 
			// add in the class name as a qualifier, because they are defined
			// inside the IClass definition.
			sptr<IDLType> storedtype=FindType(obj);
			if (storedtype->GetName() != obj->GetName() && rec != kInsideClassScope) {
				SString classQualifier = rec->ID();
				classQualifier.Append("::");
				cpptype.Prepend(classQualifier);
			}
			if (asConst) {
				uint32_t code = storedtype->GetCode();
				if (code == B_WILD_TYPE || code == B_VARIABLE_ARRAY_TYPE) {
					// If B_WILD_TYPE then we have an exported type
					// that we really don't know about, or
					// if B_VARIABLE_ARRAY_TYPE, then we have a sequence
					// typedef.  Both of which want const references
					// for input parameters.
					cpptype.Prepend("const ");
					cpptype.Append("&");
				}
			}	
		}
	}

	return cpptype;
}