From 55e900bba2be06cf91789e749d9fc31f017a0dd0 Mon Sep 17 00:00:00 2001 From: "rumpf_a@web.de" <> Date: Sun, 10 Jan 2010 17:53:33 +0100 Subject: [PATCH] devel of web frontend --- config/nimrod.cfg | 1 + lib/devel/httpserver.nim | 6 ++-- lib/pure/osproc.nim | 4 +-- lib/windows/shellapi.nim | 1 + lib/windows/winlean.nim | 6 ++++ noprefix.nim | 64 ++++++++++++++++++++++++++++++++++++ rod/main.nim | 6 ++-- rod/webrepl.nim | 71 ++++++++++++++++++++++++++++++++++++++++ tests/tcolors.nim | 39 ++++++++++++++++++++++ 9 files changed, 189 insertions(+), 9 deletions(-) create mode 100644 noprefix.nim create mode 100644 rod/webrepl.nim create mode 100644 tests/tcolors.nim diff --git a/config/nimrod.cfg b/config/nimrod.cfg index 5f4c127862..6a9289a5ec 100755 --- a/config/nimrod.cfg +++ b/config/nimrod.cfg @@ -15,6 +15,7 @@ cc = gcc @end path="$lib/pure" +path="$lib/devel" path="$lib/impure" path="$lib/wrappers" path="$lib/wrappers/cairo" diff --git a/lib/devel/httpserver.nim b/lib/devel/httpserver.nim index 285dadf0aa..be317c9528 100755 --- a/lib/devel/httpserver.nim +++ b/lib/devel/httpserver.nim @@ -12,7 +12,7 @@ import strutils, os, osproc, strtabs, streams, sockets const - wwwNL = "\r\L" + wwwNL* = "\r\L" ServerSig = "Server: httpserver.nim/1.0.0" & wwwNL # --------------- output messages -------------------------------------------- @@ -222,12 +222,12 @@ proc run*(handleRequest: proc (client: TSocket, path, query: string): bool, ## encapsulates the server object and main loop var s: TServer open(s, port) - echo("httpserver running on port ", s.port) + #echo("httpserver running on port ", s.port) while true: next(s) if handleRequest(s.client, s.path, s.query): break close(s.client) - close(s.socket) + close(s) when false: proc main = diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index d76825531a..bbdea1eee9 100755 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2009 Andreas Rumpf +# (c) Copyright 2010 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -33,7 +33,7 @@ type TProcessOption* = enum ## options that can be passed `startProcess` poEchoCmd, ## echo the command before execution poUseShell, ## use the shell to execute the command; NOTE: This - ## often creates a security whole! + ## often creates a security hole! poStdErrToStdOut, ## merge stdout and stderr to the stdout stream poParentStreams ## use the parent's streams diff --git a/lib/windows/shellapi.nim b/lib/windows/shellapi.nim index af6972c969..a4a976c609 100755 --- a/lib/windows/shellapi.nim +++ b/lib/windows/shellapi.nim @@ -6,6 +6,7 @@ # See the file "copying.txt", included in this # distribution, for details about the copyright. # + # leave out unused functions so the unit can be used on win2000 as well #+------------------------------------------------------------------------- diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim index d6ef9ffbb6..f384a04e80 100755 --- a/lib/windows/winlean.nim +++ b/lib/windows/winlean.nim @@ -60,6 +60,8 @@ const STD_ERROR_HANDLE* = -12'i32 DETACHED_PROCESS* = 8'i32 + + SW_SHOWNORMAL* = 1'i32 proc CloseHandle*(hObject: THANDLE): WINBOOL {.stdcall, dynlib: "kernel32", importc: "CloseHandle".} @@ -190,4 +192,8 @@ proc rdFileTime*(f: FILETIME): int64 = proc Sleep*(dwMilliseconds: int32){.stdcall, dynlib: "kernel32", importc: "Sleep".} +proc ShellExecute*(HWND: THandle, lpOperation, lpFile, + lpParameters, lpDirectory: cstring, + nShowCmd: int32): THandle{. + stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".} diff --git a/noprefix.nim b/noprefix.nim new file mode 100644 index 0000000000..e7ec26c560 --- /dev/null +++ b/noprefix.nim @@ -0,0 +1,64 @@ +# strip those silly GTK/ATK prefixes... + +import + expandimportc, os + +const + filelist = [ + ("sdl/sdl", "sdl"), + ("sdl/sdl_net", "sdl"), + ("sdl/sdl_gfx", "sdl"), + ("sdl/sdl_image", "sdl"), + ("sdl/sdl_mixer_nosmpeg", "sdl"), + ("sdl/sdl_mixer", "sdl"), + ("sdl/sdl_ttf", "sdl"), + ("sdl/smpeg", "sdl"), + + ("libcurl", "curl"), + ("mysql", "mysql"), + ("postgres", ""), + ("sqlite3", "sqlite3"), + ("tcl", "tcl"), + ("cairo/cairo", "cairo"), + ("cairo/cairoft", "cairo"), + ("cairo/cairowin32", "cairo"), + ("cairo/cairoxlib", "cairo"), + + ("gtk/atk", "atk"), + ("gtk/gdk2", "gdk"), + ("gtk/gdk2pixbuf", "gdk"), + ("gtk/gdkglext", "gdk"), + ("gtk/glib2", ""), + ("gtk/gtk2", "gtk"), + ("gtk/gtkglext", "gtk"), + ("gtk/gtkhtml", "gtk"), + ("gtk/libglade2", "glade"), + ("gtk/pango", "pango"), + ("gtk/pangoutils", "pango"), + + ("lua/lua", "lua"), + ("lua/lauxlib", "luaL"), + ("lua/lualib", "lua"), + + ("opengl/gl", ""), + ("opengl/glext", ""), + ("opengl/wingl", ""), + ("opengl/glu", ""), + ("opengl/glut", ""), + ("opengl/glx", ""), + + ("pcre/pcre", "pcre") + ] + +proc createDirs = + createDir("lib/newwrap/sdl") + createDir("lib/newwrap/cairo") + createDir("lib/newwrap/gtk") + createDir("lib/newwrap/lua") + createDir("lib/newwrap/opengl") + createDir("lib/newwrap/pcre") + +for filename, prefix in items(filelist): + var f = addFileExt(filename, "nim") + main("lib/wrappers" / f, "lib/newwrap" / f, prefix) + diff --git a/rod/main.nim b/rod/main.nim index d386a10aad..6cdd026b54 100755 --- a/rod/main.nim +++ b/rod/main.nim @@ -170,15 +170,13 @@ proc exSymbols(n: PNode) = proc CommandExportSymbols(filename: string) = # now unused! - var module: PNode - module = parseFile(addFileExt(filename, NimExt)) + var module = parseFile(addFileExt(filename, NimExt)) if module != nil: exSymbols(module) renderModule(module, getOutFile(filename, "pretty." & NimExt)) proc CommandPretty(filename: string) = - var module: PNode - module = parseFile(addFileExt(filename, NimExt)) + var module = parseFile(addFileExt(filename, NimExt)) if module != nil: renderModule(module, getOutFile(filename, "pretty." & NimExt)) diff --git a/rod/webrepl.nim b/rod/webrepl.nim new file mode 100644 index 0000000000..bf59bbfec9 --- /dev/null +++ b/rod/webrepl.nim @@ -0,0 +1,71 @@ +# +# +# The Nimrod Compiler +# (c) Copyright 2010 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## Creates a server, opens a browser and starts serving a Repl for the user. +## Unfortunately it doesn't ever stop... + +import httpserver, sockets, browsers, strutils, cgi, options + +const + gui = """ + +
+