dmd v2.071.0 updates

This commit is contained in:
Adam D. Ruppe 2016-04-07 00:15:11 -04:00
parent 033d88dfa6
commit 5d2836489d
9 changed files with 50 additions and 62 deletions

4
cgi.d
View File

@ -163,6 +163,8 @@
+/ +/
module arsd.cgi; module arsd.cgi;
static import std.file;
version(embedded_httpd) { version(embedded_httpd) {
version(linux) version(linux)
version=embedded_httpd_processes; version=embedded_httpd_processes;
@ -291,7 +293,7 @@ private struct stdin {
} }
} }
import std.c.windows.windows; import core.sys.windows.windows;
static: static:
static this() { static this() {

View File

@ -1,6 +1,8 @@
/// crappy event loop for linux /// crappy event loop for linux
module arsd.eventloop; module arsd.eventloop;
version(linux):
/* **** */ /* **** */
// Loop implementation // Loop implementation
// FIXME: much of this is posix or even linux specific, but we ideally want the same interface across all operating systems, though not necessarily even a remotely similar implementation // FIXME: much of this is posix or even linux specific, but we ideally want the same interface across all operating systems, though not necessarily even a remotely similar implementation

1
html.d
View File

@ -11,6 +11,7 @@ module arsd.html;
public import arsd.dom; public import arsd.dom;
import arsd.color; import arsd.color;
static import std.uri;
import std.array; import std.array;
import std.string; import std.string;
import std.variant; import std.variant;

View File

@ -61,6 +61,7 @@ module arsd.jsvar;
version=new_std_json; version=new_std_json;
import std.stdio; import std.stdio;
static import std.array;
import std.traits; import std.traits;
import std.conv; import std.conv;
import std.json; import std.json;

View File

@ -988,7 +988,7 @@ class Window : Widget {
auto b = SelectObject(painter.impl.hdc, GetSysColorBrush(COLOR_3DFACE)); auto b = SelectObject(painter.impl.hdc, GetSysColorBrush(COLOR_3DFACE));
auto p = SelectObject(painter.impl.hdc, GetStockObject(NULL_PEN)); auto p = SelectObject(painter.impl.hdc, GetStockObject(NULL_PEN));
// since the pen is null, to fill the whole space, we need the +1 on both. // since the pen is null, to fill the whole space, we need the +1 on both.
Rectangle(painter.impl.hdc, 0, 0, this.width + 1, this.height + 1); gdi.Rectangle(painter.impl.hdc, 0, 0, this.width + 1, this.height + 1);
SelectObject(painter.impl.hdc, p); SelectObject(painter.impl.hdc, p);
SelectObject(painter.impl.hdc, b); SelectObject(painter.impl.hdc, b);
}; };
@ -1341,7 +1341,7 @@ class MenuBar : Widget {
this.addChild(item); this.addChild(item);
items ~= item; items ~= item;
version(win32_widgets) { version(win32_widgets) {
AppendMenu(handle, MF_STRING, item.action is null ? 9000 : item.action.id, toStringzInternal(item.label)); AppendMenuA(handle, MF_STRING, item.action is null ? 9000 : item.action.id, toStringzInternal(item.label)); // XXX
} }
return item; return item;
} }
@ -1353,7 +1353,7 @@ class MenuBar : Widget {
items ~= mbItem; items ~= mbItem;
version(win32_widgets) { version(win32_widgets) {
AppendMenu(handle, MF_STRING | MF_POPUP, cast(UINT) item.handle, toStringzInternal(item.label)); AppendMenuA(handle, MF_STRING | MF_POPUP, cast(UINT) item.handle, toStringzInternal(item.label)); // XXX
} else { } else {
mbItem.defaultEventHandlers["click"] = (Widget e, Event ev) { mbItem.defaultEventHandlers["click"] = (Widget e, Event ev) {
item.parentWindow = e.parentWindow; item.parentWindow = e.parentWindow;
@ -1695,7 +1695,7 @@ class Menu : Widget {
addChild(item); addChild(item);
items ~= item; items ~= item;
version(win32_widgets) { version(win32_widgets) {
AppendMenu(handle, MF_STRING, item.action is null ? 9000 : item.action.id, toStringzInternal(item.label)); AppendMenuA(handle, MF_STRING, item.action is null ? 9000 : item.action.id, toStringzInternal(item.label)); // XXX
} }
return item; return item;
} }
@ -2506,7 +2506,8 @@ extern(Windows):
} }
version(win32_widgets) { version(win32_widgets) {
import std.c.windows.windows; import core.sys.windows.windows;
import gdi = core.sys.windows.wingdi;
// import win32.commctrl; // import win32.commctrl;
// import win32.winuser; // import win32.winuser;
@ -2531,8 +2532,6 @@ extern(Windows):
HMENU CreateMenu(); HMENU CreateMenu();
bool SetMenu(HWND, HMENU); bool SetMenu(HWND, HMENU);
HMENU CreatePopupMenu(); HMENU CreatePopupMenu();
BOOL AppendMenuA(HMENU, uint, UINT_PTR, LPCTSTR);
alias AppendMenuA AppendMenu;
enum MF_POPUP = 0x10; enum MF_POPUP = 0x10;
enum MF_STRING = 0; enum MF_STRING = 0;

View File

@ -1063,7 +1063,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent {
version(X11) { version(X11) {
return (glXMakeCurrent(display, impl.window, impl.glc) != 0); return (glXMakeCurrent(display, impl.window, impl.glc) != 0);
} else version(Windows) { } else version(Windows) {
return wglMakeCurrent(ghDC, ghRC); return wglMakeCurrent(ghDC, ghRC) ? true : false;
} }
} }
@ -1074,7 +1074,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent {
version(X11) { version(X11) {
return (glXMakeCurrent(display, 0, null) != 0); return (glXMakeCurrent(display, 0, null) != 0);
} else version(Windows) { } else version(Windows) {
return wglMakeCurrent(ghDC, null); return wglMakeCurrent(ghDC, null) ? true : false;
} }
} }
@ -1337,23 +1337,7 @@ class Timer {
} else version(linux) { } else version(linux) {
static import ep = core.sys.linux.epoll; static import ep = core.sys.linux.epoll;
// static import tfd = core.sys.linux.timerfd; static import tfd = core.sys.linux.timerfd;
static struct tfd {
static:
import core.sys.posix.time;
extern(C):
pragma(mangle, "timerfd_create")
int timerfd_create(int, int);
pragma(mangle, "timerfd_settime")
int timerfd_settime(int, int, const itimerspec*, itimerspec*);
pragma(mangle, "timerfd_gettime")
int timerfd_gettime(int, itimerspec*);
enum TFD_TIMER_ABSTIME = 1 << 0;
enum TFD_CLOEXEC = 0x80000;
enum TFD_NONBLOCK = 0x800;
}
fd = tfd.timerfd_create(tfd.CLOCK_MONOTONIC, 0); fd = tfd.timerfd_create(tfd.CLOCK_MONOTONIC, 0);
if(fd == -1) if(fd == -1)
@ -1437,9 +1421,11 @@ class Timer {
version(Windows) version(Windows)
extern(Windows) extern(Windows)
static void timerCallback(HWND, UINT, UINT_PTR timer, DWORD dwTime) { static void timerCallback(HWND, UINT, UINT_PTR timer, DWORD dwTime) nothrow {
if(Timer* t = timer in mapping) { if(Timer* t = timer in mapping) {
try
(*t).trigger(); (*t).trigger();
catch(Exception e) { throw new Error(e.msg, e.file, e.line); }
} }
} }
@ -1856,6 +1842,14 @@ enum RasterOp {
// being phobos-free keeps the size WAY down // being phobos-free keeps the size WAY down
private const(char)* toStringz(string s) { return (s ~ '\0').ptr; } private const(char)* toStringz(string s) { return (s ~ '\0').ptr; }
private const(wchar)* toWStringz(wstring s) { return (s ~ '\0').ptr; }
private const(wchar)* toWStringz(string s) {
wstring r;
foreach(dchar c; s)
r ~= c;
r ~= '\0';
return r.ptr;
}
private string[] split(in void[] a, char c) { private string[] split(in void[] a, char c) {
string[] ret; string[] ret;
size_t previous = 0; size_t previous = 0;
@ -3474,14 +3468,14 @@ version(Windows) {
Size textSize(string text) { Size textSize(string text) {
RECT rect; RECT rect;
DrawText(hdc, text.ptr, cast(int) text.length, &rect, DT_CALCRECT); DrawTextA(hdc, text.ptr, cast(int) text.length, &rect, DT_CALCRECT); /// XXX
return Size(rect.right, rect.bottom); return Size(rect.right, rect.bottom);
} }
void drawText(int x, int y, int x2, int y2, string text, uint alignment) { void drawText(int x, int y, int x2, int y2, string text, uint alignment) {
// FIXME: use the unicode function // FIXME: use the unicode function
if(x2 == 0 && y2 == 0) if(x2 == 0 && y2 == 0)
TextOut(hdc, x, y, text.ptr, cast(int) text.length); TextOutA(hdc, x, y, text.ptr, cast(int) text.length); // XXX
else { else {
RECT rect; RECT rect;
rect.left = x; rect.left = x;
@ -3499,7 +3493,7 @@ version(Windows) {
if(alignment & TextAlignment.VerticalCenter) if(alignment & TextAlignment.VerticalCenter)
mode |= DT_VCENTER | DT_SINGLELINE; mode |= DT_VCENTER | DT_SINGLELINE;
DrawText(hdc, text.ptr, cast(int) text.length, &rect, mode); DrawTextA(hdc, text.ptr, cast(int) text.length, &rect, mode); // XXX
} }
/* /*
@ -3533,7 +3527,7 @@ version(Windows) {
} }
void drawRectangle(int x, int y, int width, int height) { void drawRectangle(int x, int y, int width, int height) {
Rectangle(hdc, x, y, x + width, y + height); gdi.Rectangle(hdc, x, y, x + width, y + height);
} }
/// Arguments are the points of the bounding rectangle /// Arguments are the points of the bounding rectangle
@ -3589,7 +3583,7 @@ version(Windows) {
} }
void createWindow(int width, int height, string title, OpenGlOptions opengl, SimpleWindow parent) { void createWindow(int width, int height, string title, OpenGlOptions opengl, SimpleWindow parent) {
const char* cn = "DSimpleWindow"; wstring cn = "DSimpleWindow"w;
HINSTANCE hInstance = cast(HINSTANCE) GetModuleHandle(null); HINSTANCE hInstance = cast(HINSTANCE) GetModuleHandle(null);
@ -3599,13 +3593,13 @@ version(Windows) {
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
wc.hbrBackground = cast(HBRUSH) (COLOR_WINDOW+1); // GetStockObject(WHITE_BRUSH); wc.hbrBackground = cast(HBRUSH) (COLOR_WINDOW+1); // GetStockObject(WHITE_BRUSH);
wc.hCursor = LoadCursor(null, IDC_ARROW); wc.hCursor = LoadCursorW(null, IDC_ARROW);
wc.hIcon = LoadIcon(hInstance, null); wc.hIcon = LoadIcon(hInstance, null);
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.lpfnWndProc = &WndProc; wc.lpfnWndProc = &WndProc;
wc.lpszClassName = cn; wc.lpszClassName = cn.ptr;
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
if(!RegisterClass(&wc)) if(!RegisterClassW(&wc))
throw new Exception("RegisterClass"); throw new Exception("RegisterClass");
classRegistered = true; classRegistered = true;
} }
@ -3622,7 +3616,7 @@ version(Windows) {
break; break;
} }
hwnd = CreateWindow(cn, toStringz(title), style, hwnd = CreateWindow(cn.ptr, toWStringz(title), style,
CW_USEDEFAULT, CW_USEDEFAULT, width, height, CW_USEDEFAULT, CW_USEDEFAULT, width, height,
parent is null ? null : parent.impl.hwnd, null, hInstance, null); parent is null ? null : parent.impl.hwnd, null, hInstance, null);
@ -3668,7 +3662,7 @@ version(Windows) {
auto oldBmp = SelectObject(hdcBmp, buffer); auto oldBmp = SelectObject(hdcBmp, buffer);
auto oldBrush = SelectObject(hdcBmp, GetStockObject(WHITE_BRUSH)); auto oldBrush = SelectObject(hdcBmp, GetStockObject(WHITE_BRUSH));
auto oldPen = SelectObject(hdcBmp, GetStockObject(WHITE_PEN)); auto oldPen = SelectObject(hdcBmp, GetStockObject(WHITE_PEN));
Rectangle(hdcBmp, 0, 0, width, height); gdi.Rectangle(hdcBmp, 0, 0, width, height);
SelectObject(hdcBmp, oldBmp); SelectObject(hdcBmp, oldBmp);
SelectObject(hdcBmp, oldBrush); SelectObject(hdcBmp, oldBrush);
SelectObject(hdcBmp, oldPen); SelectObject(hdcBmp, oldPen);
@ -4950,25 +4944,7 @@ version(X11) {
static import unix = core.sys.posix.unistd; static import unix = core.sys.posix.unistd;
static import err = core.stdc.errno; static import err = core.stdc.errno;
// until this is reliably in druntime i'll use my own static import tfd = core.sys.linux.timerfd;
// so probably like next year i'll switch this over!
// static import tfd = core.sys.linux.timerfd;
static struct tfd {
static:
import core.sys.posix.time;
extern(C):
pragma(mangle, "timerfd_create")
int timerfd_create(int, int);
pragma(mangle, "timerfd_settime")
int timerfd_settime(int, int, const itimerspec*, itimerspec*);
pragma(mangle, "timerfd_gettime")
int timerfd_gettime(int, itimerspec*);
enum TFD_TIMER_ABSTIME = 1 << 0;
enum TFD_CLOEXEC = 0x80000;
enum TFD_NONBLOCK = 0x800;
}
prepareEventLoop(); prepareEventLoop();
ep.epoll_event[16] events = void; ep.epoll_event[16] events = void;
@ -5474,9 +5450,13 @@ version(X11) {
version(Windows) { version(Windows) {
import core.sys.windows.windows; import core.sys.windows.windows;
static import gdi = core.sys.windows.wingdi;
pragma(lib, "gdi32"); pragma(lib, "gdi32");
pragma(lib, "user32"); pragma(lib, "user32");
} else
version(none) {
extern(Windows) { extern(Windows) {
HWND GetConsoleWindow(); HWND GetConsoleWindow();

View File

@ -18,7 +18,7 @@ import std.exception;
import std.string; import std.string;
import std.c.stdlib; import core.stdc.stdlib;
import core.exception; import core.exception;
import core.memory; import core.memory;
import std.file; import std.file;
@ -558,7 +558,7 @@ template extract(A, T, R...){
{ {
void* p; void* p;
p = std.c.stdlib.malloc(sz); p = core.stdc.stdlib.malloc(sz);
if (!p) if (!p)
throw new OutOfMemoryError(__FILE__, __LINE__); throw new OutOfMemoryError(__FILE__, __LINE__);
GC.addRange(p, sz); GC.addRange(p, sz);
@ -569,7 +569,7 @@ template extract(A, T, R...){
{ {
if (p) if (p)
{ GC.removeRange(p); { GC.removeRange(p);
std.c.stdlib.free(p); core.stdc.stdlib.free(p);
} }
} }

View File

@ -41,6 +41,7 @@ version(use_openssl) {
SSL_CTX* SSL_CTX_new(const SSL_METHOD* method); SSL_CTX* SSL_CTX_new(const SSL_METHOD* method);
SSL* SSL_new(SSL_CTX*); SSL* SSL_new(SSL_CTX*);
int SSL_pending(SSL*);
int SSL_set_fd(SSL*, int); int SSL_set_fd(SSL*, int);
int SSL_connect(SSL*); int SSL_connect(SSL*);
int SSL_write(SSL*, const void*, int); int SSL_write(SSL*, const void*, int);

6
web.d
View File

@ -174,6 +174,7 @@ struct IfInputContentType {
*/ */
import std.exception; import std.exception;
static import std.uri;
public import arsd.dom; public import arsd.dom;
public import arsd.cgi; // you have to import this in the actual usage file or else it won't link; surely a compiler bug public import arsd.cgi; // you have to import this in the actual usage file or else it won't link; surely a compiler bug
import arsd.sha; import arsd.sha;
@ -2946,7 +2947,8 @@ deprecated string getSessionId(Cgi cgi) {
} }
version(Posix) { version(Posix) {
static import linux = std.c.linux.linux; static import linux = core.sys.linux.unistd;
static import sys_stat = core.sys.posix.sys.stat;
} }
/// This is cookie parameters for the Session class. The default initializers provide some simple default /// This is cookie parameters for the Session class. The default initializers provide some simple default
@ -3433,7 +3435,7 @@ class Session {
// users on the operating system for each user, it's still possible // users on the operating system for each user, it's still possible
// for them to access this file and hijack your session! // for them to access this file and hijack your session!
version(linux) version(linux)
enforce(linux.chmod(toStringz(getFilePath()), octal!600) == 0, "chmod failed"); enforce(sys_stat.chmod(toStringz(getFilePath()), octal!600) == 0, "chmod failed");
// FIXME: ensure the file's read permissions are locked down // FIXME: ensure the file's read permissions are locked down
// on Windows too. // on Windows too.
} }