template <typename R> bool extract_control(R& result,tokenizer& tokenizer)
{
 result.clear();
 
 //controls
 
 dictionary<string,id<string>> controls=
 {
  "\r",symbols()._cr,
  "\n",symbols()._lf
 };

 //buffer
 
 array<ascii> buffer;

 //any
 
 if(!tokenizer.any(buffer,controls.keys()))
  return false;
  
 //commit
 
 result=buffer;

 update(controls[buffer.join("")],buffer);
 
 return true;
}
template <typename R> bool extract_word(R& result,tokenizer& tokenizer)
{
 result.clear();
 
 //buffer
 
 array<ascii> buffer;

 //word
 
 if(!tokenizer.word(buffer))
  return false;
  
 //delimited
 
 if(!tokenizer.is_delimited())
  return false;
  
 //commit
 
 result=buffer;
 
 update(symbols()._word,buffer);
 
 return true;
}
template <typename R> bool extract_identifier(R& result,tokenizer& tokenizer)
{
 result.clear();
 
 //buffer
 
 array<ascii> buffer;
 array<ascii> current;
 
 //identifier

 if(!tokenizer.identifier(current))
  return false;
  
 buffer.append(current);
  
 //word
 
 if(tokenizer.word(current))
  buffer.append(current);
  
 //delimited
 
 if(!tokenizer.is_delimited())
  return false;
  
 //commit

 result=buffer;
 
 update(symbols()._identifier,buffer);
 
 return true;
}
示例#4
0
    void ArithmeticUtilDecoder::decode(std::vector<byte>& data) {
        long p = in->pos;
        uint64 length = in->read48bits();
        bits_left = in->read48bits()*8;
        //       std::cout<<"Current position: "<<in->pos<<" - "<<" bits to read: "<<bits_left<<"\n";
        data.resize(length);
        std::vector<uint64> counts(256);
        std::vector<SYMBOL> symbols(256);
        utils::gammaDecode(counts,in);
        in->flushBuffer();
        uint64 cumul=0;
        for(int i=0;i<256;i++) {
            symbols[i].low_count=cumul;
            symbols[i].high_count = cumul = cumul + counts[i];
        }
        byte aa = in->readByte();
        byte bb = in->readByte();
        byte cc = in->readByte();
        byte dd = in->readByte();
        bits_left-=32;
        code = (aa<<24)|(bb<<16)|(cc<<8)|dd;
        for(int i=0;i<length;i++) {
            uint64 v = get_value();
            byte b = get_byte(symbols,v);
            if(i+1<length)    del_symbol(symbols[b]);
            data[i]=b;
        }
        in->flushBuffer();

    }
template <typename R> bool extract_unit(R& result,reducer<T>& parser)
{
 result.clear();
 
 //buffer
 
 array<T> buffer;
 
 //empty
 
 if(parser.is_empty())
  return false;
  
 //shift
 
 buffer.push(parser.shift());
  
 //commit
 
 result=buffer;
 
 update(symbols()._unit,buffer);
 
 return true;
}
void
ShaderInstance::evaluate_writes_globals_and_userdata_params ()
{
    writes_globals (false);
    userdata_params (false);
    BOOST_FOREACH (Symbol &s, symbols()) {
        if (s.symtype() == SymTypeGlobal && s.everwritten())
            writes_globals (true);
        if ((s.symtype() == SymTypeParam || s.symtype() == SymTypeOutputParam)
                && ! s.lockgeom() && ! s.connected())
            userdata_params (true);
        if (s.symtype() == SymTypeTemp) // Once we hit a temp, we'll never
            break;                      // see another global or param.
    }

    // In case this method is called before the Symbol vector is copied
    // (i.e. before copy_code_from_master is called), try to set
    // userdata_params as accurately as we can based on what we know from
    // the symbol overrides. This is very important to get instance merging
    // working correctly.
    int p = 0;
    BOOST_FOREACH (SymOverrideInfo &s, m_instoverrides) {
        if (! s.lockgeom())
            userdata_params (true);
        ++p;
    }
}
示例#7
0
文件: unum.cpp 项目: 119120119/node
U_CAPI void U_EXPORT2
unum_setSymbol(UNumberFormat *fmt,
               UNumberFormatSymbol symbol,
               const UChar *value,
               int32_t length,
               UErrorCode *status)
{
    if(status==NULL || U_FAILURE(*status)) {
        return;
    }
    if(fmt==NULL || symbol< 0 || symbol>=UNUM_FORMAT_SYMBOL_COUNT || value==NULL || length<-1) {
        *status=U_ILLEGAL_ARGUMENT_ERROR;
        return;
    }
    NumberFormat *nf = reinterpret_cast<NumberFormat *>(fmt);
    DecimalFormat *dcf = dynamic_cast<DecimalFormat *>(nf);
    if (dcf == NULL) {
      *status = U_UNSUPPORTED_ERROR;
      return;
    }

    DecimalFormatSymbols symbols(*dcf->getDecimalFormatSymbols());
    symbols.setSymbol((DecimalFormatSymbols::ENumberFormatSymbol)symbol,
        UnicodeString(value, length));  /* UnicodeString can handle the case when length = -1. */
    dcf->setDecimalFormatSymbols(symbols);
}
示例#8
0
bool Cocos2dExporter::Export(QByteArray& out) {
    QString res = "info ";
    res += QString("face=\"") + fontConfig()->family() +  QString("\" ");
    res += QString("size=") + QString().number(fontConfig()->size()) + QString(" bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2\n");
    res += QString("common lineHeight=") + QString().number(metrics().height) + QString(" base=29 scaleW=") + QString().number(texWidth()) + QString(" scaleH=") + QString().number(texWidth()) + QString(" pages=1 packed=0\n");
    res += QString("page id=0 file=\"") + texFilename() + QString("\"\n");
    res += QString("chars count=") + QString().number(symbols().size()) + QString("\n");

    foreach(const Symbol& c , symbols())
    {
        res += QString("char id=") + QString().number(c.id) + QString(" x=") + QString().number(c.placeX) + QString(" y=") + QString().number(c.placeY);
        res += QString(" width=") + QString().number(c.placeW) + QString(" height=") + QString().number(c.placeH);
        res += QString(" xoffset=") + QString().number(c.offsetX) + QString(" yoffset=") + QString().number(fontConfig()->size() - c.offsetY);
        res += QString(" xadvance=") + QString().number(c.advance) + QString(" page=0 chnl=0 ");

        if(c.id==32)
        {
            res += QString("letter=\"space\"");
        }
        else
        {
            res += QString("letter=\"" + QString().append(c.id) + "\"");
        }

        res += QString("\n");
    }
示例#9
0
void CyclRatFunct::showCoprimeCRF(){
// shows *this also with coprime numerator and denominator
// makes only sense if only x[0] appears in the numerator (not checked)

    if(!verbose_INT)
        return;

    cout << "--------------------------------------------" << endl << endl;
    cout << "Given form" << endl << endl;
    showCRF();
    cout << endl;
    SparsePolyRing R=owner(num);
    SparsePolyRing P=NewPolyRing_DMPI(RingQQ(),symbols("t"));
    vector<RingElem> Im(NumIndets(R),zero(P));
    Im[0]=indets(P)[0];
    RingHom phi=PolyAlgebraHom(R,P,Im);
    RingElem f(phi(num));
    RingElem g(denom2poly(P,denom));
    RingElem h=CoCoA::gcd(f,g);
    f/=h;
    g/=h;
    cout << "Coprime numerator (for denom with remaining factor 1)" << endl <<endl;
    factorization<RingElem> gf=factor(g);
    cout << f/gf.myRemainingFactor() << endl << endl << "Factorization of denominator" << endl << endl;
    size_t nf=gf.myFactors().size();
    for(size_t i=0;i<nf;++i)
        cout << gf.myFactors()[i] << "  mult " << gf.myMultiplicities()[i] << endl;
    cout << "--------------------------------------------" << endl;

}
示例#10
0
void DecimalFormatTest::execFormatTest(int32_t lineNum,
                           const UnicodeString &pattern,     // Pattern
                           const UnicodeString &round,       // rounding mode
                           const UnicodeString &input,       // input decimal number
                           const UnicodeString &expected,    // expected formatted result
                           UErrorCode &status) {
    if (U_FAILURE(status)) {
        return;
    }

    DecimalFormatSymbols symbols(Locale::getUS(), status);
    // printf("Pattern = %s\n", UnicodeStringPiece(pattern).data());
    DecimalFormat fmtr(pattern, symbols, status);
    if (U_FAILURE(status)) {
        errln("file dcfmtest.txt, line %d: %s error creating the formatter.",
            lineNum, u_errorName(status));
        return;
    }
    if (round=="ceiling") {
        fmtr.setRoundingMode(DecimalFormat::kRoundCeiling);
    } else if (round=="floor") {
        fmtr.setRoundingMode(DecimalFormat::kRoundFloor);
    } else if (round=="down") {
        fmtr.setRoundingMode(DecimalFormat::kRoundDown);
    } else if (round=="up") {
        fmtr.setRoundingMode(DecimalFormat::kRoundUp);
    } else if (round=="halfeven") {
        fmtr.setRoundingMode(DecimalFormat::kRoundHalfEven);
    } else if (round=="halfdown") {
        fmtr.setRoundingMode(DecimalFormat::kRoundHalfDown);
    } else if (round=="halfup") {
        fmtr.setRoundingMode(DecimalFormat::kRoundHalfUp);
    } else if (round=="default") {
        // don't set any value.
    } else {
        fmtr.setRoundingMode(DecimalFormat::kRoundFloor);
        errln("file dcfmtest.txt, line %d: Bad rounding mode \"%s\"",
                lineNum, UnicodeStringPiece(round).data());
    }
    
    UnicodeString result;
    UnicodeStringPiece spInput(input);
    //fmtr.format(spInput, result, NULL, status);

    Formattable fmtbl;
    fmtbl.setDecimalNumber(spInput, status);
    //NumberFormat &nfmtr = fmtr;
    fmtr.format(fmtbl, result, NULL, status);

    if (U_FAILURE(status)) {
        errln("file dcfmtest.txt, line %d: format() returned %s.",
            lineNum, u_errorName(status));
        return;
    }
    
    if (result != expected) {
        errln("file dcfmtest.txt, line %d: expected \"%s\", got \"%s\"",
            lineNum, UnicodeStringPiece(expected).data(), UnicodeStringPiece(result).data());
    }
}
示例#11
0
	bool get_entry(
		Elf_Xword		index,
		Elf64_Addr		&offset,
		Elf64_Addr		&symbolValue,
		std::string		&symbolName,
		Elf_Word		&type,
		Elf_Sxword		&addend,
		Elf_Sxword		&calcValue
	) const {
		// Do regular job
		Elf_Word symbol;
		bool ret = get_entry( index, offset, symbol, type, addend );
		// Find the symbol
		Elf_Xword	size;
		unsigned char bind;
		unsigned char symbolType;
		Elf_Half	section;
		unsigned char other;
		symbol_section_accessor symbols( elf_file, elf_file.sections[get_symbol_table_index()] );
		ret = symbols.get_symbol( symbol, symbolName, symbolValue, size, bind, symbolType, section, other );
		if ( ret ) { // Was it successful?
			switch ( type ) {
			case R_386_NONE:		// none
				calcValue = 0;
				break;
			case R_386_32:		// S + A
				calcValue = symbolValue + addend;
				break;
			case R_386_PC32:		// S + A - P
				calcValue = symbolValue + addend - offset;
				break;
			case R_386_GOT32:	// G + A - P
				calcValue = 0;
				break;
			case R_386_PLT32:	// L + A - P
				calcValue = 0;
				break;
			case R_386_COPY:		// none
				calcValue = 0;
				break;
			case R_386_GLOB_DAT:	// S
			case R_386_JMP_SLOT:	// S
				calcValue = symbolValue;
				break;
			case R_386_RELATIVE:	// B + A
				calcValue = addend;
				break;
			case R_386_GOTOFF:	// S + A - GOT
				calcValue = 0;
				break;
			case R_386_GOTPC:	// GOT + A - P
				calcValue = 0;
				break;
			default:				// Not recognized symbol!
				calcValue = 0;
				break;
			}
		}
		return ret;
	}
示例#12
0
/*!
  バックトレースを出力するマニピュレータ関数.

  コンパイル時に g++ -g -rdynamic を指定しないと、関数名がわからない
 */
inline std::ostream & backtrace(std::ostream & os)
{
    static const int MAX = 256;
    void * frames[MAX];
    int size = ::backtrace(frames, MAX);
    if (size <= 0 || size >= MAX)
        return os << "failed to backtrace (" << size << ")" << std::endl;
    std::unique_ptr<char*> symbols(::backtrace_symbols(frames, MAX));
    if (!symbols)
        return os << "failed to backtrace_symbols" << std::endl;

    for(int i = 0; i < size; ++i) {
        char * beg = symbols.get()[i];
        char * end = beg + std::char_traits<char>::length(beg);
        char * a = std::find(beg, end, '(');
        char * b = std::find(a, end, '+');
        char * c = std::find(b, end, ')');
        if (c != end && std::distance(a, b) >= 1) {
            *const_cast<char *>(a++) = '\0';
            *const_cast<char *>(b++) = '\0';
            os << beg << ' ' << boost::units::detail::demangle(a) << ++c;
        } else {
            os << beg;
        }
        os << std::endl;
    }
    return os;
}
U_CAPI void U_EXPORT2
unum_setSymbol(UNumberFormat *fmt,
               UNumberFormatSymbol symbol,
               const UChar *value,
               int32_t length,
               UErrorCode *status)
{
    if(status==NULL || U_FAILURE(*status)) {
        return;
    }
    
    if(fmt==NULL || (uint16_t)symbol>=UNUM_FORMAT_SYMBOL_COUNT || value==NULL || length<-1) {
        *status=U_ILLEGAL_ARGUMENT_ERROR;
        return;
    }
    
    if (((NumberFormat*)fmt)->getDynamicClassID() != DecimalFormat::getStaticClassID()) {
      *status = U_UNSUPPORTED_ERROR;
      return;
    }

    DecimalFormatSymbols symbols(*((DecimalFormat *)fmt)->getDecimalFormatSymbols());
    symbols.setSymbol((DecimalFormatSymbols::ENumberFormatSymbol)symbol,
        UnicodeString(value, length));  /* UnicodeString can handle the case when length = -1. */
    ((DecimalFormat *)fmt)->setDecimalFormatSymbols(symbols);
}
示例#14
0
QgsSymbolV2List QgsFeatureRendererV2::symbols( QgsRenderContext &context )
{
  Q_UNUSED( context );

  //base implementation calls deprecated method to maintain API
  Q_NOWARN_DEPRECATED_PUSH
  return symbols();
  Q_NOWARN_DEPRECATED_POP
}
示例#15
0
PyField::PyField(std::string name, const PyType &parentType)
    : d(new PyFieldPrivate(name, parentType))
{
    auto extcmd = ExtensionCommandContext::instance();
    unsigned long typeID = 0;
    if (SUCCEEDED(extcmd->symbols()->GetFieldTypeAndOffset(
                      d->parentType.getModule(), d->parentType.getTypeId(), d->name.c_str(),
                      &typeID, &d->offset))) {
        d->type = PyType(d->parentType.getModule(), typeID);
    }
}
示例#16
0
 void ClassBuilder::add ( Method definition )
 {
       // Create code object for function.
     const Object function(Object::acquire(
         ::PyCFunction_New(&definition.data(), 0)));
       // Create a class method with the function.
     const Object method(Object::acquire(
         ::PyMethod_New(function.handle(), 0, handle())));
       // Register method in class dictionary.
     symbols().put(definition.name(), method);
 }
示例#17
0
bool AGEExporter::Export(QByteArray& out)
{
    QVector<Symbol> list = symbols();
    qSort(list.begin(), list.end(), sortSymbols);

    unsigned charsCount = list.size();
    unsigned maxHeight = 0;

    foreach(const Symbol& c, list)
    {
        maxHeight = std::max<float>(maxHeight, c.placeH);
    }
示例#18
0
template <typename R> bool extract_number(R& result,tokenizer& tokenizer)
{
 result.clear();
 
 //buffer
 
 array<ascii> buffer;
 array<ascii> current;
 
 //sign

 if(tokenizer.any(current,pack("+","-")))
  buffer.append(current);
 
 //integer part
 
 if(tokenizer.digit(current))
  buffer.append(current);
 
 //real part
 
 if(tokenizer.delimit(current,"."))
 {
  buffer.append(current);
  
  if(tokenizer.digit(current))
   buffer.append(current);
 }
 
 //parse with c api
 
 if(!buffer.join("").is_real())
  return false;

 //no dot after
 
 if(tokenizer.starts_with("."))
  return false;

 //delimited
 
 if(!tokenizer.is_delimited())
  return false;
  
 //commit

 result=buffer;

 update(symbols()._number,buffer);
 
 return true;
}
示例#19
0
    void reflectable_descriptor::write_value(const void* source_ptr, symbol& target_symbol) const
    {
        // ensure target is a symbols value
        if (!is_symbols(target_symbol)) target_symbol = symbols({});

        // get type to write
        VAR& symbols = get_symbols(target_symbol);
        VAL* reflectable_ptr = static_cast<const reflectable*>(source_ptr);
        VAL& reflectable = *reflectable_ptr;
        VAL& type = get_type(reflectable);

        // write values
        write_value_internal(type, reflectable, symbols);
    }
示例#20
0
status_t
ImageDebugInfo::FinishInit(DebuggerInterface* interface)
{
	BObjectList<SymbolInfo> symbols(50, true);
	status_t error = interface->GetSymbolInfos(fImageInfo.TeamID(),
		fImageInfo.ImageID(), symbols);
	if (error != B_OK)
		return error;
	symbols.SortItems(&_CompareSymbols);

	// get functions -- get them from most expressive debug info first and add
	// missing functions from less expressive debug infos
	for (int32 i = 0; SpecificImageDebugInfo* specificInfo
			= fSpecificInfos.ItemAt(i); i++) {
		BObjectList<FunctionDebugInfo> functions;
		error = specificInfo->GetFunctions(symbols, functions);
		if (error != B_OK)
			return error;

		for (int32 k = 0; FunctionDebugInfo* function = functions.ItemAt(k);
				k++) {
			if (FunctionAtAddress(function->Address()) != NULL)
				continue;

			FunctionInstance* instance = new(std::nothrow) FunctionInstance(
				this, function);
			if (instance == NULL
				|| !fFunctions.BinaryInsert(instance, &_CompareFunctions)) {
				delete instance;
				error = B_NO_MEMORY;
				break;
			}

			if (function->IsMain())
				fMainFunction = instance;
		}

		// Remove references returned by the specific debug info -- the
		// FunctionInstance objects have references, now.
		for (int32 k = 0; FunctionDebugInfo* function = functions.ItemAt(k);
				k++) {
			function->ReleaseReference();
		}

		if (error != B_OK)
			return error;
	}

	return B_OK;
}
示例#21
0
 const PolyRing& RingQQt(const MachineInt& NumIndets)
 {
   static vector<PolyRing*> QQtTable;
   if (IsNegative(NumIndets) || IsZero(NumIndets)) CoCoA_ERROR(ERR::NotPositive, "RingQQt");
   const long n = AsSignedLong(NumIndets);
   if (n >= len(QQtTable)) QQtTable.resize(n+1); // will fill with NULL ptrs
   if (QQtTable[n] == 0/*NULL ptr*/)
   {
     vector<symbol> IndetNames;
     if (n == 1) IndetNames = symbols("t"); else IndetNames = SymbolRange("t",1,n);
     QQtTable[n] = new SparsePolyRing(NewPolyRing(RingQQ(), IndetNames)); // wasteful copy!!
     RegisterDtorForGlobal(QQtTable[n], &RingQQtDtor);
   }
   return *QQtTable[n];
 }
示例#22
0
bool getFrame(unsigned n, StackFrame *f, std::string *errorMessage)
{
    IInterfacePointer<CIDebugClient> client;
    if (!client.create()) {
        *errorMessage = "Cannot obtain client.";
        return false;
    }
    IInterfacePointer<CIDebugSymbols> symbols(client.data());
    IInterfacePointer<CIDebugControl> control(client.data());
    if (!symbols || !control) {
        *errorMessage = "Cannot obtain required objects.";
        return false;
    }
    return getFrame(symbols.data(), control.data(), n, f, errorMessage);
}
示例#23
0
bool SparrowExporter::Export(QByteArray& out) {
    QDomDocument doc;
    QDomElement root = doc.createElement("font");
    doc.appendChild(root);
    QDomElement info = doc.createElement("info");
    root.appendChild(info);
    info.setAttribute("face", fontConfig()->family());
    info.setAttribute("size", fontConfig()->size());
    QDomElement common = doc.createElement("common");
    root.appendChild(common);
    int height = metrics().height;
    common.setAttribute("lineHeight", height);
    QDomElement pages = doc.createElement("pages");
    root.appendChild(pages);
    QDomElement page = doc.createElement("page");
    pages.appendChild(page);
    page.setAttribute("id", "0");
    page.setAttribute("file", texFilename());
    QDomElement chars = doc.createElement("chars");
    root.appendChild(chars);
    chars.setAttribute("count", symbols().size());
    QDomElement kernings = doc.createElement("kernings");
    int kernNumber = 0;
    foreach(const Symbol& c , symbols()) {
        QDomElement ch = doc.createElement("char");
        ch.setAttribute("id", QString::number(c.id));
        ch.setAttribute("x", QString::number(c.placeX));
        ch.setAttribute("y", QString::number(c.placeY));
        ch.setAttribute("width", QString::number(c.placeW));
        ch.setAttribute("height", QString::number(c.placeH));
        ch.setAttribute("xoffset", QString::number(c.offsetX));
        ch.setAttribute("yoffset", QString::number(height - c.offsetY));
        ch.setAttribute("xadvance", QString::number(c.advance));
        ch.setAttribute("page", "0");
        ch.setAttribute("chnl", "0");
        ch.setAttribute("letter", c.id==32 ? "space" : QString().append(c.id));
        chars.appendChild(ch);
        typedef QMap<uint,int>::ConstIterator Kerning;
        for ( Kerning k = c.kerning.begin();k!=c.kerning.end();k++) {
            QDomElement ker = doc.createElement("kerning");
            ker.setAttribute("first", QString::number(c.id));
            ker.setAttribute("second", QString::number(k.key()));
            ker.setAttribute("amount", k.value());
            kernings.appendChild(ker);
            kernNumber ++;
        }
    }
Drum::Drum(unsigned int size_,unsigned int line_) : size(size_), line(line_), current(0){

	std::vector<char> symbols(size);
	symbols.assign(size, 25);
	symbols[0] = 6;
	char symb = 5;

	for (unsigned int i = 1; i < size; ++i)
	{
		//если закончились пятерки (10%)
		if (i <= size / 10)
		{
			symb = 4;
		}
		//если закончились четверки (25%)
		else if (i <= size / 4)
		{
			symb = 3;
		}
		//если закончились тройки (40%)
		else if (i <= size * 4 / 10)
		{
			symb = 2;
		}
		//если закончились двойки (60%)
		 else if (i <= size * 6 / 10)
		{
			symb = 1;
		}
		//если закончились единицы (80%)
		else 
		{
			symb = 0;
		}

		symbols[i] += symb;
	}

	unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
	
	// experiment to three tapes
	for (unsigned int i = 0; i < line; i++)
	{
		shuffle(symbols.begin(), symbols.end(), std::default_random_engine(seed));
		drum.push_back(symbols);
	}
};
示例#25
0
void GameFileSystem::InitializeFunctions()
{
    const char *symbols[] =
    {
        "_ZN15CBaseFileSystem13AddSearchPathEPKcS1_15SearchPathAdd_t",
        "_ZN15CBaseFileSystem9FindFirstEPKcPi",
        "_ZN15CBaseFileSystem8FindNextEi",
        "_ZN15CBaseFileSystem15FindIsDirectoryEi",
        "_ZN15CBaseFileSystem9FindCloseEi",
        nullptr
    };
    
    SymbolInfo info[5];
    memset(&info, 0, sizeof(info));
    
    size_t notFound = lib_->ResolveHiddenSymbols(info, symbols);
    
    if (notFound > 0)
    {
        ErrorReporter &reporter = GameAPI::GetInstance().GetErrorReporter();
        
        AString symbols("");
        
        // Build list of symbols for error string below
        for (size_t i = 0; i < ARRAY_LENGTH(info); i++)
        {
            if (!info[i].address && info[i].name)
            {
                symbols.append(info[i].name);
                symbols.append("\n");
            }
        }
        
        reporter.Error("Failed to locate the following symbols for %s:\n%s",
                        lib_->GetName().chars(),
                        symbols.chars());

        return;
    }
    
    AddSearchPath_ = (AddSearchPathFn)info[0].address;
    FindFirst_ = (FindFirstFn)info[1].address;
    FindNext_ = (FindNextFn)info[2].address;
    FindIsDirectory_ = (FindIsDirectoryFn)info[3].address;
    FindClose_ = (FindCloseFn)info[4].address;
}
示例#26
0
status_t
SharedImage::_Init(debug_symbol_iterator* iterator)
{
	// get an image info
	status_t error = debug_get_symbol_iterator_image_info(iterator, &fInfo);
	if (error != B_OK)
		return error;

	// iterate through the symbols
	BObjectList<Symbol>	symbols(512, true);
	char symbolName[1024];
	int32 symbolType;
	void* symbolLocation;
	size_t symbolSize;
	while (debug_next_image_symbol(iterator, symbolName, sizeof(symbolName),
			&symbolType, &symbolLocation, &symbolSize) == B_OK) {
//		printf("  %s %p (%6lu) %s\n",
//			symbolType == B_SYMBOL_TYPE_TEXT ? "text" : "data",
//			symbolLocation, symbolSize, symbolName);
		if (symbolSize > 0 && symbolType == B_SYMBOL_TYPE_TEXT) {
			Symbol* symbol = new(std::nothrow) Symbol(this,
				(addr_t)symbolLocation, symbolSize, symbolName);
			if (symbol == NULL || !symbols.AddItem(symbol)) {
				delete symbol;
				fprintf(stderr, "%s: Out of memory\n", kCommandName);
				return B_NO_MEMORY;
			}
		}
	}

	// sort the symbols
	fSymbolCount = symbols.CountItems();
	fSymbols = new(std::nothrow) Symbol*[fSymbolCount];
	if (fSymbols == NULL)
		return B_NO_MEMORY;

	for (int32 i = fSymbolCount - 1; i >= 0 ; i--)
		fSymbols[i] = symbols.RemoveItemAt(i);

	std::sort(fSymbols, fSymbols + fSymbolCount, SymbolComparator());

	return B_OK;
}
示例#27
0
文件: debug.hpp 项目: arrrrrrr/ebftpd
inline void DumpBacktrace(std::ostream& out, unsigned skip = 0)
{
  static const size_t maxSize = 100;

  void *array[maxSize];
  
  int size = backtrace(array, maxSize);
  if (size <= 0) return;
  
  boost::scoped_array<char*> symbols(backtrace_symbols(array, size));
  if (!symbols) return;
  
  for (int i = skip; i < size; ++i)
  { 
    std::string symbol(symbols[i]);
    std::string::size_type pos = symbol.find('(');
    std::string path(symbol, 0, pos);
    std::string mangled(symbol, pos + 1, symbol.find(')') - pos - 1);
    std::string offset;

    pos = mangled.find('+');
    if (pos != std::string::npos)
    {
      offset.assign(mangled, pos + 1, mangled.length() - pos);
      mangled.erase(pos);
    }
    
    pos = symbol.find('[');
    std::string address(symbol, pos + 1, symbol.find(']', pos) - pos - 1);

    out << std::left << std::setw(3) << (i - skip + 1);
        
    boost::scoped_array<char> demangled(abi::
        __cxa_demangle(mangled.c_str(), nullptr, nullptr, nullptr)); 

    out << path << " ";
    if (demangled.get()) out << demangled.get() << " ";
    else if (!mangled.empty()) out << mangled << " ";
    if (!offset.empty()) out << "[+" << offset << "] ";
    out << "[" << address << "]" << std::endl;
  }
}
示例#28
0
template <typename R> bool extract_blank(R& result,tokenizer& tokenizer)
{
 result.clear();
 
 //buffer
 
 array<ascii> buffer;
 
 //blank
 
 if(!tokenizer.blank(buffer))
  return false;
  
 //commit
 
 result=buffer;
 
 update(symbols()._blank,buffer);
 
 return true;
}
示例#29
0
文件: a7.cpp 项目: abhishek-ub/algo
int main(int argc, char* argv[]) {
    if (argc != 2) {
        std::cout << "usage: ./a7 file" << std::endl;
        return -1;
    }

    // get input text
    std::ifstream f(argv[1]);

    std::string s;
    std::vector<std::string> lines;

    while (!f.eof()) {
        s = "";
        std::getline(f, s);
        if (!s.empty()) lines.push_back(s);
    }

    f.close();

    // create a list of symbols
    std::vector<symbol> A;
    symbols(lines.begin(), lines.end(), std::back_inserter(A));

    // process the list (student's code)

    bnode<symbol>* tree = huffman_tree(A.begin(), A.end());

    // print dictionary
    print_dictionary(std::cout, tree);

    // free memory (student's code)
    release_tree(tree);
    // print dictionary
    print_dictionary(std::cout, tree);


    return 0;
} // main
示例#30
0
文件: error.hpp 项目: dbarbier/feelpp
        void setSolution(std::string const& expression ="", std::string const& p ="")
        {
            if ( expression.empty() )
                FEELPP_ASSERT( M_rhs.size() ).error( "undefined rhs exact" );
            else
                M_exact = expression;

            if ( !p.empty() )
                M_exact_params = p;

            vars = symbols<Dim>();
            std::vector<std::string> lst_params;
            boost::split(lst_params, M_exact_params, boost::is_any_of(";"));
            LOG(INFO) << "Loading additionnal parameters : ";
            boost::for_each(lst_params, [](const std::string &s){LOG(INFO) << s << ", ";});
            LOG(INFO) << std::endl;
            parameters = symbols(lst_params);

            LOG(INFO) << "Loading function : " << M_exact << std::endl;
            boost::for_each( parameters, [](symbol const& s ) {LOG(INFO) << "Symbol " << s.get_name() << " found\n";});
            exact = parse(M_exact, vars, parameters);
            LOG(INFO) << "exact solution is : " << exact << "\n";
        }