Example #1
0
bool D2Container::parseDir(wchar_t const* path, D2Data* d2data)
{
  if (!path) return false;
  items.clear();
  WIN32_FIND_DATA data;
  HANDLE hFind = FindFirstFile(WideString::buildFullName(path, L"*"), &data);
  if (hFind == INVALID_HANDLE_VALUE)
    return false;
  Array<D2Container*> newSub;
  bool changes = false;
  do
  {
    if (!wcscmp(data.cFileName, L".") || !wcscmp(data.cFileName, L".."))
      continue;
    if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
    {
      D2Container* cur = find(data.cFileName);
      if (!cur)
      {
        cur = new D2Container(data.cFileName, this);
        newSub.push(cur);
      }
      if (cur->parseDir(WideString::buildFullName(path, data.cFileName), d2data))
        changes = true;
    }
    else if (!WideString::getExtension(data.cFileName).icompare(L".txt"))
    {
      WideString curName(WideString::getFileTitle(data.cFileName));
      D2Container* cur = find(curName);
      if (!cur)
      {
        cur = new D2Container(curName, this);
        newSub.push(cur);
      }
      if (cur->parseFile(WideString::buildFullName(path, data.cFileName), d2data))
        changes = true;
    }
  } while (FindNextFile(hFind, &data));
  FindClose(hFind);
  sub.append(newSub);
  sub.sort(compare);
  return changes;
}
Example #2
0
Array RandomSet::to_a() {
  Array array;
  
  std::vector<int>::iterator it;
  for(it = this->elements.begin(); it != this->elements.end(); it++) {
    array.push(*it);
  }
  
  return array;
}
Example #3
0
void ColorTransform_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("alphaMultiplier"));
	outFields->push(HX_CSTRING("alphaOffset"));
	outFields->push(HX_CSTRING("blueMultiplier"));
	outFields->push(HX_CSTRING("blueOffset"));
	outFields->push(HX_CSTRING("greenMultiplier"));
	outFields->push(HX_CSTRING("greenOffset"));
	outFields->push(HX_CSTRING("redMultiplier"));
	outFields->push(HX_CSTRING("redOffset"));
	super::__GetFields(outFields);
};
Example #4
0
bool AuxPathFinder::find (Array<int>& vertices, Array<int>& edges, int u, int v)
{
   // init
   _queue.clear();
   _prev.fffill();
   vertices.clear();
   edges.clear();

   // push initial vertex
   _queue.push(v);
   _prev[v] = u;

   while (!_queue.isEmpty())
   {
      // pop vertex
      int w = _queue.pop();

      const Vertex& vert = _graph.getVertexAndBuild(w);
      for (int i = vert.neiBegin(); i < vert.neiEnd(); i = vert.neiNext(i))
      {
         int n = vert.neiVertex(i);
         if (_prev[n] >= 0)
            continue; // vertex is already done

         if (n == u)
         {
            // shortest path found. mark and return
            _prev[u] = w;
            for (int j = u; j != v; j = _prev[j])
            {
               vertices.push(j);
               edges.push(_graph.findEdgeIndex(j, _prev[j]));
            }
            vertices.push(v);
            return true;
         }

         _queue.push(n);
         _prev[n] = w;
      }
   }
   return false;
}
Example #5
0
void __hxcpp_dbg_getScriptableFiles( Array< ::String> ioPaths )
{
   Array<String> merge = hx::gAllFiles;
   if (merge.mPtr)
      for(int i=0;i< merge->length; i++)
      {
         if (ioPaths->indexOf( merge[i] ) < 0)
            ioPaths->push( merge[i] );
      }
}
Example #6
0
int line_to( const FT_Vector*  to, void* user)
{
    Line l;
    l[0] = cursor;
    cursor.set(to->x/64., to->y/64.);
    l[1] = cursor;

    std::swap(l[0], l[1]);
    lines.push(l);
    return 0;
}
void MoleculeSubstructureMatcher::makeTransposition (BaseMolecule &mol, Array<int> &transposition_out)
{
   int i;

   transposition_out.clear();

   for (i = mol.vertexBegin(); i < mol.vertexEnd(); i = mol.vertexNext(i))
      transposition_out.push(i);

   transposition_out.qsort(_compare, &mol);
}
void FolderWindow::getSelList(Array<String>& sel)
{
    for (int cur = ListView_GetNextItem(list->getHandle(), -1, LVNI_SELECTED);
            cur >= 0; cur = ListView_GetNextItem(list->getHandle(), cur, LVNI_SELECTED))
    {
        int pos = list->getItemParam(cur);
        if (pos >= 0 && pos < items.length() &&
                (items[pos].type == ITEM_FOLDER || items[pos].type == ITEM_REPLAY))
            sel.push(items[pos].path);
    }
}
Example #9
0
Array to_a(Polygon_set_2 S){
	Array ps;	
	list<Polygon_with_holes_2> res;
  list<Polygon_with_holes_2>::const_iterator it;
	S.polygons_with_holes (back_inserter (res));
  for (it = res.begin(); it != res.end(); ++it){
		Polygon_with_holes_2 pwh = *it;
		ps.push(pwh);
  }
	return ps;
}
Example #10
0
File: Sys.cpp Project: vroad/hxcpp
/**
   sys_env : void -> #list
   <doc>Return all the (key,value) pairs in the environment as a chained list</doc>
**/
Array<String> _hx_std_sys_env()
{
   Array<String> result = Array_obj<String>::__new();
   #ifndef HX_WINRT
   char **e = environ;
   while( *e )
   {
      char *x = strchr(*e,'=');
      if( x == NULL )
      {
         e++;
         continue;
      }
      result->push(String(*e,(int)(x-*e)).dup());
      result->push(String(x+1));
      e++;
   }
   #endif
   return result;
}
Example #11
0
void addScriptableFile(String inName)
{
   #ifdef HXCPP_DEBUGGER
   if (!gAllFiles.mPtr)
   {
      gAllFiles = Array_obj<Dynamic>::__new();
      GCAddRoot( (hx::Object **)&gAllFiles.mPtr );
   }
   if (gAllFiles->indexOf(inName)<0)
      gAllFiles->push(inName);
   #endif
}
Example #12
0
void NounShip::initializeGadgets()
{
	m_JumpDrive = NULL;
	m_Gadgets.release();
	m_Shields.release();
	m_Armor.release();

	// make a list of all child objects first, sort them into the gadgets array sorted by type
	Array< NounGadget * > gadgets;
	for(int i=0;i<childCount();i++)
	{
		BaseNode * pChild = child(i);
		if ( WidgetCast<NounGadget>( pChild ) != NULL )
		{
			NounGadget * pGadget = (NounGadget *)pChild;

			// set the gadget level
			pGadget->setLevel( gadgetLevel() );

			if ( WidgetCast<GadgetJumpDrive>( pGadget ) )
			{
				m_JumpDrive = (GadgetJumpDrive *)pGadget;
			}
			else if ( WidgetCast<GadgetShield>( pGadget ) )
			{
				m_Shields.push( (GadgetShield *)pGadget );
				// set the shield modifier
				((GadgetShield *)pGadget)->setModifier( shieldModifier() );
			}
			else if ( WidgetCast<GadgetArmor>( pGadget ) )
			{
				m_Armor.push( (GadgetArmor *)pGadget );
				// set the armor modifier
				((GadgetArmor *)pGadget)->setModifier( armorModifier() );
			}

			bool bInserted = false;
			for(int k=0;k<gadgets.size() && !bInserted;k++)
				if ( energyClassPriority( pGadget->energyClass() ) < energyClassPriority( gadgets[k]->energyClass() ) )
				{
					bInserted = true;
					gadgets.insert( k, pGadget );
				}

			if (! bInserted )
				gadgets.push( pGadget );
		}
	}

	// now push all gadgets in order of energy priority level..
	for(int i=0;i<gadgets.size();i++)
		m_Gadgets.push( gadgets[ i ] );
}
Example #13
0
Object model_rank_text(Object self, Object text) {
  Model::Model *model = from_ruby<Model::Model *>(self);
  string example_text = from_ruby<string>(text);
  Array indexes;
  
  vector<Classifier::Score> *ranks = model->rank_text(example_text);
  for(unsigned int i = 0; i < ranks->size(); i++)
    indexes.push(ranks->at(i).category);

  delete ranks;
  return indexes;
}
Example #14
0
int conic_to( const FT_Vector*  ctrl,  const FT_Vector*  to, void* user)
{
    Bez2 l;
    l[0] = cursor;
    l[1].set(ctrl->x/64., ctrl->y/64.);
    cursor.set(to->x/64., to->y/64.);
    l[2] = cursor;

    std::swap(l[0], l[2]);
    bez2s.push(l);
    return 0;
}
Example #15
0
Object model_rank(Object self, Object ex) {
  Model::Model *model = from_ruby<Model::Model *>(self);
  DataSet::Example *example = from_ruby<DataSet::Example *>(ex);
  Array indexes;
  
  vector<Classifier::Score> *ranks = model->rank(example);
  for(unsigned int i = 0; i < ranks->size(); i++)
    indexes.push(ranks->at(i).category);

  delete ranks;
  return indexes;
}
Example #16
0
void TmxObjectGroup_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_HCSTRING("map","\x9c","\x0a","\x53","\x00"));
	outFields->push(HX_HCSTRING("name","\x4b","\x72","\xff","\x48"));
	outFields->push(HX_HCSTRING("x","\x78","\x00","\x00","\x00"));
	outFields->push(HX_HCSTRING("y","\x79","\x00","\x00","\x00"));
	outFields->push(HX_HCSTRING("width","\x06","\xb6","\x62","\xca"));
	outFields->push(HX_HCSTRING("height","\xe7","\x07","\x4c","\x02"));
	outFields->push(HX_HCSTRING("opacity","\xcb","\x5d","\x65","\xeb"));
	outFields->push(HX_HCSTRING("visible","\x72","\x78","\x24","\xa3"));
	outFields->push(HX_HCSTRING("properties","\xf3","\xfb","\x0e","\x61"));
	outFields->push(HX_HCSTRING("objects","\xd4","\x68","\x4f","\x82"));
	super::__GetFields(outFields);
};
Example #17
0
static int findStat(Array<D2ItemStat>& stats, D2Stat* stat, int param = 0, bool add = false)
{
  for (int i = 0; i < stats.length(); i++)
    if (stats[i].stat == stat && (param < 0 || stats[i].param == param ||
        stat->descfunc == 34 || stat->descfunc == 33 || (stat->descfunc >= 6 && stat->descfunc <= 9)))
      return i;
  if (!add) return -1;
  D2ItemStat& res = stats.push();
  res.stat = stat;
  res.param = param;
  res.value1 = res.value2 = 0;
  return stats.length() - 1;
}
Example #18
0
void ID3Info_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_HCSTRING("album","\x2f","\x13","\x8c","\x21"));
	outFields->push(HX_HCSTRING("artist","\xc7","\xf2","\x48","\xb9"));
	outFields->push(HX_HCSTRING("comment","\x5f","\x7a","\x70","\x81"));
	outFields->push(HX_HCSTRING("genre","\x43","\x28","\x5c","\x91"));
	outFields->push(HX_HCSTRING("songName","\xc0","\xd0","\xd7","\x36"));
	outFields->push(HX_HCSTRING("track","\x8b","\x8e","\x1f","\x16"));
	outFields->push(HX_HCSTRING("year","\xbd","\xc9","\x47","\x50"));
	super::__GetFields(outFields);
};
Example #19
0
void LevelFailedUI_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("background"));
	outFields->push(HX_CSTRING("title"));
	outFields->push(HX_CSTRING("menuButton"));
	outFields->push(HX_CSTRING("retryButton"));
	outFields->push(HX_CSTRING("hitButton"));
	outFields->push(HX_CSTRING("tipContainer"));
	outFields->push(HX_CSTRING("buttonContainer"));
	super::__GetFields(outFields);
};
Example #20
0
void ID3Info_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("year"));
	outFields->push(HX_CSTRING("track"));
	outFields->push(HX_CSTRING("songName"));
	outFields->push(HX_CSTRING("genre"));
	outFields->push(HX_CSTRING("comment"));
	outFields->push(HX_CSTRING("artist"));
	outFields->push(HX_CSTRING("album"));
	super::__GetFields(outFields);
};
Example #21
0
Array<String> __hxcpp_get_class_list()
{
   Array<String> result = Array_obj<String>::__new();
   if (hx::sClassMap)
   {
      for(hx::ClassMap::iterator i=hx::sClassMap->begin(); i!=hx::sClassMap->end(); ++i)
      {
         if (i->second.mPtr)
            result->push( i->first );
      }
   }
   return result;
}
Example #22
0
void Window_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("layers"));
	outFields->push(HX_CSTRING("viewports"));
	outFields->push(HX_CSTRING("nativeId"));
	outFields->push(HX_CSTRING("title"));
	outFields->push(HX_CSTRING("fullscreen"));
	outFields->push(HX_CSTRING("mode"));
	outFields->push(HX_CSTRING("modal"));
	super::__GetFields(outFields);
};
Example #23
0
void Decoder::showChildren() const
{
	Array decoders;
	for (std::map<int, Decoder*>::const_iterator it = m_children.begin(); it != m_children.end(); ++it) {
		Decoder *child = it->second;
		if (!child) continue;
		decoders.push((Object*)child);
#if 0
		child->showChildren();
#endif
	}
	fprintf(stderr, "%s\n", decoders.toJson().c_str());
}
Example #24
0
Object model_rank_text_names(Object self, Object text) {
  Model::Model *model = from_ruby<Model::Model *>(self);
  string example_text = from_ruby<string>(text);
  Array names;
  
  vector<Classifier::Score> *ranks = model->rank_text(example_text);
  DataSet::NominalFeature *categories = model->data_set->category_feature();
  for(unsigned int i = 0; i < ranks->size(); i++)
    names.push(categories->names[ranks->at(i).category]);
  
  delete ranks;
  return names;
}
int AutomorphismSearch::_targetcell (int level, Array<int> &cell)
{
   int i = 0, j, k;
   int ibest = -1, jbest = -1, bestdegree = -1;
   
   while (i < _n)
   {
      for (; i < _n && _ptn[i] <= level; ++i)
         ;

      if (i == _n)
         break;
      else for (j = i + 1; _ptn[j] > level; j++)
         ;

      int degree = _degree[_mapping[_lab[i]]];

      // Choose cell with single vertices first and then biggest cell
      if (ibest == -1 || (degree == 0 && bestdegree != 0) || (bestdegree != 0 && j - i > jbest - ibest))
      {
         jbest = j;
         ibest = i;
         bestdegree = degree;
      }

      i = j + 1;
   }

   if (ibest == -1)
      throw Error("(intenal error) target cell cannot be found");

   i = ibest;
   j = jbest; 

   cell.clear();

   int imin = 0;

   for (k = i; k <= j; k++)
   {
      cell.push(_lab[k]);

      if (cell.size() > 0 && cell[cell.size() - 1] < cell[imin])
         imin = cell.size() - 1;
   }

   if (imin > 0)
      cell.swap(0, imin);

   return i;
}
Example #26
0
void OpenEllipse_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("_points"));
	outFields->push(HX_CSTRING("circleIter"));
	outFields->push(HX_CSTRING("dimensions"));
	outFields->push(HX_CSTRING("centre"));
	outFields->push(HX_CSTRING("stepAngle"));
	outFields->push(HX_CSTRING("finishAngle"));
	outFields->push(HX_CSTRING("beginAngle"));
	outFields->push(HX_CSTRING("rotation"));
	super::__GetFields(outFields);
};
Example #27
0
void DrawStackItem_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("antialiasing"));
	outFields->push(HX_CSTRING("initialized"));
	outFields->push(HX_CSTRING("blending"));
	outFields->push(HX_CSTRING("colored"));
	outFields->push(HX_CSTRING("next"));
	outFields->push(HX_CSTRING("position"));
	outFields->push(HX_CSTRING("drawData"));
	outFields->push(HX_CSTRING("graphics"));
	super::__GetFields(outFields);
};
Example #28
0
void KeyboardEvent_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("shiftKey"));
	outFields->push(HX_CSTRING("keyLocation"));
	outFields->push(HX_CSTRING("keyCode"));
	outFields->push(HX_CSTRING("commandKey"));
	outFields->push(HX_CSTRING("controlKey"));
	outFields->push(HX_CSTRING("ctrlKey"));
	outFields->push(HX_CSTRING("charCode"));
	outFields->push(HX_CSTRING("altKey"));
	super::__GetFields(outFields);
};
Example #29
0
            ::Array<int> getAttachedShaders(int program) {

                GLuint shaders[2];
                GLsizei count;
                glGetAttachedShaders(program, 2, &count, shaders);

                Array<int> result = Array_obj<int>::__new();
                
                    result->push(shaders[0]);
                    result->push(shaders[1]);

                return result;

            } //getAttachedShaders
Example #30
0
void bingoGetTauCondition (const char *list_ptr, int &aromaticity, Array<int> &label_list)
{
   if (isdigit(*list_ptr))
   {
      if (*list_ptr == '1')
         aromaticity = 1;
      else if (*list_ptr == '0')
         aromaticity = 0;
      else
         throw BingoError("Bad tautomer configuration string format");
      list_ptr++;
   } else {
      aromaticity = -1;
   }

   label_list.clear();

   QS_DEF(Array<char>, buf);
   buf.clear();

   while (*list_ptr != 0)
   {
      if (isalpha((unsigned)*list_ptr))
         buf.push(*list_ptr);
      else if (*list_ptr == ',')
      {
         buf.push(0);
         label_list.push(Element::fromString(buf.ptr()));
         buf.clear();
      } else
         throw BingoError("Bad label list format");
      list_ptr++;
   }

   buf.push(0);
   label_list.push(Element::fromString(buf.ptr()));
}