/* Decide if the dependency identified by item is in a onedir or onfile archive
 * then call the appropriate function.
 */
static int _extract_dependency(ARCHIVE_STATUS *archive_pool[], const char *item)
{
    ARCHIVE_STATUS *status = NULL;
    ARCHIVE_STATUS *archive_status = archive_pool[0];
    char path[PATH_MAX];
    char filename[PATH_MAX];
    char srcpath[PATH_MAX];
    char archive_path[PATH_MAX];

    char dirname[PATH_MAX];

    VS("LOADER: Extracting dependencies\n");
    if (splitName(path, filename, item) == -1)
        return -1;

    pyi_path_dirname(dirname, path);

    /* We need to identify three situations: 1) dependecies are in a onedir archive
     * next to the current onefile archive, 2) dependencies are in a onedir/onefile
     * archive next to the current onedir archive, 3) dependencies are in a onefile
     * archive next to the current onefile archive.
     */
    VS("LOADER: Checking if file exists\n");
    // TODO implement pyi_path_join to accept variable length of arguments for this case.
    if (checkFile(srcpath, "%s%s%s%s%s", archive_status->homepath, PYI_SEPSTR, dirname, PYI_SEPSTR, filename) == 0) {
        VS("LOADER: File %s found, assuming is onedir\n", srcpath);
        if (copyDependencyFromDir(archive_status, srcpath, filename) == -1) {
            FATALERROR("Error coping %s\n", filename);
            return -1;
        }
    // TODO implement pyi_path_join to accept variable length of arguments for this case.
    } else if (checkFile(srcpath, "%s%s%s%s%s%s%s", archive_status->homepath, PYI_SEPSTR, "..", PYI_SEPSTR, dirname, PYI_SEPSTR, filename) == 0) {
        VS("LOADER: File %s found, assuming is onedir\n", srcpath);
        if (copyDependencyFromDir(archive_status, srcpath, filename) == -1) {
            FATALERROR("Error coping %s\n", filename);
            return -1;
        }
    } else {
        VS("LOADER: File %s not found, assuming is onefile.\n", srcpath);
        // TODO implement pyi_path_join to accept variable length of arguments for this case.
        if ((checkFile(archive_path, "%s%s%s.pkg", archive_status->homepath, PYI_SEPSTR, path) != 0) &&
            (checkFile(archive_path, "%s%s%s.exe", archive_status->homepath, PYI_SEPSTR, path) != 0) &&
            (checkFile(archive_path, "%s%s%s", archive_status->homepath, PYI_SEPSTR, path) != 0)) {
            FATALERROR("Archive not found: %s\n", archive_path);
            return -1;
        }

        if ((status = _get_archive(archive_pool, archive_path)) == NULL) {
            FATALERROR("Archive not found: %s\n", archive_path);
            return -1;
        }
        if (extractDependencyFromArchive(status, filename) == -1) {
            FATALERROR("Error extracting %s\n", filename);
            free(status);
            return -1;
        }
    }

    return 0;
}
Esempio n. 2
0
static iface::cellml_api::CellMLVariable* findLocalVariable(iface::cellml_api::Model* model,const char* name)
{
  iface::cellml_api::CellMLVariable* v = NULL;
  // find named variable - in local components only!
  CVpair cv = splitName(name);
  RETURN_INTO_OBJREF(components,iface::cellml_api::CellMLComponentSet,model->localComponents());
  RETURN_INTO_WSTRING(cname,string2wstring(cv.first.c_str()));
  RETURN_INTO_OBJREF(component,iface::cellml_api::CellMLComponent,components->getComponent(cname.c_str()));
  if (!component)
  {
    std::cerr << "CellMLModelDefinition::findLocalVariable -- unable to find component: " << cv.first.c_str() << std::endl;
    return NULL;
  }
  RETURN_INTO_OBJREF(variables,iface::cellml_api::CellMLVariableSet,component->variables());
  RETURN_INTO_WSTRING(vname,string2wstring(cv.second.c_str()));
  RETURN_INTO_OBJREF(variable,iface::cellml_api::CellMLVariable,variables->getVariable(vname.c_str()));
  if (!variable)
  {
    std::cerr << "CellMLModelDefinition::findLocalVariable -- unable to find variable: " << cv.first.c_str() << " / "
        << cv.second.c_str() << std::endl;
    return NULL;
  }
  // get source variable
  v = variable->sourceVariable();
  if (!v)
  {
    std::cerr << "CellMLModelDefinition::findLocalVariable -- unable get source variable for variable: "
        << cv.first.c_str() << " / " << cv.second.c_str() << std::endl;
    return NULL;
  }
  return v;
}
Esempio n. 3
0
static void splitArchivedFileName(const char *fullName, StringAttr &container, StringAttr &option, StringAttr &relPath)
{
    const char *tail = splitName(fullName);
    assertex(tail);
    size_t containerLen = tail-fullName;
    if (fullName[containerLen-1]==PATHSEPCHAR)
        containerLen--;
    container.set(fullName, containerLen);
    if (*tail=='{')
    {
        tail++;
        const char *end = strchr(tail, '}');
        if (!end)
            throw MakeStringException(0, "Invalid archive-embedded filename - no matching } found");
        option.set(tail, end - tail);
        tail = end+1;
        if (*tail==PATHSEPCHAR)
            tail++;
        else if (*tail != 0)
            throw MakeStringException(0, "Invalid archive-embedded filename - " PATHSEPSTR " expected after }");
    }
    else
        option.clear();
    if (tail && *tail)
    {
        StringBuffer s(tail);
        s.replace(PATHSEPCHAR, '/');
        relPath.set(s);
    }
    else
        relPath.clear();
}
static void XMLCALL startElementHandler(void* userData, const char* name, const char** attrs) {
    XML_Parser parser = reinterpret_cast<XML_Parser>(userData);
    Stack* stack = reinterpret_cast<Stack*>(XML_GetUserData(parser));

    std::unique_ptr<Element> el = util::make_unique<Element>();
    splitName(name, &el->namespaceUri, &el->name);

    while (*attrs) {
        Attribute attribute;
        splitName(*attrs++, &attribute.namespaceUri, &attribute.name);
        attribute.value = util::utf8ToUtf16(*attrs++);

        // Insert in sorted order.
        auto iter = std::lower_bound(el->attributes.begin(), el->attributes.end(), attribute,
                                     lessAttribute);
        el->attributes.insert(iter, std::move(attribute));
    }

    el->comment = std::move(stack->pendingComment);
    addToStack(stack, parser, std::move(el));
}
Esempio n. 5
0
void Folder::addChild(string name, int& id)
{
	Node *temp_node;
	string first, last;

	temp_node = lookupID(name);

	if (splitName(name, first, last) && temp_node != NULL)
	{
		if (temp_node->numberOfChildren == 0) //first child
		{
			temp_node->numberOfChildren++;

			temp_node->child = new string *[1];
			temp_node->child[0] = new string[2];

			temp_node->child[0][0] = first;
			temp_node->child[0][1] = last;
		}

		else
		{
			temp_node->numberOfChildren++;

			string **temp = new string* [temp_node->numberOfChildren]; //create temporary multidimensional dynamically allocated array of size numberOfChildren

			for (int i = 0; i < temp_node->numberOfChildren - 1; ++i) //populate array with old data
			{
				temp[i] = new string[2];

				temp[i][0] = temp_node->child[i][0];
				temp[i][1] = temp_node->child[i][1];

				delete[] temp_node->child[i];
			}
			delete temp_node->child; //delete old child array

			temp[temp_node->numberOfChildren - 1] = new string[2]; //assign new child to last array position
			temp[temp_node->numberOfChildren - 1][0] = first;
			temp[temp_node->numberOfChildren - 1][1] = last;

			temp_node->child = temp; //assign temp memory address to node
		}
		addName(true, true, name, "", id);
		cout << "ADDED: " << name << " UID: ID" << setw(3) << setfill('0') << temp_node->id << " <as child>" << endl;
	}
}
void* configParserStruct::pythonParser::finalClassPyobject( const std::string &Name ) const
{
  if ( Dictionary == NULL )
    return NULL;

  PyObject *Object = castToPyObject(Dictionary);
  const std::list<std::string> &NameFields = splitName(Name);

  for ( std::list<std::string>::const_iterator Field = NameFields.begin(); Field != NameFields.end(); ++Field )
  {
    Object = ( Object == Dictionary ? PyDict_GetItemString : PyObject_GetAttrString )( Object, Field->c_str() );
    //std::cout << "Field = " << *Field << " Object = " << Object << std::endl;
    if ( Object == NULL )
      break;
  }
  return Object;
}
Esempio n. 7
0
void Folder::addSpouse(string name, int& id) //working
{
	Node *temp_node;
	string first, last;

	temp_node = lookupID(name);

	if (splitName(name, first, last))
		if (temp_node != NULL)
		{
			temp_node->spouse[0] = first;
			temp_node->spouse[1] = last;

			addName(true, false, name, temp_node->name[0] + ' ' + temp_node->name[1], id);

			cout << "ADDED: " << name << " UID: ID" << setw(3) << setfill('0') << temp_node->id << " <as spouse>" << endl;
		}
}
Esempio n. 8
0
void DownloadTask::start()
{
	Q_ASSERT(state_ != Unvalid);
	state_ = Start;

	if (name_.isEmpty())
	{
		splitName();
	}
	
	QNetworkRequest request(url_);
	QString range("bytes=%1-");
	range = range.arg(progress_);
	request.setRawHeader("Range", range.toAscii());
	QNetworkReply *reply = networkMgr_->get(request);
	connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(onDownloadProgress(qint64, qint64)));
	connect(reply, SIGNAL(finished()), this, SLOT(onFinished()));
	connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
	speedTest_.lastMSecsSinceEpoch_ = QDateTime::currentMSecsSinceEpoch();
}
Esempio n. 9
0
void DownloadTask::init(const QString &savePath, const QString &url, QNetworkAccessManager *netMgr)
{
	Q_ASSERT(state_ == Unvalid);
	path_ = savePath;
	url_ = url;
	networkMgr_ = netMgr;
	splitName();
	infoFile_.setFileName(infoFileFullName());
	if (!infoFile_.open(QFile::ReadWrite))
	{
		qDebug() << QString(__FUNCTION__) << " " << __LINE__ << " error : " << infoFile_.error();
		return;
	}
	if (infoFile_.size() != 0)
	{
		infoFile_.read((char*)&size_, sizeof(size_));
		infoFile_.read((char*)&progress_, sizeof(progress_));
	}
	state_ = Init;
	emit inited();
}
Esempio n. 10
0
ObjRef<iface::cellml_api::CellMLVariable> findLocalVariable(CellmlApiObjects* capi, const std::string& variableId)
{
    if (!(capi->cevas))
    {
        std::cerr << "CellMLModelDefinition::findLocalVariable -- missing CeVAS object?" << std::endl;
        return NULL;
    }
    // find named variable - in local components only!
    CVpair cv = splitName(variableId);
    if ((cv.first.length() == 0) || (cv.second.length() == 0)) return NULL;
    //std::cout << "Component name: " << cv.first << "; variable name: " << cv.second << std::endl;
    ObjRef<iface::cellml_api::CellMLComponentSet> components = capi->model->localComponents();
    ObjRef<iface::cellml_api::CellMLComponent> component = components->getComponent(s2ws(cv.first));
    if (!component)
    {
        std::cerr << "CellMLModelDefinition::findLocalVariable -- unable to find local component: " << cv.first << std::endl;
        return NULL;
    }
    ObjRef<iface::cellml_api::CellMLVariableSet> variables = component->variables();
    ObjRef<iface::cellml_api::CellMLVariable> variable = variables->getVariable(s2ws(cv.second));
    if (!variable)
    {
        std::cerr << "CellMLModelDefinition::findLocalVariable -- unable to find variable: " << cv.first << " / "
                  << cv.second << std::endl;
        return NULL;
    }
    // get source variable
    ObjRef<iface::cellml_services::ConnectedVariableSet> cvs = capi->cevas->findVariableSet(variable);
    ObjRef<iface::cellml_api::CellMLVariable> v = cvs->sourceVariable();
    if (!v)
    {
        std::cerr << "CellMLModelDefinition::findLocalVariable -- unable get source variable for variable: "
                  << cv.first << " / " << cv.second << std::endl;
        return NULL;
    }
    return v;
}
Esempio n. 11
0
SessionHelper::MatchMap SessionHelper::getMatchMap(const std::vector<std::string> &patternList, ShPatternResolver patternResolver, bool hidden)
{
  MatchMap matchMap;

  for (unsigned int i = 0; i < patternList.size(); ++i)
  {
    std::string servicePattern;
    std::string memberPattern;

    splitName(patternList[i], servicePattern, memberPattern, true);
    std::list<std::string> matchingServices = getMatchingServices(servicePattern, hidden);

    for(const std::string &it: matchingServices)
    {
      if (!matchMap.count(it))
        matchMap[it].first = getServiceHelper(it);

      std::pair<ServiceHelper, std::set<std::string> > &matchPair = matchMap[it];
      std::list<std::string> matchingMembers = (matchPair.first.*patternResolver)(memberPattern, hidden);
      matchMap[it].second.insert(matchingMembers.begin(), matchingMembers.end());
    }
  }
  return matchMap;
}
Esempio n. 12
0
/* Decide if the dependency identified by item is in a onedir or onfile archive
 * then call the appropriate function.
 */
static int extractDependency(ARCHIVE_STATUS *status_list[], const char *item)
{
    ARCHIVE_STATUS *status = NULL;
    char path[_MAX_PATH + 1];
    char filename[_MAX_PATH + 1];
    char srcpath[_MAX_PATH + 1];
    char archive_path[_MAX_PATH + 1];

    char *dirname = NULL;

    VS("Extracting dependencies\n");
    if (splitName(path, filename, item) == -1)
        return -1;

    dirname = dirName(path);
    if (dirname[0] == 0) {
        free(dirname);
        return -1;
    }

    /* We need to identify three situations: 1) dependecies are in a onedir archive
     * next to the current onefile archive, 2) dependencies are in a onedir/onefile
     * archive next to the current onedir archive, 3) dependencies are in a onefile
     * archive next to the current onefile archive.
     */
    VS("Checking if file exists\n");
    if (checkFile(srcpath, "%s/%s/%s", status_list[SELF]->homepath, dirname, filename) == 0) {
        VS("File %s found, assuming is onedir\n", srcpath);
        if (copyDependencyFromDir(status_list[SELF], srcpath, filename) == -1) {
            FATALERROR("Error coping %s\n", filename);
            free(dirname);
            return -1;
        }
    } else if (checkFile(srcpath, "%s../%s/%s", status_list[SELF]->homepath, dirname, filename) == 0) {
        VS("File %s found, assuming is onedir\n", srcpath);
        if (copyDependencyFromDir(status_list[SELF], srcpath, filename) == -1) {
            FATALERROR("Error coping %s\n", filename);
            free(dirname);
            return -1;
        }
    } else {
        VS("File %s not found, assuming is onefile.\n", srcpath);
        if ((checkFile(archive_path, "%s%s.pkg", status_list[SELF]->homepath, path) != 0) &&
            (checkFile(archive_path, "%s%s.exe", status_list[SELF]->homepath, path) != 0) &&
            (checkFile(archive_path, "%s%s", status_list[SELF]->homepath, path) != 0)) {
            FATALERROR("Archive not found: %s\n", archive_path);
            return -1;
        }

        if ((status = get_archive(status_list, archive_path)) == NULL) {
            FATALERROR("Archive not found: %s\n", archive_path);
            return -1;
        }
        if (extractDependencyFromArchive(status, filename) == -1) {
            FATALERROR("Error extracting %s\n", filename);
            free(status);
            return -1;
        }
    }
    free(dirname);

    return 0;
}
Esempio n. 13
0
int main( int argc, char **argv ){
    
    B3_MSTPNetwork b3_mstpnetwork;
    IO_Folder io_Folder;
    char *  filename =argv[1];
    RowHolder row;
    TiXmlDocument doc(filename);
    if(doc.LoadFile())
    {
        TiXmlHandle hDoc(&doc);
        TiXmlElement* pElem, *pTable,*pCell, *pData;
        int i,j,k =0;
        bool input = false;
        pElem = hDoc.FirstChild("Workbook").Child("Worksheet", 0).ToElement();
        for( pElem; pElem; pElem=pElem->NextSiblingElement() )
        {
            //cout<<(pElem->Attribute("ss:Name"))<<"\n";
            i=0; // keeps track of the row
            char * type = splitName(pElem->Attribute("ss:Name"));
            //splits name to find IO module type io16, ao8...
            //if the type is a valid IO module type then the parsing continues
            //otherwise the entire worksheet is considered irrelevant
            
            if(type && ( (strcmp(controllerType(type), "cIO")== 0)||(strcmp(controllerType(type), "b3")== 0))){
                int slot = splitSlot(pElem->Attribute("ss:Name")); //split name to retrieve slot number
                char * charStarName = strdup(pElem->Attribute("ss:Name"));
                IO_Module *module = new IO_Module(getName(charStarName)); //create new module with correct name
                B3_Controller *b3_controller = new B3_Controller(strtok (charStarName,"-"));
                if((strcmp(controllerType(type), "b3")== 0)){
                    k++;
                }
                else{
                    //getName(pElem->Attribute("ss:Name"));
                    
                }
                pTable =pElem->FirstChildElement("Table")->FirstChildElement("Row")->ToElement(); // get first row
                for( (pTable); pTable; pTable=pTable->NextSiblingElement() ){
                    //iterate through all rows
                    pCell=pTable->FirstChildElement("Cell")->ToElement();
                    i++;
                    j = 0;
                    
                    if(i>10)
                        input = false; // all points start after line 10 so infgormation prior to line 11 is ignored
                    for( pCell; pCell; pCell=pCell->NextSiblingElement() ){
                        j++; //keeps track of columns
                        pData =pCell->FirstChildElement("Data"); //text is stored in data element. not cell elements have data child
                        if(pData){
                            if(pData->ToElement()->GetText()) //get data text
                                //iterate through all other cells in that row and extract the information
                                if(i >=11 && j == 1 && strcmp (pCell->Attribute("ss:Index"),"2") == 0){
                                    row.update(strdup(pData->ToElement()->GetText()), j); // store the information in row object
                                }
                                else {
                                    if(i>=11 &&row.getPoint()){
                                        row.update(strdup(pData->ToElement()->GetText()), j);
                                    }
                                    else{
                                        
                                    }
                                }
                        }
                    }
                    
                    if(row.getColumns()>1 && (strcmp(controllerType(type), "cIO") == 0)){
                        int channelTempcIO =atoi(&row.getPoint()[2]);
                        module->addPoint(row.createPoint(), channelTempcIO); //save the data from the row in the IO module object as a point
                        //cout<<type<<"\n";
                        module->setType(type);
                        io_Folder.addModule(module, slot); //add the module to the IO Folder object

                    }
                    else if ((row.getColumns()>1 && (strcmp(controllerType(type), "b3") == 0))){
                        int channelTempcb3 =atoi(&row.getPoint()[2]);
                        char* pointype = row.getPoint();
                        pointype[2] = '\0';
                        if((strcmp(pointype, "IN") == 0)){
                            b3_controller->addInput(row.b3createPoint(channelTempcb3), channelTempcb3);}
                        else{
                            b3_controller-> addOutput(row.b3createPoint(channelTempcb3), channelTempcb3);
                        }
                        b3_controller->setType(type);
                        b3_mstpnetwork.addController(b3_controller,k); //add the module to the IO Folder object

                    }
                    row.clear(); // clear the row object completely so it can be reused for the next row of data
                    
                    
                    
                }
            }
        }
    }
    
    int PrintB3 = 0;
    int PrintIO = 0;
    for(int i;i<argc;i++){
        if (argv[i]) {
            if(strcmp(argv[i], "IO") == 0) PrintIO = 1;
        }
        if (argv[i]) {
            if(strcmp(argv[i], "B3") == 0) PrintB3 = 1;
        }
    }
    static char B3[LOGNAME_SIZE];
    static char IO[LOGNAME_SIZE];
    time_t now = time(0);
    strftime(B3, sizeof(B3), LOGNAME_FORMAT_B3, localtime(&now));
    strftime(IO, sizeof(IO), LOGNAME_FORMAT_IO, localtime(&now));

    //cout<<IO<<"\n";

    if (PrintIO) {
        FILE* file;
        file = freopen(IO,"w",stdout);
        io_Folder.writeSelf(); // write complete xml of all points stored in all IO_Modules
        fclose(file);

    }
    if (PrintB3) {
        FILE* file;
        file = freopen(B3,"w",stdout);
        b3_mstpnetwork.writeSelf();
        //fclose(stdout);
        fclose(file);
    }

        //freopen("outputb3.xml","w",stdout);
    //b3_mstpnetwork.writeSelf();
    return 0;
};
Esempio n. 14
0
Method& Namespace::getItem_<Method>(const string& name)
{
    pair<string, string> nameParts = splitName(name, NameTail);
    const Class* clazz = dynamic_cast<Class*>(this);
    return getItem_(nameParts.first, Method(nameParts.second, *clazz));
}
ChannelAlias*
ChannelContext::getChannelAlias (const char* name)
{
    if (!name || !name[0])
        return NULL; // don't crash!

    // Does alias already exist?
    ChannelAlias* chan = findChannelAlias(name);
    if (chan)
        return chan;

    // Not found, see if name can be split into separate layer/chan strings:
    std::string layer_name, chan_name;
    splitName(name, layer_name, chan_name);

    ChannelIdx channel = Chan_Invalid;
    int position = 0;

    // Does channel string corresponds to any standard ones? If so we
    // can determine the 'kind' of channel:
    std::string    std_layer_name = "";
    std::string    std_chan_name  = "";
    std::string    std_io_name    = "";
    Imf::PixelType std_io_type    = Imf::HALF;
    if (matchStandardChannel(chan_name.c_str(),
                             std_layer_name,
                             std_chan_name,
                             channel,
                             std_io_name,
                             std_io_type))
    {
        // Channel name matches one of the standard ones, so
        // get it's layer position:
        position = getLayerPositionFromKind(channel);
        // Update layer name if it's empty:
        // TODO: don't think we need to do this - we should
        //      handle channel names without layer prefixes!
        if (layer_name.empty())
            layer_name = std_layer_name;
        // TODO: change chan_name to match the standard name?  No, we
        //    probably want to add two ChannelAlias, one with the
        //    provided name and one with the std name.
        //chan_name = std_chan_name;
    }
    else
    {
        // Channel string unrecognized, this is a custom channel
        // so default to 'other' if there's no layer in name:
        // TODO: don't think we need to do this - we should
        //      handle channel names without layer prefixes!
        if (layer_name.empty())
            layer_name = "other";
    }

    // Does the full name now match any existing aliases?
    if (!layer_name.empty())
    {
        std::string full_name = layer_name + "." + chan_name;
        chan = findChannelAlias(full_name);
        if (chan)
            return chan;
    }

    // Create new alias, and possibly a new layer. If channel is still Chan_Invalid
    // it will get assigned the next available channel slot when added to context:
    chan = addChannelAlias(chan_name,
                           layer_name,
                           channel,
                           position,
                           std_io_name,
                           std_io_type,
                           0/*io_part*/);
    if (!chan)
        return NULL; // shouldn't happen...

    ChanOrder chan_order;
    chan_order.channel = chan->channel();
    chan_order.order   = chan->layerPosition();

    LayerNameToListMap::iterator it = m_layer_name_map.find(layer_name);
    if (it == m_layer_name_map.end())
    {
        m_layers.push_back(Layer());
        Layer& new_layer = m_layers[m_layers.size()-1];
        new_layer.name = layer_name;
        new_layer.channels.push_back(chan_order);
        m_layer_name_map[layer_name] = m_layers.size()-1;
    }
    else
    {
        m_layers[it->second].channels.push_back(chan_order);
    }

    return chan;
}
Esempio n. 16
0
/**
* Synchronizes one element of a DFM tree with an element of a VMT tree.
* @param classname Class of the element the property belongs to.
* @param value Name of value of a property.
* @param vmtdir VMT tree.
* @param dfmres DFM tree.
**/
void synchronizePropertyValue(const std::string& classname, std::vector<std::string*>& value, const VMTDir& vmtdir, const DFMData& dfmres)
{
	splitName(value);
	
	VMT* vmt = handleCollections(find<FindByName>(vmtdir, classname), vmtdir);
	if (!vmt) return;

	for (unsigned int i=0;i<value.size();++i)
	{
		if (!value[i]->size()) continue;
		
		VMT* vmt2;
		if (vmt2 = findVMT<FindByPropertyName>(vmt, *value[i]))
		{
			std::string* y = getVMTAttribute(vmt2->typeinfo, *value[i]);
			if (!y) break;
			delete value[i];
			value[i] = y;

			std::string* x = getAttributeType(vmt2, *value[i], vmtdir);
			if (!x) break;

			// Special handling. Figure out a better way.
			if (*x == "TCustomActionBarColorMap")
			{
				x = new std::string("TXPColorMap");
			}

			vmt2 = find<FindByName>(vmtdir, *x);
			if (!vmt2) break;
		}
		else if (vmt2 = findVMT<FindByMethodName>(vmt, *value[i]))
		{
			std::string* x = getValue(vmt2->methods, *value[i], true);
			delete value[i];
			value[i] = x;
		}
		else if (vmt2 = findVMT<FindByFieldName>(vmt, *value[i]))
		{
			std::string* x = getValue(vmt2->fields, *value[i]);
			delete value[i];
			value[i] = x;
		}
		else if (DFMResource* res = find<FindByName>(dfmres, *value[i]))
		{
			delete value[i];
			value[i] = res->name;
			vmt2 = find<FindByName>(vmtdir, *res->classname);
		}
		else if (vmt2 = find<FindByName>(vmtdir, *value[i]))
		{
			// This last if-branch is required for bitmaps.
			// value[i] should be TBitmap or TIcon here.
			delete value[i];
			value[i] = vmt2->name;
		}
		else
		{
//			std::cout << "Couldn't find " << *value[i] << std::endl;
		}
		
		vmt = vmt2;
		
		if (!vmt) break;
	}
}
Esempio n. 17
0
Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& alreadyVisited) const
{
    Symbol* pSymbol = 0;

    if (name.empty())
        return pSymbol;

    if (alreadyVisited.find(this) != alreadyVisited.end())
        return pSymbol;
    std::string head;
    std::string tail;
    splitName(name, head, tail);

    alreadyVisited.insert(this);
    bool currentNSInserted = true;


    if (head.empty())
    {
        alreadyVisited.insert(this);
        return root()->lookup(tail, alreadyVisited);
    }
    SymbolTable::const_iterator it = _symbols.find(head);
    if (it != _symbols.end())
    {
        pSymbol = it->second;
        if (!tail.empty())
        {
            alreadyVisited.insert(this);
            NameSpace* pNS = dynamic_cast<NameSpace*>(pSymbol);
            if (pNS)
                pSymbol = static_cast<NameSpace*>(pSymbol)->lookup(tail, alreadyVisited);
            else
                pSymbol = 0;
        }
    }
    else if (tail.empty())
    {
        AliasMap::const_iterator itAlias = _importedSymbols.find(head);
        if (itAlias != _importedSymbols.end())
            pSymbol = lookup(itAlias->second, alreadyVisited);
        else
        {
            for (NameSpaceVec::const_iterator it = _importedNameSpaces.begin(); !pSymbol && it != _importedNameSpaces.end(); ++it)
            {
                Symbol* pNS = lookup(*it, alreadyVisited);
                if (pNS && pNS->kind() == Symbol::SYM_NAMESPACE)
                {
                    pSymbol = static_cast<NameSpace*>(pNS)->lookup(name, alreadyVisited);
                }
            }
        }
    }
    NameSpace* pNS = nameSpace();
    if (!pSymbol && pNS && (alreadyVisited.find(pNS) == alreadyVisited.end()))
    {
        // if we have to go up, never push the NS!
        if (currentNSInserted)
            alreadyVisited.erase(this);
        pSymbol = nameSpace()->lookup(name, alreadyVisited);
    }
    return pSymbol;
}