Alien-SmokeQt
view release on metacpan or search on metacpan
generator/parser/indexedstring.cpp view on Meta::CPAN
int getIndex(const QString& str) {
int idx = strings()->indexOf(str);
if (idx > -1) return idx;
strings()->append(str);
return strings()->count() - 1;
}
IndexedString::IndexedString() : m_index(0) {
}
///@param str must be a utf8 encoded string, does not need to be 0-terminated.
///@param length must be its length in bytes.
IndexedString::IndexedString( const char* str, unsigned short length, unsigned int hash ) {
if(!length)
m_index = 0;
else if(length == 1)
m_index = 0xffff0000 | str[0];
else {
m_index = getIndex(QString::fromUtf8(str, length));
/*QMutexLocker lock(globalIndexedStringRepository->mutex());
generator/parser/indexedstring.h view on Meta::CPAN
///just use this class in every duchain data type without restrictions.
///
///@warning Do not use IndexedString after QCoreApplication::aboutToQuit() has been emitted, items that are not disk-referenced will be invalid at that point
///
///Empty strings have an index of zero.
///Strings of length one are not put into the repository, but are encoded directly within the index:
///They are encoded like 0xffff00bb where bb is the byte of the character.
class CPPPARSER_EXPORT IndexedString {
public:
IndexedString();
///@param str must be a utf8 encoded string, does not need to be 0-terminated.
///@param length must be its length in bytes.
///@param hash must be a hash as constructed with the here defined hash functions. If it is zero, it will be computed.
explicit IndexedString( const char* str, unsigned short length, unsigned int hash = 0 );
///Needs a zero terminated string. When the information is already available, try using the other constructor.
explicit IndexedString( const char* str );
explicit IndexedString( char c );
///When the information is already available, try using the other constructor. This is expensive.
generator/parser/rpp/macrorepository.cpp view on Meta::CPAN
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "macrorepository.h"
//The text is supposed to be utf8 encoded
using namespace rpp;
size_t MacroRepositoryItemRequest::itemSize() const {
return macro.dynamicSize();
}
MacroRepositoryItemRequest::MacroRepositoryItemRequest(const rpp::pp_macro& _macro) : macro(_macro) {
_macro.completeHash(); //Make sure the hash is valid
}
generator/parser/rpp/macrorepository.h view on Meta::CPAN
#ifndef MACROREPOSITORY_H
#define MACROREPOSITORY_H
#include <language/duchain/repositories/itemrepository.h>
#include <cppparserexport.h>
#include "pp-macro.h"
struct Q_DECL_EXPORT MacroRepositoryItemRequest {
//The text is supposed to be utf8 encoded
MacroRepositoryItemRequest(const rpp::pp_macro& _macro);
enum {
AverageSize = 20 //This should be the approximate average size of an Item
};
typedef unsigned int HashType;
HashType hash() const {
return macro.completeHash();
generator/parser/rpp/pp-engine.cpp view on Meta::CPAN
problemEncountered(problem);
}
void pp::handle_define (Stream& input)
{
pp_macro* macro = new pp_macro;
macro->file = currentFileName();
macro->sourceLine = input.originalInputPosition().line;
skip_blanks (input, devnull());
macro->name = IndexedString::fromIndex(skip_identifier(input)); //@todo make macros utf8 too
if (!input.atEnd() && input == '(')
{
macro->function_like = true;
skip_blanks (++input, devnull()); // skip '('
uint formal = skip_identifier(input);
if (formal)
macro->formals.append( IndexedString::fromIndex(formal) );
generator/parser/rpp/pp-engine.h view on Meta::CPAN
enum StringType { File, Data };
///@todo Remove
inline QString currentFileNameString () const { return m_files.top().str(); }
inline IndexedString currentFileName () const { return m_files.top(); }
Value eval_expression (Stream& input);
/** Read file @p fileName and preprocess
* Currently the file is expected to be utf8-encoded. */
PreprocessedContents processFile(const QString& fileName);
/** Preprocess @p fileName with content @p data. Do not actually open file @p fileName
* Currently the file is expected to be utf8-encoded. */
PreprocessedContents processFile(const QString& fileName, const QByteArray& data);
void operator () (Stream& input, Stream& output);
void checkMarkNeeded(Stream& input, Stream& output);
bool hideNextMacro() const;
void setHideNextMacro(bool hideNext);
Environment* environment() const;
( run in 1.275 second using v1.01-cache-2.11-cpan-49f99fa48dc )