*uppsrc: mr_ped's GCC warnings fix, Core: now methods in Thread based on tojocky's ideas

git-svn-id: svn://ultimatepp.org/upp/trunk@2972 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-01-08 12:36:46 +00:00
parent bf7a0963ea
commit 7e63d65e57
26 changed files with 52 additions and 65 deletions

View file

@ -56,14 +56,17 @@ public:
int Wait();
bool IsOpen() const { return handle; }
#ifdef PLATFORM_WIN32
HANDLE GetHandle() const { return handle; }
typedef HANDLE Handle;
#endif
#ifdef PLATFORM_POSIX
pthread_t GetHandle() const { return handle; }
typedef pthread_t Handle;
#endif
Handle GetHandle() const { return handle; }
void Priority(int percent); // 0 = lowest, 100 = normal
static void Start(Callback cb);
@ -76,6 +79,12 @@ public:
static void ShutdownThreads();
static bool IsShutdownThreads();
#ifdef PLATFORM_WIN32
static Handle GetCurrentHandle() { return GetCurrentThread(); }
#endif
#ifdef PLATFORM_POSIX
static Handle GetCurrentHandle() { return pthread_self(); }
#endif
Thread();
~Thread();

View file

@ -206,15 +206,15 @@ inline bool operator==(const wchar *x, const Value& v) { return (WString)v == x
inline bool operator!=(const Value& v, const wchar *x) { return (WString)v != x; }
inline bool operator!=(const wchar *x, const Value& v) { return (WString)v != x; }
inline bool IsVoidValueTypeNo(int q) { return q == VOID_V; }
inline bool IsErrorValueTypeNo(int q) { return q == ERROR_V; }
inline bool IsStringValueTypeNo(int q) { return q == STRING_V || q == WSTRING_V; }
inline bool IsVoidValueTypeNo(int q) { return (dword)q == VOID_V; }
inline bool IsErrorValueTypeNo(int q) { return (dword)q == ERROR_V; }
inline bool IsStringValueTypeNo(int q) { return (dword)q == STRING_V || (dword)q == WSTRING_V; }
inline bool IsIntegerValueTypeNo(int q) { return q == INT_V || q == INT64_V || q == BOOL_V; }
inline bool IsFloatValueTypeNo(int q) { return q == DOUBLE_V; }
inline bool IsIntegerValueTypeNo(int q) { return (dword)q == INT_V || (dword)q == INT64_V || (dword)q == BOOL_V; }
inline bool IsFloatValueTypeNo(int q) { return (dword)q == DOUBLE_V; }
inline bool IsNumberValueTypeNo(int q) { return IsIntegerValueTypeNo(q) || IsFloatValueTypeNo(q); }
inline bool IsDateTimeValueTypeNo(int q) { return q == DATE_V || q == TIME_V; }
inline bool IsDateTimeValueTypeNo(int q) { return (dword)q == DATE_V || (dword)q == TIME_V; }
inline bool IsVoid(const Value& v) { return v.GetType() == VOID_V; }
inline bool IsError(const Value& v) { return v.GetType() == ERROR_V; }

View file

@ -860,7 +860,6 @@ String AsXML(const XmlNode& node, dword style)
XmlTag tag(node.GetText());
for(int i = 0; i < node.GetAttrCount(); i++)
tag(node.AttrId(i), node.Attr(i));
bool preserve = false;
if(node.GetCount()) {
StringBuffer body;
for(int i = 0; i < node.GetCount(); i++)

View file

@ -18,7 +18,6 @@ void Heap::Init()
return;
LLOG("Init heap " << (void *)this);
for(int i = 0; i < NKLASS; i++) {
int sz = Ksz(i);
empty[i] = NULL;
full[i]->LinkSelf();
work[i]->LinkSelf();

View file

@ -381,7 +381,7 @@ CParser::CParser(const char *ptr)
}
CParser::CParser(const char *ptr, const char *fn, int line)
: term(ptr), line(line), fn(fn), lineptr(ptr)
: term(ptr), lineptr(ptr), line(line), fn(fn)
{
skipspaces = true;
Spaces();

View file

@ -1207,7 +1207,7 @@ CppItem& Parser::Fn(const Decl& d, const String& templ, bool body,
int q;
if(d.castoper) {
q = d.name.ReverseFind(' ');
q = q > 0 ? d.name.ReverseFind(':', q) : q = d.name.ReverseFind(':');
q = q > 0 ? d.name.ReverseFind(':', q) : d.name.ReverseFind(':');
}
else
q = d.name.ReverseFind(':');

View file

@ -338,7 +338,7 @@ Image GetImage(PasteClip& clip)
}
if(clip.Accept("dib")) {
String data = ~clip;
if(data.GetCount() < sizeof(BITMAPINFO)) return Null;
if((unsigned)data.GetCount() < sizeof(BITMAPINFO)) return Null;
BITMAPINFO *lpBI = (BITMAPINFO *)~data;
BITMAPINFOHEADER& hdr = lpBI->bmiHeader;
byte *bits = (byte *)lpBI + hdr.biSize;
@ -437,7 +437,7 @@ Vector<String> GetFiles(PasteClip& clip)
GuiLock __;
Vector<String> f;
String data = clip;
if(data.GetCount() < sizeof(sDROPFILES) + 2)
if((unsigned)data.GetCount() < sizeof(sDROPFILES) + 2)
return f;
const sDROPFILES *df = (const sDROPFILES *)~data;
const char *s = ((const char *)df + df->offset);

View file

@ -624,7 +624,7 @@ struct WinMsg {
}
sWinMsg[] = {
#include "Win32Msg.i"
0, NULL
{0, NULL}
};
#endif

View file

@ -167,7 +167,6 @@ int XpInt(int widget, int part, int state, int type)
if(!theme)
return Null;
int n = Null;
int x = 0;
int r = XpTheme().GetThemeInt(theme, part, state, type, &n);
return r == S_OK ? n : Null;
}
@ -177,7 +176,6 @@ int XpBool(int widget, int part, int state, int type)
HANDLE theme = XpWidget(widget);
if(!theme)
return Null;
int x = 0;
BOOL flag = false;
int r = XpTheme().GetThemeBool(theme, part, state, type, &flag);
return r == S_OK ? flag : Null;

View file

@ -437,7 +437,6 @@ void ColumnList::PaintRows(Draw &w, Size &sz)
int pos = sb % cy;
int y = -pos;
int i = GetSbPos(sz);
int coli = 0;
while(y < sz.cy-pos+cy) {
int x = 0;
while (x + cx <= sz.cx) {

View file

@ -79,7 +79,6 @@ int ExtractAccessKey(const char *s, String& label)
byte akey = 0;
int pos = 0;
String text;
const char* start = s;
bool qtf = *s == '\1';
while(*s)
if((*s == '&' && !qtf || *s == '\b') && s[1] && s[1] != '&') {
@ -488,7 +487,6 @@ void DisplayPopup::Sync()
Ctrl *top = ctrl->GetTopCtrl();
if(top && top->HasFocusDeep()) {
Size sz = display->GetStdSize(value);
Ctrl *top = ctrl->GetTopWindow();
if(sz.cx + 2 * margin > item.GetWidth() || sz.cy > item.GetHeight()) {
Rect wa = GetWorkArea();
slim = item + ctrl->GetScreenView().TopLeft();

View file

@ -111,7 +111,6 @@ void DrawMnemonicText(Draw& w, int x, int y, const String& s, Font font, Color c
int mnemonic)
{
int apos = HIWORD(mnemonic);
int akey = LOWORD(mnemonic);
int q;
if(apos && apos < s.GetLength())
q = apos - 1;

View file

@ -228,30 +228,30 @@ struct sRFace {
const char *name;
dword l, h;
} sFontReplacements[] = {
"sans-serif", 0xffee0008, 0xdc000801,
"Arial", 0xfffe0000, 0x09c00080,
"Arial Unicode MS", 0xfffc3fef, 0xfa7ff7e7,
"MS UI Gothic", 0xffc01008, 0x0fffff00,
"MS Mincho", 0xffc01008, 0x0fffff00,
"WenQuanYi Zen Hei Mono", 0xfd800000, 0x0ae7ff7e,
"WenQuanYi Zen Hei", 0xfd800000, 0x0ae7ff7e,
"VL Gothic", 0xfd800000, 0x09a7ff80,
"VL PGothic", 0xffe00008, 0x0de7ff80,
"UnDotum", 0xe5800000, 0x0aa7ff7e,
"UnBatang", 0xe5800000, 0x0aa7ff7e,
"DejaVu Sans Mono", 0xffec0004, 0x0fc00080,
"DejaVu Sans", 0xfffd000c, 0x0fc40080,
"AlArabiyaFreeSerif", 0xffdc0008, 0xd8000007,
"Kochi Mincho", 0xffdc0008, 0xd8000007,
"Kochi Gothic", 0xffdc0008, 0xd8000007,
"Sazanami Mincho", 0xffdc0008, 0xd8000007,
"Sazanami Gothic", 0xffdc0008, 0xd8000007,
"Gulim", 0xf7c00000, 0x0ba7ff7e,
"SimSun", 0xfd800000, 0x09ffff00,
"PMingLiU", 0xff800000, 0x09ffff00,
"FreeSans", 0xfff23d00, 0x0fc00000,
"FreeSerif", 0xfffd3938, 0x0fc00080,
"Symbol", 0xe4000000, 0x88000002,
{ "sans-serif", 0xffee0008, 0xdc000801 },
{ "Arial", 0xfffe0000, 0x09c00080 },
{ "Arial Unicode MS", 0xfffc3fef, 0xfa7ff7e7 },
{ "MS UI Gothic", 0xffc01008, 0x0fffff00 },
{ "MS Mincho", 0xffc01008, 0x0fffff00 },
{ "WenQuanYi Zen Hei Mono", 0xfd800000, 0x0ae7ff7e },
{ "WenQuanYi Zen Hei", 0xfd800000, 0x0ae7ff7e },
{ "VL Gothic", 0xfd800000, 0x09a7ff80 },
{ "VL PGothic", 0xffe00008, 0x0de7ff80 },
{ "UnDotum", 0xe5800000, 0x0aa7ff7e },
{ "UnBatang", 0xe5800000, 0x0aa7ff7e },
{ "DejaVu Sans Mono", 0xffec0004, 0x0fc00080 },
{ "DejaVu Sans", 0xfffd000c, 0x0fc40080 },
{ "AlArabiyaFreeSerif", 0xffdc0008, 0xd8000007 },
{ "Kochi Mincho", 0xffdc0008, 0xd8000007 },
{ "Kochi Gothic", 0xffdc0008, 0xd8000007 },
{ "Sazanami Mincho", 0xffdc0008, 0xd8000007 },
{ "Sazanami Gothic", 0xffdc0008, 0xd8000007 },
{ "Gulim", 0xf7c00000, 0x0ba7ff7e },
{ "SimSun", 0xfd800000, 0x09ffff00 },
{ "PMingLiU", 0xff800000, 0x09ffff00 },
{ "FreeSans", 0xfff23d00, 0x0fc00000 },
{ "FreeSerif", 0xfffd3938, 0x0fc00080 },
{ "Symbol", 0xe4000000, 0x88000002 },
};
struct sFontMetricsReplacement {

View file

@ -104,12 +104,12 @@ void HexViewInfo::Paint(Draw& w)
i = 0;
for(;;) {
if(data[i] < 0) {
if(i < sizeof(float))
if((unsigned)i < sizeof(float))
ftxt = "?";
txt = "?";
break;
}
if(i >= sizeof(double)) {
if((unsigned)i >= sizeof(double)) {
double h;
memcpy(&h, sh, sizeof(double));
txt = Sprintf("%.8g", h);
@ -310,7 +310,6 @@ bool HexView::Key(dword key, int)
{
int pg = max(columns, bytes - columns);
int q = int(sc % columns);
int64 c = cursor & ~1023;
switch(key) {
case K_LEFT:
SetCursor(cursor - 1);

View file

@ -75,7 +75,6 @@ struct PainterImageSpan : SpanSource {
Image image;
void Set(const Xform2D& m, const Image& img) {
int level = 0;
image = img;
int nx = 1;
int ny = 1;

View file

@ -19,8 +19,6 @@ struct PainterRadialSpan : SpanSource {
fy = _fy;
fx -= cx;
fy -= cy;
double fx2 = double(fx) * double(fx);
double fy2 = double(fy) * double(fy);
C = fx * fx + fy * fy - r * r;
}

View file

@ -186,7 +186,6 @@ void Rasterizer::LineRaw(int x1, int y1, int x2, int y2)
LLOG("Rasterizer::LineRaw " << x1 / 256.0 << ':' << y1 / 256.0
<< " - " << x2 / 256.0 << ':' << y2 / 256.0);
int ex1 = x1 >> 8;
int ex2 = x2 >> 8;
int ey1 = y1 >> 8;
int ey2 = y2 >> 8;
@ -233,8 +232,7 @@ void Rasterizer::LineRaw(int x1, int y1, int x2, int y2)
}
incr = 1;
if(dx == 0) {
int ex = x1 >> 8;
int two_fx = (x1 - (ex << 8)) << 1;
int two_fx = (x1 - (ex1 << 8)) << 1;
int area;
first = 256;
if(dy < 0) {

View file

@ -898,7 +898,7 @@ String PdfDraw::Finish()
if(hfont) {
HDC hdc = Win32_IC();
HFONT ohfont = (HFONT) ::SelectObject(hdc, hfont);
int size = GetFontData(hdc, 0, 0, NULL, 0);
DWORD size = GetFontData(hdc, 0, 0, NULL, 0);
if(size == GDI_ERROR) {
LLOG("PdfDraw::Finish: GDI_ERROR on font " << pdffont.GetKey(i));
return Null;

View file

@ -41,7 +41,6 @@ void RichTxt::Sync0(const Para& pp, int parti, const RichContext& rc) const
}
void RichTxt::Sync(int parti, const RichContext& rc) const {
int cx = rc.page.Width();
ASSERT(part[parti].Is<Para>());
const Para& pp = part[parti].Get<Para>();
if(rc.page.Width() != pp.ccx)

View file

@ -34,7 +34,7 @@ static double ToLibraryTime(Time time)
}
ArchiveJob::Object::Object(ArchiveJob& archive, int index, String fn, String od, double ft, int ho, bool nf)
: archive(archive), index(index), filename(fn), object_data(od), filetime(ft), header_offset(ho), newfile(nf)
: archive(archive), index(index), filename(fn), object_data(od), filetime(ft), newfile(nf), header_offset(ho)
{
trimmed_name = archive.TrimObjectName(filename);
longname_offset = -1;
@ -107,7 +107,6 @@ void ArchiveJob::LoadLibrary(String libfile)
if(verbose)
PutStdOut(NFormat("%s: reading archive (%d B)", libfile, mapping.GetFileSize()));
int objcount = -1;
const byte *ptr = mapping.GetIter(8);
const byte *end = mapping.End();
const byte *longptr = NULL;

View file

@ -271,7 +271,6 @@ String CreateQtf(const String& item, const String& name, const CppItem& m, bool
d.Clear();
d = "[%% ";
Vector<String> p = Split(m.pname, ';');
bool was = false;
if(!str)
for(int i = 0; i < p.GetCount(); i++)
d << " [%-*@r " << DeQtf(p[i]) << "]";

View file

@ -219,11 +219,9 @@ void Ide::FindFileName() {
ffdlg.mask.NullText("Search");
ffdlg.mask.SetFilter(CharFilterFindFileMask);
ffdlg.mask <<= ffdlg.Breaker(IDYES);
int prev = 0;
for(;;) {
ffdlg.list.Clear();
String mask = ~ffdlg.mask;
const char *best_err = NULL;
for(int p = 0; p < wspc.GetCount(); p++) {
String packname = wspc[p];
const Package& pack = wspc.GetPackage(p);

View file

@ -112,7 +112,6 @@ void Ide::Print()
job.Landscape(dlg.orientation);
if(!job.Execute())
return;
Draw& w = job;
int l, h;
if(editor.GetSelection(l, h)) {
l = editor.GetLine(l);

View file

@ -310,6 +310,7 @@ void WorkspaceWork::AddFile(ADDFILE af)
case HOME_FILE: fs->ActiveDir(GetHomeDirectory()); break;
#endif
case LOCAL_FILE: fs->ActiveDir(GetLocalDir()); break;
default: ; // GCC warns otherwise
}
if(!fs->ExecuteOpen("Add files to package..")) return;
int fci = filelist.GetCursor();
@ -426,7 +427,6 @@ void WorkspaceWork::Import()
Progress pi("Importing file %d");
int fci = filelist.GetCursor();
int cs = filelist.GetSbPos();
int ci = fci >= 0 && fci < fileindex.GetCount() ? fileindex[fci] : -1;
try {
DoImport(~dlg.folder, ~dlg.files, false, pi);
}

View file

@ -319,7 +319,6 @@ bool Ide::FindLineError(int l, Host& host) {
String file;
int lineno;
int error;
int q = btabs.GetCursor();
Console& c = GetConsole();
if (FindLineError(c.GetUtf8Line(l), host, file, lineno, error)) {
file = NormalizePath(file);

View file

@ -35,7 +35,6 @@ bool SvnSel::Load(const String& path)
for(int i = 0; i < l.GetCount(); i++) {
String fn = l[i];
if(fn.GetLength()) {
bool isdir = false;
if(*fn.Last() == '/' || *fn.Last() == '\\') {
fn.Trim(fn.GetLength() - 1);
if(pass == 0)