From 07b784373b1701d962f3e089e648838f96ac8947 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 16 Jan 2011 14:30:31 +0100 Subject: [PATCH] docgen: module dependencies are now listed --- config/nimdoc.cfg | 4 ---- config/nimdoc.tex.cfg | 6 ------ doc/nimrodc.txt | 13 ++++++++++++- lib/posix/posix.nim | 6 +++--- lib/system/systhread.nim | 37 ++++++++++++++++++++++++------------- rod/ast.nim | 2 +- rod/docgen.nim | 24 +++++++++++++++--------- 7 files changed, 55 insertions(+), 37 deletions(-) diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg index 541eacced5..d9a5b1ae2c 100755 --- a/config/nimdoc.cfg +++ b/config/nimdoc.cfg @@ -45,16 +45,12 @@ doc.body_toc = """ $tableofcontents
$moduledesc -

Dependencies

- $deps $content
""" doc.body_no_toc = """ $moduledesc -

Dependencies

- $deps $content """ diff --git a/config/nimdoc.tex.cfg b/config/nimdoc.tex.cfg index 2ec5f98cb4..ecb95fe01f 100755 --- a/config/nimdoc.tex.cfg +++ b/config/nimdoc.tex.cfg @@ -30,17 +30,11 @@ doc.toc = r"\tableofcontents \newpage" doc.body_toc = """ $tableofcontents $moduledesc - -Dependencies: $deps - $content """ doc.body_no_toc = """ $moduledesc - -Dependencies: $deps - $content """ diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt index 0a0781e368..c4b61a14f6 100755 --- a/doc/nimrodc.txt +++ b/doc/nimrodc.txt @@ -70,13 +70,24 @@ However, the generated C code is not platform independent. C code generated for Linux does not compile on Windows, for instance. The comment on top of the C file lists the OS, CPU and CC the file has been compiled for. + +Cross compilation +================= + +To `cross compile`:idx:, use for example:: + + nimrod c --cpu:i386 --os:linux --compile_only --gen_script myproject.nim + +Then move the C code and the compile script ``compile_myproject.sh`` to your +Linux i386 machine and run the script. + DLL generation ============== Nimrod supports the generation of DLLs. However, there must be only one instance of the GC per process/address space. This instance is contained in -``nimrtl.dll``. This means that every generated Nimrod DLL depends +``nimrtl.dll``. This means that every generated Nimrod `DLL`:idx: depends on ``nimrtl.dll``. To generate the "nimrtl.dll" file, use the command:: nimrod c -d:release lib/nimrtl.nim diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index 6bda372bb5..fa8a56dba0 100755 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2010 Andreas Rumpf +# (c) Copyright 2011 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -19,11 +19,11 @@ ## Coding conventions: ## ALL types are named the same as in the POSIX standard except that they start -## with 'T' or 'P' (if they are pointers) and without the '_t' prefix to be +## with 'T' or 'P' (if they are pointers) and without the '_t' suffix to be ## consistent with Nimrod conventions. If an identifier is a Nimrod keyword ## the \`identifier\` notation is used. ## -## This library relies on the header files of your C compiler. Thus the +## This library relies on the header files of your C compiler. The ## resulting C code will just include and *not* define the ## symbols declared here. diff --git a/lib/system/systhread.nim b/lib/system/systhread.nim index a124fa92f1..b9c882ae05 100755 --- a/lib/system/systhread.nim +++ b/lib/system/systhread.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2010 Andreas Rumpf +# (c) Copyright 2011 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -69,7 +69,21 @@ when defined(Windows): dwCreationFlags: int32, lpThreadId: var int32): THandle {. stdcall, dynlib: "kernel32", importc: "CreateThread".} - + proc winSuspendThread(hThread: TSysThread): int32 {. + stdcall, dynlib: "kernel32", importc: "SuspendThread".} + + proc winResumeThread(hThread: TSysThread): int32 {. + stdcall, dynlib: "kernel32", importc: "ResumeThread".} + + proc WaitForMultipleObjects(nCount: int32, + lpHandles: ptr array[0..10, THandle], + bWaitAll: int32, + dwMilliseconds: int32): int32 {. + stdcall, dynlib: "kernel32", importc: "WaitForMultipleObjects".} + + proc WaitForSingleObject(hHandle: THANDLE, dwMilliseconds: int32): int32 {. + stdcall, dynlib: "kernel32", importc: "WaitForSingleObject".} + else: type TSysLock {.importc: "pthread_mutex_t", header: "".} = int @@ -81,23 +95,20 @@ else: importc: "pthread_mutex_lock", header: "".} proc Release(L: var TSysLock) {. importc: "pthread_mutex_unlock", header: "".} - + + proc pthread_create(a1: ptr TSysThread, a2: ptr int, + a3: proc (x: pointer): pointer {.noconv.}, + a4: pointer): cint {.importc: "pthread_create", + header: "".} + proc pthread_join(a1: TSysThread, a2: ptr pointer): cint {. + importc, header: "".} + type TThread* = TSysThread TLock* = TSysLock TThreadFunc* = proc (closure: pointer) {.cdecl.} -#DWORD WINAPI SuspendThread( -# __in HANDLE hThread -#); -#DWORD WINAPI ResumeThread( -# __in HANDLE hThread -#); -#DWORD WINAPI ThreadProc( -# __in LPVOID lpParameter -#); - proc createThread*(t: var TThread, fn: TThreadFunc, closure: pointer) = when defined(windows): nil diff --git a/rod/ast.nim b/rod/ast.nim index 47d3d8621b..1d689deb96 100755 --- a/rod/ast.nim +++ b/rod/ast.nim @@ -280,6 +280,7 @@ type skParam, # a parameter skGenericParam, # a generic parameter; eq in ``proc x[eq=`==`]()`` skTemp, # a temporary variable (introduced by compiler) + skModule, # module identifier skType, # a type skConst, # a constant skVar, # a variable @@ -293,7 +294,6 @@ type skField, # a field in a record or object skEnumField, # an identifier in an enum skForVar, # a for loop variable - skModule, # module identifier skLabel, # a label (for block statement) skStub # symbol is a stub and not yet loaded from the ROD # file (it is loaded on demand, which may mean: never) diff --git a/rod/docgen.nim b/rod/docgen.nim index ade2aa93f5..04330bb414 100755 --- a/rod/docgen.nim +++ b/rod/docgen.nim @@ -32,7 +32,6 @@ type filename*: string # filename of the source file; without extension basedir*: string # base directory (where to put the documentation) modDesc*: PRope # module description - deps*: PRope # dependencies id*: int # for generating IDs splitAfter*: int # split too long entries in the TOC tocPart*: seq[TTocEntry] @@ -765,9 +764,12 @@ proc getModuleFile(n: PNode): string = result = "" proc traceDeps(d: PDoc, n: PNode) = - if d.deps != nil: app(d.deps, ", ") - app(d.deps, getModuleFile(n)) - + const k = skModule + if d.section[k] != nil: app(d.section[k], ", ") + dispA(d.section[k], + "$1", + "$1", [toRope(getModuleFile(n))]) + proc generateDoc(d: PDoc, n: PNode) = if n == nil: return case n.kind @@ -802,8 +804,12 @@ proc generateDoc(d: PDoc, n: PNode) = else: nil proc genSection(d: PDoc, kind: TSymKind) = + const sectionNames: array[skModule..skTemplate, string] = [ + "Imports", "Types", "Consts", "Vars", "Procs", "Methods", + "Iterators", "Converters", "Macros", "Templates" + ] if d.section[kind] == nil: return - var title = toRope(copy($kind, 2) & 's') + var title = toRope(sectionNames[kind]) d.section[kind] = ropeFormatNamedVars(getConfigVar("doc.section"), [ "sectionid", "sectionTitle", "sectionTitleID", "content"], [ toRope(ord(kind)), title, toRope(ord(kind) + 50), d.section[kind]]) @@ -833,14 +839,14 @@ proc genOutFile(d: PDoc): PRope = if d.hasToc: bodyname = "doc.body_toc" else: bodyname = "doc.body_no_toc" content = ropeFormatNamedVars(getConfigVar(bodyname), ["title", - "tableofcontents", "moduledesc", "deps", "date", "time", "content"], - [title, toc, d.modDesc, d.deps, toRope(getDateStr()), + "tableofcontents", "moduledesc", "date", "time", "content"], + [title, toc, d.modDesc, toRope(getDateStr()), toRope(getClockStr()), code]) if optCompileOnly notin gGlobalOptions: code = ropeFormatNamedVars(getConfigVar("doc.file"), ["title", - "tableofcontents", "moduledesc", "deps", "date", "time", + "tableofcontents", "moduledesc", "date", "time", "content", "author", "version"], - [title, toc, d.modDesc, d.deps, toRope(getDateStr()), + [title, toc, d.modDesc, toRope(getDateStr()), toRope(getClockStr()), content, d.meta[metaAuthor], d.meta[metaVersion]]) else: