Example #1
0
bool InstanceConfig :: load(path_t path, Templates* templates)
{
   IniConfigFile config;
   if (_ELENA_::emptystr(path) || !config.load(path, feUTF8)) {
      return false;
   }

   if (templates != NULL) {
      // load template
      IdentifierString projectTemplate(config.getSetting(PROJECT_CATEGORY, PROJECT_TEMPLATE));

      if (!_ELENA_::emptystr(projectTemplate)) {
         Path templatePath;
         Path::loadPath(templatePath, templates->get(projectTemplate));

         load(templatePath, templates);
      }
   }

   _ELENA_::Path configPath;
   configPath.copySubPath(path);

   // init config
   init(configPath, config);

   return true;
}
Example #2
0
void RecentList :: save(IniConfigFile& file, const char* section)
{
   file.clear(section);
   for(List<text_c*>::Iterator it = _list.start() ; !it.Eof() ; it++) {
      file.setSetting(section, _ELENA_::IdentifierString(*it), (const char*)NULL);
   }
}
Example #3
0
// === Main Program ===
int main(int argc, char* argv[])
{
	printf("ELENA command line ByteCode Viewer %d.%d.%d (C)2012-2013 by Alexei Rakov\n\n", ENGINE_MAJOR_VERSION, ENGINE_MINOR_VERSION, BUILD_VERSION);

   if (argc<2) {
      printf("ecv <module name> | ecv -p<module path>");
      return 0;
   }

   // prepare library manager
   const char* configPath = "elc.cfg";
   const char* rootPath = NULL;

   // get viewing module name
   IdentifierString moduleName(argv[1]);

   // load config attributes
   IniConfigFile config;
   if (config.load(Path(configPath), feUTF8)) {
      rootPath = config.getSetting(PROJECT_SECTION, ROOTPATH_OPTION, rootPath);
   }

   LibraryManager loader(Path(rootPath), NULL);
   LoadResult result = lrNotFound;
   _Module* module = NULL;

   // if direct path is provieded
   if (moduleName[0]=='-' && moduleName[1]=='p') {
      moduleName = moduleName + 2;

      Path     path;
      path.copyPath(moduleName);

      FileName name(moduleName);

      loader.setPackage(name, path);
      module = loader.loadModule(name, result, false);
   }
   else module = loader.loadModule(moduleName, result, false);

   if (result != lrSuccessful) {
      printLoadError(result);

      return -1;
   }
   else wprintf(_T("%s module loaded\n"), (const wchar16_t*)moduleName);

   loadVerbs(_verbs);

   runSession(module);

   if (_writer)
      freeobj(_writer);

   return 0;
}
Example #4
0
void InstanceConfig :: init(path_t configPath, IniConfigFile& config)
{
   // compiler options
   //maxThread = config.getIntSetting(SYSTEM_CATEGORY, SYSTEM_MAXTHREAD, maxThread);
   mgSize = config.getIntSetting(LINKER_CATEGORY, LINKER_MGSIZE, mgSize);
   ygSize = config.getIntSetting(LINKER_CATEGORY, LINKER_YGSIZE, ygSize);
   objSize = config.getIntSetting(LINKER_CATEGORY, LINKER_OBJSIZE, objSize);

   const char* path = config.getSetting(LIBRARY_CATEGORY, LIBRARY_PATH, NULL);
   if (!emptystr(path)) {
      libPath.copy(configPath);
      Path::combinePath(libPath, path);
   }

   loadList(config, PRIMITIVE_CATEGORY, configPath, &primitives);
   loadForwardList(config);
}
Example #5
0
bool ELENAMachine::Config :: load(path_t path, Templates* templates)
{
   IniConfigFile config;
   _ELENA_::Path rootPath;

   rootPath.copySubPath(path);

   if (_ELENA_::emptystr(path) || !config.load(path, feUTF8)) {
      return false;
   }

   // load templates
   if (templates) {
      loadList(config, TEMPLATE_CATEGORY, rootPath, templates);
   }

   init(rootPath, config);

   return true;
}
Example #6
0
void InstanceConfig :: loadList(IniConfigFile& config, const char* category, const wchar_t* path, Map<ident_t, ident_c*>* list)
{
   ConfigCategoryIterator it = config.getCategoryIt(category);
   while (!it.Eof()) {
      const char* key = it.key();
      const char* value = (const char*)*it;

      if(emptystr(value))
         value = key;

      // add path if provided
      if (!emptystr(path)) {
         Path filePath(path);
         Path::combinePath(filePath, value);

         list->add(key, IdentifierString::clonePath(filePath));
      }
      else list->add(key, StringHelper::clone(value));

      it++;
   }
}
Example #7
0
void InstanceConfig :: loadForwardList(IniConfigFile& config)
{
   ConfigCategoryIterator it = config.getCategoryIt(FORWARD_CATEGORY);
   while (!it.Eof()) {
      const char* key = it.key();
      const char* value = (const char*)*it;

      // if it is a wildcard
      if (key[getlength(key) - 1] == '*') {
         NamespaceName alias(key);
         NamespaceName module(value);

         moduleForwards.erase(alias);
         moduleForwards.add(alias, StringHelper::clone(module));
      }
      else {
         forwards.erase(key);
         forwards.add(key, StringHelper::clone(value));
      }
      it++;
   }
}
Example #8
0
void RecentList :: load(IniConfigFile& file, const char* section)
{
   for(ConfigCategoryIterator it = file.getCategoryIt(section) ; !it.Eof() ; it++) {
      _list.add(text_str(TextString(it.key())).clone());
   }
}