summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-09-19 00:54:01 +0200
committerAraq <rumpf_a@web.de>2014-09-19 00:54:01 +0200
commitd4bc11b654384ffbccef8b2f549513f2c5a8fdc0 (patch)
tree930d1e0c56c0bfe71138a5f1d87be977e4ec4b2c
parent4367fb26adf3111aac8a9b4078c0126a8e215077 (diff)
downloadNim-d4bc11b654384ffbccef8b2f549513f2c5a8fdc0.tar.gz
cleaned up various modules
-rw-r--r--lib/impure/db_postgres.nim10
-rw-r--r--lib/impure/osinfo_posix.nim31
-rw-r--r--lib/impure/osinfo_win.nim10
-rw-r--r--lib/impure/rdstdin.nim8
-rw-r--r--lib/impure/zipfiles.nim20
-rw-r--r--lib/wrappers/expat.nim8
-rw-r--r--lib/wrappers/postgres.nim14
-rw-r--r--lib/wrappers/readline/history.nim2
-rw-r--r--lib/wrappers/readline/readline.nim10
-rw-r--r--lib/wrappers/readline/rltypedefs.nim2
-rw-r--r--lib/wrappers/zip/libzip.nim12
-rw-r--r--web/nim.ini2
12 files changed, 65 insertions, 64 deletions
diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim
index 116356489..6ea2bdbee 100644
--- a/lib/impure/db_postgres.nim
+++ b/lib/impure/db_postgres.nim
@@ -16,14 +16,14 @@ type
   TDbConn* = PPGconn   ## encapsulates a database connection
   TRow* = seq[string]  ## a row of a dataset. NULL database values will be
                        ## transformed always to the empty string.
-  EDb* = object of EIO ## exception that is raised if a database error occurs
+  EDb* = object of IOError ## exception that is raised if a database error occurs
   
   TSqlQuery* = distinct string ## an SQL query string
 
-  FDb* = object of FIO ## effect that denotes a database operation
-  FReadDb* = object of FDB   ## effect that denotes a read operation
-  FWriteDb* = object of FDB  ## effect that denotes a write operation
-  
+  FDb* = object of IOEffect ## effect that denotes a database operation
+  FReadDb* = object of FDb   ## effect that denotes a read operation
+  FWriteDb* = object of FDb  ## effect that denotes a write operation
+
 proc sql*(query: string): TSqlQuery {.noSideEffect, inline.} =  
   ## constructs a TSqlQuery from the string `query`. This is supposed to be 
   ## used as a raw-string-literal modifier:
diff --git a/lib/impure/osinfo_posix.nim b/lib/impure/osinfo_posix.nim
index 4fde82012..1baff8c55 100644
--- a/lib/impure/osinfo_posix.nim
+++ b/lib/impure/osinfo_posix.nim
@@ -1,20 +1,21 @@
 import posix, strutils, os
 
-type
-  Tstatfs {.importc: "struct statfs64", 
-            header: "<sys/statfs.h>", final, pure.} = object
-    f_type: int
-    f_bsize: int
-    f_blocks: int
-    f_bfree: int
-    f_bavail: int
-    f_files: int
-    f_ffree: int
-    f_fsid: int
-    f_namelen: int
+when false:
+  type
+    Tstatfs {.importc: "struct statfs64", 
+              header: "<sys/statfs.h>", final, pure.} = object
+      f_type: int
+      f_bsize: int
+      f_blocks: int
+      f_bfree: int
+      f_bavail: int
+      f_files: int
+      f_ffree: int
+      f_fsid: int
+      f_namelen: int
 
-proc statfs(path: string, buf: var Tstatfs): int {.
-  importc, header: "<sys/vfs.h>".}
+  proc statfs(path: string, buf: var Tstatfs): int {.
+    importc, header: "<sys/vfs.h>".}
 
 
 proc getSystemVersion*(): string =
@@ -23,7 +24,7 @@ proc getSystemVersion*(): string =
   var unix_info: TUtsname
   
   if uname(unix_info) != 0:
-    os.OSError()
+    os.raiseOSError(osLastError())
   
   if $unix_info.sysname == "Linux":
     # Linux
diff --git a/lib/impure/osinfo_win.nim b/lib/impure/osinfo_win.nim
index 572e50273..f423a34a3 100644
--- a/lib/impure/osinfo_win.nim
+++ b/lib/impure/osinfo_win.nim
@@ -375,7 +375,7 @@ proc getFileSize*(file: string): BiggestInt =
     var hFile = findFirstFileA(file, fileData)
   
   if hFile == INVALID_HANDLE_VALUE:
-    raise newException(EIO, $getLastError())
+    raise newException(IOError, $getLastError())
   
   return fileData.nFileSizeLow
 
@@ -386,10 +386,10 @@ proc getDiskFreeSpaceEx*(lpDirectoryName: cstring, lpFreeBytesAvailableToCaller,
 
 proc getPartitionInfo*(partition: string): TPartitionInfo =
   ## Retrieves partition info, for example ``partition`` may be ``"C:\"``
-  var FreeBytes, TotalBytes, TotalFreeBytes: TFiletime 
-  var res = getDiskFreeSpaceEx(r"C:\", FreeBytes, TotalBytes, 
-                               TotalFreeBytes)
-  return (FreeBytes, TotalBytes)
+  var freeBytes, totalBytes, totalFreeBytes: TFiletime 
+  discard getDiskFreeSpaceEx(r"C:\", freeBytes, totalBytes, 
+                               totalFreeBytes)
+  return (freeBytes, totalBytes)
 
 when isMainModule:
   var r = getMemoryInfo()
diff --git a/lib/impure/rdstdin.nim b/lib/impure/rdstdin.nim
index 9153d2360..07ef13fd9 100644
--- a/lib/impure/rdstdin.nim
+++ b/lib/impure/rdstdin.nim
@@ -15,13 +15,13 @@
 
 when defined(Windows):
   proc readLineFromStdin*(prompt: string): TaintedString {.
-                          tags: [FReadIO, FWriteIO].} = 
+                          tags: [ReadIOEffect, WriteIOEffect].} = 
     ## Reads a line from stdin.
     stdout.write(prompt)
     result = readLine(stdin)
 
   proc readLineFromStdin*(prompt: string, line: var TaintedString): bool {.
-                          tags: [FReadIO, FWriteIO].} =
+                          tags: [ReadIOEffect, WriteIOEffect].} =
     ## Reads a `line` from stdin. `line` must not be
     ## ``nil``! May throw an IO exception.
     ## A line of text may be delimited by ``CR``, ``LF`` or
@@ -35,7 +35,7 @@ else:
   import readline, history
     
   proc readLineFromStdin*(prompt: string): TaintedString {.
-                          tags: [FReadIO, FWriteIO].} =
+                          tags: [ReadIOEffect, WriteIOEffect].} =
     var buffer = readline.readLine(prompt)
     if isNil(buffer): quit(0)
     result = TaintedString($buffer)
@@ -44,7 +44,7 @@ else:
     readline.free(buffer)
 
   proc readLineFromStdin*(prompt: string, line: var TaintedString): bool {.
-                          tags: [FReadIO, FWriteIO].} =
+                          tags: [ReadIOEffect, WriteIOEffect].} =
     var buffer = readline.readLine(prompt)
     if isNil(buffer): quit(0)
     line = TaintedString($buffer)
diff --git a/lib/impure/zipfiles.nim b/lib/impure/zipfiles.nim
index b7df30d89..fb687e6f1 100644
--- a/lib/impure/zipfiles.nim
+++ b/lib/impure/zipfiles.nim
@@ -13,18 +13,18 @@ import
   streams, libzip, times, os
 
 type
-  TZipArchive* = object of TObject ## represents a zip archive
-    mode: TFileMode
+  TZipArchive* = object of RootObj ## represents a zip archive
+    mode: FileMode
     w: PZip
 
 
 proc zipError(z: var TZipArchive) = 
-  var e: ref EIO
+  var e: ref IOError
   new(e)
   e.msg = $zip_strerror(z.w)
   raise e
   
-proc open*(z: var TZipArchive, filename: string, mode: TFileMode = fmRead): bool =
+proc open*(z: var TZipArchive, filename: string, mode: FileMode = fmRead): bool =
   ## Opens a zip file for reading, writing or appending. All file modes are 
   ## supported. Returns true iff successful, false otherwise.
   var err, flags: int32
@@ -72,7 +72,7 @@ proc addFile*(z: var TZipArchive, file: string) =
   
 proc mySourceCallback(state, data: pointer, len: int, 
                       cmd: TZipSourceCmd): int {.cdecl.} = 
-  var src = cast[PStream](state)
+  var src = cast[Stream](state)
   case cmd
   of ZIP_SOURCE_OPEN: 
     if src.setPositionImpl != nil: setPosition(src, 0) # reset
@@ -93,7 +93,7 @@ proc mySourceCallback(state, data: pointer, len: int,
   of constZIP_SOURCE_FREE: GC_unref(src)
   else: assert(false)
   
-proc addFile*(z: var TZipArchive, dest: string, src: PStream) = 
+proc addFile*(z: var TZipArchive, dest: string, src: Stream) = 
   ## Adds a file named with `dest` to the archive `z`. `dest`
   ## may contain a path. The file's content is read from the `src` stream.
   assert(z.mode != fmRead)
@@ -107,14 +107,14 @@ proc addFile*(z: var TZipArchive, dest: string, src: PStream) =
 # -------------- zip file stream ---------------------------------------------
 
 type
-  TZipFileStream = object of TStream
+  TZipFileStream = object of StreamObj
     f: PZipFile
 
   PZipFileStream* = 
     ref TZipFileStream ## a reader stream of a file within a zip archive 
 
-proc fsClose(s: PStream) = zip_fclose(PZipFileStream(s).f)
-proc fsReadData(s: PStream, buffer: pointer, bufLen: int): int = 
+proc fsClose(s: Stream) = zip_fclose(PZipFileStream(s).f)
+proc fsReadData(s: Stream, buffer: pointer, bufLen: int): int = 
   result = zip_fread(PZipFileStream(s).f, buffer, bufLen)
 
 proc newZipFileStream(f: PZipFile): PZipFileStream = 
@@ -144,7 +144,7 @@ iterator walkFiles*(z: var TZipArchive): string =
     inc(i)
 
 
-proc extractFile*(z: var TZipArchive, srcFile: string, dest: PStream) =
+proc extractFile*(z: var TZipArchive, srcFile: string, dest: Stream) =
   ## extracts a file from the zip archive `z` to the destination stream.
   var strm = getStream(z, srcFile)
   while true:
diff --git a/lib/wrappers/expat.nim b/lib/wrappers/expat.nim
index 3400dfdf7..d2dac44c3 100644
--- a/lib/wrappers/expat.nim
+++ b/lib/wrappers/expat.nim
@@ -176,7 +176,7 @@ proc ParserCreate_MM*(encoding: cstring, memsuite: ptr TMemory_Handling_Suite,
 #   Added in Expat 1.95.3.
 #
 
-proc ParserReset*(parser: PParser, encoding: cstring): Bool{.cdecl, 
+proc ParserReset*(parser: PParser, encoding: cstring): bool{.cdecl, 
     importc: "XML_ParserReset", dynlib: expatDll.}
 # atts is array of name/value pairs, terminated by 0;
 #   names and values are 0 terminated.
@@ -601,7 +601,7 @@ proc UseParserAsHandlerArg*(parser: PParser){.cdecl,
 #     XML_ERROR_FEATURE_REQUIRES_XML_DTD.
 #
 
-proc UseForeignDTD*(parser: PParser, useDTD: Bool): TError{.cdecl, 
+proc UseForeignDTD*(parser: PParser, useDTD: bool): TError{.cdecl, 
     importc: "XML_UseForeignDTD", dynlib: expatDll.}
 # Sets the base to be used for resolving relative URIs in system
 #   identifiers in declarations.  Resolving relative identifiers is
@@ -681,7 +681,7 @@ proc ParseBuffer*(parser: PParser, len: cint, isFinal: cint): TStatus{.cdecl,
 #   When suspended, parsing can be resumed by calling XML_ResumeParser(). 
 #
 
-proc StopParser*(parser: PParser, resumable: Bool): TStatus{.cdecl, 
+proc StopParser*(parser: PParser, resumable: bool): TStatus{.cdecl, 
     importc: "XML_StopParser", dynlib: expatDll.}
 # Resumes parsing after it has been suspended with XML_StopParser().
 #   Must not be called from within a handler call-back. Returns same
@@ -703,7 +703,7 @@ type
     INITIALIZED, PARSING, FINISHED, SUSPENDED
   TParsingStatus*{.pure, final.} = object 
     parsing*: TParsing
-    finalBuffer*: Bool
+    finalBuffer*: bool
 
 
 # Returns status of parser with respect to being initialized, parsing,
diff --git a/lib/wrappers/postgres.nim b/lib/wrappers/postgres.nim
index b69c34f3a..6c857de40 100644
--- a/lib/wrappers/postgres.nim
+++ b/lib/wrappers/postgres.nim
@@ -68,9 +68,9 @@ type
     dbName*: cstring
     status*: TConnStatusType
     errorMessage*: array[0..(ERROR_MSG_LENGTH) - 1, char]
-    Pfin*: TFile
-    Pfout*: TFile
-    Pfdebug*: TFile
+    Pfin*: File
+    Pfout*: File
+    Pfdebug*: File
     sock*: int32
     laddr*: TSockAddr
     raddr*: TSockAddr
@@ -199,7 +199,7 @@ when defined(USE_SSL):
                                        importc: "PQgetssl".}
 proc pqsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
     cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity".}
-proc pqtrace*(conn: PPGconn, debug_port: TFile){.cdecl, dynlib: dllName, 
+proc pqtrace*(conn: PPGconn, debug_port: File){.cdecl, dynlib: dllName, 
     importc: "PQtrace".}
 proc pquntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
 proc pqsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
@@ -315,12 +315,12 @@ proc pqescapeBytea*(bintext: cstring, binlen: int, bytealen: var int): cstring{.
     cdecl, dynlib: dllName, importc: "PQescapeBytea".}
 proc pqunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl, 
     dynlib: dllName, importc: "PQunescapeBytea".}
-proc pqprint*(fout: TFile, res: PPGresult, ps: PPQprintOpt){.cdecl, 
+proc pqprint*(fout: File, res: PPGresult, ps: PPQprintOpt){.cdecl, 
     dynlib: dllName, importc: "PQprint".}
-proc pqdisplayTuples*(res: PPGresult, fp: TFile, fillAlign: int32, 
+proc pqdisplayTuples*(res: PPGresult, fp: File, fillAlign: int32, 
                       fieldSep: cstring, printHeader: int32, quiet: int32){.
     cdecl, dynlib: dllName, importc: "PQdisplayTuples".}
-proc pqprintTuples*(res: PPGresult, fout: TFile, printAttName: int32, 
+proc pqprintTuples*(res: PPGresult, fout: File, printAttName: int32, 
                     terseOutput: int32, width: int32){.cdecl, dynlib: dllName, 
     importc: "PQprintTuples".}
 proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl, 
diff --git a/lib/wrappers/readline/history.nim b/lib/wrappers/readline/history.nim
index 12dfa2707..caa857ceb 100644
--- a/lib/wrappers/readline/history.nim
+++ b/lib/wrappers/readline/history.nim
@@ -142,7 +142,7 @@ proc history_get*(a2: cint): ptr THIST_ENTRY{.cdecl, importc: "history_get",
 # Return the timestamp associated with the HIST_ENTRY * passed as an
 #   argument 
 
-proc history_get_time*(a2: ptr THIST_ENTRY): TTime{.cdecl, 
+proc history_get_time*(a2: ptr THIST_ENTRY): Time{.cdecl, 
     importc: "history_get_time", dynlib: historyDll.}
 # Return the number of bytes that the primary history entries are using.
 #   This just adds up the lengths of the_history->lines. 
diff --git a/lib/wrappers/readline/readline.nim b/lib/wrappers/readline/readline.nim
index bbe416534..5a319243e 100644
--- a/lib/wrappers/readline/readline.nim
+++ b/lib/wrappers/readline/readline.nim
@@ -776,7 +776,7 @@ proc execute_next*(a2: cint): cint{.cdecl, importc: "rl_execute_next",
 proc clear_pending_input*(): cint{.cdecl, importc: "rl_clear_pending_input", 
                                    dynlib: readlineDll.}
 proc read_key*(): cint{.cdecl, importc: "rl_read_key", dynlib: readlineDll.}
-proc getc*(a2: TFile): cint{.cdecl, importc: "rl_getc", dynlib: readlineDll.}
+proc getc*(a2: File): cint{.cdecl, importc: "rl_getc", dynlib: readlineDll.}
 proc set_keyboard_input_timeout*(a2: cint): cint{.cdecl, 
     importc: "rl_set_keyboard_input_timeout", dynlib: readlineDll.}
 # `Public' utility functions . 
@@ -881,8 +881,8 @@ when false:
   # The name of the terminal to use. 
   var terminal_name*{.importc: "rl_terminal_name", dynlib: readlineDll.}: cstring
   # The input and output streams. 
-  var instream*{.importc: "rl_instream", dynlib: readlineDll.}: TFile
-  var outstream*{.importc: "rl_outstream", dynlib: readlineDll.}: TFile
+  var instream*{.importc: "rl_instream", dynlib: readlineDll.}: File
+  var outstream*{.importc: "rl_outstream", dynlib: readlineDll.}: File
   # If non-zero, Readline gives values of LINES and COLUMNS from the environment
   #   greater precedence than values fetched from the kernel when computing the
   #   screen dimensions. 
@@ -1184,8 +1184,8 @@ type
     insmode*: cint
     edmode*: cint
     kseqlen*: cint
-    inf*: TFile
-    outf*: TFile
+    inf*: File
+    outf*: File
     pendingin*: cint
     theMacro*: cstring        # signal state 
     catchsigs*: cint
diff --git a/lib/wrappers/readline/rltypedefs.nim b/lib/wrappers/readline/rltypedefs.nim
index 202cf925d..847834e80 100644
--- a/lib/wrappers/readline/rltypedefs.nim
+++ b/lib/wrappers/readline/rltypedefs.nim
@@ -48,7 +48,7 @@ type
 # Input function type 
 
 type 
-  Tgetc_func* = proc (a2: TFile): cint{.cdecl.}
+  Tgetc_func* = proc (a2: File): cint{.cdecl.}
 
 # Generic function that takes a character buffer (which could be the readline
 #   line buffer) and an index into it (which could be rl_point) and returns
diff --git a/lib/wrappers/zip/libzip.nim b/lib/wrappers/zip/libzip.nim
index ebd74c7fd..86670b450 100644
--- a/lib/wrappers/zip/libzip.nim
+++ b/lib/wrappers/zip/libzip.nim
@@ -64,15 +64,15 @@ type
   TZipSourceCallback* = proc (state: pointer, data: pointer, length: int, 
                               cmd: TZipSourceCmd): int {.cdecl.}
   PZipStat* = ptr TZipStat
-  TZipStat* = object ## the 'zip_stat' struct
+  TZipStat* = object          ## the 'zip_stat' struct
     name*: cstring            ## name of the file  
     index*: int32             ## index within archive  
     crc*: int32               ## crc of file data  
-    mtime*: TTime             ## modification time  
+    mtime*: Time              ## modification time  
     size*: int                ## size of file (uncompressed)  
-    compSize*: int           ## size of file (compressed)  
-    compMethod*: int16       ## compression method used  
-    encryptionMethod*: int16 ## encryption method used  
+    compSize*: int            ## size of file (compressed)  
+    compMethod*: int16        ## compression method used  
+    encryptionMethod*: int16  ## encryption method used  
   
   TZip = object
   TZipSource = object 
@@ -225,7 +225,7 @@ proc zip_source_buffer*(para1: PZip, para2: pointer, para3: int, para4: int32):
     cdecl, mydll, importc: "zip_source_buffer".}
 proc zip_source_file*(para1: PZip, para2: cstring, para3: int, para4: int): PZipSource {.
     cdecl, mydll, importc: "zip_source_file".}
-proc zip_source_filep*(para1: PZip, para2: TFile, para3: int, para4: int): PZipSource {.
+proc zip_source_filep*(para1: PZip, para2: File, para3: int, para4: int): PZipSource {.
     cdecl, mydll, importc: "zip_source_filep".}
 proc zip_source_free*(para1: PZipSource) {.cdecl, mydll,
     importc: "zip_source_free".}
diff --git a/web/nim.ini b/web/nim.ini
index a5efbaf2a..1bf75e209 100644
--- a/web/nim.ini
+++ b/web/nim.ini
@@ -80,7 +80,7 @@ webdoc: "wrappers/expat;wrappers/pcre"
 webdoc: "wrappers/tre;wrappers/openssl"
 webdoc: "wrappers/libuv;wrappers/joyent_http_parser"
 
-webdoc: "posix/posix;wrappers/odbcsql;impure/dialogs"
+webdoc: "posix/posix;wrappers/odbcsql"
 webdoc: "wrappers/zip/zlib;wrappers/zip/libzip"
 webdoc: "wrappers/libsvm.nim"
 webdoc: "windows"