Exemple #1
0
// calls either process_dir or process_file, above
static void process(const char *what, int level, int recursive,
                    char *overlapping_dems[], int *next_dem_number,
                    meta_parameters *meta, int *n_dems_total)
{
  struct stat stbuf;

  if (stat(what, &stbuf) == -1) {
    asfPrintStatus("  Cannot access: %s\n", what);
    return;
  }

  char *base = get_filename(what);

  if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
      if (level==0 || recursive) {
          asfPrintStatus("  %s%s/\n", spaces(level), base);
          process_dir(what, level+1, recursive, overlapping_dems,
              next_dem_number, meta, n_dems_total);
      }
      else {
          asfPrintStatus("  %s%s (skipped)\n", spaces(level), base);
      }
  }
  else {
      process_file(what, level, overlapping_dems, next_dem_number,
          meta, n_dems_total);
  }

  FREE(base);
}
Exemple #2
0
static void DumpType(IDiaSymbol *symbol, int deep)
{
    IDiaEnumSymbols *   enumChilds = NULL;
    HRESULT             hr;
    const char *        nameStr = NULL;
    const char *        type;
    LONG                offset;
    ULONGLONG           length;
    ULONG               celt = 0;
    ULONG               symtag;
    DWORD               locType;
    bool                typeSeen;

#if 0
    if (deep > 2)
        return;
#endif

    if (symbol->get_symTag(&symtag) != S_OK)
        return;

    nameStr = GetTypeName(symbol);

    g_typesSeen.Intern(nameStr, &typeSeen);
    if (typeSeen)
        return;

    symbol->get_length(&length);
    symbol->get_offset(&offset);

    if (SymTagData == symtag) {
        if (symbol->get_locationType(&locType) != S_OK)
            return; // must be a symbol in optimized code

        // TODO: use get_offsetInUdt (http://msdn.microsoft.com/en-us/library/dd997149.aspx) ?
        // TODO: use get_type (http://msdn.microsoft.com/en-US/library/cwx3656b(v=vs.80).aspx) ?
        // TODO: see what else we can get http://msdn.microsoft.com/en-US/library/w8ae4k32(v=vs.80).aspx
        if (LocIsThisRel == locType) {
            g_report.AppendFmt("%s%s|%d\n", spaces(deep), nameStr, (int)offset);
        }
    } else if (SymTagUDT == symtag) {
        // TODO: why is it always "struct" even for classes?
        type = GetUdtType(symbol);
        g_report.AppendFmt("%s%s|%s|%d\n", spaces(deep), type, nameStr, (int)length);
        hr = symbol->findChildren(SymTagNull, NULL, nsNone, &enumChilds);
        if (!SUCCEEDED(hr))
            return;
        IDiaSymbol* child;
        while (SUCCEEDED(enumChilds->Next(1, &child, &celt)) && (celt == 1))
        {
            DumpType(child, deep+1);
            child->Release();
        }
        enumChilds->Release();
    } else {
        if (symbol->get_locationType(&locType) != S_OK)
            return; // must be a symbol in optimized code
        // TODO: assert?
    }
}
Exemple #3
0
void XmlWriter::write(const NodePtr nodeArg)
{
    NodePtr node = nodeArg;

    indent+=2;

    NamedNodeMap attributes = node->getAttributes();
    int nrAttrs = attributes.getLength();

    //### Start open tag
    spaces();
    po("<");
    pos(node->getNodeName());
    if (nrAttrs>0)
        po("\n");

    //### Attributes
    for (int i=0 ; i<nrAttrs ; i++)
        {
        NodePtr attr = attributes.item(i);
        spaces();
        pos(attr->getNodeName());
        po("=\"");
        pos(attr->getNodeValue());
        po("\"\n");
        }

    //### Finish open tag
    if (nrAttrs>0)
        spaces();
    po(">\n");

    //### Contents
    spaces();
    pos(node->getNodeValue());

    //### Children
    for (NodePtr child = node->getFirstChild() ;
         child.get() ;
         child=child->getNextSibling())
        {
        write(child);
        }

    //### Close tag
    spaces();
    po("</");
    pos(node->getNodeName());
    po(">\n");

    indent-=2;
}
Exemple #4
0
 void InfoVisitor::apply(osg::Geode& geode)
 {
     std::cout << spaces() << geode.libraryName() << "::" << geode.className() << std::endl;
     ++_level;
     osg::Drawable* drawable = nullptr;
     for (size_t i = 0; i < geode.getNumDrawables(); ++i)
     {
         drawable = geode.getDrawable(i);
         std::cout << spaces() << drawable->libraryName() << "::" << drawable->className() << std::endl;
     }
     traverse(geode);
     --_level;
 }
Exemple #5
0
 double Building_Impl::peoplePerFloorArea() const {
   double area = floorArea();
   double np = numberOfPeople();
   if (equal(area,0.0)) {
     if (equal(np,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].peoplePerFloorArea();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return np / area;
 }
Exemple #6
0
 double Building_Impl::infiltrationDesignAirChangesPerHour() const {
   double volume = airVolume();
   double idfr = infiltrationDesignFlowRate();
   if (equal(volume,0.0)) {
     if (equal(idfr,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].infiltrationDesignAirChangesPerHour();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return convert(idfr/volume,"1/s","1/h").get();
 }
Exemple #7
0
void world_free(World *w){
	int i;	
	assert(w!=NULL);
	for(i=0; i<numobj(w);i++)
		object_free(obj(w)[i]);
	free(obj(w));
	for(i=0; i<numspaces(w);i++)
		space_free(spaces(w)[i]);
	player_free(player(w));
	free(spaces(w));
	free(w);

	return;
}
Exemple #8
0
 double Building_Impl::lightingPowerPerFloorArea() const {
   double area = floorArea();
   double lp = lightingPower();
   if (equal(area,0.0)) {
     if (equal(lp,0.0)) {
       return 0.0;
     }
     else if (spaces().size() == 1u) {
       return spaces()[0].lightingPowerPerFloorArea();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return lp / area;
 }
Exemple #9
0
 double Building_Impl::infiltrationDesignFlowPerExteriorWallArea() const {
   double area = exteriorWallArea();
   double idfr = infiltrationDesignFlowRate();
   if (equal(area,0.0)) {
     if (equal(idfr,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].infiltrationDesignFlowPerExteriorWallArea();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return idfr/area;
 }
Exemple #10
0
 double Building_Impl::gasEquipmentPowerPerPerson() const {
   double np = numberOfPeople();
   double ep = gasEquipmentPower();
   if (equal(np,0.0)) {
     if (equal(ep,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].gasEquipmentPowerPerPerson();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return ep / np;
 }
Exemple #11
0
 double Building_Impl::gasEquipmentPowerPerFloorArea() const {
   double area = floorArea();
   double ep = gasEquipmentPower();
   if (equal(area,0.0)) {
     if (equal(ep,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].gasEquipmentPowerPerFloorArea();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return ep / area;
 }
Exemple #12
0
 double Building_Impl::lightingPowerPerPerson() const {
   double np = numberOfPeople();
   double lp = lightingPower();
   if (equal(np,0.0)) {
     if (equal(lp,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].lightingPowerPerPerson();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return lp / np;
 }
Exemple #13
0
void gen_headings( int width, int depth, int subh, char *alpha)
{
    char alphabet[100];
    int k, i;
    int count = 0;
    
    for (k = width - 1 ; k >= 0 ; k--)
    {
        count++;

        if (subh)
            sprintf(alphabet, "%s%i", alpha, ((width)- k));
        
        else
            sprintf(alphabet, "%s%c", alpha, ('a'-1) + ((width) - k ));
     
	printf("Section %s\n",alphabet);
	spaces(count);        
        if (depth == 0)
            return;
        else if ( depth != 0)
        {
            i = strlen(alphabet);
            alphabet[i] = '.';
            alphabet[i + 1] = '\0';
        }
    
    
    gen_headings(width, depth - 1, !subh,  alphabet);

    }
}
Exemple #14
0
std::string __error_gen_internal(const Location& loc, const std::string& msg, const char* type, bool context)
{
	std::string ret;

	auto colour = COLOUR_RED_BOLD;
	if(strcmp(type, "warning") == 0)
		colour = COLOUR_MAGENTA_BOLD;

	else if(strcmp(type, "note") == 0)
		colour = COLOUR_GREY_BOLD;

	// bool empty = strcmp(type, "") == 0;
	// bool dobold = strcmp(type, "note") != 0;

	//? do we want to truncate the file path?
	//? we're doing it now, might want to change (or use a flag)

	std::string filename = frontend::getFilenameFromPath(loc.fileID == 0 ? "(unknown)"
		: frontend::getFilenameFromID(loc.fileID));

	ret += strprintf("%s%s%s:%s %s\n", COLOUR_RESET, colour, type, COLOUR_RESET, msg);

	if(loc.fileID > 0)
	{
		auto location = strprintf("%s:%d:%d", filename, loc.line + 1, loc.col + 1);
		ret += strprintf("%s%sat:%s %s%s", COLOUR_RESET, COLOUR_GREY_BOLD, spaces(strlen(type) - 2), COLOUR_RESET, location);
	}

	ret += "\n";

	if(context && loc.fileID > 0)
		ret += getSingleContext(loc) + "\n";

	return ret;
}
Exemple #15
0
 void InfoVisitor::apply(osg::Node& node)
 {
     std::cout << spaces() << node.libraryName() << "::" << node.className() << std::endl;
     ++_level;
     traverse(node);
     --_level;
 }
Exemple #16
0
void ConsoleInput::parse()
{
    if ( kbhit() )
    {
        char ch = getch();

        if( (int)ch == 13 && !mInputBuffer.empty() )
        {
            // Enter
            std::cout << "Lua: " << mInputBuffer << std::endl;
            mCommandCallback( mInputBuffer );
            String spaces( mInputBuffer.size(), ' ' );
            std::cout << spaces << "\r" << std::flush;
            mInputBuffer.clear();
        }
        else if( (int)ch == 8 && !mInputBuffer.empty() )
        {
            // Backspace
            mInputBuffer[ mInputBuffer.size() - 1 ] = ' ';
            std::cout << mInputBuffer << "\r" << std::flush;
            mInputBuffer.erase( mInputBuffer.size() - 1 );
        }
        else if( (int)ch >= 32 && (int)ch <= 126 )
        {
            // Normal input
            mInputBuffer.append( 1, ch );
        }

        std::cout << mInputBuffer << "\r" << std::flush;
    }
}
Exemple #17
0
 double Building_Impl::airVolume() const {
   double result(0.0);
   for (const Space& space : spaces()) {
     result += space.volume() * space.multiplier();
   }
   return result;
 }
Exemple #18
0
 double Building_Impl::numberOfPeople() const {
   double result(0.0);
   for (const Space& space : spaces()) {
     result += space.numberOfPeople() * space.multiplier();
   }
   return result;
 }
Exemple #19
0
 double Building_Impl::infiltrationDesignFlowRate() const {
   double result(0.0);
   for (const Space& space : spaces()){
     result += space.multiplier() * space.infiltrationDesignFlowRate();
   }
   return result;
 }
Exemple #20
0
 double Building_Impl::gasEquipmentPower() const {
   double result(0.0);
   for (const Space& space : spaces()){
     result += space.multiplier() * space.gasEquipmentPower();
   }
   return result;
 }
Exemple #21
0
int print_struct_def(struct struct_def *sdef, long long offset, char *data)
{
	struct struct_member *member; 
	struct type_info *tinfo;
	int end;

	if (sdef->type == TYPE_ENUM) {
		my_printf("0x%lx",*((int*)data));		
		return 4;
	}
	if (sdef->type != TYPE_STRUCTURE) return 0;	
	if (!sdef) {
		my_printf("Structure not found\n");
		return 0;
	}
	
	my_printf("\n");
	indent_struct(offset);
	my_printf("struct %s size=%d {\n", sdef->name, sdef->size);
	indent++;
	member = sdef->members;
	while(member != NULL) {
		indent_struct(member->offset + offset);
		col += my_printf("%s",member->name); spaces();
		tinfo = member->type;
		print_id(tinfo->id, offset + member->offset, data + (member->offset / 8));
		end = member->offset + offset + member->size;
		member = member->next;
		my_printf("\n");
	}
	indent--;
	indent_struct(end); my_printf("}");
	return sdef->size;
}
Exemple #22
0
static std::string fetchContextLine(Location loc, size_t* adjust)
{
	if(loc.fileID == 0) return "";

	auto lines = frontend::getFileLines(loc.fileID);
	if(lines.size() > loc.line)
	{
		std::string orig = util::to_string(lines[loc.line]);
		std::stringstream ln;

		// skip all leading whitespace.
		bool ws = true;
		for(auto c : orig)
		{
			if(ws && c == '\t')                 { *adjust += TAB_WIDTH; continue;   }
			else if(ws && c == ' ')             { *adjust += 1; continue;           }
			else if(c == '\n')                  { break;                            }
			else                                { ws = false; ln << c;              }
		}

		return strprintf("%s%s", spaces(LEFT_PADDING), ln.str().c_str());
	}

	return "";
}
Exemple #23
0
void PASCAL::print(){

	int offset = 1;

	int tot_n_rows = _triangle.size();
	int n_spaces = std::sqrt(3) * tot_n_rows / 2 + offset;
	int max_plaque_size = max_n_digits_in_triangle();
	
	
	std::cout << "nspaces = " << n_spaces << std::endl;
	std::cout << "tot_n_rows = " << tot_n_rows <<std::endl;
	std::cout << "max_n_digits_in_triangle = " << max_plaque_size << std::endl;


	for(int r = 0; r < tot_n_rows; r++){
		std::cout << spaces(n_spaces);
		for(int e = 0; e < _triangle[r].size(); e++){
			std::cout << _triangle[r][e] << " ";
			//std::cout << gen_plaque(max_plaque_size, _triangle[r][e]) << " ";
		}	
		std::cout << std::endl;
		n_spaces --;
	}

	clean();


}
Exemple #24
0
 double Building_Impl::lightingPower() const {
   double result(0.0);
   for (const Space& space : spaces()){
     result += space.multiplier() * space.lightingPower();
   }
   return result;
 }
LLTemplateTokenizer::LLTemplateTokenizer(const std::string & contents) : mStarted(false), mTokens()
{
	boost::char_separator<char> newline("\r\n", "", boost::keep_empty_tokens);
	boost::char_separator<char> spaces(" \t");
	U32 line_counter = 1;
	
	tokenizer line_tokens(contents, newline);
	for(tokenizer::iterator line_iter = line_tokens.begin();
		line_iter != line_tokens.end();
		++line_iter, ++line_counter)
	{
		tokenizer word_tokens(*line_iter, spaces);
		for(tokenizer::iterator word_iter = word_tokens.begin();
			word_iter != word_tokens.end();
			++word_iter)
		{
			if((*word_iter)[0] == '/')
			{
				break;   // skip to end of line on comments
			}
			positioned_token pt;// = new positioned_token();
			pt.str = std::string(*word_iter);
			pt.line = line_counter;
			mTokens.push_back(pt);
		}
	}
	mCurrent = mTokens.begin();
}
Exemple #26
0
void TextBox::draw(sf::RenderTarget& w) {

    w.draw(sprite);

    sf::FloatRect totalSpace;
    totalSpace = sprite.getGlobalBounds();
    sf::Vector2f spaces( totalSpace.width/10, totalSpace.height/8);
    float yPos = totalSpace.top;

    for(int i = 0; i < int(boxTexts.size()); ++i) {

        text.setString(boxTexts[i]);

        text.setPosition(sprite.getPosition().x+spaces.x, yPos+spaces.y/2 );

        sf::Vector2f textSize(text.getLocalBounds().width, text.getLocalBounds().height);
        float oldSize = text.getCharacterSize();
        text.setCharacterSize(50);
        text.setScale(textSize.x/text.getLocalBounds().width, textSize.y/text.getLocalBounds().height);
        w.draw(text);
        text.setCharacterSize(oldSize);
        yPos += textSize.y;

    }

}
Exemple #27
0
static void
print_generic2(const slang_operation *op, const char *oper,
               const char *s, int indent)
{
   GLuint i;
   if (oper) {
      spaces(indent);
      printf("%s %s at %p locals=%p outer=%p\n",
             oper, s, (void *) op, (void *) op->locals, 
             (void *) op->locals->outer_scope);
   }
   for (i = 0; i < op->num_children; i++) {
      spaces(indent);
      printf("//child %u of %u:\n", i, op->num_children);
      slang_print_tree(&op->children[i], indent);
   }
}
Exemple #28
0
void
cli_ui_out::do_field_string (int fldno, int width, ui_align align,
			     const char *fldname, const char *string)
{
  int before = 0;
  int after = 0;

  if (m_suppress_output)
    return;

  if ((align != ui_noalign) && string)
    {
      before = width - strlen (string);
      if (before <= 0)
	before = 0;
      else
	{
	  if (align == ui_right)
	    after = 0;
	  else if (align == ui_left)
	    {
	      after = before;
	      before = 0;
	    }
	  else
	    /* ui_center */
	    {
	      after = before / 2;
	      before -= after;
	    }
	}
    }

  if (before)
    spaces (before);

  if (string)
    fputs_filtered (string, m_streams.back ());

  if (after)
    spaces (after);

  if (align != ui_noalign)
    field_separator ();
}
/** \relates Vector */
template <class Scalar> inline
Vector<Scalar> blockVector(const Array<Vector<Scalar> >& x)
{
  Array<VectorSpace<Scalar> > spaces(x.size());
  for (int i=0; i<x.size(); i++) spaces[i] = x[i].space();

  VectorSpace<Scalar> bs = blockSpace(spaces);
  RCP<VectorBase<Scalar> > rtn = rcp(new DefaultBlockVector<Scalar>(bs, x));
  return rtn;
}
Exemple #30
0
void
_slang_print_var_scope(const slang_variable_scope *vars, int indent)
{
   GLuint i;

   spaces(indent);
   printf("Var scope %p  %d vars:\n", (void *) vars, vars->num_variables);
   for (i = 0; i < vars->num_variables; i++) {
      spaces(indent + 3);
      printf("%s (at %p)\n", (char *) vars->variables[i]->a_name, (void*) (vars->variables + i));
   }
   spaces(indent + 3);
   printf("outer_scope = %p\n", (void*) vars->outer_scope);

   if (vars->outer_scope) {
      /*spaces(indent + 3);*/
      _slang_print_var_scope(vars->outer_scope, indent + 3);
   }
}