Automatic style cleanup with the astyle program.

This commit is contained in:
plfiorini 2010-07-10 13:58:15 +00:00
parent 082f2ad34e
commit a651de0f53
16 changed files with 2779 additions and 3014 deletions

View File

@ -39,8 +39,7 @@ Emoconfig::Emoconfig(const char* xmlfile):BMessage()
BFile* settings = new BFile(xmlfile, B_READ_ONLY); BFile* settings = new BFile(xmlfile, B_READ_ONLY);
off_t size; off_t size;
settings->GetSize(&size); settings->GetSize(&size);
if(size) if (size) {
{
void* buffer = malloc(size); void* buffer = malloc(size);
size = settings->Read(buffer, size); size = settings->Read(buffer, size);
XML_Parse(fParser, (const char*)buffer, size, true); XML_Parse(fParser, (const char*)buffer, size, true);
@ -65,28 +64,17 @@ Emoconfig::StartElement(void * /*pUserData*/, const char * pName, const char **
{ {
//printf("StartElement %s\n",pName); //printf("StartElement %s\n",pName);
BString name(pName); BString name(pName);
if(name.ICompare("emoticon")==0) if (name.ICompare("emoticon") == 0) {
{
faces = new BMessage(); faces = new BMessage();
svg = false; svg = false;
} } else if (name.ICompare("text") == 0 && faces) {
else
if(name.ICompare("text")==0 && faces)
{
valid = true; valid = true;
} } else if (name.ICompare("file") == 0 && faces) {
else
if(name.ICompare("file")==0 && faces)
{
fname = true; fname = true;
} else } else if (name.ICompare("svg") == 0 && faces) {
if(name.ICompare("svg")==0 && faces)
{
// printf("File is SVG\n"); // printf("File is SVG\n");
svg = true; svg = true;
} else } else if (name.ICompare("size") == 0) {
if(name.ICompare("size")==0)
{
size = true; size = true;
gCharacters = ""; gCharacters = "";
} }
@ -98,25 +86,18 @@ Emoconfig::EndElement(void * pUserData, const char * pName)
//printf("EndElement %s\n",pName); //printf("EndElement %s\n",pName);
BString name(pName); BString name(pName);
if(name.ICompare("emoticon")==0 && faces) if (name.ICompare("emoticon") == 0 && faces) {
{
//faces->PrintToStream(); //debug //faces->PrintToStream(); //debug
delete faces; delete faces;
faces = NULL; faces = NULL;
} } else if (name.ICompare("text") == 0 && faces) {
else
if(name.ICompare("text")==0 && faces)
{
valid = false; valid = false;
faces->AddString("face", face); faces->AddString("face", face);
//printf("to ]%s[\n",face.String()); //printf("to ]%s[\n",face.String());
face.SetTo(""); face.SetTo("");
} } else if (name.ICompare("file") == 0 && faces) {
else
if(name.ICompare("file")==0 && faces)
{
//load file //load file
//compose the filename //compose the filename
@ -124,8 +105,8 @@ Emoconfig::EndElement(void * pUserData, const char * pName)
p.Append(filename.String()); p.Append(filename.String());
BBitmap* icons = NULL; BBitmap* icons = NULL;
if ( !svg ) if ( !svg ) {
{ // //
icons = BTranslationUtils::GetBitmap(p.Path()); icons = BTranslationUtils::GetBitmap(p.Path());
} }
@ -137,11 +118,9 @@ Emoconfig::EndElement(void * pUserData, const char * pName)
int i = 0; int i = 0;
BString s; BString s;
while(faces->FindString("face",i,&s)==B_OK) while (faces->FindString("face", i, &s) == B_OK) {
{
if(i==0) if (i == 0) {
{
((Emoconfig*)pUserData)->menu.AddPointer(s.String(), (const void*)icons); ((Emoconfig*)pUserData)->menu.AddPointer(s.String(), (const void*)icons);
((Emoconfig*)pUserData)->menu.AddString("face", s.String()); ((Emoconfig*)pUserData)->menu.AddString("face", s.String());
} }
@ -153,11 +132,8 @@ Emoconfig::EndElement(void * pUserData, const char * pName)
} }
} else } else if (name.ICompare("size") == 0) {
if(name.ICompare("size")==0) if ( size ) {
{
if ( size )
{
((Emoconfig*)pUserData)->fEmoticonSize = atoi(gCharacters.String()); ((Emoconfig*)pUserData)->fEmoticonSize = atoi(gCharacters.String());
} }
@ -171,22 +147,16 @@ Emoconfig::Characters(void * /*pUserData*/, const char * pString, int pLen)
{ {
BString f(pString, pLen); BString f(pString, pLen);
//printf("Characters %s\n",f.String()); //printf("Characters %s\n",f.String());
if(faces && valid) if (faces && valid) {
{
f.RemoveAll(" "); f.RemoveAll(" ");
f.RemoveAll("\""); f.RemoveAll("\"");
if (f.Length() > 0) if (f.Length() > 0)
face.Append(f); face.Append(f);
} } else if (fname) {
else
if(fname)
{
f.RemoveAll(" "); f.RemoveAll(" ");
filename = f; filename = f;
} } else {
else
{
gCharacters.Append(f); gCharacters.Append(f);
} }
} }

View File

@ -14,7 +14,9 @@ class Emoconfig : public BMessage
int numfaces; int numfaces;
BMessage menu; BMessage menu;
float GetEmoticonSize() { return fEmoticonSize; } float GetEmoticonSize() {
return fEmoticonSize;
}
private: private:

View File

@ -52,8 +52,7 @@ Emoticor::_findTokens(RunView *fTextView,BString text,int tokenstart, int16 cols
BString cur; BString cur;
int i = tokenstart; int i = tokenstart;
if (fConfig != NULL) if (fConfig != NULL) {
{
while (fConfig->FindString("face", i, &cur) == B_OK) while (fConfig->FindString("face", i, &cur) == B_OK)
//for(int i=tokenstart;i<config->numfaces;i++) //for(int i=tokenstart;i<config->numfaces;i++)
{ {
@ -62,19 +61,16 @@ Emoticor::_findTokens(RunView *fTextView,BString text,int tokenstart, int16 cols
newindex = 0; newindex = 0;
while(true) while (true) {
{
newindex = text.IFindFirst(cur.String(), 0); newindex = text.IFindFirst(cur.String(), 0);
//printf("Try %d %s -- match %d\n",i,cur->original.String(),newindex); //printf("Try %d %s -- match %d\n",i,cur->original.String(),newindex);
if(newindex!=B_ERROR) if (newindex != B_ERROR) {
{
//take a walk on the left side ;) //take a walk on the left side ;)
//printf("Found at %ld \n",newindex); //printf("Found at %ld \n",newindex);
if(newindex-1>=0) if (newindex - 1 >= 0) {
{
BString left; BString left;
text.CopyInto(left, 0, newindex); text.CopyInto(left, 0, newindex);
//printf("ready to recourse! [%s]\n",left.String()); //printf("ready to recourse! [%s]\n",left.String());
@ -89,8 +85,7 @@ Emoticor::_findTokens(RunView *fTextView,BString text,int tokenstart, int16 cols
fTextView->Append(cur.String(), cols2, cols2, font2); fTextView->Append(cur.String(), cols2, cols2, font2);
if (text.Length() == 0) return; //useless stack if (text.Length() == 0) return; //useless stack
} } else
else
break; break;
} }

View File

@ -25,14 +25,17 @@ class NormalTextRender : public TextRender
}; };
virtual float Size(){ return font.Size();} virtual float Size() {
return font.Size();
}
virtual void GetHeight(font_height *height){ font.GetHeight(height); }; virtual void GetHeight(font_height* height) {
font.GetHeight(height);
};
virtual void virtual void
GetEscapements(const char charArray[], int32 numChars,float escapementArray[]) GetEscapements(const char charArray[], int32 numChars, float escapementArray[]) {
{
font.GetEscapements(charArray, numChars, escapementArray); font.GetEscapements(charArray, numChars, escapementArray);
} }

View File

@ -76,7 +76,9 @@ struct UnaryPredicate {
virtual int operator()(const T*) const virtual int operator()(const T*) const
// virtual could be avoided here if FindBinaryInsertionIndex, // virtual could be avoided here if FindBinaryInsertionIndex,
// etc. were member template functions // etc. were member template functions
{ return 0; } {
return 0;
}
private: private:
static int _unary_predicate_glue(const void* item, void* context); static int _unary_predicate_glue(const void* item, void* context);
@ -92,7 +94,8 @@ UnaryPredicate<T>::_unary_predicate_glue(const void *item, void *context)
} }
class _PointerList_ : public BList { class _PointerList_ : public BList
{
public: public:
_PointerList_(const _PointerList_ &list); _PointerList_(const _PointerList_ &list);
_PointerList_(int32 itemsPerBlock = 20, bool owning = false); _PointerList_(int32 itemsPerBlock = 20, bool owning = false);
@ -126,7 +129,8 @@ protected:
}; };
template<class T> template<class T>
class BObjectList : private _PointerList_ { class BObjectList : private _PointerList_
{
public: public:
// iteration and sorting // iteration and sorting
@ -238,10 +242,12 @@ public:
// or index of an existing item that matches the predicate // or index of an existing item that matches the predicate
// deprecated API, will go away // deprecated API, will go away
BList *AsBList() BList* AsBList() {
{ return this; } return this;
const BList *AsBList() const }
{ return this; } const BList* AsBList() const {
return this;
}
private: private:
void SetItem(int32, T*); void SetItem(int32, T*);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -70,21 +70,18 @@ class SelectPos
~SelectPos (void) ~SelectPos (void)
{ } { }
SelectPos &operator = (const SelectPos &pos) SelectPos& operator = (const SelectPos& pos) {
{
fLine = pos.fLine; fLine = pos.fLine;
fOffset = pos.fOffset; fOffset = pos.fOffset;
return *this; return *this;
} }
inline int operator == (const SelectPos &rhs) const inline int operator == (const SelectPos& rhs) const {
{
return ((fLine == rhs.fLine) && (fOffset == rhs.fOffset)); return ((fLine == rhs.fLine) && (fOffset == rhs.fOffset));
} }
inline int operator != (const SelectPos &rhs) const inline int operator != (const SelectPos& rhs) const {
{
return (!(*this == rhs)); return (!(*this == rhs));
} }
@ -149,8 +146,10 @@ class RunView : public BView
virtual void MessageReceived (BMessage*); virtual void MessageReceived (BMessage*);
virtual void SetViewColor (rgb_color); virtual void SetViewColor (rgb_color);
void SetViewColor (uchar red, uchar green, uchar blue, uchar alpha = 255) void SetViewColor (uchar red, uchar green, uchar blue, uchar alpha = 255) {
{ rgb_color color = {red, green, blue, alpha}; SetViewColor (color); } rgb_color color = {red, green, blue, alpha};
SetViewColor (color);
}
virtual void MouseDown (BPoint); virtual void MouseDown (BPoint);

View File

@ -25,8 +25,7 @@ class SmileTextRender : public TextRender
BBitmap* pointer = NULL; BBitmap* pointer = NULL;
BString f(txt, num); BString f(txt, num);
if(Emoticor::Get()->Config()->FindPointer(f.String(),(void**)&pointer)==B_OK) if (Emoticor::Get()->Config()->FindPointer(f.String(), (void**)&pointer) == B_OK) {
{
target->SetDrawingMode( B_OP_ALPHA ); target->SetDrawingMode( B_OP_ALPHA );
target->DrawBitmapAsync( pointer, BPoint(pos.x, pos.y - (Emoticor::Get()->Config()->GetEmoticonSize() / 2)) ); target->DrawBitmapAsync( pointer, BPoint(pos.x, pos.y - (Emoticor::Get()->Config()->GetEmoticonSize() / 2)) );
target->SetDrawingMode( B_OP_OVER ); target->SetDrawingMode( B_OP_OVER );
@ -34,17 +33,17 @@ class SmileTextRender : public TextRender
}; };
virtual float Size(){ return Emoticor::Get()->Config()->GetEmoticonSize();} virtual float Size() {
return Emoticor::Get()->Config()->GetEmoticonSize();
}
virtual void GetHeight(font_height *h) virtual void GetHeight(font_height* h) {
{
h->descent = h->ascent = Emoticor::Get()->Config()->GetEmoticonSize() / 2; h->descent = h->ascent = Emoticor::Get()->Config()->GetEmoticonSize() / 2;
h->leading = 0; h->leading = 0;
}; };
virtual void virtual void
GetEscapements(const char * /*charArray*/, int32 numChars,float escapementArray[]) GetEscapements(const char * /*charArray*/, int32 numChars, float escapementArray[]) {
{
//font.GetEscapements(charArray,numChars,escapementArray); //font.GetEscapements(charArray,numChars,escapementArray);
escapementArray[0] = 1; escapementArray[0] = 1;
for (int i = 1; i < numChars; i++) escapementArray[i] = 0; for (int i = 1; i < numChars; i++) escapementArray[i] = 0;

View File

@ -73,8 +73,9 @@ class Theme
int16); int16);
virtual ~Theme (void); virtual ~Theme (void);
const char *Name (void) const const char* Name (void) const {
{ return name; } return name;
}
void ReadLock (void); void ReadLock (void);
void ReadUnlock (void); void ReadUnlock (void);
@ -94,11 +95,15 @@ class Theme
TextRender* TextRenderAt(int16); TextRender* TextRenderAt(int16);
bool SetForeground (int16, const rgb_color); bool SetForeground (int16, const rgb_color);
bool SetForeground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) bool SetForeground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) {
{ rgb_color color = {r, g, b, a}; return SetForeground (w, color); } rgb_color color = {r, g, b, a};
return SetForeground (w, color);
}
bool SetBackground (int16, const rgb_color); bool SetBackground (int16, const rgb_color);
bool SetBackground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) bool SetBackground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) {
{ rgb_color color = {r, g, b, a}; return SetBackground (w, color); } rgb_color color = {r, g, b, a};
return SetBackground (w, color);
}
//bool SetFont (int16, const BFont &); //bool SetFont (int16, const BFont &);
bool SetTextRender(int16, TextRender*); bool SetTextRender(int16, TextRender*);
@ -106,8 +111,12 @@ class Theme
void SetSoftLineIndent(float indent); void SetSoftLineIndent(float indent);
void SetTextMargin(float margin); void SetTextMargin(float margin);
float TextMargin() const { return fTextMargin; } float TextMargin() const {
float SoftLineIndent() const { return fSoftLineIndent; } return fTextMargin;
}
float SoftLineIndent() const {
return fSoftLineIndent;
}

View File

@ -42,8 +42,7 @@ URLCrunch::Crunch (BString *url)
return B_ERROR; return B_ERROR;
const int32 tagNum = 7; const int32 tagNum = 7;
const char *tags[tagNum] = const char* tags[tagNum] = {
{
"http://", "http://",
"https://", "https://",
"www.", "www.",
@ -65,8 +64,7 @@ URLCrunch::Crunch (BString *url)
for (i = 0; i < tagNum; ++i) for (i = 0; i < tagNum; ++i)
if (markers[i] != B_ERROR if (markers[i] != B_ERROR
&& markers[i] < marker) && markers[i] < marker) {
{
url_length = markers[i] + strlen(tags[i]); url_length = markers[i] + strlen(tags[i]);
url_length += strcspn (buffer.String() + url_length, " \t\n|\\<>\")(][}{;'*^"); url_length += strcspn (buffer.String() + url_length, " \t\n|\\<>\")(][}{;'*^");
@ -76,18 +74,15 @@ URLCrunch::Crunch (BString *url)
if (url_length - markers[i] > len if (url_length - markers[i] > len
&& (isdigit (buffer[markers[i] + len]) && (isdigit (buffer[markers[i] + len])
|| isalpha (buffer[markers[i] + len]))) || isalpha (buffer[markers[i] + len]))) {
{
marker = markers[i]; marker = markers[i];
pos = url_length + 1; pos = url_length + 1;
url_length -= marker; url_length -= marker;
} } else
else
pos = markers[i] + 1; pos = markers[i] + 1;
} }
if (marker < buffer.Length()) if (marker < buffer.Length()) {
{
*url = ""; *url = "";
url->Append (buffer.String() + marker, url_length); url->Append (buffer.String() + marker, url_length);

View File

@ -44,8 +44,7 @@ GetWord (const char *cData, int32 wordNeeded)
BString buffer ("-9z99"); BString buffer ("-9z99");
int32 wordAt (1), place (0); int32 wordAt (1), place (0);
while (wordAt != wordNeeded && place != B_ERROR) while (wordAt != wordNeeded && place != B_ERROR) {
{
if ((place = data.FindFirst ('\x20', place)) != B_ERROR) if ((place = data.FindFirst ('\x20', place)) != B_ERROR)
if (++place < data.Length() if (++place < data.Length()
&& data[place] != '\x20') && data[place] != '\x20')
@ -54,8 +53,7 @@ GetWord (const char *cData, int32 wordNeeded)
if (wordAt == wordNeeded if (wordAt == wordNeeded
&& place != B_ERROR && place != B_ERROR
&& place < data.Length()) && place < data.Length()) {
{
int32 end (data.FindFirst ('\x20', place)); int32 end (data.FindFirst ('\x20', place));
if (end == B_ERROR) if (end == B_ERROR)
@ -79,8 +77,7 @@ GetWordColon (const char *cData, int32 wordNeeded)
BString buffer ("-9z99"); BString buffer ("-9z99");
int32 wordAt (1), place (0); int32 wordAt (1), place (0);
while (wordAt != wordNeeded && place != B_ERROR) while (wordAt != wordNeeded && place != B_ERROR) {
{
if ((place = data.FindFirst (':', place)) != B_ERROR) if ((place = data.FindFirst (':', place)) != B_ERROR)
if (++place < data.Length() if (++place < data.Length()
&& data[place] != ':') && data[place] != ':')
@ -89,8 +86,7 @@ GetWordColon (const char *cData, int32 wordNeeded)
if (wordAt == wordNeeded if (wordAt == wordNeeded
&& place != B_ERROR && place != B_ERROR
&& place < data.Length()) && place < data.Length()) {
{
int32 end (data.FindFirst (':', place)); int32 end (data.FindFirst (':', place));
if (end == B_ERROR) if (end == B_ERROR)
@ -115,8 +111,7 @@ RestOfString (const char *cData, int32 wordStart)
int32 wordAt (1), place (0); int32 wordAt (1), place (0);
BString buffer ("-9z99"); BString buffer ("-9z99");
while (wordAt != wordStart && place != B_ERROR) while (wordAt != wordStart && place != B_ERROR) {
{
if ((place = data.FindFirst ('\x20', place)) != B_ERROR) if ((place = data.FindFirst ('\x20', place)) != B_ERROR)
if (++place < data.Length() if (++place < data.Length()
&& data[place] != '\x20') && data[place] != '\x20')
@ -163,8 +158,7 @@ GetIdent (const char *cData)
int32 place[2]; int32 place[2];
if ((place[0] = data.FindFirst ('!')) != B_ERROR if ((place[0] = data.FindFirst ('!')) != B_ERROR
&& (place[1] = data.FindFirst ('@')) != B_ERROR) && (place[1] = data.FindFirst ('@')) != B_ERROR) {
{
++(place[0]); ++(place[0]);
data.CopyInto (theIdent, place[0], place[1] - place[0]); data.CopyInto (theIdent, place[0], place[1] - place[0]);
} }
@ -185,8 +179,7 @@ GetAddress (const char *cData)
BString address; BString address;
int32 place; int32 place;
if ((place = data.FindFirst ('@')) != B_ERROR) if ((place = data.FindFirst ('@')) != B_ERROR) {
{
int32 length (data.FindFirst ('\x20', place)); int32 length (data.FindFirst ('\x20', place));
if (length == B_ERROR) if (length == B_ERROR)
@ -232,10 +225,8 @@ ExpandKeyed (
{ {
BString buffer; BString buffer;
while (incoming && *incoming) while (incoming && *incoming) {
{ if (*incoming == '$') {
if (*incoming == '$')
{
const char* place; const char* place;
++incoming; ++incoming;
@ -244,8 +235,7 @@ ExpandKeyed (
buffer += expansions[place - keys]; buffer += expansions[place - keys];
else else
buffer += *incoming; buffer += *incoming;
} } else
else
buffer += *incoming; buffer += *incoming;
++incoming; ++incoming;
@ -344,8 +334,7 @@ Get440Len (const char *cData)
if (data.Length() < 440) if (data.Length() < 440)
return data.Length(); return data.Length();
else else {
{
int32 place (data.FindLast ('\x20', 440)); int32 place (data.FindLast ('\x20', 440));
if (place == B_ERROR) if (place == B_ERROR)
return 440; return 440;

View File

@ -26,20 +26,18 @@
#include <String.h> #include <String.h>
template<class T> class AutoDestructor { template<class T> class AutoDestructor
public:
AutoDestructor(T *t)
{ {
public:
AutoDestructor(T* t) {
fObject = t; fObject = t;
} }
virtual ~AutoDestructor(void) virtual ~AutoDestructor(void) {
{
delete fObject; delete fObject;
} }
void SetTo(T *t) void SetTo(T* t) {
{
delete fObject; delete fObject;
fObject = t; fObject = t;
} }