mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
better subscript overloading
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
=======================================================
|
||||
The Nimrod Compiler
|
||||
Copyright (C) 2004-2009 Andreas Rumpf
|
||||
Copyright (C) 2004-2010 Andreas Rumpf
|
||||
=======================================================
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -32,6 +32,7 @@ get get, ``[]`` consider overloading ``[]`` for get;
|
||||
prefix: ``len`` instead of ``getLen``
|
||||
length len also used for *number of elements*
|
||||
size size, len size should refer to a byte size
|
||||
memory mem implies a low-level operation
|
||||
items items default iterator over a collection
|
||||
pairs pairs iterator over (key, value) pairs
|
||||
delete delete, del del is supposed to be faster than
|
||||
|
||||
@@ -24,7 +24,8 @@ indexExpr ::= '..' [expr] | expr ['=' expr | '..' expr]
|
||||
castExpr ::= 'cast' '[' optInd typeDesc optPar ']' '(' optInd expr optPar ')'
|
||||
addrExpr ::= 'addr' '(' optInd expr optPar ')'
|
||||
symbol ::= '`' (KEYWORD | IDENT | operator | '(' ')'
|
||||
| '[' ']' | '=' | literal)+ '`'
|
||||
| '[' (',' | ['$'] '..' ['$'])* ']'
|
||||
| '=' | literal)+ '`'
|
||||
| IDENT
|
||||
|
||||
primaryPrefix ::= (prefixOperator | 'bind') optInd
|
||||
|
||||
244
doc/manual.txt
244
doc/manual.txt
@@ -693,15 +693,16 @@ Example:
|
||||
var
|
||||
x: TIntArray
|
||||
y: TIntSeq
|
||||
x = [1, 2, 3, 4, 5, 6] # [] this is the array constructor
|
||||
x = [1, 2, 3, 4, 5, 6] # [] is the array constructor
|
||||
y = @[1, 2, 3, 4, 5, 6] # the @ turns the array into a sequence
|
||||
|
||||
The lower bound of an array or sequence may be received by the built-in proc
|
||||
``low()``, the higher bound by ``high()``. The length may be
|
||||
received by ``len()``. ``low()`` for a sequence or an open array always returns
|
||||
0, as this is the first valid index.
|
||||
One can append elements to a sequence with the ``add()`` proc or the ``&`` operator,
|
||||
and remove (and get) the last element of a sequence with the ``pop()`` proc.
|
||||
One can append elements to a sequence with the ``add()`` proc or the ``&``
|
||||
operator, and remove (and get) the last element of a sequence with the
|
||||
``pop()`` proc.
|
||||
|
||||
The notation ``x[i]`` can be used to access the i-th element of ``x``.
|
||||
|
||||
@@ -935,8 +936,8 @@ Example:
|
||||
forEach(printItem) # this will NOT work because calling conventions differ
|
||||
|
||||
A subtle issue with procedural types is that the calling convention of the
|
||||
procedure influences the type compatibility: procedural types are only compatible
|
||||
if they have the same calling convention.
|
||||
procedure influences the type compatibility: procedural types are only
|
||||
compatible if they have the same calling convention.
|
||||
|
||||
Nimrod supports these `calling conventions`:idx:, which are all incompatible to
|
||||
each other:
|
||||
@@ -1304,7 +1305,7 @@ variables of the same type:
|
||||
a: int = 0
|
||||
x, y, z: int
|
||||
|
||||
If an initializer is given the type can be omitted: the variable is of the
|
||||
If an initializer is given the type can be omitted: the variable is then of the
|
||||
same type as the initializing expression. Variables are always initialized
|
||||
with a default value if there is no initializing expression. The default
|
||||
value depends on the type and is always a zero in binary.
|
||||
@@ -1776,8 +1777,8 @@ Calling a procedure can be done in many different ways:
|
||||
callme 0, 1, "abc", '\t'
|
||||
|
||||
|
||||
A procedure cannot modify its parameters (unless the parameters have the
|
||||
type `var`).
|
||||
A procedure cannot modify its parameters (unless the parameters have the type
|
||||
`var`).
|
||||
|
||||
`Operators`:idx: are procedures with a special operator symbol as identifier:
|
||||
|
||||
@@ -1809,7 +1810,8 @@ Var parameters
|
||||
The type of a parameter may be prefixed with the ``var`` keyword:
|
||||
|
||||
.. code-block:: nimrod
|
||||
proc divmod(a, b: int, res, remainder: var int) =
|
||||
proc divmod(a, b: int,
|
||||
res, remainder: var int) =
|
||||
res = a div b
|
||||
remainder = a mod b
|
||||
|
||||
@@ -1827,7 +1829,8 @@ an l-value. Var parameters are implemented as hidden pointers. The
|
||||
above example is equivalent to:
|
||||
|
||||
.. code-block:: nimrod
|
||||
proc divmod(a, b: int, res, remainder: ptr int) =
|
||||
proc divmod(a, b: int,
|
||||
res, remainder: ptr int) =
|
||||
res^ = a div b
|
||||
remainder^ = a mod b
|
||||
|
||||
@@ -1856,6 +1859,15 @@ One can use `tuple unpacking`:idx: to access the tuple's fields:
|
||||
assert y == 3
|
||||
|
||||
|
||||
Overloading of the subscript operator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``[]`` subscript operator for arrays/openarrays/sequences can be overloaded.
|
||||
Overloading support is only possible if the first parameter has no type that
|
||||
already supports the built-in ``[]`` notation. Currently the compiler currently
|
||||
does not check this. XXX Multiple indexes
|
||||
|
||||
|
||||
Multi-methods
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@@ -2313,11 +2325,12 @@ regular expressions:
|
||||
Modules
|
||||
-------
|
||||
Nimrod supports splitting a program into pieces by a `module`:idx: concept.
|
||||
Each module needs to be in its own file. Modules enable
|
||||
`information hiding`:idx: and `separate compilation`:idx:. A module may gain
|
||||
access to symbols of another module by the `import`:idx: statement.
|
||||
`Recursive module dependencies`:idx: are allowed, but slightly subtle. Only
|
||||
top-level symbols that are marked with an asterisk (``*``) are exported.
|
||||
Each module needs to be in its own file and has its own `namespace`:idx:.
|
||||
Modules enable `information hiding`:idx: and `separate compilation`:idx:.
|
||||
A module may gain access to symbols of another module by the `import`:idx:
|
||||
statement. `Recursive module dependencies`:idx: are allowed, but slightly
|
||||
subtle. Only top-level symbols that are marked with an asterisk (``*``) are
|
||||
exported.
|
||||
|
||||
The algorithm for compiling modules is:
|
||||
|
||||
@@ -2413,6 +2426,7 @@ The Nimrod compiler emits different kinds of messages: `hint`:idx:,
|
||||
`warning`:idx:, and `error`:idx: messages. An *error* message is emitted if
|
||||
the compiler encounters any static error.
|
||||
|
||||
|
||||
Pragmas
|
||||
=======
|
||||
|
||||
@@ -2426,7 +2440,9 @@ Syntax::
|
||||
Pragmas are Nimrod's method to give the compiler additional information/
|
||||
commands without introducing a massive number of new keywords. Pragmas are
|
||||
processed on the fly during semantic checking. Pragmas are enclosed in the
|
||||
special ``{.`` and ``.}`` curly brackets.
|
||||
special ``{.`` and ``.}`` curly brackets. Pragmas are also often used as a
|
||||
first implementation to play with a language feature before a nicer syntax
|
||||
to access the feature becomes available.
|
||||
|
||||
|
||||
noSideEffect pragma
|
||||
@@ -2439,6 +2455,12 @@ or ``ref T`` or ``ptr T`` this means no locations are modified. It is a static
|
||||
error to mark a proc/iterator to have no side effect if the compiler cannot
|
||||
verify this.
|
||||
|
||||
**Possible future**: ``func`` may become a keyword and syntactic sugar for a
|
||||
proc with no side effects:
|
||||
|
||||
.. code-block:: nimrod
|
||||
func `+` (x, y: int): int
|
||||
|
||||
|
||||
procvar pragma
|
||||
--------------
|
||||
@@ -2458,6 +2480,53 @@ noReturn pragma
|
||||
The `noreturn`:idx: pragma is used to mark a proc that it never returns.
|
||||
|
||||
|
||||
Acyclic pragma
|
||||
--------------
|
||||
The `acyclic`:idx: pragma can be used for object types to mark them as acyclic
|
||||
even though they seem to be cyclic. This is an **optimization** for the garbage
|
||||
collector to not consider objects of this type as part of a cycle:
|
||||
|
||||
.. code-block:: nimrod
|
||||
type
|
||||
PNode = ref TNode
|
||||
TNode {.acyclic, final.} = object
|
||||
left, right: PNode
|
||||
data: string
|
||||
|
||||
In the example a tree structure is declared with the ``TNode`` type. Note that
|
||||
the type definition is recursive and the GC has to assume that objects of
|
||||
this type may form a cyclic graph. The ``acyclic`` pragma passes the
|
||||
information that this cannot happen to the GC. If the programmer uses the
|
||||
``acyclic`` pragma for data types that are in reality cyclic, the GC may leak
|
||||
memory, but nothing worse happens.
|
||||
|
||||
**Possible future**: The ``acyclic`` pragma may become a property of a
|
||||
``ref`` type:
|
||||
|
||||
.. code-block:: nimrod
|
||||
type
|
||||
PNode = acyclic ref TNode
|
||||
TNode = object
|
||||
left, right: PNode
|
||||
data: string
|
||||
|
||||
|
||||
Final pragma
|
||||
------------
|
||||
The `final`:idx: pragma can be used for an object type to specify that it
|
||||
cannot be inherited from.
|
||||
|
||||
|
||||
Pure pragma
|
||||
-----------
|
||||
The `pure`:idx: pragma serves two completely different purposes:
|
||||
1) To mark a procedure that Nimrod should not generate any exit statements like
|
||||
``return result;`` in the generated code. This is useful for procs that only
|
||||
consist of an assembler statement.
|
||||
2) To mark an object type that Nimrod should omit its type field. This is
|
||||
necessary for compatibility with other compiled languages.
|
||||
|
||||
|
||||
error pragma
|
||||
------------
|
||||
The `error`:idx: pragma is used to make the compiler output an error message
|
||||
@@ -2487,8 +2556,8 @@ compilation option pragmas
|
||||
The listed pragmas here can be used to override the code generation options
|
||||
for a section of code.
|
||||
|
||||
The implementation currently provides the following possible options (later
|
||||
various others may be added).
|
||||
The implementation currently provides the following possible options (various
|
||||
others may be added later).
|
||||
|
||||
=============== =============== ============================================
|
||||
pragma allowed values description
|
||||
@@ -2532,3 +2601,142 @@ but are used to override the settings temporarily. Example:
|
||||
# speed critical
|
||||
# ... some code ...
|
||||
{.pop.} # restore old settings
|
||||
|
||||
|
||||
Register pragma
|
||||
---------------
|
||||
The `register`:idx: pragma is for variables only. It declares the variable as
|
||||
``register``, giving the compiler a hint that the variable should be placed
|
||||
in a hardware register for faster access. C compilers usually ignore this
|
||||
though and for good reasons: Often they do a better job without it anyway.
|
||||
|
||||
In highly specific cases (a dispatch loop of an bytecode interpreter for
|
||||
example) it may provide benefits, though.
|
||||
|
||||
|
||||
DeadCodeElim pragma
|
||||
-------------------
|
||||
The `deadCodeElim`:idx: pragma only applies to whole modules: It tells the
|
||||
compiler to activate (or deactivate) dead code elimination for the module the
|
||||
pragma appers in.
|
||||
|
||||
The ``--deadCodeElim:on`` command line switch has the same effect as marking
|
||||
every module with ``{.deadCodeElim:on}``. However, for some modules such as
|
||||
the GTK wrapper it makes sense to *always* turn on dead code elimination -
|
||||
no matter if it is globally active or not.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: nimrod
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
|
||||
Disabling certain messages
|
||||
--------------------------
|
||||
Nimrod generates some warnings and hints ("line too long") that may annoy the
|
||||
user. A mechanism for disabling certain messages is provided: Each hint
|
||||
and warning message contains a symbol in brackets. This is the message's
|
||||
identifier that can be used to enable or disable it:
|
||||
|
||||
.. code-block:: Nimrod
|
||||
{.warning[LineTooLong]: off.} # turn off warning about too long lines
|
||||
|
||||
This is often better than disabling all warnings at once.
|
||||
|
||||
|
||||
Foreign function interface
|
||||
==========================
|
||||
|
||||
Nimrod's `FFI`:idx: (foreign function interface) is extensive and only the
|
||||
parts that scale to other future backends (like the LLVM/EcmaScript backends)
|
||||
are documented here.
|
||||
|
||||
|
||||
Importc pragma
|
||||
--------------
|
||||
The `importc`:idx: pragma provides a means to import a proc or a variable
|
||||
from C. The optional argument is a string containing the C identifier. If
|
||||
the argument is missing, the C name is the Nimrod identifier *exactly as
|
||||
spelled*:
|
||||
|
||||
.. code-block::
|
||||
proc printf(formatstr: cstring) {.importc: "printf", varargs.}
|
||||
|
||||
Note that this pragma is somewhat of a misnomer: Other backends will provide
|
||||
the same feature under the same name.
|
||||
|
||||
|
||||
Exportc pragma
|
||||
--------------
|
||||
The `exportc`:idx: pragma provides a means to export a type, a variable, or a
|
||||
procedure to C. The optional argument is a string containing the C identifier.
|
||||
If the argument is missing, the C name is the Nimrod
|
||||
identifier *exactly as spelled*:
|
||||
|
||||
.. code-block:: Nimrod
|
||||
proc callme(formatstr: cstring) {.exportc: "callMe", varargs.}
|
||||
|
||||
Note that this pragma is somewhat of a misnomer: Other backends will provide
|
||||
the same feature under the same name.
|
||||
|
||||
|
||||
Varargs pragma
|
||||
--------------
|
||||
The `varargs`:idx: pragma can be applied to procedures only (and procedure
|
||||
types). It tells Nimrod that the proc can take a variable number of parameters
|
||||
after the last specified parameter. Nimrod string values will be converted to C
|
||||
strings automatically:
|
||||
|
||||
.. code-block:: Nimrod
|
||||
proc printf(formatstr: cstring) {.nodecl, varargs.}
|
||||
|
||||
printf("hallo %s", "world") # "world" will be passed as C string
|
||||
|
||||
|
||||
Dynlib pragma
|
||||
-------------
|
||||
With the `dynlib`:idx: pragma a procedure can be imported from
|
||||
a dynamic library (``.dll`` files for Windows, ``lib*.so`` files for UNIX). The
|
||||
non-optional argument has to be the name of the dynamic library:
|
||||
|
||||
.. code-block:: Nimrod
|
||||
proc gtk_image_new(): PGtkWidget {.cdecl, dynlib: "libgtk-x11-2.0.so", importc.}
|
||||
|
||||
In general, importing a dynamic library does not require any special linker
|
||||
options or linking with import libraries. This also implies that no *devel*
|
||||
packages need to be installed.
|
||||
|
||||
The ``dynlib`` import mechanism supports a versioning scheme:
|
||||
|
||||
.. code-block:: nimrod
|
||||
proc Tcl_Eval(interp: pTcl_Interp, script: cstring): int {.cdecl,
|
||||
importc, dynlib: "libtcl(|8.5|8.4|8.3).so.(1|0)".}
|
||||
|
||||
At runtime the dynamic library is searched for (in this order)::
|
||||
|
||||
libtcl.so.1
|
||||
libtcl.so.0
|
||||
libtcl8.5.so.1
|
||||
libtcl8.5.so.0
|
||||
libtcl8.4.so.1
|
||||
libtcl8.4.so.0
|
||||
libtcl8.3.so.1
|
||||
libtcl8.3.so.0
|
||||
|
||||
The ``dynlib`` pragma supports not only constant strings as argument but also
|
||||
string expressions in general:
|
||||
|
||||
.. code-block:: nimrod
|
||||
import os
|
||||
|
||||
proc getDllName: string =
|
||||
result = "mylib.dll"
|
||||
if ExistsFile(result): return
|
||||
result = "mylib2.dll"
|
||||
if ExistsFile(result): return
|
||||
quit("could not load dynamic library")
|
||||
|
||||
proc myImport(s: cstring) {.cdecl, importc, dynlib: getDllName().}
|
||||
|
||||
**Note**: Patterns like ``libtcl(|8.5|8.4).so`` are only supported in constant
|
||||
strings, because they are precompiled.
|
||||
|
||||
187
doc/nimrodc.txt
187
doc/nimrodc.txt
@@ -71,87 +71,12 @@ Additional Features
|
||||
===================
|
||||
|
||||
This section describes Nimrod's additional features that are not listed in the
|
||||
Nimrod manual.
|
||||
|
||||
New Pragmas and Options
|
||||
-----------------------
|
||||
|
||||
Because Nimrod generates C code it needs some "red tape" to work properly.
|
||||
Lots of options and pragmas for tweaking the generated C code are available.
|
||||
|
||||
Importc Pragma
|
||||
~~~~~~~~~~~~~~
|
||||
The `importc`:idx: pragma provides a means to import a type, a variable, or a
|
||||
procedure from C. The optional argument is a string containing the C
|
||||
identifier. If the argument is missing, the C name is the Nimrod
|
||||
identifier *exactly as spelled*:
|
||||
|
||||
.. code-block::
|
||||
proc printf(formatstr: cstring) {.importc: "printf", varargs.}
|
||||
Nimrod manual. Some of the features here only make sense for the C code
|
||||
generator and are subject to change.
|
||||
|
||||
|
||||
Exportc Pragma
|
||||
~~~~~~~~~~~~~~
|
||||
The `exportc`:idx: pragma provides a means to export a type, a variable, or a
|
||||
procedure to C. The optional argument is a string containing the C
|
||||
identifier. If the argument is missing, the C name is the Nimrod
|
||||
identifier *exactly as spelled*:
|
||||
|
||||
.. code-block:: Nimrod
|
||||
proc callme(formatstr: cstring) {.exportc: "callMe", varargs.}
|
||||
|
||||
|
||||
Dynlib Pragma
|
||||
~~~~~~~~~~~~~
|
||||
With the `dynlib`:idx: pragma a procedure or a variable can be imported from
|
||||
a dynamic library (``.dll`` files for Windows, ``lib*.so`` files for UNIX). The
|
||||
non-optional argument has to be the name of the dynamic library:
|
||||
|
||||
.. code-block:: Nimrod
|
||||
proc gtk_image_new(): PGtkWidget {.cdecl, dynlib: "libgtk-x11-2.0.so", importc.}
|
||||
|
||||
In general, importing a dynamic library does not require any special linker
|
||||
options or linking with import libraries. This also implies that no *devel*
|
||||
packages need to be installed.
|
||||
|
||||
The ``dynlib`` import mechanism supports a versioning scheme:
|
||||
|
||||
.. code-block:: nimrod
|
||||
proc Tcl_Eval(interp: pTcl_Interp, script: cstring): int {.cdecl,
|
||||
importc, dynlib: "libtcl(|8.5|8.4|8.3).so.(1|0)".}
|
||||
|
||||
At runtime the dynamic library is searched for (in this order)::
|
||||
|
||||
libtcl.so.1
|
||||
libtcl.so.0
|
||||
libtcl8.5.so.1
|
||||
libtcl8.5.so.0
|
||||
libtcl8.4.so.1
|
||||
libtcl8.4.so.0
|
||||
libtcl8.3.so.1
|
||||
libtcl8.3.so.0
|
||||
|
||||
The ``dynlib`` pragma supports not only constant strings as argument but also
|
||||
string expressions in general:
|
||||
|
||||
.. code-block:: nimrod
|
||||
import os
|
||||
|
||||
proc getDllName: string =
|
||||
result = "mylib.dll"
|
||||
if ExistsFile(result): return
|
||||
result = "mylib2.dll"
|
||||
if ExistsFile(result): return
|
||||
quit("could not load dynamic library")
|
||||
|
||||
proc myImport(s: cstring) {.cdecl, importc, dynlib: getDllName().}
|
||||
|
||||
**Note**: Patterns like ``libtcl(|8.5|8.4).so`` are only supported in constant
|
||||
strings, because they are precompiled.
|
||||
|
||||
|
||||
NoDecl Pragma
|
||||
~~~~~~~~~~~~~
|
||||
NoDecl pragma
|
||||
-------------
|
||||
The `noDecl`:idx: pragma can be applied to almost any symbol (variable, proc,
|
||||
type, etc.) and is sometimes useful for interoperability with C:
|
||||
It tells Nimrod that it should not generate a declaration for the symbol in
|
||||
@@ -164,9 +89,11 @@ the C code. For example:
|
||||
|
||||
However, the ``header`` pragma is often the better alternative.
|
||||
|
||||
**Note**: This will not work for the LLVM backend.
|
||||
|
||||
Header Pragma
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Header pragma
|
||||
-------------
|
||||
The `header`:idx: pragma is very similar to the ``noDecl`` pragma: It can be
|
||||
applied to almost any symbol and specifies that it should not be declared
|
||||
and instead the generated code should contain an ``#include``:
|
||||
@@ -181,118 +108,48 @@ contains the header file: As usual for C, a system header file is enclosed
|
||||
in angle brackets: ``<>``. If no angle brackets are given, Nimrod
|
||||
encloses the header file in ``""`` in the generated C code.
|
||||
|
||||
|
||||
Varargs Pragma
|
||||
~~~~~~~~~~~~~~
|
||||
The `varargs`:idx: pragma can be applied to procedures only (and procedure
|
||||
types). It tells Nimrod that the proc can take a variable number of parameters
|
||||
after the last specified parameter. Nimrod string values will be converted to C
|
||||
strings automatically:
|
||||
|
||||
.. code-block:: Nimrod
|
||||
proc printf(formatstr: cstring) {.nodecl, varargs.}
|
||||
|
||||
printf("hallo %s", "world") # "world" will be passed as C string
|
||||
**Note**: This will not work for the LLVM backend.
|
||||
|
||||
|
||||
LineDir Option
|
||||
~~~~~~~~~~~~~~
|
||||
LineDir option
|
||||
--------------
|
||||
The `lineDir`:idx: option can be turned on or off. If turned on the
|
||||
generated C code contains ``#line`` directives. This may be helpful for
|
||||
debugging with GDB.
|
||||
|
||||
|
||||
StackTrace Option
|
||||
~~~~~~~~~~~~~~~~~
|
||||
StackTrace option
|
||||
-----------------
|
||||
If the `stackTrace`:idx: option is turned on, the generated C contains code to
|
||||
ensure that proper stack traces are given if the program crashes or an
|
||||
uncaught exception is raised.
|
||||
|
||||
|
||||
LineTrace Option
|
||||
~~~~~~~~~~~~~~~~
|
||||
LineTrace option
|
||||
----------------
|
||||
The `lineTrace`:idx: option implies the ``stackTrace`` option. If turned on,
|
||||
the generated C contains code to ensure that proper stack traces with line
|
||||
number information are given if the program crashes or an uncaught exception
|
||||
is raised.
|
||||
|
||||
Debugger Option
|
||||
~~~~~~~~~~~~~~~
|
||||
Debugger option
|
||||
---------------
|
||||
The `debugger`:idx: option enables or disables the *Embedded Nimrod Debugger*.
|
||||
See the documentation of endb_ for further information.
|
||||
|
||||
|
||||
Breakpoint Pragma
|
||||
~~~~~~~~~~~~~~~~~
|
||||
Breakpoint pragma
|
||||
-----------------
|
||||
The *breakpoint* pragma was specially added for the sake of debugging with
|
||||
ENDB. See the documentation of `endb <endb.html>`_ for further information.
|
||||
|
||||
|
||||
Volatile Pragma
|
||||
~~~~~~~~~~~~~~~
|
||||
Volatile pragma
|
||||
---------------
|
||||
The `volatile`:idx: pragma is for variables only. It declares the variable as
|
||||
``volatile``, whatever that means in C/C++.
|
||||
|
||||
Register Pragma
|
||||
~~~~~~~~~~~~~~~
|
||||
The `register`:idx: pragma is for variables only. It declares the variable as
|
||||
``register``, giving the compiler a hint that the variable should be placed
|
||||
in a hardware register for faster access. C compilers usually ignore this
|
||||
though and for good reasons: Often they do a better job without it anyway.
|
||||
|
||||
In highly specific cases (a dispatch loop of an bytecode interpreter for
|
||||
example) it may provide benefits, though.
|
||||
|
||||
|
||||
Acyclic Pragma
|
||||
~~~~~~~~~~~~~~
|
||||
The `acyclic`:idx: pragma can be used for object types to mark them as acyclic
|
||||
even though they seem to be cyclic. This is an **optimization** for the garbage
|
||||
collector to not consider objects of this type as part of a cycle:
|
||||
|
||||
.. code-block:: nimrod
|
||||
type
|
||||
PNode = ref TNode
|
||||
TNode {.acyclic, final.} = object
|
||||
left, right: PNode
|
||||
data: string
|
||||
|
||||
In the example a tree structure is declared with the ``TNode`` type. Note that
|
||||
the type definition is recursive and the GC has to assume that objects of
|
||||
this type may form a cyclic graph. The ``acyclic`` pragma passes the
|
||||
information that this cannot happen to the GC. If the programmer uses the
|
||||
``acyclic`` pragma for data types that are in reality cyclic, the GC may leak
|
||||
memory, but nothing worse happens.
|
||||
|
||||
|
||||
DeadCodeElim Pragma
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
The `deadCodeElim`:idx: pragma only applies to whole modules: It tells the
|
||||
compiler to activate (or deactivate) dead code elimination for the module the
|
||||
pragma appers in.
|
||||
|
||||
The ``--deadCodeElim:on`` command line switch has the same effect as marking
|
||||
every module with ``{.deadCodeElim:on}``. However, for some modules such as
|
||||
the GTK wrapper it makes sense to *always* turn on dead code elimination -
|
||||
no matter if it is globally active or not.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: nimrod
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
|
||||
Disabling certain messages
|
||||
--------------------------
|
||||
Nimrod generates some warnings and hints ("line too long") that may annoy the
|
||||
user. A mechanism for disabling certain messages is provided: Each hint
|
||||
and warning message contains a symbol in brackets. This is the message's
|
||||
identifier that can be used to enable or disable it:
|
||||
|
||||
.. code-block:: Nimrod
|
||||
{.warning[LineTooLong]: off.} # turn off warning about too long lines
|
||||
|
||||
This is often better than disabling all warnings at once.
|
||||
**Note**: This pragma will not exist for the LLVM backend.
|
||||
|
||||
|
||||
Debugging with Nimrod
|
||||
|
||||
@@ -46,8 +46,8 @@ Installation on Windows
|
||||
|
||||
Install Nimrod by downloading and running the ``nimrod_$version.exe`` file.
|
||||
As default, the ``GCC`` compiler is used that is bundled with this installer.
|
||||
**You can change the configuration file** ``config/nimrod.cfg`` **to use
|
||||
another C compiler or change the path to GCC.**
|
||||
You can change the configuration file ``config/nimrod.cfg`` to use
|
||||
another C compiler or change the path to GCC.
|
||||
|
||||
Currently, the following C compilers are supported under Windows:
|
||||
|
||||
|
||||
8
koch.nim
8
koch.nim
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# Maintenance program for Nimrod
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
@@ -15,7 +15,7 @@ const
|
||||
+-----------------------------------------------------------------+
|
||||
| Maintenance program for Nimrod |
|
||||
| Version $1|
|
||||
| (c) 2009 Andreas Rumpf |
|
||||
| (c) 2010 Andreas Rumpf |
|
||||
+-----------------------------------------------------------------+
|
||||
Build time: $2, $3
|
||||
|
||||
@@ -113,7 +113,9 @@ proc bootIteration(args: string): bool =
|
||||
# Nimrod does not produce an executable again if nothing changed. That's ok:
|
||||
result = sameFileContent("rod" / "nimrod".exe, nimrod1)
|
||||
safeRemove("bin" / "nimrod".exe)
|
||||
copyFile("bin" / "nimrod".exe, "rod" / "nimrod".exe)
|
||||
var dest = "bin" / "nimrod".exe
|
||||
copyFile(dest, "rod" / "nimrod".exe)
|
||||
inclFilePermissions(dest, {fpUserExec})
|
||||
safeRemove(nimrod1)
|
||||
if result: echo "executables are equal: SUCCESS!"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=======================================================
|
||||
The Nimrod Runtime Library
|
||||
Copyright (C) 2004-2009 Andreas Rumpf
|
||||
Copyright (C) 2004-2010 Andreas Rumpf
|
||||
=======================================================
|
||||
|
||||
This is the file copying.txt, it applies to the Nimrod Run-Time Library
|
||||
|
||||
196
lib/devel/httpserver.nim
Normal file
196
lib/devel/httpserver.nim
Normal file
@@ -0,0 +1,196 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements a simple HTTP-Server.
|
||||
|
||||
import strutils, os, osproc, strtabs, streams, sockets
|
||||
|
||||
const
|
||||
wwwNL = "\r\L"
|
||||
ServerSig = "Server: httpserver.nim/1.0.0" & wwwNL
|
||||
|
||||
# --------------- output messages --------------------------------------------
|
||||
|
||||
proc sendTextContentType(client: TSocket) =
|
||||
send(client, "Content-type: text/html" & wwwNL)
|
||||
send(client, wwwNL)
|
||||
|
||||
proc badRequest(client: TSocket) =
|
||||
# Inform the client that a request it has made has a problem.
|
||||
send(client, "HTTP/1.0 400 BAD REQUEST" & wwwNL)
|
||||
sendTextContentType(client)
|
||||
send(client, "<p>Your browser sent a bad request, " &
|
||||
"such as a POST without a Content-Length." & wwwNL)
|
||||
|
||||
proc cannotExec(client: TSocket) =
|
||||
send(client, "HTTP/1.0 500 Internal Server Error" & wwwNL)
|
||||
sendTextContentType(client)
|
||||
send(client, "<P>Error prohibited CGI execution." & wwwNL)
|
||||
|
||||
proc headers(client: TSocket, filename: string) =
|
||||
# XXX could use filename to determine file type
|
||||
send(client, "HTTP/1.0 200 OK" & wwwNL)
|
||||
send(client, ServerSig)
|
||||
sendTextContentType(client)
|
||||
|
||||
proc notFound(client: TSocket) =
|
||||
send(client, "HTTP/1.0 404 NOT FOUND" & wwwNL)
|
||||
send(client, ServerSig)
|
||||
sendTextContentType(client)
|
||||
send(client, "<html><title>Not Found</title>" & wwwNL)
|
||||
send(client, "<body><p>The server could not fulfill" & wwwNL)
|
||||
send(client, "your request because the resource specified" & wwwNL)
|
||||
send(client, "is unavailable or nonexistent." & wwwNL)
|
||||
send(client, "</body></html>" & wwwNL)
|
||||
|
||||
proc unimplemented(client: TSocket) =
|
||||
send(client, "HTTP/1.0 501 Method Not Implemented" & wwwNL)
|
||||
send(client, ServerSig)
|
||||
sendTextContentType(client)
|
||||
send(client, "<html><head><title>Method Not Implemented" &
|
||||
"</title></head>" &
|
||||
"<body><p>HTTP request method not supported." &
|
||||
"</body></HTML>" & wwwNL)
|
||||
|
||||
# ----------------- file serving ---------------------------------------------
|
||||
|
||||
proc discardHeaders(client: TSocket) = skip(client)
|
||||
|
||||
proc serveFile(client: TSocket, filename: string) =
|
||||
discardHeaders(client)
|
||||
|
||||
var f: TFile
|
||||
if open(f, filename):
|
||||
headers(client, filename)
|
||||
const bufSize = 8000 # != 8K might be good for memory manager
|
||||
var buf = alloc(bufsize)
|
||||
while True:
|
||||
var bytesread = readBuffer(f, buf, bufsize)
|
||||
if bytesread > 0:
|
||||
var byteswritten = send(client, buf, bytesread)
|
||||
if bytesread != bytesWritten:
|
||||
dealloc(buf)
|
||||
close(f)
|
||||
OSError()
|
||||
if bytesread != bufSize: break
|
||||
dealloc(buf)
|
||||
close(f)
|
||||
else:
|
||||
notFound(client)
|
||||
|
||||
# ------------------ CGI execution -------------------------------------------
|
||||
|
||||
type
|
||||
TRequestMethod = enum reqGet, reqPost
|
||||
|
||||
proc executeCgi(client: TSocket, path, query: string, meth: TRequestMethod) =
|
||||
var env = newStringTable(modeCaseInsensitive)
|
||||
var contentLength = -1
|
||||
case meth
|
||||
of reqGet:
|
||||
discardHeaders(client)
|
||||
|
||||
env["REQUEST_METHOD"] = "GET"
|
||||
env["QUERY_STRING"] = query
|
||||
of reqPost:
|
||||
var buf = ""
|
||||
var dataAvail = false
|
||||
while dataAvail:
|
||||
dataAvail = recvLine(client, buf)
|
||||
var L = toLower(buf)
|
||||
if L.startsWith("content-length:"):
|
||||
var i = len("content-length:")
|
||||
while L[i] in Whitespace: inc(i)
|
||||
contentLength = parseInt(copy(L, i))
|
||||
|
||||
if contentLength < 0:
|
||||
badRequest(client)
|
||||
return
|
||||
|
||||
env["REQUEST_METHOD"] = "POST"
|
||||
env["CONTENT_LENGTH"] = $contentLength
|
||||
|
||||
send(client, "HTTP/1.0 200 OK" & wwwNL)
|
||||
|
||||
var process = startProcess(command=path, env=env)
|
||||
if meth == reqPost:
|
||||
# get from client and post to CGI program:
|
||||
var buf = alloc(contentLength)
|
||||
if recv(client, buf, contentLength) != contentLength: OSError()
|
||||
var inp = process.inputStream
|
||||
inp.writeData(inp, buf, contentLength)
|
||||
|
||||
var outp = process.outputStream
|
||||
while running(process) or not outp.atEnd(outp):
|
||||
var line = outp.readLine()
|
||||
send(client, line)
|
||||
send(client, wwwNL)
|
||||
|
||||
# --------------- Server Setup -----------------------------------------------
|
||||
|
||||
proc startup(): tuple[socket: TSocket, port: TPort] =
|
||||
var s = socket(AF_INET)
|
||||
if s == InvalidSocket: OSError()
|
||||
bindAddr(s)
|
||||
listen(s)
|
||||
result.socket = s
|
||||
result.port = getSockName(s)
|
||||
|
||||
proc acceptRequest(client: TSocket) =
|
||||
var cgi = false
|
||||
var query = ""
|
||||
var buf = ""
|
||||
discard recvLine(client, buf)
|
||||
var data = buf.split()
|
||||
var meth = reqGet
|
||||
if cmpIgnoreCase(data[0], "GET") == 0:
|
||||
var q = find(data[1], '?')
|
||||
if q >= 0:
|
||||
cgi = true
|
||||
query = data[1].copy(q+1)
|
||||
elif cmpIgnoreCase(data[0], "POST") == 0:
|
||||
cgi = true
|
||||
meth = reqPost
|
||||
else:
|
||||
unimplemented(client)
|
||||
|
||||
var path = data[1]
|
||||
if path[path.len-1] == '/' or existsDir(path):
|
||||
path = path / "index.html"
|
||||
|
||||
if not ExistsFile(path):
|
||||
discardHeaders(client)
|
||||
notFound(client)
|
||||
else:
|
||||
when defined(Windows):
|
||||
var ext = splitFile(path).ext.toLower
|
||||
if ext == ".exe" or ext == ".cgi":
|
||||
# XXX: extract interpreter information here?
|
||||
cgi = true
|
||||
else:
|
||||
if {fpUserExec, fpGroupExec, fpOthersExec} * path.getFilePermissions != {}:
|
||||
cgi = true
|
||||
if not cgi:
|
||||
serveFile(client, path)
|
||||
else:
|
||||
executeCgi(client, path, query, meth)
|
||||
|
||||
proc main =
|
||||
var (server, port) = startup()
|
||||
echo("httpserver running on port ", int16(port))
|
||||
|
||||
while true:
|
||||
var client = accept(server)
|
||||
if client == InvalidSocket: OSError()
|
||||
acceptRequest(client)
|
||||
close(client)
|
||||
close(server)
|
||||
|
||||
when isMainModule:
|
||||
main()
|
||||
693
lib/newwrap/cairo/cairo.nim
Normal file
693
lib/newwrap/cairo/cairo.nim
Normal file
@@ -0,0 +1,693 @@
|
||||
#* cairo - a vector graphics library with display and print output
|
||||
# *
|
||||
# * Copyright <20> 2002 University of Southern California
|
||||
# * Copyright <20> 2005 Red Hat, Inc.
|
||||
# *
|
||||
# * This library is free software; you can redistribute it and/or
|
||||
# * modify it either under the terms of the GNU Lesser General Public
|
||||
# * License version 2.1 as published by the Free Software Foundation
|
||||
# * (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
# * Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
# * notice, a recipient may use your version of this file under either
|
||||
# * the MPL or the LGPL.
|
||||
# *
|
||||
# * You should have received a copy of the LGPL along with this library
|
||||
# * in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
# * You should have received a copy of the MPL along with this library
|
||||
# * in the file COPYING-MPL-1.1
|
||||
# *
|
||||
# * The contents of this file are subject to the Mozilla Public License
|
||||
# * Version 1.1 (the "License"); you may not use this file except in
|
||||
# * compliance with the License. You may obtain a copy of the License at
|
||||
# * http://www.mozilla.org/MPL/
|
||||
# *
|
||||
# * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
# * OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
# * the specific language governing rights and limitations.
|
||||
# *
|
||||
# * The Original Code is the cairo graphics library.
|
||||
# *
|
||||
# * The Initial Developer of the Original Code is University of Southern
|
||||
# * California.
|
||||
# *
|
||||
# * Contributor(s):
|
||||
# * Carl D. Worth <cworth@cworth.org>
|
||||
# #*
|
||||
# * This FreePascal binding generated August 26, 2005
|
||||
# * by Jeffrey Pohlmeyer <yetanothergeek@yahoo.com>
|
||||
#
|
||||
|
||||
#
|
||||
# - Updated to cairo version 1.4
|
||||
# - Grouped OS specific fuctions in separated units
|
||||
# - Organized the functions by group and ordered exactly as the c header
|
||||
# - Cleared parameter list syntax according to pascal standard
|
||||
#
|
||||
# By Luiz Am<41>rico Pereira C<>mara
|
||||
# October 2007
|
||||
#
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
LIB_CAIRO* = "cairo.dll"
|
||||
else:
|
||||
const
|
||||
LIB_CAIRO* = "libcairo.so"
|
||||
type
|
||||
PByte = cstring
|
||||
TStatus* = enum
|
||||
STATUS_SUCCESS = 0, STATUS_NO_MEMORY, STATUS_INVALID_RESTORE,
|
||||
STATUS_INVALID_POP_GROUP, STATUS_NO_CURRENT_POINT, STATUS_INVALID_MATRIX,
|
||||
STATUS_INVALID_STATUS, STATUS_NULL_POINTER, STATUS_INVALID_STRING,
|
||||
STATUS_INVALID_PATH_DATA, STATUS_READ_ERROR, STATUS_WRITE_ERROR,
|
||||
STATUS_SURFACE_FINISHED, STATUS_SURFACE_TYPE_MISMATCH,
|
||||
STATUS_PATTERN_TYPE_MISMATCH, STATUS_INVALID_CONTENT, STATUS_INVALID_FORMAT,
|
||||
STATUS_INVALID_VISUAL, STATUS_FILE_NOT_FOUND, STATUS_INVALID_DASH
|
||||
TOperator* = enum
|
||||
OPERATOR_CLEAR, OPERATOR_SOURCE, OPERATOR_OVER, OPERATOR_IN, OPERATOR_OUT,
|
||||
OPERATOR_ATOP, OPERATOR_DEST, OPERATOR_DEST_OVER, OPERATOR_DEST_IN,
|
||||
OPERATOR_DEST_OUT, OPERATOR_DEST_ATOP, OPERATOR_XOR, OPERATOR_ADD,
|
||||
OPERATOR_SATURATE
|
||||
TAntialias* = enum
|
||||
ANTIALIAS_DEFAULT, ANTIALIAS_NONE, ANTIALIAS_GRAY, ANTIALIAS_SUBPIXEL
|
||||
TFillRule* = enum
|
||||
FILL_RULE_WINDING, FILL_RULE_EVEN_ODD
|
||||
TLineCap* = enum
|
||||
LINE_CAP_BUTT, LINE_CAP_ROUND, LINE_CAP_SQUARE
|
||||
TLineJoin* = enum
|
||||
LINE_JOIN_MITER, LINE_JOIN_ROUND, LINE_JOIN_BEVEL
|
||||
TFontSlant* = enum
|
||||
FONT_SLANT_NORMAL, FONT_SLANT_ITALIC, FONT_SLANT_OBLIQUE
|
||||
TFontWeight* = enum
|
||||
FONT_WEIGHT_NORMAL, FONT_WEIGHT_BOLD
|
||||
TSubpixelOrder* = enum
|
||||
SUBPIXEL_ORDER_DEFAULT, SUBPIXEL_ORDER_RGB, SUBPIXEL_ORDER_BGR,
|
||||
SUBPIXEL_ORDER_VRGB, SUBPIXEL_ORDER_VBGR
|
||||
THintStyle* = enum
|
||||
HINT_STYLE_DEFAULT, HINT_STYLE_NONE, HINT_STYLE_SLIGHT, HINT_STYLE_MEDIUM,
|
||||
HINT_STYLE_FULL
|
||||
THintMetrics* = enum
|
||||
HINT_METRICS_DEFAULT, HINT_METRICS_OFF, HINT_METRICS_ON
|
||||
TPathDataType* = enum
|
||||
PATH_MOVE_TO, PATH_LINE_TO, PATH_CURVE_TO, PATH_CLOSE_PATH
|
||||
TContent* = enum
|
||||
CONTENT_COLOR = 0x00001000, CONTENT_ALPHA = 0x00002000,
|
||||
CONTENT_COLOR_ALPHA = 0x00003000
|
||||
TFormat* = enum
|
||||
FORMAT_ARGB32, FORMAT_RGB24, FORMAT_A8, FORMAT_A1
|
||||
TExtend* = enum
|
||||
EXTEND_NONE, EXTEND_REPEAT, EXTEND_REFLECT, EXTEND_PAD
|
||||
TFilter* = enum
|
||||
FILTER_FAST, FILTER_GOOD, FILTER_BEST, FILTER_NEAREST, FILTER_BILINEAR,
|
||||
FILTER_GAUSSIAN
|
||||
TFontType* = enum
|
||||
FONT_TYPE_TOY, FONT_TYPE_FT, FONT_TYPE_WIN32, FONT_TYPE_ATSUI
|
||||
TPatternType* = enum
|
||||
PATTERN_TYPE_SOLID, PATTERN_TYPE_SURFACE, PATTERN_TYPE_LINEAR,
|
||||
PATTERN_TYPE_RADIAL
|
||||
TSurfaceType* = enum
|
||||
SURFACE_TYPE_IMAGE, SURFACE_TYPE_PDF, SURFACE_TYPE_PS, SURFACE_TYPE_XLIB,
|
||||
SURFACE_TYPE_XCB, SURFACE_TYPE_GLITZ, SURFACE_TYPE_QUARTZ,
|
||||
SURFACE_TYPE_WIN32, SURFACE_TYPE_BEOS, SURFACE_TYPE_DIRECTFB,
|
||||
SURFACE_TYPE_SVG, SURFACE_TYPE_OS2
|
||||
TSvgVersion* = enum
|
||||
SVG_VERSION_1_1, SVG_VERSION_1_2
|
||||
PSurface* = ptr TSurface
|
||||
PPCairoSurface* = ptr PSurface
|
||||
P* = ptr T
|
||||
PPattern* = ptr TPattern
|
||||
PFontOptions* = ptr TFontOptions
|
||||
PFontFace* = ptr TFontFace
|
||||
PScaledFont* = ptr TScaledFont
|
||||
PBool* = ptr TBool
|
||||
TBool* = int32
|
||||
PMatrix* = ptr TMatrix
|
||||
PUserDataKey* = ptr TUserDataKey
|
||||
PGlyph* = ptr TGlyph
|
||||
PTextExtents* = ptr TTextExtents
|
||||
PFontExtents* = ptr TFontExtents
|
||||
PPathDataType* = ptr TPathDataType
|
||||
PPathData* = ptr TPathData
|
||||
PPath* = ptr TPath
|
||||
PRectangle* = ptr TRectangle
|
||||
PRectangleList* = ptr TRectangleList
|
||||
TDestroyFunc* = proc (data: Pointer){.cdecl.}
|
||||
TWriteFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.}
|
||||
TReadFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.}
|
||||
T*{.final.} = object #OPAQUE
|
||||
TSurface*{.final.} = object #OPAQUE
|
||||
TPattern*{.final.} = object #OPAQUE
|
||||
TScaledFont*{.final.} = object #OPAQUE
|
||||
TFontFace*{.final.} = object #OPAQUE
|
||||
TFontOptions*{.final.} = object #OPAQUE
|
||||
TMatrix*{.final.} = object
|
||||
xx: float64
|
||||
yx: float64
|
||||
xy: float64
|
||||
yy: float64
|
||||
x0: float64
|
||||
y0: float64
|
||||
|
||||
TUserDataKey*{.final.} = object
|
||||
unused: int32
|
||||
|
||||
TGlyph*{.final.} = object
|
||||
index: int32
|
||||
x: float64
|
||||
y: float64
|
||||
|
||||
TTextExtents*{.final.} = object
|
||||
x_bearing: float64
|
||||
y_bearing: float64
|
||||
width: float64
|
||||
height: float64
|
||||
x_advance: float64
|
||||
y_advance: float64
|
||||
|
||||
TFontExtents*{.final.} = object
|
||||
ascent: float64
|
||||
descent: float64
|
||||
height: float64
|
||||
max_x_advance: float64
|
||||
max_y_advance: float64
|
||||
|
||||
TPathData*{.final.} = object #* _type : TCairoPathDataType;
|
||||
# length : LongInt;
|
||||
# end
|
||||
x: float64
|
||||
y: float64
|
||||
|
||||
TPath*{.final.} = object
|
||||
status: TStatus
|
||||
data: PPathData
|
||||
num_data: int32
|
||||
|
||||
TRectangle*{.final.} = object
|
||||
x, y, width, height: float64
|
||||
|
||||
TRectangleList*{.final.} = object
|
||||
status: TStatus
|
||||
rectangles: PRectangle
|
||||
num_rectangles: int32
|
||||
|
||||
|
||||
proc version*(): int32{.cdecl, importc: "cairo_version", dynlib: LIB_CAIRO.}
|
||||
proc version_string*(): cstring{.cdecl, importc: "cairo_version_string",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#Helper function to retrieve decoded version
|
||||
proc version*(major, minor, micro: var int32)
|
||||
#* Functions for manipulating state objects
|
||||
proc create*(target: PSurface): P{.cdecl, importc: "cairo_create",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc reference*(cr: P): P{.cdecl, importc: "cairo_reference", dynlib: LIB_CAIRO.}
|
||||
proc destroy*(cr: P){.cdecl, importc: "cairo_destroy", dynlib: LIB_CAIRO.}
|
||||
proc get_reference_count*(cr: P): int32{.cdecl,
|
||||
importc: "cairo_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc get_user_data*(cr: P, key: PUserDataKey): pointer{.cdecl,
|
||||
importc: "cairo_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc set_user_data*(cr: P, key: PUserDataKey, user_data: Pointer,
|
||||
destroy: TDestroyFunc): TStatus{.cdecl,
|
||||
importc: "cairo_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc save*(cr: P){.cdecl, importc: "cairo_save", dynlib: LIB_CAIRO.}
|
||||
proc restore*(cr: P){.cdecl, importc: "cairo_restore", dynlib: LIB_CAIRO.}
|
||||
proc push_group*(cr: P){.cdecl, importc: "cairo_push_group", dynlib: LIB_CAIRO.}
|
||||
proc push_group_with_content*(cr: P, content: TContent){.cdecl,
|
||||
importc: "cairo_push_group_with_content", dynlib: LIB_CAIRO.}
|
||||
proc pop_group*(cr: P): PPattern{.cdecl, importc: "cairo_pop_group",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc pop_group_to_source*(cr: P){.cdecl, importc: "cairo_pop_group_to_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Modify state
|
||||
proc set_operator*(cr: P, op: TOperator){.cdecl, importc: "cairo_set_operator",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc set_source*(cr: P, source: PPattern){.cdecl, importc: "cairo_set_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc set_source_rgb*(cr: P, red, green, blue: float64){.cdecl,
|
||||
importc: "cairo_set_source_rgb", dynlib: LIB_CAIRO.}
|
||||
proc set_source_rgba*(cr: P, red, green, blue, alpha: float64){.cdecl,
|
||||
importc: "cairo_set_source_rgba", dynlib: LIB_CAIRO.}
|
||||
proc set_source_surface*(cr: P, surface: PSurface, x, y: float64){.cdecl,
|
||||
importc: "cairo_set_source_surface", dynlib: LIB_CAIRO.}
|
||||
proc set_tolerance*(cr: P, tolerance: float64){.cdecl,
|
||||
importc: "cairo_set_tolerance", dynlib: LIB_CAIRO.}
|
||||
proc set_antialias*(cr: P, antialias: TAntialias){.cdecl,
|
||||
importc: "cairo_set_antialias", dynlib: LIB_CAIRO.}
|
||||
proc set_fill_rule*(cr: P, fill_rule: TFillRule){.cdecl,
|
||||
importc: "cairo_set_fill_rule", dynlib: LIB_CAIRO.}
|
||||
proc set_line_width*(cr: P, width: float64){.cdecl,
|
||||
importc: "cairo_set_line_width", dynlib: LIB_CAIRO.}
|
||||
proc set_line_cap*(cr: P, line_cap: TLineCap){.cdecl,
|
||||
importc: "cairo_set_line_cap", dynlib: LIB_CAIRO.}
|
||||
proc set_line_join*(cr: P, line_join: TLineJoin){.cdecl,
|
||||
importc: "cairo_set_line_join", dynlib: LIB_CAIRO.}
|
||||
proc set_dash*(cr: P, dashes: openarray[float64], offset: float64){.cdecl,
|
||||
importc: "cairo_set_dash", dynlib: LIB_CAIRO.}
|
||||
proc set_miter_limit*(cr: P, limit: float64){.cdecl,
|
||||
importc: "cairo_set_miter_limit", dynlib: LIB_CAIRO.}
|
||||
proc translate*(cr: P, tx, ty: float64){.cdecl, importc: "cairo_translate",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc scale*(cr: P, sx, sy: float64){.cdecl, importc: "cairo_scale",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc rotate*(cr: P, angle: float64){.cdecl, importc: "cairo_rotate",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc transform*(cr: P, matrix: PMatrix){.cdecl, importc: "cairo_transform",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc set_matrix*(cr: P, matrix: PMatrix){.cdecl, importc: "cairo_set_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc identity_matrix*(cr: P){.cdecl, importc: "cairo_identity_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc user_to_device*(cr: P, x, y: var float64){.cdecl,
|
||||
importc: "cairo_user_to_device", dynlib: LIB_CAIRO.}
|
||||
proc user_to_device_distance*(cr: P, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_user_to_device_distance", dynlib: LIB_CAIRO.}
|
||||
proc device_to_user*(cr: P, x, y: var float64){.cdecl,
|
||||
importc: "cairo_device_to_user", dynlib: LIB_CAIRO.}
|
||||
proc device_to_user_distance*(cr: P, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_device_to_user_distance", dynlib: LIB_CAIRO.}
|
||||
#* Path creation functions
|
||||
proc new_path*(cr: P){.cdecl, importc: "cairo_new_path", dynlib: LIB_CAIRO.}
|
||||
proc move_to*(cr: P, x, y: float64){.cdecl, importc: "cairo_move_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc new_sub_path*(cr: P){.cdecl, importc: "cairo_new_sub_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc line_to*(cr: P, x, y: float64){.cdecl, importc: "cairo_line_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc curve_to*(cr: P, x1, y1, x2, y2, x3, y3: float64){.cdecl,
|
||||
importc: "cairo_curve_to", dynlib: LIB_CAIRO.}
|
||||
proc arc*(cr: P, xc, yc, radius, angle1, angle2: float64){.cdecl,
|
||||
importc: "cairo_arc", dynlib: LIB_CAIRO.}
|
||||
proc arc_negative*(cr: P, xc, yc, radius, angle1, angle2: float64){.cdecl,
|
||||
importc: "cairo_arc_negative", dynlib: LIB_CAIRO.}
|
||||
proc rel_move_to*(cr: P, dx, dy: float64){.cdecl, importc: "cairo_rel_move_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc rel_line_to*(cr: P, dx, dy: float64){.cdecl, importc: "cairo_rel_line_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc rel_curve_to*(cr: P, dx1, dy1, dx2, dy2, dx3, dy3: float64){.cdecl,
|
||||
importc: "cairo_rel_curve_to", dynlib: LIB_CAIRO.}
|
||||
proc rectangle*(cr: P, x, y, width, height: float64){.cdecl,
|
||||
importc: "cairo_rectangle", dynlib: LIB_CAIRO.}
|
||||
proc close_path*(cr: P){.cdecl, importc: "cairo_close_path", dynlib: LIB_CAIRO.}
|
||||
#* Painting functions
|
||||
proc paint*(cr: P){.cdecl, importc: "cairo_paint", dynlib: LIB_CAIRO.}
|
||||
proc paint_with_alpha*(cr: P, alpha: float64){.cdecl,
|
||||
importc: "cairo_paint_with_alpha", dynlib: LIB_CAIRO.}
|
||||
proc mask*(cr: P, pattern: PPattern){.cdecl, importc: "cairo_mask",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc mask_surface*(cr: P, surface: PSurface, surface_x, surface_y: float64){.
|
||||
cdecl, importc: "cairo_mask_surface", dynlib: LIB_CAIRO.}
|
||||
proc stroke*(cr: P){.cdecl, importc: "cairo_stroke", dynlib: LIB_CAIRO.}
|
||||
proc stroke_preserve*(cr: P){.cdecl, importc: "cairo_stroke_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc fill*(cr: P){.cdecl, importc: "cairo_fill", dynlib: LIB_CAIRO.}
|
||||
proc fill_preserve*(cr: P){.cdecl, importc: "cairo_fill_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc copy_page*(cr: P){.cdecl, importc: "cairo_copy_page", dynlib: LIB_CAIRO.}
|
||||
proc show_page*(cr: P){.cdecl, importc: "cairo_show_page", dynlib: LIB_CAIRO.}
|
||||
#* Insideness testing
|
||||
proc in_stroke*(cr: P, x, y: float64): TBool{.cdecl, importc: "cairo_in_stroke",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc in_fill*(cr: P, x, y: float64): TBool{.cdecl, importc: "cairo_in_fill",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Rectangular extents
|
||||
proc stroke_extents*(cr: P, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_stroke_extents", dynlib: LIB_CAIRO.}
|
||||
proc fill_extents*(cr: P, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_fill_extents", dynlib: LIB_CAIRO.}
|
||||
#* Clipping
|
||||
proc reset_clip*(cr: P){.cdecl, importc: "cairo_reset_clip", dynlib: LIB_CAIRO.}
|
||||
proc clip*(cr: P){.cdecl, importc: "cairo_clip", dynlib: LIB_CAIRO.}
|
||||
proc clip_preserve*(cr: P){.cdecl, importc: "cairo_clip_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc clip_extents*(cr: P, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_clip_extents", dynlib: LIB_CAIRO.}
|
||||
proc copy_clip_rectangle_list*(cr: P): PRectangleList{.cdecl,
|
||||
importc: "cairo_copy_clip_rectangle_list", dynlib: LIB_CAIRO.}
|
||||
proc rectangle_list_destroy*(rectangle_list: PRectangleList){.cdecl,
|
||||
importc: "cairo_rectangle_list_destroy", dynlib: LIB_CAIRO.}
|
||||
#* Font/Text functions
|
||||
proc font_options_create*(): PFontOptions{.cdecl,
|
||||
importc: "cairo_font_options_create", dynlib: LIB_CAIRO.}
|
||||
proc font_options_copy*(original: PFontOptions): PFontOptions{.cdecl,
|
||||
importc: "cairo_font_options_copy", dynlib: LIB_CAIRO.}
|
||||
proc font_options_destroy*(options: PFontOptions){.cdecl,
|
||||
importc: "cairo_font_options_destroy", dynlib: LIB_CAIRO.}
|
||||
proc font_options_status*(options: PFontOptions): TStatus{.cdecl,
|
||||
importc: "cairo_font_options_status", dynlib: LIB_CAIRO.}
|
||||
proc font_options_merge*(options, other: PFontOptions){.cdecl,
|
||||
importc: "cairo_font_options_merge", dynlib: LIB_CAIRO.}
|
||||
proc font_options_equal*(options, other: PFontOptions): TBool{.cdecl,
|
||||
importc: "cairo_font_options_equal", dynlib: LIB_CAIRO.}
|
||||
proc font_options_hash*(options: PFontOptions): int32{.cdecl,
|
||||
importc: "cairo_font_options_hash", dynlib: LIB_CAIRO.}
|
||||
proc font_options_set_antialias*(options: PFontOptions, antialias: TAntialias){.
|
||||
cdecl, importc: "cairo_font_options_set_antialias", dynlib: LIB_CAIRO.}
|
||||
proc font_options_get_antialias*(options: PFontOptions): TAntialias{.cdecl,
|
||||
importc: "cairo_font_options_get_antialias", dynlib: LIB_CAIRO.}
|
||||
proc font_options_set_subpixel_order*(options: PFontOptions,
|
||||
subpixel_order: TSubpixelOrder){.cdecl,
|
||||
importc: "cairo_font_options_set_subpixel_order", dynlib: LIB_CAIRO.}
|
||||
proc font_options_get_subpixel_order*(options: PFontOptions): TSubpixelOrder{.
|
||||
cdecl, importc: "cairo_font_options_get_subpixel_order", dynlib: LIB_CAIRO.}
|
||||
proc font_options_set_hint_style*(options: PFontOptions, hint_style: THintStyle){.
|
||||
cdecl, importc: "cairo_font_options_set_hint_style", dynlib: LIB_CAIRO.}
|
||||
proc font_options_get_hint_style*(options: PFontOptions): THintStyle{.cdecl,
|
||||
importc: "cairo_font_options_get_hint_style", dynlib: LIB_CAIRO.}
|
||||
proc font_options_set_hint_metrics*(options: PFontOptions,
|
||||
hint_metrics: THintMetrics){.cdecl,
|
||||
importc: "cairo_font_options_set_hint_metrics", dynlib: LIB_CAIRO.}
|
||||
proc font_options_get_hint_metrics*(options: PFontOptions): THintMetrics{.cdecl,
|
||||
importc: "cairo_font_options_get_hint_metrics", dynlib: LIB_CAIRO.}
|
||||
#* This interface is for dealing with text as text, not caring about the
|
||||
# font object inside the the TCairo.
|
||||
proc select_font_face*(cr: P, family: cstring, slant: TFontSlant,
|
||||
weight: TFontWeight){.cdecl,
|
||||
importc: "cairo_select_font_face", dynlib: LIB_CAIRO.}
|
||||
proc set_font_size*(cr: P, size: float64){.cdecl,
|
||||
importc: "cairo_set_font_size", dynlib: LIB_CAIRO.}
|
||||
proc set_font_matrix*(cr: P, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_set_font_matrix", dynlib: LIB_CAIRO.}
|
||||
proc get_font_matrix*(cr: P, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_get_font_matrix", dynlib: LIB_CAIRO.}
|
||||
proc set_font_options*(cr: P, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_set_font_options", dynlib: LIB_CAIRO.}
|
||||
proc get_font_options*(cr: P, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_get_font_options", dynlib: LIB_CAIRO.}
|
||||
proc set_font_face*(cr: P, font_face: PFontFace){.cdecl,
|
||||
importc: "cairo_set_font_face", dynlib: LIB_CAIRO.}
|
||||
proc get_font_face*(cr: P): PFontFace{.cdecl, importc: "cairo_get_font_face",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc set_scaled_font*(cr: P, scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_set_scaled_font", dynlib: LIB_CAIRO.}
|
||||
proc get_scaled_font*(cr: P): PScaledFont{.cdecl,
|
||||
importc: "cairo_get_scaled_font", dynlib: LIB_CAIRO.}
|
||||
proc show_text*(cr: P, utf8: cstring){.cdecl, importc: "cairo_show_text",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc show_glyphs*(cr: P, glyphs: PGlyph, num_glyphs: int32){.cdecl,
|
||||
importc: "cairo_show_glyphs", dynlib: LIB_CAIRO.}
|
||||
proc text_path*(cr: P, utf8: cstring){.cdecl, importc: "cairo_text_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc glyph_path*(cr: P, glyphs: PGlyph, num_glyphs: int32){.cdecl,
|
||||
importc: "cairo_glyph_path", dynlib: LIB_CAIRO.}
|
||||
proc text_extents*(cr: P, utf8: cstring, extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_text_extents", dynlib: LIB_CAIRO.}
|
||||
proc glyph_extents*(cr: P, glyphs: PGlyph, num_glyphs: int32,
|
||||
extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_glyph_extents", dynlib: LIB_CAIRO.}
|
||||
proc font_extents*(cr: P, extents: PFontExtents){.cdecl,
|
||||
importc: "cairo_font_extents", dynlib: LIB_CAIRO.}
|
||||
#* Generic identifier for a font style
|
||||
proc font_face_reference*(font_face: PFontFace): PFontFace{.cdecl,
|
||||
importc: "cairo_font_face_reference", dynlib: LIB_CAIRO.}
|
||||
proc font_face_destroy*(font_face: PFontFace){.cdecl,
|
||||
importc: "cairo_font_face_destroy", dynlib: LIB_CAIRO.}
|
||||
proc font_face_get_reference_count*(font_face: PFontFace): int32{.cdecl,
|
||||
importc: "cairo_font_face_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc font_face_status*(font_face: PFontFace): TStatus{.cdecl,
|
||||
importc: "cairo_font_face_status", dynlib: LIB_CAIRO.}
|
||||
proc font_face_get_type*(font_face: PFontFace): TFontType{.cdecl,
|
||||
importc: "cairo_font_face_get_type", dynlib: LIB_CAIRO.}
|
||||
proc font_face_get_user_data*(font_face: PFontFace, key: PUserDataKey): pointer{.
|
||||
cdecl, importc: "cairo_font_face_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc font_face_set_user_data*(font_face: PFontFace, key: PUserDataKey,
|
||||
user_data: pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_font_face_set_user_data", dynlib: LIB_CAIRO.}
|
||||
#* Portable interface to general font features
|
||||
proc scaled_font_create*(font_face: PFontFace, font_matrix: PMatrix,
|
||||
ctm: PMatrix, options: PFontOptions): PScaledFont{.
|
||||
cdecl, importc: "cairo_scaled_font_create", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_reference*(scaled_font: PScaledFont): PScaledFont{.cdecl,
|
||||
importc: "cairo_scaled_font_reference", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_destroy*(scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_scaled_font_destroy", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_reference_count*(scaled_font: PScaledFont): int32{.cdecl,
|
||||
importc: "cairo_scaled_font_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_status*(scaled_font: PScaledFont): TStatus{.cdecl,
|
||||
importc: "cairo_scaled_font_status", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_type*(scaled_font: PScaledFont): TFontType{.cdecl,
|
||||
importc: "cairo_scaled_font_get_type", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_user_data*(scaled_font: PScaledFont, key: PUserDataKey): Pointer{.
|
||||
cdecl, importc: "cairo_scaled_font_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_set_user_data*(scaled_font: PScaledFont, key: PUserDataKey,
|
||||
user_data: Pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_scaled_font_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_extents*(scaled_font: PScaledFont, extents: PFontExtents){.
|
||||
cdecl, importc: "cairo_scaled_font_extents", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_text_extents*(scaled_font: PScaledFont, utf8: cstring,
|
||||
extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_scaled_font_text_extents", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_glyph_extents*(scaled_font: PScaledFont, glyphs: PGlyph,
|
||||
num_glyphs: int32, extents: PTextExtents){.
|
||||
cdecl, importc: "cairo_scaled_font_glyph_extents", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_font_face*(scaled_font: PScaledFont): PFontFace{.cdecl,
|
||||
importc: "cairo_scaled_font_get_font_face", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_font_matrix*(scaled_font: PScaledFont, font_matrix: PMatrix){.
|
||||
cdecl, importc: "cairo_scaled_font_get_font_matrix", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_ctm*(scaled_font: PScaledFont, ctm: PMatrix){.cdecl,
|
||||
importc: "cairo_scaled_font_get_ctm", dynlib: LIB_CAIRO.}
|
||||
proc scaled_font_get_font_options*(scaled_font: PScaledFont,
|
||||
options: PFontOptions){.cdecl,
|
||||
importc: "cairo_scaled_font_get_font_options", dynlib: LIB_CAIRO.}
|
||||
#* Query functions
|
||||
proc get_operator*(cr: P): TOperator{.cdecl, importc: "cairo_get_operator",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_source*(cr: P): PPattern{.cdecl, importc: "cairo_get_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_tolerance*(cr: P): float64{.cdecl, importc: "cairo_get_tolerance",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_antialias*(cr: P): TAntialias{.cdecl, importc: "cairo_get_antialias",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_current_point*(cr: P, x, y: var float64){.cdecl,
|
||||
importc: "cairo_get_current_point", dynlib: LIB_CAIRO.}
|
||||
proc get_fill_rule*(cr: P): TFillRule{.cdecl, importc: "cairo_get_fill_rule",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_line_width*(cr: P): float64{.cdecl, importc: "cairo_get_line_width",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_line_cap*(cr: P): TLineCap{.cdecl, importc: "cairo_get_line_cap",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_line_join*(cr: P): TLineJoin{.cdecl, importc: "cairo_get_line_join",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_miter_limit*(cr: P): float64{.cdecl, importc: "cairo_get_miter_limit",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_dash_count*(cr: P): int32{.cdecl, importc: "cairo_get_dash_count",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_dash*(cr: P, dashes, offset: var float64){.cdecl,
|
||||
importc: "cairo_get_dash", dynlib: LIB_CAIRO.}
|
||||
proc get_matrix*(cr: P, matrix: PMatrix){.cdecl, importc: "cairo_get_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_target*(cr: P): PSurface{.cdecl, importc: "cairo_get_target",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc get_group_target*(cr: P): PSurface{.cdecl,
|
||||
importc: "cairo_get_group_target", dynlib: LIB_CAIRO.}
|
||||
proc copy_path*(cr: P): PPath{.cdecl, importc: "cairo_copy_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc copy_path_flat*(cr: P): PPath{.cdecl, importc: "cairo_copy_path_flat",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc append_path*(cr: P, path: PPath){.cdecl, importc: "cairo_append_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc path_destroy*(path: PPath){.cdecl, importc: "cairo_path_destroy",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Error status queries
|
||||
proc status*(cr: P): TStatus{.cdecl, importc: "cairo_status", dynlib: LIB_CAIRO.}
|
||||
proc status_to_string*(status: TStatus): cstring{.cdecl,
|
||||
importc: "cairo_status_to_string", dynlib: LIB_CAIRO.}
|
||||
#* Surface manipulation
|
||||
proc surface_create_similar*(other: PSurface, content: TContent,
|
||||
width, height: int32): PSurface{.cdecl,
|
||||
importc: "cairo_surface_create_similar", dynlib: LIB_CAIRO.}
|
||||
proc surface_reference*(surface: PSurface): PSurface{.cdecl,
|
||||
importc: "cairo_surface_reference", dynlib: LIB_CAIRO.}
|
||||
proc surface_finish*(surface: PSurface){.cdecl, importc: "cairo_surface_finish",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc surface_destroy*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_surface_destroy", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_reference_count*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_surface_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc surface_status*(surface: PSurface): TStatus{.cdecl,
|
||||
importc: "cairo_surface_status", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_type*(surface: PSurface): TSurfaceType{.cdecl,
|
||||
importc: "cairo_surface_get_type", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_content*(surface: PSurface): TContent{.cdecl,
|
||||
importc: "cairo_surface_get_content", dynlib: LIB_CAIRO.}
|
||||
proc surface_write_to_png*(surface: PSurface, filename: cstring): TStatus{.
|
||||
cdecl, importc: "cairo_surface_write_to_png", dynlib: LIB_CAIRO.}
|
||||
proc surface_write_to_png_stream*(surface: PSurface, write_func: TWriteFunc,
|
||||
closure: pointer): TStatus{.cdecl,
|
||||
importc: "cairo_surface_write_to_png_stream", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_user_data*(surface: PSurface, key: PUserDataKey): pointer{.
|
||||
cdecl, importc: "cairo_surface_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc surface_set_user_data*(surface: PSurface, key: PUserDataKey,
|
||||
user_data: pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_surface_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_font_options*(surface: PSurface, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_surface_get_font_options", dynlib: LIB_CAIRO.}
|
||||
proc surface_flush*(surface: PSurface){.cdecl, importc: "cairo_surface_flush",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc surface_mark_dirty*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_surface_mark_dirty", dynlib: LIB_CAIRO.}
|
||||
proc surface_mark_dirty_rectangle*(surface: PSurface, x, y, width, height: int32){.
|
||||
cdecl, importc: "cairo_surface_mark_dirty_rectangle", dynlib: LIB_CAIRO.}
|
||||
proc surface_set_device_offset*(surface: PSurface, x_offset, y_offset: float64){.
|
||||
cdecl, importc: "cairo_surface_set_device_offset", dynlib: LIB_CAIRO.}
|
||||
proc surface_get_device_offset*(surface: PSurface,
|
||||
x_offset, y_offset: var float64){.cdecl,
|
||||
importc: "cairo_surface_get_device_offset", dynlib: LIB_CAIRO.}
|
||||
proc surface_set_fallback_resolution*(surface: PSurface, x_pixels_per_inch,
|
||||
y_pixels_per_inch: float64){.cdecl, importc: "cairo_surface_set_fallback_resolution",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Image-surface functions
|
||||
proc image_surface_create*(format: TFormat, width, height: int32): PSurface{.
|
||||
cdecl, importc: "cairo_image_surface_create", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_create_for_data*(data: Pbyte, format: TFormat,
|
||||
width, height, stride: int32): PSurface{.
|
||||
cdecl, importc: "cairo_image_surface_create_for_data", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_data*(surface: PSurface): cstring{.cdecl,
|
||||
importc: "cairo_image_surface_get_data", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_format*(surface: PSurface): TFormat{.cdecl,
|
||||
importc: "cairo_image_surface_get_format", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_width*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_width", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_height*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_height", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_get_stride*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_stride", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_create_from_png*(filename: cstring): PSurface{.cdecl,
|
||||
importc: "cairo_image_surface_create_from_png", dynlib: LIB_CAIRO.}
|
||||
proc image_surface_create_from_png_stream*(read_func: TReadFunc,
|
||||
closure: pointer): PSurface{.cdecl, importc: "cairo_image_surface_create_from_png_stream",
|
||||
dynlib: LIB_CAIRO.}
|
||||
#* Pattern creation functions
|
||||
proc pattern_create_rgb*(red, green, blue: float64): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_create_rgb", dynlib: LIB_CAIRO.}
|
||||
proc pattern_create_rgba*(red, green, blue, alpha: float64): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_create_rgba", dynlib: LIB_CAIRO.}
|
||||
proc pattern_create_for_surface*(surface: PSurface): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_create_for_surface", dynlib: LIB_CAIRO.}
|
||||
proc pattern_create_linear*(x0, y0, x1, y1: float64): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_create_linear", dynlib: LIB_CAIRO.}
|
||||
proc pattern_create_radial*(cx0, cy0, radius0, cx1, cy1, radius1: float64): PPattern{.
|
||||
cdecl, importc: "cairo_pattern_create_radial", dynlib: LIB_CAIRO.}
|
||||
proc pattern_reference*(pattern: PPattern): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_reference", dynlib: LIB_CAIRO.}
|
||||
proc pattern_destroy*(pattern: PPattern){.cdecl,
|
||||
importc: "cairo_pattern_destroy", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_reference_count*(pattern: PPattern): int32{.cdecl,
|
||||
importc: "cairo_pattern_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
proc pattern_status*(pattern: PPattern): TStatus{.cdecl,
|
||||
importc: "cairo_pattern_status", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_user_data*(pattern: PPattern, key: PUserDataKey): Pointer{.
|
||||
cdecl, importc: "cairo_pattern_get_user_data", dynlib: LIB_CAIRO.}
|
||||
proc pattern_set_user_data*(pattern: PPattern, key: PUserDataKey,
|
||||
user_data: Pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_type*(pattern: PPattern): TPatternType{.cdecl,
|
||||
importc: "cairo_pattern_get_type", dynlib: LIB_CAIRO.}
|
||||
proc pattern_add_color_stop_rgb*(pattern: PPattern,
|
||||
offset, red, green, blue: float64){.cdecl,
|
||||
importc: "cairo_pattern_add_color_stop_rgb", dynlib: LIB_CAIRO.}
|
||||
proc pattern_add_color_stop_rgba*(pattern: PPattern,
|
||||
offset, red, green, blue, alpha: float64){.
|
||||
cdecl, importc: "cairo_pattern_add_color_stop_rgba", dynlib: LIB_CAIRO.}
|
||||
proc pattern_set_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_pattern_set_matrix", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_pattern_get_matrix", dynlib: LIB_CAIRO.}
|
||||
proc pattern_set_extend*(pattern: PPattern, extend: TExtend){.cdecl,
|
||||
importc: "cairo_pattern_set_extend", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_extend*(pattern: PPattern): TExtend{.cdecl,
|
||||
importc: "cairo_pattern_get_extend", dynlib: LIB_CAIRO.}
|
||||
proc pattern_set_filter*(pattern: PPattern, filter: TFilter){.cdecl,
|
||||
importc: "cairo_pattern_set_filter", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_filter*(pattern: PPattern): TFilter{.cdecl,
|
||||
importc: "cairo_pattern_get_filter", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_rgba*(pattern: PPattern, red, green, blue, alpha: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_rgba", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_surface*(pattern: PPattern, surface: PPCairoSurface): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_surface", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_color_stop_rgba*(pattern: PPattern, index: int32,
|
||||
offset, red, green, blue, alpha: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_color_stop_rgba", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_color_stop_count*(pattern: PPattern, count: var int32): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_color_stop_count", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_linear_points*(pattern: PPattern, x0, y0, x1, y1: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_linear_points", dynlib: LIB_CAIRO.}
|
||||
proc pattern_get_radial_circles*(pattern: PPattern,
|
||||
x0, y0, r0, x1, y1, r1: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_radial_circles", dynlib: LIB_CAIRO.}
|
||||
#* Matrix functions
|
||||
proc matrix_init*(matrix: PMatrix, xx, yx, xy, yy, x0, y0: float64){.cdecl,
|
||||
importc: "cairo_matrix_init", dynlib: LIB_CAIRO.}
|
||||
proc matrix_init_identity*(matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_matrix_init_identity", dynlib: LIB_CAIRO.}
|
||||
proc matrix_init_translate*(matrix: PMatrix, tx, ty: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_translate", dynlib: LIB_CAIRO.}
|
||||
proc matrix_init_scale*(matrix: PMatrix, sx, sy: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_scale", dynlib: LIB_CAIRO.}
|
||||
proc matrix_init_rotate*(matrix: PMatrix, radians: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_rotate", dynlib: LIB_CAIRO.}
|
||||
proc matrix_translate*(matrix: PMatrix, tx, ty: float64){.cdecl,
|
||||
importc: "cairo_matrix_translate", dynlib: LIB_CAIRO.}
|
||||
proc matrix_scale*(matrix: PMatrix, sx, sy: float64){.cdecl,
|
||||
importc: "cairo_matrix_scale", dynlib: LIB_CAIRO.}
|
||||
proc matrix_rotate*(matrix: PMatrix, radians: float64){.cdecl,
|
||||
importc: "cairo_matrix_rotate", dynlib: LIB_CAIRO.}
|
||||
proc matrix_invert*(matrix: PMatrix): TStatus{.cdecl,
|
||||
importc: "cairo_matrix_invert", dynlib: LIB_CAIRO.}
|
||||
proc matrix_multiply*(result, a, b: PMatrix){.cdecl,
|
||||
importc: "cairo_matrix_multiply", dynlib: LIB_CAIRO.}
|
||||
proc matrix_transform_distance*(matrix: PMatrix, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_matrix_transform_distance", dynlib: LIB_CAIRO.}
|
||||
proc matrix_transform_point*(matrix: PMatrix, x, y: var float64){.cdecl,
|
||||
importc: "cairo_matrix_transform_point", dynlib: LIB_CAIRO.}
|
||||
#* PDF functions
|
||||
proc pdf_surface_create*(filename: cstring,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_pdf_surface_create", dynlib: LIB_CAIRO.}
|
||||
proc pdf_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_pdf_surface_create_for_stream", dynlib: LIB_CAIRO.}
|
||||
proc pdf_surface_set_size*(surface: PSurface,
|
||||
width_in_points, height_in_points: float64){.cdecl,
|
||||
importc: "cairo_pdf_surface_set_size", dynlib: LIB_CAIRO.}
|
||||
#* PS functions
|
||||
proc ps_surface_create*(filename: cstring,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_ps_surface_create", dynlib: LIB_CAIRO.}
|
||||
proc ps_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_ps_surface_create_for_stream", dynlib: LIB_CAIRO.}
|
||||
proc ps_surface_set_size*(surface: PSurface,
|
||||
width_in_points, height_in_points: float64){.cdecl,
|
||||
importc: "cairo_ps_surface_set_size", dynlib: LIB_CAIRO.}
|
||||
proc ps_surface_dsc_comment*(surface: PSurface, comment: cstring){.cdecl,
|
||||
importc: "cairo_ps_surface_dsc_comment", dynlib: LIB_CAIRO.}
|
||||
proc ps_surface_dsc_begin_setup*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_ps_surface_dsc_begin_setup", dynlib: LIB_CAIRO.}
|
||||
proc ps_surface_dsc_begin_page_setup*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_ps_surface_dsc_begin_page_setup", dynlib: LIB_CAIRO.}
|
||||
#* SVG functions
|
||||
proc svg_surface_create*(filename: cstring,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_svg_surface_create", dynlib: LIB_CAIRO.}
|
||||
proc svg_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_svg_surface_create_for_stream", dynlib: LIB_CAIRO.}
|
||||
proc svg_surface_restrict_to_version*(surface: PSurface, version: TSvgVersion){.
|
||||
cdecl, importc: "cairo_svg_surface_restrict_to_version", dynlib: LIB_CAIRO.}
|
||||
#todo: see how translate this
|
||||
#procedure cairo_svg_get_versions(TCairoSvgVersion const **versions,
|
||||
# int *num_versions);
|
||||
proc svg_version_to_string*(version: TSvgVersion): cstring{.cdecl,
|
||||
importc: "cairo_svg_version_to_string", dynlib: LIB_CAIRO.}
|
||||
#* Functions to be used while debugging (not intended for use in production code)
|
||||
proc debug_reset_static_data*(){.cdecl,
|
||||
importc: "cairo_debug_reset_static_data",
|
||||
dynlib: LIB_CAIRO.}
|
||||
# implementation
|
||||
|
||||
proc version(major, minor, micro: var int32) =
|
||||
var version: int32
|
||||
version = version()
|
||||
major = version div 10000'i32
|
||||
minor = (version mod (major * 10000'i32)) div 100'i32
|
||||
micro = (version mod ((major * 10000'i32) + (minor * 100'i32)))
|
||||
35
lib/newwrap/cairo/cairoft.nim
Normal file
35
lib/newwrap/cairo/cairoft.nim
Normal file
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# Translation of cairo-ft.h
|
||||
# by Jeffrey Pohlmeyer
|
||||
# updated to version 1.4 by Luiz Am<41>rico Pereira C<>mara 2007
|
||||
#
|
||||
|
||||
import
|
||||
, freetypeh
|
||||
|
||||
#todo: properly define FcPattern:
|
||||
#It will require translate FontConfig header
|
||||
|
||||
#*
|
||||
#typedef struct _XftPattern {
|
||||
# int num;
|
||||
# int size;
|
||||
# XftPatternElt *elts;
|
||||
# } XftPattern;
|
||||
# typedef FcPattern XftPattern;
|
||||
#
|
||||
|
||||
type
|
||||
FcPattern* = Pointer
|
||||
PFcPattern* = ptr FcPattern
|
||||
|
||||
proc ft_font_face_create_for_pattern*(pattern: PFcPattern): PFontFace{.cdecl,
|
||||
importc: "cairo_ft_font_face_create_for_pattern", dynlib: LIB_CAIRO.}
|
||||
proc ft_font_options_substitute*(options: PFontOptions, pattern: PFcPattern){.
|
||||
cdecl, importc: "cairo_ft_font_options_substitute", dynlib: LIB_CAIRO.}
|
||||
proc ft_font_face_create_for_ft_face*(face: TFT_Face, load_flags: int32): PFontFace{.
|
||||
cdecl, importc: "cairo_ft_font_face_create_for_ft_face", dynlib: LIB_CAIRO.}
|
||||
proc ft_scaled_font_lock_face*(scaled_font: PScaledFont): TFT_Face{.cdecl,
|
||||
importc: "cairo_ft_scaled_font_lock_face", dynlib: LIB_CAIRO.}
|
||||
proc ft_scaled_font_unlock_face*(scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_ft_scaled_font_unlock_face", dynlib: LIB_CAIRO.}
|
||||
37
lib/newwrap/cairo/cairowin32.nim
Normal file
37
lib/newwrap/cairo/cairowin32.nim
Normal file
@@ -0,0 +1,37 @@
|
||||
#
|
||||
# Translation of cairo-win32.h version 1.4
|
||||
# by Luiz Am<41>rico Pereira C<>mara 2007
|
||||
#
|
||||
|
||||
import
|
||||
, windows
|
||||
|
||||
proc win32_surface_create*(hdc: HDC): PSurface{.cdecl,
|
||||
importc: "cairo_win32_surface_create", dynlib: LIB_CAIRO.}
|
||||
proc win32_surface_create_with_ddb*(hdc: HDC, format: TFormat,
|
||||
width, height: int32): PSurface{.cdecl,
|
||||
importc: "cairo_win32_surface_create_with_ddb", dynlib: LIB_CAIRO.}
|
||||
proc win32_surface_create_with_dib*(format: TFormat, width, height: int32): PSurface{.
|
||||
cdecl, importc: "cairo_win32_surface_create_with_dib", dynlib: LIB_CAIRO.}
|
||||
proc win32_surface_get_dc*(surface: PSurface): HDC{.cdecl,
|
||||
importc: "cairo_win32_surface_get_dc", dynlib: LIB_CAIRO.}
|
||||
proc win32_surface_get_image*(surface: PSurface): PSurface{.cdecl,
|
||||
importc: "cairo_win32_surface_get_image", dynlib: LIB_CAIRO.}
|
||||
proc win32_font_face_create_for_logfontw*(logfont: pLOGFONTW): PFontFace{.cdecl,
|
||||
importc: "cairo_win32_font_face_create_for_logfontw", dynlib: LIB_CAIRO.}
|
||||
proc win32_font_face_create_for_hfont*(font: HFONT): PFontFace{.cdecl,
|
||||
importc: "cairo_win32_font_face_create_for_hfont", dynlib: LIB_CAIRO.}
|
||||
proc win32_scaled_font_select_font*(scaled_font: PScaledFont, hdc: HDC): TStatus{.
|
||||
cdecl, importc: "cairo_win32_scaled_font_select_font", dynlib: LIB_CAIRO.}
|
||||
proc win32_scaled_font_done_font*(scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_win32_scaled_font_done_font", dynlib: LIB_CAIRO.}
|
||||
proc win32_scaled_font_get_metrics_factor*(scaled_font: PScaledFont): float64{.
|
||||
cdecl, importc: "cairo_win32_scaled_font_get_metrics_factor",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc win32_scaled_font_get_logical_to_device*(scaled_font: PScaledFont,
|
||||
logical_to_device: PMatrix){.cdecl, importc: "cairo_win32_scaled_font_get_logical_to_device",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc win32_scaled_font_get_device_to_logical*(scaled_font: PScaledFont,
|
||||
device_to_logical: PMatrix){.cdecl, importc: "cairo_win32_scaled_font_get_device_to_logical",
|
||||
dynlib: LIB_CAIRO.}
|
||||
# implementation
|
||||
39
lib/newwrap/cairo/cairoxlib.nim
Normal file
39
lib/newwrap/cairo/cairoxlib.nim
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# Translation of cairo-xlib.h version 1.4
|
||||
# by Jeffrey Pohlmeyer
|
||||
# updated to version 1.4 by Luiz Am<41>rico Pereira C<>mara 2007
|
||||
#
|
||||
|
||||
import
|
||||
, x, xlib, xrender
|
||||
|
||||
proc xlib_surface_create*(dpy: PDisplay, drawable: TDrawable, visual: PVisual,
|
||||
width, height: int32): PSurface{.cdecl,
|
||||
importc: "cairo_xlib_surface_create", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_create_for_bitmap*(dpy: PDisplay, bitmap: TPixmap,
|
||||
screen: PScreen, width, height: int32): PSurface{.
|
||||
cdecl, importc: "cairo_xlib_surface_create_for_bitmap", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_create_with_xrender_format*(dpy: PDisplay,
|
||||
drawable: TDrawable, screen: PScreen, format: PXRenderPictFormat,
|
||||
width, height: int32): PSurface{.cdecl, importc: "cairo_xlib_surface_create_with_xrender_format",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_get_depth*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_depth", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_get_display*(surface: PSurface): PDisplay{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_display", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_get_drawable*(surface: PSurface): TDrawable{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_drawable", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_get_height*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_height", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_get_screen*(surface: PSurface): PScreen{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_screen", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_get_visual*(surface: PSurface): PVisual{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_visual", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_get_width*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_width", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_set_size*(surface: PSurface, width, height: int32){.cdecl,
|
||||
importc: "cairo_xlib_surface_set_size", dynlib: LIB_CAIRO.}
|
||||
proc xlib_surface_set_drawable*(surface: PSurface, drawable: TDrawable,
|
||||
width, height: int32){.cdecl,
|
||||
importc: "cairo_xlib_surface_set_drawable", dynlib: LIB_CAIRO.}
|
||||
# implementation
|
||||
1305
lib/newwrap/gtk/atk.nim
Normal file
1305
lib/newwrap/gtk/atk.nim
Normal file
File diff suppressed because it is too large
Load Diff
3869
lib/newwrap/gtk/gdk2.nim
Normal file
3869
lib/newwrap/gtk/gdk2.nim
Normal file
File diff suppressed because it is too large
Load Diff
271
lib/newwrap/gtk/gdk2pixbuf.nim
Normal file
271
lib/newwrap/gtk/gdk2pixbuf.nim
Normal file
@@ -0,0 +1,271 @@
|
||||
{.deadCodeElim: on.}
|
||||
import
|
||||
glib2
|
||||
|
||||
when defined(win32):
|
||||
const
|
||||
pixbuflib = "libgdk_pixbuf-2.0-0.dll"
|
||||
elif defined(darwin):
|
||||
const
|
||||
pixbuflib = "gdk_pixbuf-2.0.0"
|
||||
# linklib gtk-x11-2.0
|
||||
# linklib gdk-x11-2.0
|
||||
# linklib pango-1.0.0
|
||||
# linklib glib-2.0.0
|
||||
# linklib gobject-2.0.0
|
||||
# linklib gdk_pixbuf-2.0.0
|
||||
# linklib atk-1.0.0
|
||||
else:
|
||||
const
|
||||
pixbuflib = "libgdk_pixbuf-2.0.so"
|
||||
type
|
||||
PPixbuf* = pointer
|
||||
PPixbufAnimation* = pointer
|
||||
PPixbufAnimationIter* = pointer
|
||||
PPixbufAlphaMode* = ptr TPixbufAlphaMode
|
||||
TPixbufAlphaMode* = enum
|
||||
PIXBUF_ALPHA_BILEVEL, PIXBUF_ALPHA_FULL
|
||||
PColorspace* = ptr TColorspace
|
||||
TColorspace* = enum
|
||||
COLORSPACE_RGB
|
||||
TPixbufDestroyNotify* = proc (pixels: Pguchar, data: gpointer){.cdecl.}
|
||||
PPixbufError* = ptr TPixbufError
|
||||
TPixbufError* = enum
|
||||
PIXBUF_ERROR_CORRUPT_IMAGE, PIXBUF_ERROR_INSUFFICIENT_MEMORY,
|
||||
PIXBUF_ERROR_BAD_OPTION, PIXBUF_ERROR_UNKNOWN_TYPE,
|
||||
PIXBUF_ERROR_UNSUPPORTED_OPERATION, PIXBUF_ERROR_FAILED
|
||||
PInterpType* = ptr TInterpType
|
||||
TInterpType* = enum
|
||||
INTERP_NEAREST, INTERP_TILES, INTERP_BILINEAR, INTERP_HYPER
|
||||
|
||||
proc TYPE_PIXBUF*(): GType
|
||||
proc PIXBUF*(anObject: pointer): PPixbuf
|
||||
proc IS_PIXBUF*(anObject: pointer): bool
|
||||
proc TYPE_PIXBUF_ANIMATION*(): GType
|
||||
proc PIXBUF_ANIMATION*(anObject: pointer): PPixbufAnimation
|
||||
proc IS_PIXBUF_ANIMATION*(anObject: pointer): bool
|
||||
proc TYPE_PIXBUF_ANIMATION_ITER*(): GType
|
||||
proc PIXBUF_ANIMATION_ITER*(anObject: pointer): PPixbufAnimationIter
|
||||
proc IS_PIXBUF_ANIMATION_ITER*(anObject: pointer): bool
|
||||
proc PIXBUF_ERROR*(): TGQuark
|
||||
proc pixbuf_error_quark*(): TGQuark{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_error_quark".}
|
||||
proc pixbuf_get_type*(): GType{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_get_type".}
|
||||
when not defined(PIXBUF_DISABLE_DEPRECATED):
|
||||
proc pixbuf_ref*(pixbuf: PPixbuf): PPixbuf{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_ref".}
|
||||
proc pixbuf_unref*(pixbuf: PPixbuf){.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_unref".}
|
||||
proc pixbuf_get_colorspace*(pixbuf: PPixbuf): TColorspace{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_get_colorspace".}
|
||||
proc pixbuf_get_n_channels*(pixbuf: PPixbuf): int32{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_get_n_channels".}
|
||||
proc pixbuf_get_has_alpha*(pixbuf: PPixbuf): gboolean{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_get_has_alpha".}
|
||||
proc pixbuf_get_bits_per_sample*(pixbuf: PPixbuf): int32{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_get_bits_per_sample".}
|
||||
proc pixbuf_get_pixels*(pixbuf: PPixbuf): Pguchar{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_get_pixels".}
|
||||
proc pixbuf_get_width*(pixbuf: PPixbuf): int32{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_get_width".}
|
||||
proc pixbuf_get_height*(pixbuf: PPixbuf): int32{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_get_height".}
|
||||
proc pixbuf_get_rowstride*(pixbuf: PPixbuf): int32{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_get_rowstride".}
|
||||
proc pixbuf_new*(colorspace: TColorspace, has_alpha: gboolean,
|
||||
bits_per_sample: int32, width: int32, height: int32): PPixbuf{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_new".}
|
||||
proc pixbuf_copy*(pixbuf: PPixbuf): PPixbuf{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_copy".}
|
||||
proc pixbuf_new_subpixbuf*(src_pixbuf: PPixbuf, src_x: int32, src_y: int32,
|
||||
width: int32, height: int32): PPixbuf{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_new_subpixbuf".}
|
||||
proc pixbuf_new_from_file*(filename: cstring, error: pointer): PPixbuf{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_file".}
|
||||
proc pixbuf_new_from_data*(data: Pguchar, colorspace: TColorspace,
|
||||
has_alpha: gboolean, bits_per_sample: int32,
|
||||
width: int32, height: int32, rowstride: int32,
|
||||
destroy_fn: TPixbufDestroyNotify,
|
||||
destroy_fn_data: gpointer): PPixbuf{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_data".}
|
||||
proc pixbuf_new_from_xpm_data*(data: PPchar): PPixbuf{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_new_from_xpm_data".}
|
||||
proc pixbuf_new_from_inline*(data_length: gint, a: var guint8,
|
||||
copy_pixels: gboolean, error: pointer): PPixbuf{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_inline".}
|
||||
proc pixbuf_new_from_file_at_size*(filename: cstring, width, height: gint,
|
||||
error: pointer): PPixbuf{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_file_at_size".}
|
||||
proc pixbuf_new_from_file_at_scale*(filename: cstring, width, height: gint,
|
||||
preserve_aspect_ratio: gboolean,
|
||||
error: pointer): PPixbuf{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_new_from_file_at_scale".}
|
||||
proc pixbuf_fill*(pixbuf: PPixbuf, pixel: guint32){.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_fill".}
|
||||
proc pixbuf_save*(pixbuf: PPixbuf, filename: cstring, `type`: cstring,
|
||||
error: pointer): gboolean{.cdecl, varargs, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_save".}
|
||||
proc pixbuf_savev*(pixbuf: PPixbuf, filename: cstring, `type`: cstring,
|
||||
option_keys: PPchar, option_values: PPchar, error: pointer): gboolean{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_savev".}
|
||||
proc pixbuf_add_alpha*(pixbuf: PPixbuf, substitute_color: gboolean, r: guchar,
|
||||
g: guchar, b: guchar): PPixbuf{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_add_alpha".}
|
||||
proc pixbuf_copy_area*(src_pixbuf: PPixbuf, src_x: int32, src_y: int32,
|
||||
width: int32, height: int32, dest_pixbuf: PPixbuf,
|
||||
dest_x: int32, dest_y: int32){.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_copy_area".}
|
||||
proc pixbuf_saturate_and_pixelate*(src: PPixbuf, dest: PPixbuf,
|
||||
saturation: gfloat, pixelate: gboolean){.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_saturate_and_pixelate".}
|
||||
proc pixbuf_scale*(src: PPixbuf, dest: PPixbuf, dest_x: int32, dest_y: int32,
|
||||
dest_width: int32, dest_height: int32, offset_x: float64,
|
||||
offset_y: float64, scale_x: float64, scale_y: float64,
|
||||
interp_type: TInterpType){.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_scale".}
|
||||
proc pixbuf_composite*(src: PPixbuf, dest: PPixbuf, dest_x: int32,
|
||||
dest_y: int32, dest_width: int32, dest_height: int32,
|
||||
offset_x: float64, offset_y: float64, scale_x: float64,
|
||||
scale_y: float64, interp_type: TInterpType,
|
||||
overall_alpha: int32){.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_composite".}
|
||||
proc pixbuf_composite_color*(src: PPixbuf, dest: PPixbuf, dest_x: int32,
|
||||
dest_y: int32, dest_width: int32,
|
||||
dest_height: int32, offset_x: float64,
|
||||
offset_y: float64, scale_x: float64,
|
||||
scale_y: float64, interp_type: TInterpType,
|
||||
overall_alpha: int32, check_x: int32,
|
||||
check_y: int32, check_size: int32, color1: guint32,
|
||||
color2: guint32){.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_composite_color".}
|
||||
proc pixbuf_scale_simple*(src: PPixbuf, dest_width: int32, dest_height: int32,
|
||||
interp_type: TInterpType): PPixbuf{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_scale_simple".}
|
||||
proc pixbuf_composite_color_simple*(src: PPixbuf, dest_width: int32,
|
||||
dest_height: int32,
|
||||
interp_type: TInterpType,
|
||||
overall_alpha: int32, check_size: int32,
|
||||
color1: guint32, color2: guint32): PPixbuf{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_composite_color_simple".}
|
||||
proc pixbuf_animation_get_type*(): GType{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_animation_get_type".}
|
||||
proc pixbuf_animation_new_from_file*(filename: cstring, error: pointer): PPixbufAnimation{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_new_from_file".}
|
||||
when not defined(PIXBUF_DISABLE_DEPRECATED):
|
||||
proc pixbuf_animation_ref*(animation: PPixbufAnimation): PPixbufAnimation{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_ref".}
|
||||
proc pixbuf_animation_unref*(animation: PPixbufAnimation){.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_animation_unref".}
|
||||
proc pixbuf_animation_get_width*(animation: PPixbufAnimation): int32{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_animation_get_width".}
|
||||
proc pixbuf_animation_get_height*(animation: PPixbufAnimation): int32{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_animation_get_height".}
|
||||
proc pixbuf_animation_is_static_image*(animation: PPixbufAnimation): gboolean{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_is_static_image".}
|
||||
proc pixbuf_animation_get_static_image*(animation: PPixbufAnimation): PPixbuf{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_get_static_image".}
|
||||
proc pixbuf_animation_get_iter*(animation: PPixbufAnimation, e: var TGTimeVal): PPixbufAnimationIter{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_get_iter".}
|
||||
proc pixbuf_animation_iter_get_type*(): GType{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_animation_iter_get_type".}
|
||||
proc pixbuf_animation_iter_get_delay_time*(iter: PPixbufAnimationIter): int32{.
|
||||
cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_animation_iter_get_delay_time".}
|
||||
proc pixbuf_animation_iter_get_pixbuf*(iter: PPixbufAnimationIter): PPixbuf{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_iter_get_pixbuf".}
|
||||
proc pixbuf_animation_iter_on_currently_loading_frame*(
|
||||
iter: PPixbufAnimationIter): gboolean{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_animation_iter_on_currently_loading_frame".}
|
||||
proc pixbuf_animation_iter_advance*(iter: PPixbufAnimationIter, e: var TGTimeVal): gboolean{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_animation_iter_advance".}
|
||||
proc pixbuf_get_option*(pixbuf: PPixbuf, key: cstring): cstring{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_get_option".}
|
||||
type
|
||||
PPixbufLoader* = ptr TPixbufLoader
|
||||
TPixbufLoader*{.final, pure.} = object
|
||||
parent_instance*: TGObject
|
||||
priv*: gpointer
|
||||
|
||||
PPixbufLoaderClass* = ptr TPixbufLoaderClass
|
||||
TPixbufLoaderClass*{.final, pure.} = object
|
||||
parent_class*: TGObjectClass
|
||||
area_prepared*: proc (loader: PPixbufLoader){.cdecl.}
|
||||
area_updated*: proc (loader: PPixbufLoader, x: int32, y: int32,
|
||||
width: int32, height: int32){.cdecl.}
|
||||
closed*: proc (loader: PPixbufLoader){.cdecl.}
|
||||
|
||||
|
||||
proc TYPE_PIXBUF_LOADER*(): GType
|
||||
proc PIXBUF_LOADER*(obj: pointer): PPixbufLoader
|
||||
proc PIXBUF_LOADER_CLASS*(klass: pointer): PPixbufLoaderClass
|
||||
proc IS_PIXBUF_LOADER*(obj: pointer): bool
|
||||
proc IS_PIXBUF_LOADER_CLASS*(klass: pointer): bool
|
||||
proc PIXBUF_LOADER_GET_CLASS*(obj: pointer): PPixbufLoaderClass
|
||||
proc pixbuf_loader_get_type*(): GType{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_loader_get_type".}
|
||||
proc pixbuf_loader_new*(): PPixbufLoader{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_loader_new".}
|
||||
proc pixbuf_loader_new_with_type*(image_type: cstring, error: pointer): PPixbufLoader{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_loader_new_with_type".}
|
||||
proc pixbuf_loader_write*(loader: PPixbufLoader, buf: Pguchar, count: gsize,
|
||||
error: pointer): gboolean{.cdecl, dynlib: pixbuflib,
|
||||
importc: "gdk_pixbuf_loader_write".}
|
||||
proc pixbuf_loader_get_pixbuf*(loader: PPixbufLoader): PPixbuf{.cdecl,
|
||||
dynlib: pixbuflib, importc: "gdk_pixbuf_loader_get_pixbuf".}
|
||||
proc pixbuf_loader_get_animation*(loader: PPixbufLoader): PPixbufAnimation{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_loader_get_animation".}
|
||||
proc pixbuf_loader_close*(loader: PPixbufLoader, error: pointer): gboolean{.
|
||||
cdecl, dynlib: pixbuflib, importc: "gdk_pixbuf_loader_close".}
|
||||
proc TYPE_PIXBUF_LOADER*(): GType =
|
||||
result = pixbuf_loader_get_type()
|
||||
|
||||
proc PIXBUF_LOADER*(obj: pointer): PPixbufLoader =
|
||||
result = cast[PPixbufLoader](G_TYPE_CHECK_INSTANCE_CAST(obj,
|
||||
TYPE_PIXBUF_LOADER()))
|
||||
|
||||
proc PIXBUF_LOADER_CLASS*(klass: pointer): PPixbufLoaderClass =
|
||||
result = cast[PPixbufLoaderClass](G_TYPE_CHECK_CLASS_CAST(klass,
|
||||
TYPE_PIXBUF_LOADER()))
|
||||
|
||||
proc IS_PIXBUF_LOADER*(obj: pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_PIXBUF_LOADER())
|
||||
|
||||
proc IS_PIXBUF_LOADER_CLASS*(klass: pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_PIXBUF_LOADER())
|
||||
|
||||
proc PIXBUF_LOADER_GET_CLASS*(obj: pointer): PPixbufLoaderClass =
|
||||
result = cast[PPixbufLoaderClass](G_TYPE_INSTANCE_GET_CLASS(obj,
|
||||
TYPE_PIXBUF_LOADER()))
|
||||
|
||||
proc TYPE_PIXBUF*(): GType =
|
||||
result = pixbuf_get_type()
|
||||
|
||||
proc PIXBUF*(anObject: pointer): PPixbuf =
|
||||
result = cast[PPixbuf](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_PIXBUF()))
|
||||
|
||||
proc IS_PIXBUF*(anObject: pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_PIXBUF())
|
||||
|
||||
proc TYPE_PIXBUF_ANIMATION*(): GType =
|
||||
result = pixbuf_animation_get_type()
|
||||
|
||||
proc PIXBUF_ANIMATION*(anObject: pointer): PPixbufAnimation =
|
||||
result = cast[PPixbufAnimation](G_TYPE_CHECK_INSTANCE_CAST(anObject,
|
||||
TYPE_PIXBUF_ANIMATION()))
|
||||
|
||||
proc IS_PIXBUF_ANIMATION*(anObject: pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_PIXBUF_ANIMATION())
|
||||
|
||||
proc TYPE_PIXBUF_ANIMATION_ITER*(): GType =
|
||||
result = pixbuf_animation_iter_get_type()
|
||||
|
||||
proc PIXBUF_ANIMATION_ITER*(anObject: pointer): PPixbufAnimationIter =
|
||||
result = cast[PPixbufAnimationIter](G_TYPE_CHECK_INSTANCE_CAST(anObject,
|
||||
TYPE_PIXBUF_ANIMATION_ITER()))
|
||||
|
||||
proc IS_PIXBUF_ANIMATION_ITER*(anObject: pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_PIXBUF_ANIMATION_ITER())
|
||||
|
||||
proc PIXBUF_ERROR*(): TGQuark =
|
||||
result = pixbuf_error_quark()
|
||||
551
lib/newwrap/gtk/gdkglext.nim
Normal file
551
lib/newwrap/gtk/gdkglext.nim
Normal file
@@ -0,0 +1,551 @@
|
||||
{.deadCodeElim: on.}
|
||||
import
|
||||
Glib2, 2
|
||||
|
||||
when defined(WIN32):
|
||||
const
|
||||
GLExtLib = "libgdkglext-win32-1.0-0.dll"
|
||||
else:
|
||||
const
|
||||
GLExtLib = "libgdkglext-x11-1.0.so"
|
||||
type
|
||||
TGLConfigAttrib* = int32
|
||||
TGLConfigCaveat* = int32
|
||||
TGLVisualType* = int32
|
||||
TGLTransparentType* = int32
|
||||
TGLDrawableTypeMask* = int32
|
||||
TGLRenderTypeMask* = int32
|
||||
TGLBufferMask* = int32
|
||||
TGLConfigError* = int32
|
||||
TGLRenderType* = int32
|
||||
TGLDrawableAttrib* = int32
|
||||
TGLPbufferAttrib* = int32
|
||||
TGLEventMask* = int32
|
||||
TGLEventType* = int32
|
||||
TGLDrawableType* = int32
|
||||
TGLProc* = Pointer
|
||||
PGLConfig* = ptr TGLConfig
|
||||
PGLContext* = ptr TGLContext
|
||||
PGLDrawable* = ptr TGLDrawable
|
||||
PGLPixmap* = ptr TGLPixmap
|
||||
PGLWindow* = ptr TGLWindow
|
||||
TGLConfig* = object of TGObject
|
||||
layer_plane*: gint
|
||||
n_aux_buffers*: gint
|
||||
n_sample_buffers*: gint
|
||||
flag0*: int16
|
||||
|
||||
PGLConfigClass* = ptr TGLConfigClass
|
||||
TGLConfigClass* = object of TGObjectClass
|
||||
TGLContext* = object of TGObject
|
||||
PGLContextClass* = ptr TGLContextClass
|
||||
TGLContextClass* = object of TGObjectClass
|
||||
TGLDrawable* = object of TGObject
|
||||
PGLDrawableClass* = ptr TGLDrawableClass
|
||||
TGLDrawableClass* = object of TGTypeInterface
|
||||
create_new_context*: proc (gldrawable: PGLDrawable, share_list: PGLContext,
|
||||
direct: gboolean, render_type: int32): PGLContext{.
|
||||
cdecl.}
|
||||
make_context_current*: proc (draw: PGLDrawable, a_read: PGLDrawable,
|
||||
glcontext: PGLContext): gboolean{.cdecl.}
|
||||
is_double_buffered*: proc (gldrawable: PGLDrawable): gboolean{.cdecl.}
|
||||
swap_buffers*: proc (gldrawable: PGLDrawable){.cdecl.}
|
||||
wait_gl*: proc (gldrawable: PGLDrawable){.cdecl.}
|
||||
wait_gdk*: proc (gldrawable: PGLDrawable){.cdecl.}
|
||||
gl_begin*: proc (draw: PGLDrawable, a_read: PGLDrawable,
|
||||
glcontext: PGLContext): gboolean{.cdecl.}
|
||||
gl_end*: proc (gldrawable: PGLDrawable){.cdecl.}
|
||||
get_gl_config*: proc (gldrawable: PGLDrawable): PGLConfig{.cdecl.}
|
||||
get_size*: proc (gldrawable: PGLDrawable, width, height: PGInt){.cdecl.}
|
||||
|
||||
TGLPixmap* = object of TGObject
|
||||
drawable*: PDrawable
|
||||
|
||||
PGLPixmapClass* = ptr TGLPixmapClass
|
||||
TGLPixmapClass* = object of TGObjectClass
|
||||
TGLWindow* = object of TGObject
|
||||
drawable*: PDrawable
|
||||
|
||||
PGLWindowClass* = ptr TGLWindowClass
|
||||
TGLWindowClass* = object of TGObjectClass
|
||||
|
||||
const
|
||||
HEADER_GDKGLEXT_MAJOR_VERSION* = 1
|
||||
HEADER_GDKGLEXT_MINOR_VERSION* = 0
|
||||
HEADER_GDKGLEXT_MICRO_VERSION* = 6
|
||||
HEADER_GDKGLEXT_INTERFACE_AGE* = 4
|
||||
HEADER_GDKGLEXT_BINARY_AGE* = 6
|
||||
|
||||
proc HEADER_GDKGLEXT_CHECK_VERSION*(major, minor, micro: guint): bool
|
||||
var
|
||||
glext_major_version*{.importc, dynlib: GLExtLib.}: guint
|
||||
glext_minor_version*{.importc, dynlib: GLExtLib.}: guint
|
||||
glext_micro_version*{.importc, dynlib: GLExtLib.}: guint
|
||||
glext_interface_age*{.importc, dynlib: GLExtLib.}: guint
|
||||
glext_binary_age*{.importc, dynlib: GLExtLib.}: guint
|
||||
|
||||
const
|
||||
GL_SUCCESS* = 0
|
||||
GL_ATTRIB_LIST_NONE* = 0
|
||||
GL_USE_GL* = 1
|
||||
GL_BUFFER_SIZE* = 2
|
||||
GL_LEVEL* = 3
|
||||
GL_RGBA* = 4
|
||||
GL_DOUBLEBUFFER* = 5
|
||||
GL_STEREO* = 6
|
||||
GL_AUX_BUFFERS* = 7
|
||||
GL_RED_SIZE* = 8
|
||||
GL_GREEN_SIZE* = 9
|
||||
GL_BLUE_SIZE* = 10
|
||||
GL_ALPHA_SIZE* = 11
|
||||
GL_DEPTH_SIZE* = 12
|
||||
GL_STENCIL_SIZE* = 13
|
||||
GL_ACCUM_RED_SIZE* = 14
|
||||
GL_ACCUM_GREEN_SIZE* = 15
|
||||
GL_ACCUM_BLUE_SIZE* = 16
|
||||
GL_ACCUM_ALPHA_SIZE* = 17
|
||||
GL_CONFIG_CAVEAT* = 0x00000020
|
||||
GL_X_VISUAL_TYPE* = 0x00000022
|
||||
GL_TRANSPARENT_TYPE* = 0x00000023
|
||||
GL_TRANSPARENT_INDEX_VALUE* = 0x00000024
|
||||
GL_TRANSPARENT_RED_VALUE* = 0x00000025
|
||||
GL_TRANSPARENT_GREEN_VALUE* = 0x00000026
|
||||
GL_TRANSPARENT_BLUE_VALUE* = 0x00000027
|
||||
GL_TRANSPARENT_ALPHA_VALUE* = 0x00000028
|
||||
GL_DRAWABLE_TYPE* = 0x00008010
|
||||
GL_RENDER_TYPE* = 0x00008011
|
||||
GL_X_RENDERABLE* = 0x00008012
|
||||
GL_FBCONFIG_ID* = 0x00008013
|
||||
GL_MAX_PBUFFER_WIDTH* = 0x00008016
|
||||
GL_MAX_PBUFFER_HEIGHT* = 0x00008017
|
||||
GL_MAX_PBUFFER_PIXELS* = 0x00008018
|
||||
GL_VISUAL_ID* = 0x0000800B
|
||||
GL_SCREEN* = 0x0000800C
|
||||
GL_SAMPLE_BUFFERS* = 100000
|
||||
GL_SAMPLES* = 100001
|
||||
GL_DONT_CARE* = 0xFFFFFFFF
|
||||
GL_NONE* = 0x00008000
|
||||
GL_CONFIG_CAVEAT_DONT_CARE* = 0xFFFFFFFF
|
||||
GL_CONFIG_CAVEAT_NONE* = 0x00008000
|
||||
GL_SLOW_CONFIG* = 0x00008001
|
||||
GL_NON_CONFORMANT_CONFIG* = 0x0000800D
|
||||
GL_VISUAL_TYPE_DONT_CARE* = 0xFFFFFFFF
|
||||
GL_TRUE_COLOR* = 0x00008002
|
||||
GL_DIRECT_COLOR* = 0x00008003
|
||||
GL_PSEUDO_COLOR* = 0x00008004
|
||||
GL_STATIC_COLOR* = 0x00008005
|
||||
GL_GRAY_SCALE* = 0x00008006
|
||||
GL_STATIC_GRAY* = 0x00008007
|
||||
GL_TRANSPARENT_NONE* = 0x00008000
|
||||
GL_TRANSPARENT_RGB* = 0x00008008
|
||||
GL_TRANSPARENT_INDEX* = 0x00008009
|
||||
GL_WINDOW_BIT* = 1 shl 0
|
||||
GL_PIXMAP_BIT* = 1 shl 1
|
||||
GL_PBUFFER_BIT* = 1 shl 2
|
||||
GL_RGBA_BIT* = 1 shl 0
|
||||
GL_COLOR_INDEX_BIT* = 1 shl 1
|
||||
GL_FRONT_LEFT_BUFFER_BIT* = 1 shl 0
|
||||
GL_FRONT_RIGHT_BUFFER_BIT* = 1 shl 1
|
||||
GL_BACK_LEFT_BUFFER_BIT* = 1 shl 2
|
||||
GL_BACK_RIGHT_BUFFER_BIT* = 1 shl 3
|
||||
GL_AUX_BUFFERS_BIT* = 1 shl 4
|
||||
GL_DEPTH_BUFFER_BIT* = 1 shl 5
|
||||
GL_STENCIL_BUFFER_BIT* = 1 shl 6
|
||||
GL_ACCUM_BUFFER_BIT* = 1 shl 7
|
||||
GL_BAD_SCREEN* = 1
|
||||
GL_BAD_ATTRIBUTE* = 2
|
||||
GL_NO_EXTENSION* = 3
|
||||
GL_BAD_VISUAL* = 4
|
||||
GL_BAD_CONTEXT* = 5
|
||||
GL_BAD_VALUE* = 6
|
||||
GL_BAD_ENUM* = 7
|
||||
GL_RGBA_TYPE* = 0x00008014
|
||||
GL_COLOR_INDEX_TYPE* = 0x00008015
|
||||
GL_PRESERVED_CONTENTS* = 0x0000801B
|
||||
GL_LARGEST_PBUFFER* = 0x0000801C
|
||||
GL_WIDTH* = 0x0000801D
|
||||
GL_HEIGHT* = 0x0000801E
|
||||
GL_EVENT_MASK* = 0x0000801F
|
||||
GL_PBUFFER_PRESERVED_CONTENTS* = 0x0000801B
|
||||
GL_PBUFFER_LARGEST_PBUFFER* = 0x0000801C
|
||||
GL_PBUFFER_HEIGHT* = 0x00008040
|
||||
GL_PBUFFER_WIDTH* = 0x00008041
|
||||
GL_PBUFFER_CLOBBER_MASK* = 1 shl 27
|
||||
GL_DAMAGED* = 0x00008020
|
||||
GL_SAVED* = 0x00008021
|
||||
GL_WINDOW_VALUE* = 0x00008022
|
||||
GL_PBUFFER* = 0x00008023
|
||||
|
||||
proc gl_config_attrib_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_attrib_get_type".}
|
||||
proc TYPE_GL_CONFIG_ATTRIB*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_attrib_get_type".}
|
||||
proc gl_config_caveat_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_caveat_get_type".}
|
||||
proc TYPE_GL_CONFIG_CAVEAT*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_caveat_get_type".}
|
||||
proc gl_visual_type_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_visual_type_get_type".}
|
||||
proc TYPE_GL_VISUAL_TYPE*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_visual_type_get_type".}
|
||||
proc gl_transparent_type_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_transparent_type_get_type".}
|
||||
proc TYPE_GL_TRANSPARENT_TYPE*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_transparent_type_get_type".}
|
||||
proc gl_drawable_type_mask_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_type_mask_get_type".}
|
||||
proc TYPE_GL_DRAWABLE_TYPE_MASK*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_type_mask_get_type".}
|
||||
proc gl_render_type_mask_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_render_type_mask_get_type".}
|
||||
proc TYPE_GL_RENDER_TYPE_MASK*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_render_type_mask_get_type".}
|
||||
proc gl_buffer_mask_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_buffer_mask_get_type".}
|
||||
proc TYPE_GL_BUFFER_MASK*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_buffer_mask_get_type".}
|
||||
proc gl_config_error_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_error_get_type".}
|
||||
proc TYPE_GL_CONFIG_ERROR*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_error_get_type".}
|
||||
proc gl_render_type_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_render_type_get_type".}
|
||||
proc TYPE_GL_RENDER_TYPE*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_render_type_get_type".}
|
||||
proc gl_drawable_attrib_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_attrib_get_type".}
|
||||
proc TYPE_GL_DRAWABLE_ATTRIB*(): GType{.cdecl, dynlib: GLExtLib, importc: "gdk_gl_drawable_attrib_get_type".}
|
||||
proc gl_pbuffer_attrib_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_pbuffer_attrib_get_type".}
|
||||
proc TYPE_GL_PBUFFER_ATTRIB*(): GType{.cdecl, dynlib: GLExtLib, importc: "gdk_gl_pbuffer_attrib_get_type".}
|
||||
proc gl_event_mask_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_event_mask_get_type".}
|
||||
proc TYPE_GL_EVENT_MASK*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_event_mask_get_type".}
|
||||
proc gl_event_type_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_event_type_get_type".}
|
||||
proc TYPE_GL_EVENT_TYPE*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_event_type_get_type".}
|
||||
proc gl_drawable_type_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_type_get_type".}
|
||||
proc TYPE_GL_DRAWABLE_TYPE*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_type_get_type".}
|
||||
proc gl_config_mode_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_mode_get_type".}
|
||||
proc TYPE_GL_CONFIG_MODE*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_mode_get_type".}
|
||||
proc gl_parse_args*(argc: var int32, argv: ptr cstringArray): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_parse_args".}
|
||||
proc gl_init_check*(argc: var int32, argv: ptr cstringArray): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_init_check".}
|
||||
proc gl_init*(argc: var int32, argv: ptr cstringArray){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_init".}
|
||||
proc gl_query_gl_extension*(extension: cstring): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_query_gl_extension".}
|
||||
proc gl_get_proc_address*(proc_name: cstring): TGLProc{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_get_proc_address".}
|
||||
const
|
||||
bm_TGdkGLConfig_is_rgba* = 1 shl 0
|
||||
bp_TGdkGLConfig_is_rgba* = 0
|
||||
bm_TGdkGLConfig_is_double_buffered* = 1 shl 1
|
||||
bp_TGdkGLConfig_is_double_buffered* = 1
|
||||
bm_TGdkGLConfig_as_single_mode* = 1 shl 2
|
||||
bp_TGdkGLConfig_as_single_mode* = 2
|
||||
bm_TGdkGLConfig_is_stereo* = 1 shl 3
|
||||
bp_TGdkGLConfig_is_stereo* = 3
|
||||
bm_TGdkGLConfig_has_alpha* = 1 shl 4
|
||||
bp_TGdkGLConfig_has_alpha* = 4
|
||||
bm_TGdkGLConfig_has_depth_buffer* = 1 shl 5
|
||||
bp_TGdkGLConfig_has_depth_buffer* = 5
|
||||
bm_TGdkGLConfig_has_stencil_buffer* = 1 shl 6
|
||||
bp_TGdkGLConfig_has_stencil_buffer* = 6
|
||||
bm_TGdkGLConfig_has_accum_buffer* = 1 shl 7
|
||||
bp_TGdkGLConfig_has_accum_buffer* = 7
|
||||
|
||||
const
|
||||
GL_MODE_RGB* = 0
|
||||
GL_MODE_RGBA* = 0
|
||||
GL_MODE_INDEX* = 1 shl 0
|
||||
GL_MODE_SINGLE* = 0
|
||||
GL_MODE_DOUBLE* = 1 shl 1
|
||||
GL_MODE_STEREO* = 1 shl 2
|
||||
GL_MODE_ALPHA* = 1 shl 3
|
||||
GL_MODE_DEPTH* = 1 shl 4
|
||||
GL_MODE_STENCIL* = 1 shl 5
|
||||
GL_MODE_ACCUM* = 1 shl 6
|
||||
GL_MODE_MULTISAMPLE* = 1 shl 7
|
||||
|
||||
type
|
||||
TGLConfigMode* = int32
|
||||
PGLConfigMode* = ptr TGLConfigMode
|
||||
|
||||
proc TYPE_GL_CONFIG*(): GType
|
||||
proc GL_CONFIG*(anObject: Pointer): PGLConfig
|
||||
proc GL_CONFIG_CLASS*(klass: Pointer): PGLConfigClass
|
||||
proc IS_GL_CONFIG*(anObject: Pointer): bool
|
||||
proc IS_GL_CONFIG_CLASS*(klass: Pointer): bool
|
||||
proc GL_CONFIG_GET_CLASS*(obj: Pointer): PGLConfigClass
|
||||
proc gl_config_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_get_type".}
|
||||
proc gl_config_get_screen*(glconfig: PGLConfig): PScreen{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_get_screen".}
|
||||
proc gl_config_get_attrib*(glconfig: PGLConfig, attribute: int, value: var cint): gboolean{.
|
||||
cdecl, dynlib: GLExtLib, importc: "gdk_gl_config_get_attrib".}
|
||||
proc gl_config_get_colormap*(glconfig: PGLConfig): PColormap{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_get_colormap".}
|
||||
proc gl_config_get_visual*(glconfig: PGLConfig): PVisual{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_get_visual".}
|
||||
proc gl_config_get_depth*(glconfig: PGLConfig): gint{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_get_depth".}
|
||||
proc gl_config_get_layer_plane*(glconfig: PGLConfig): gint{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_get_layer_plane".}
|
||||
proc gl_config_get_n_aux_buffers*(glconfig: PGLConfig): gint{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_get_n_aux_buffers".}
|
||||
proc gl_config_get_n_sample_buffers*(glconfig: PGLConfig): gint{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_get_n_sample_buffers".}
|
||||
proc gl_config_is_rgba*(glconfig: PGLConfig): gboolean{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_config_is_rgba".}
|
||||
proc gl_config_is_double_buffered*(glconfig: PGLConfig): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_is_double_buffered".}
|
||||
proc gl_config_is_stereo*(glconfig: PGLConfig): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_is_stereo".}
|
||||
proc gl_config_has_alpha*(glconfig: PGLConfig): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_has_alpha".}
|
||||
proc gl_config_has_depth_buffer*(glconfig: PGLConfig): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_has_depth_buffer".}
|
||||
proc gl_config_has_stencil_buffer*(glconfig: PGLConfig): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_has_stencil_buffer".}
|
||||
proc gl_config_has_accum_buffer*(glconfig: PGLConfig): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_config_has_accum_buffer".}
|
||||
proc TYPE_GL_CONTEXT*(): GType
|
||||
proc GL_CONTEXT*(anObject: Pointer): PGLContext
|
||||
proc GL_CONTEXT_CLASS*(klass: Pointer): PGLContextClass
|
||||
proc IS_GL_CONTEXT*(anObject: Pointer): bool
|
||||
proc IS_GL_CONTEXT_CLASS*(klass: Pointer): bool
|
||||
proc GL_CONTEXT_GET_CLASS*(obj: Pointer): PGLContextClass
|
||||
proc gl_context_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_context_get_type".}
|
||||
proc gl_context_new*(gldrawable: PGLDrawable, share_list: PGLContext,
|
||||
direct: gboolean, render_type: int32): PGLContext{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_context_new".}
|
||||
proc gl_context_destroy*(glcontext: PGLContext){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_context_destroy".}
|
||||
proc gl_context_copy*(glcontext: PGLContext, src: PGLContext, mask: int32): gboolean{.
|
||||
cdecl, dynlib: GLExtLib, importc: "gdk_gl_context_copy".}
|
||||
proc gl_context_get_gl_drawable*(glcontext: PGLContext): PGLDrawable{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_context_get_gl_drawable".}
|
||||
proc gl_context_get_gl_config*(glcontext: PGLContext): PGLConfig{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_context_get_gl_config".}
|
||||
proc gl_context_get_share_list*(glcontext: PGLContext): PGLContext{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_context_get_share_list".}
|
||||
proc gl_context_is_direct*(glcontext: PGLContext): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_context_is_direct".}
|
||||
proc gl_context_get_render_type*(glcontext: PGLContext): int32{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_context_get_render_type".}
|
||||
proc gl_context_get_current*(): PGLContext{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_context_get_current".}
|
||||
proc TYPE_GL_DRAWABLE*(): GType
|
||||
proc GL_DRAWABLE*(inst: Pointer): PGLDrawable
|
||||
proc GL_DRAWABLE_CLASS*(vtable: Pointer): PGLDrawableClass
|
||||
proc IS_GL_DRAWABLE*(inst: Pointer): bool
|
||||
proc IS_GL_DRAWABLE_CLASS*(vtable: Pointer): bool
|
||||
proc GL_DRAWABLE_GET_CLASS*(inst: Pointer): PGLDrawableClass
|
||||
proc gl_drawable_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_get_type".}
|
||||
proc gl_drawable_make_current*(gldrawable: PGLDrawable, glcontext: PGLContext): gboolean{.
|
||||
cdecl, dynlib: GLExtLib, importc: "gdk_gl_drawable_make_current".}
|
||||
proc gl_drawable_is_double_buffered*(gldrawable: PGLDrawable): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_drawable_is_double_buffered".}
|
||||
proc gl_drawable_swap_buffers*(gldrawable: PGLDrawable){.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_drawable_swap_buffers".}
|
||||
proc gl_drawable_wait_gl*(gldrawable: PGLDrawable){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_wait_gl".}
|
||||
proc gl_drawable_wait_gdk*(gldrawable: PGLDrawable){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_wait_gdk".}
|
||||
proc gl_drawable_gl_begin*(gldrawable: PGLDrawable, glcontext: PGLContext): gboolean{.
|
||||
cdecl, dynlib: GLExtLib, importc: "gdk_gl_drawable_gl_begin".}
|
||||
proc gl_drawable_gl_end*(gldrawable: PGLDrawable){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_gl_end".}
|
||||
proc gl_drawable_get_gl_config*(gldrawable: PGLDrawable): PGLConfig{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_drawable_get_gl_config".}
|
||||
proc gl_drawable_get_size*(gldrawable: PGLDrawable, width, height: PGInt){.
|
||||
cdecl, dynlib: GLExtLib, importc: "gdk_gl_drawable_get_size".}
|
||||
proc gl_drawable_get_current*(): PGLDrawable{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_drawable_get_current".}
|
||||
proc TYPE_GL_PIXMAP*(): GType
|
||||
proc GL_PIXMAP*(anObject: Pointer): PGLPixmap
|
||||
proc GL_PIXMAP_CLASS*(klass: Pointer): PGLPixmapClass
|
||||
proc IS_GL_PIXMAP*(anObject: Pointer): bool
|
||||
proc IS_GL_PIXMAP_CLASS*(klass: Pointer): bool
|
||||
proc GL_PIXMAP_GET_CLASS*(obj: Pointer): PGLPixmapClass
|
||||
proc gl_pixmap_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_pixmap_get_type".}
|
||||
proc gl_pixmap_new*(glconfig: PGLConfig, pixmap: PPixmap, attrib_list: ptr int32): PGLPixmap{.
|
||||
cdecl, dynlib: GLExtLib, importc: "gdk_gl_pixmap_new".}
|
||||
proc gl_pixmap_destroy*(glpixmap: PGLPixmap){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_pixmap_destroy".}
|
||||
proc gl_pixmap_get_pixmap*(glpixmap: PGLPixmap): PPixmap{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_pixmap_get_pixmap".}
|
||||
proc pixmap_set_gl_capability*(pixmap: PPixmap, glconfig: PGLConfig,
|
||||
attrib_list: ptr int32): PGLPixmap{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_pixmap_set_gl_capability".}
|
||||
proc pixmap_unset_gl_capability*(pixmap: PPixmap){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_pixmap_unset_gl_capability".}
|
||||
proc pixmap_is_gl_capable*(pixmap: PPixmap): gboolean{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_pixmap_is_gl_capable".}
|
||||
proc pixmap_get_gl_pixmap*(pixmap: PPixmap): PGLPixmap{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_pixmap_get_gl_pixmap".}
|
||||
proc pixmap_get_gl_drawable*(pixmap: PPixmap): PGLDrawable
|
||||
proc TYPE_GL_WINDOW*(): GType
|
||||
proc GL_WINDOW*(anObject: Pointer): PGLWindow
|
||||
proc GL_WINDOW_CLASS*(klass: Pointer): PGLWindowClass
|
||||
proc IS_GL_WINDOW*(anObject: Pointer): bool
|
||||
proc IS_GL_WINDOW_CLASS*(klass: Pointer): bool
|
||||
proc GL_WINDOW_GET_CLASS*(obj: Pointer): PGLWindowClass
|
||||
proc gl_window_get_type*(): GType{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_window_get_type".}
|
||||
proc gl_window_new*(glconfig: PGLConfig, window: PWindow, attrib_list: ptr int32): PGLWindow{.
|
||||
cdecl, dynlib: GLExtLib, importc: "gdk_gl_window_new".}
|
||||
proc gl_window_destroy*(glwindow: PGLWindow){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_window_destroy".}
|
||||
proc gl_window_get_window*(glwindow: PGLWindow): PWindow{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_window_get_window".}
|
||||
proc window_set_gl_capability*(window: PWindow, glconfig: PGLConfig,
|
||||
attrib_list: ptr int32): PGLWindow{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_window_set_gl_capability".}
|
||||
proc window_unset_gl_capability*(window: PWindow){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_window_unset_gl_capability".}
|
||||
proc window_is_gl_capable*(window: PWindow): gboolean{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_window_is_gl_capable".}
|
||||
proc window_get_gl_window*(window: PWindow): PGLWindow{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_window_get_gl_window".}
|
||||
proc window_get_gl_drawable*(window: PWindow): PGLDrawable
|
||||
proc gl_draw_cube*(solid: gboolean, size: float64){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_draw_cube".}
|
||||
proc gl_draw_sphere*(solid: gboolean, radius: float64, slices: int32,
|
||||
stacks: int32){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_draw_sphere".}
|
||||
proc gl_draw_cone*(solid: gboolean, base: float64, height: float64,
|
||||
slices: int32, stacks: int32){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_draw_cone".}
|
||||
proc gl_draw_torus*(solid: gboolean, inner_radius: float64,
|
||||
outer_radius: float64, nsides: int32, rings: int32){.cdecl,
|
||||
dynlib: GLExtLib, importc: "gdk_gl_draw_torus".}
|
||||
proc gl_draw_tetrahedron*(solid: gboolean){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_draw_tetrahedron".}
|
||||
proc gl_draw_octahedron*(solid: gboolean){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_draw_octahedron".}
|
||||
proc gl_draw_dodecahedron*(solid: gboolean){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_draw_dodecahedron".}
|
||||
proc gl_draw_icosahedron*(solid: gboolean){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_draw_icosahedron".}
|
||||
proc gl_draw_teapot*(solid: gboolean, scale: float64){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gdk_gl_draw_teapot".}
|
||||
proc HEADER_GDKGLEXT_CHECK_VERSION*(major, minor, micro: guint): bool =
|
||||
result = (HEADER_GDKGLEXT_MAJOR_VERSION > major) or
|
||||
((HEADER_GDKGLEXT_MAJOR_VERSION == major) and
|
||||
(HEADER_GDKGLEXT_MINOR_VERSION > minor)) or
|
||||
((HEADER_GDKGLEXT_MAJOR_VERSION == major) and
|
||||
(HEADER_GDKGLEXT_MINOR_VERSION == minor) and
|
||||
(HEADER_GDKGLEXT_MICRO_VERSION >= micro))
|
||||
|
||||
proc TYPE_GL_CONFIG*(): GType =
|
||||
result = gl_config_get_type()
|
||||
|
||||
proc GL_CONFIG*(anObject: Pointer): PGLConfig =
|
||||
result = cast[PGLConfig](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_GL_CONFIG()))
|
||||
|
||||
proc GL_CONFIG_CLASS*(klass: Pointer): PGLConfigClass =
|
||||
result = cast[PGLConfigClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_GL_CONFIG()))
|
||||
|
||||
proc IS_GL_CONFIG*(anObject: Pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_GL_CONFIG())
|
||||
|
||||
proc IS_GL_CONFIG_CLASS*(klass: Pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_GL_CONFIG())
|
||||
|
||||
proc GL_CONFIG_GET_CLASS*(obj: Pointer): PGLConfigClass =
|
||||
result = cast[PGLConfigClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_GL_CONFIG()))
|
||||
|
||||
proc TYPE_GL_CONTEXT*(): GType =
|
||||
result = gl_context_get_type()
|
||||
|
||||
proc GL_CONTEXT*(anObject: Pointer): PGLContext =
|
||||
result = cast[PGLContext](G_TYPE_CHECK_INSTANCE_CAST(anObject,
|
||||
TYPE_GL_CONTEXT()))
|
||||
|
||||
proc GL_CONTEXT_CLASS*(klass: Pointer): PGLContextClass =
|
||||
result = cast[PGLContextClass](G_TYPE_CHECK_CLASS_CAST(klass,
|
||||
TYPE_GL_CONTEXT()))
|
||||
|
||||
proc IS_GL_CONTEXT*(anObject: Pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_GL_CONTEXT())
|
||||
|
||||
proc IS_GL_CONTEXT_CLASS*(klass: Pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_GL_CONTEXT())
|
||||
|
||||
proc GL_CONTEXT_GET_CLASS*(obj: Pointer): PGLContextClass =
|
||||
result = cast[PGLContextClass](G_TYPE_INSTANCE_GET_CLASS(obj,
|
||||
TYPE_GL_CONTEXT()))
|
||||
|
||||
proc TYPE_GL_DRAWABLE*(): GType =
|
||||
result = gl_drawable_get_type()
|
||||
|
||||
proc GL_DRAWABLE*(inst: Pointer): PGLDrawable =
|
||||
result = cast[PGLDrawable](G_TYPE_CHECK_INSTANCE_CAST(inst, TYPE_GL_DRAWABLE()))
|
||||
|
||||
proc GL_DRAWABLE_CLASS*(vtable: Pointer): PGLDrawableClass =
|
||||
result = cast[PGLDrawableClass](G_TYPE_CHECK_CLASS_CAST(vtable,
|
||||
TYPE_GL_DRAWABLE()))
|
||||
|
||||
proc IS_GL_DRAWABLE*(inst: Pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(inst, TYPE_GL_DRAWABLE())
|
||||
|
||||
proc IS_GL_DRAWABLE_CLASS*(vtable: Pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(vtable, TYPE_GL_DRAWABLE())
|
||||
|
||||
proc GL_DRAWABLE_GET_CLASS*(inst: Pointer): PGLDrawableClass =
|
||||
result = cast[PGLDrawableClass](G_TYPE_INSTANCE_GET_INTERFACE(inst,
|
||||
TYPE_GL_DRAWABLE()))
|
||||
|
||||
proc TYPE_GL_PIXMAP*(): GType =
|
||||
result = gl_pixmap_get_type()
|
||||
|
||||
proc GL_PIXMAP*(anObject: Pointer): PGLPixmap =
|
||||
result = cast[PGLPixmap](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_GL_PIXMAP()))
|
||||
|
||||
proc GL_PIXMAP_CLASS*(klass: Pointer): PGLPixmapClass =
|
||||
result = cast[PGLPixmapClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_GL_PIXMAP()))
|
||||
|
||||
proc IS_GL_PIXMAP*(anObject: Pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_GL_PIXMAP())
|
||||
|
||||
proc IS_GL_PIXMAP_CLASS*(klass: Pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_GL_PIXMAP())
|
||||
|
||||
proc GL_PIXMAP_GET_CLASS*(obj: Pointer): PGLPixmapClass =
|
||||
result = cast[PGLPixmapClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_GL_PIXMAP()))
|
||||
|
||||
proc pixmap_get_gl_drawable*(pixmap: PPixmap): PGLDrawable =
|
||||
result = GL_DRAWABLE(pixmap_get_gl_pixmap(pixmap))
|
||||
|
||||
proc TYPE_GL_WINDOW*(): GType =
|
||||
result = gl_window_get_type()
|
||||
|
||||
proc GL_WINDOW*(anObject: Pointer): PGLWindow =
|
||||
result = cast[PGLWindow](G_TYPE_CHECK_INSTANCE_CAST(anObject, TYPE_GL_WINDOW()))
|
||||
|
||||
proc GL_WINDOW_CLASS*(klass: Pointer): PGLWindowClass =
|
||||
result = cast[PGLWindowClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_GL_WINDOW()))
|
||||
|
||||
proc IS_GL_WINDOW*(anObject: Pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(anObject, TYPE_GL_WINDOW())
|
||||
|
||||
proc IS_GL_WINDOW_CLASS*(klass: Pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_GL_WINDOW())
|
||||
|
||||
proc GL_WINDOW_GET_CLASS*(obj: Pointer): PGLWindowClass =
|
||||
result = cast[PGLWindowClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_GL_WINDOW()))
|
||||
|
||||
proc window_get_gl_drawable*(window: PWindow): PGLDrawable =
|
||||
result = GL_DRAWABLE(window_get_gl_window(window))
|
||||
4500
lib/newwrap/gtk/glib2.nim
Normal file
4500
lib/newwrap/gtk/glib2.nim
Normal file
File diff suppressed because it is too large
Load Diff
16883
lib/newwrap/gtk/gtk2.nim
Normal file
16883
lib/newwrap/gtk/gtk2.nim
Normal file
File diff suppressed because it is too large
Load Diff
48
lib/newwrap/gtk/gtkglext.nim
Normal file
48
lib/newwrap/gtk/gtkglext.nim
Normal file
@@ -0,0 +1,48 @@
|
||||
{.deadCodeElim: on.}
|
||||
import
|
||||
Glib2, Gdk2, 2, GdkGLExt
|
||||
|
||||
const
|
||||
GLExtLib* = if defined(WIN32): "libgtkglext-win32-1.0-0.dll" else: "libgtkglext-x11-1.0.so"
|
||||
|
||||
const
|
||||
HEADER_GTKGLEXT_MAJOR_VERSION* = 1
|
||||
HEADER_GTKGLEXT_MINOR_VERSION* = 0
|
||||
HEADER_GTKGLEXT_MICRO_VERSION* = 6
|
||||
HEADER_GTKGLEXT_INTERFACE_AGE* = 4
|
||||
HEADER_GTKGLEXT_BINARY_AGE* = 6
|
||||
|
||||
proc gl_parse_args*(argc: Plongint, argv: PPPChar): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gtk_gl_parse_args".}
|
||||
proc gl_init_check*(argc: Plongint, argv: PPPChar): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gtk_gl_init_check".}
|
||||
proc gl_init*(argc: Plongint, argv: PPPChar){.cdecl, dynlib: GLExtLib,
|
||||
importc: "gtk_gl_init".}
|
||||
proc widget_set_gl_capability*(widget: PWidget, glconfig: PGdkGLConfig,
|
||||
share_list: PGdkGLContext, direct: gboolean,
|
||||
render_type: int): gboolean{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gtk_widget_set_gl_capability".}
|
||||
proc widget_is_gl_capable*(widget: PWidget): gboolean{.cdecl, dynlib: GLExtLib,
|
||||
importc: "gtk_widget_is_gl_capable".}
|
||||
proc widget_get_gl_config*(widget: PWidget): PGdkGLConfig{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gtk_widget_get_gl_config".}
|
||||
proc widget_create_gl_context*(widget: PWidget, share_list: PGdkGLContext,
|
||||
direct: gboolean, render_type: int): PGdkGLContext{.
|
||||
cdecl, dynlib: GLExtLib, importc: "gtk_widget_create_gl_context".}
|
||||
proc widget_get_gl_context*(widget: PWidget): PGdkGLContext{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gtk_widget_get_gl_context".}
|
||||
proc widget_get_gl_window*(widget: PWidget): PGdkGLWindow{.cdecl,
|
||||
dynlib: GLExtLib, importc: "gtk_widget_get_gl_window".}
|
||||
proc widget_get_gl_drawable*(widget: PWidget): PGdkGLDrawable =
|
||||
nil
|
||||
|
||||
proc HEADER_GTKGLEXT_CHECK_VERSION*(major, minor, micro: guint): bool =
|
||||
result = (HEADER_GTKGLEXT_MAJOR_VERSION > major) or
|
||||
((HEADER_GTKGLEXT_MAJOR_VERSION == major) and
|
||||
(HEADER_GTKGLEXT_MINOR_VERSION > minor)) or
|
||||
((HEADER_GTKGLEXT_MAJOR_VERSION == major) and
|
||||
(HEADER_GTKGLEXT_MINOR_VERSION == minor) and
|
||||
(HEADER_GTKGLEXT_MICRO_VERSION >= micro))
|
||||
|
||||
proc widget_get_gl_drawable*(widget: PWidget): PGdkGLDrawable =
|
||||
result = GDK_GL_DRAWABLE(widget_get_gl_window(widget))
|
||||
494
lib/newwrap/gtk/gtkhtml.nim
Normal file
494
lib/newwrap/gtk/gtkhtml.nim
Normal file
@@ -0,0 +1,494 @@
|
||||
{.deadCodeElim: on.}
|
||||
import
|
||||
2, glib2, atk, pango, gdk2pixbuf, gdk2
|
||||
|
||||
when defined(windows):
|
||||
{.define: WINDOWING_WIN32.}
|
||||
const
|
||||
htmllib = "libgtkhtml-win32-2.0-0.dll"
|
||||
else:
|
||||
const
|
||||
htmllib = "libgtkhtml-2.so"
|
||||
const
|
||||
DOM_UNSPECIFIED_EVENT_TYPE_ERR* = 0
|
||||
DOM_INDEX_SIZE_ERR* = 1
|
||||
DOM_DOMSTRING_SIZE_ERR* = 2
|
||||
DOM_HIERARCHY_REQUEST_ERR* = 3
|
||||
DOM_WRONG_DOCUMENT_ERR* = 4
|
||||
DOM_INVALID_CHARACTER_ERR* = 5
|
||||
DOM_NO_DATA_ALLOWED_ERR* = 6
|
||||
DOM_NO_MODIFICATION_ALLOWED_ERR* = 7
|
||||
DOM_NOT_FOUND_ERR* = 8
|
||||
DOM_NOT_SUPPORTED_ERR* = 9
|
||||
DOM_INUSE_ATTRIBUTE_ERR* = 10
|
||||
DOM_INVALID_STATE_ERR* = 11
|
||||
DOM_SYNTAX_ERR* = 12
|
||||
DOM_INVALID_MODIFICATION_ERR* = 13
|
||||
DOM_NAMESPACE_ERR* = 14
|
||||
DOM_INVALID_ACCESS_ERR* = 15
|
||||
DOM_NO_EXCEPTION* = 255
|
||||
DOM_ELEMENT_NODE* = 1
|
||||
DOM_ATTRIBUTE_NODE* = 2
|
||||
DOM_TEXT_NODE* = 3
|
||||
DOM_CDATA_SECTION_NODE* = 4
|
||||
DOM_ENTITY_REFERENCE_NODE* = 5
|
||||
DOM_ENTITY_NODE* = 6
|
||||
DOM_PROCESSING_INSTRUCTION_NODE* = 7
|
||||
DOM_COMMENT_NODE* = 8
|
||||
DOM_DOCUMENT_NODE* = 9
|
||||
DOM_DOCUMENT_TYPE_NODE* = 10
|
||||
DOM_DOCUMENT_FRAGMENT_NODE* = 11
|
||||
DOM_NOTATION_NODE* = 12
|
||||
bm__HtmlFontSpecification_weight* = 0x0000000F
|
||||
bp__HtmlFontSpecification_weight* = 0
|
||||
bm__HtmlFontSpecification_style* = 0x00000030
|
||||
bp__HtmlFontSpecification_style* = 4
|
||||
bm__HtmlFontSpecification_variant* = 0x000000C0
|
||||
bp__HtmlFontSpecification_variant* = 6
|
||||
bm__HtmlFontSpecification_stretch* = 0x00000F00
|
||||
bp__HtmlFontSpecification_stretch* = 8
|
||||
bm__HtmlFontSpecification_decoration* = 0x00007000
|
||||
bp__HtmlFontSpecification_decoration* = 12
|
||||
|
||||
type
|
||||
TDomString* = gchar
|
||||
TDomBoolean* = gboolean
|
||||
TDomException* = gushort
|
||||
TDomTimeStamp* = guint64
|
||||
PDomNode* = ptr TDomNode
|
||||
TDomNode* = object of TGObject
|
||||
xmlnode*: pointer
|
||||
style*: pointer
|
||||
|
||||
PDomNodeClass* = ptr TDomNodeClass
|
||||
TDomNodeClass* = object of TGObjectClass
|
||||
`get_nodeName`*: proc (node: PDomNode): PDomString{.cdecl.}
|
||||
`get_nodeValue`*: proc (node: PDomNode, exc: PDomException): PDomString{.
|
||||
cdecl.}
|
||||
`set_nodeValue`*: proc (node: PDomNode, value: PDomString,
|
||||
exc: PDomException): PDomString{.cdecl.}
|
||||
|
||||
PDomDocument* = ptr TDomDocument
|
||||
TDomDocument*{.final, pure.} = object
|
||||
parent*: PDomNode
|
||||
iterators*: PGSList
|
||||
|
||||
PDomDocumentClass* = ptr TDomDocumentClass
|
||||
TDomDocumentClass*{.final, pure.} = object
|
||||
parent_class*: PDomNodeClass
|
||||
|
||||
PHtmlFocusIterator* = ptr THtmlFocusIterator
|
||||
THtmlFocusIterator* = object of TGObject
|
||||
document*: PDomDocument
|
||||
current_node*: PDomNode
|
||||
|
||||
PHtmlFocusIteratorClass* = ptr THtmlFocusIteratorClass
|
||||
THtmlFocusIteratorClass* = object of TGObjectClass
|
||||
THtmlParserType* = enum
|
||||
HTML_PARSER_TYPE_HTML, HTML_PARSER_TYPE_XML
|
||||
PHtmlParser* = ptr THtmlParser
|
||||
THtmlParser* = object of TGObject
|
||||
parser_type*: THtmlParserType
|
||||
document*: PHtmlDocument
|
||||
stream*: PHtmlStream
|
||||
xmlctxt*: xmlParserCtxtPtr
|
||||
res*: int32
|
||||
chars*: array[0..9, char]
|
||||
blocking*: gboolean
|
||||
blocking_node*: PDomNode
|
||||
|
||||
PHtmlParserClass* = ptr THtmlParserClass
|
||||
THtmlParserClass* = object of TObjectClass
|
||||
done_parsing*: proc (parser: PHtmlParser){.cdecl.}
|
||||
new_node*: proc (parser: PHtmlParser, node: PDomNode)
|
||||
parsed_document_node*: proc (parser: PHtmlParser, document: PDomDocument)
|
||||
|
||||
PHtmlStream* = ptr THtmlStream
|
||||
THtmlStreamCloseFunc* = proc (stream: PHtmlStream, user_data: gpointer){.cdecl.}
|
||||
THtmlStreamWriteFunc* = proc (stream: PHtmlStream, buffer: Pgchar,
|
||||
size: guint, user_data: gpointer){.cdecl.}
|
||||
THtmlStreamCancelFunc* = proc (stream: PHtmlStream, user_data: gpointer,
|
||||
cancel_data: gpointer){.cdecl.}
|
||||
THtmlStream* = object of TGObject
|
||||
write_func*: THtmlStreamWriteFunc
|
||||
close_func*: THtmlStreamCloseFunc
|
||||
cancel_func*: THtmlStreamCancelFunc
|
||||
user_data*: gpointer
|
||||
cancel_data*: gpointer
|
||||
written*: gint
|
||||
mime_type*: cstring
|
||||
|
||||
PHtmlStreamClass* = ptr THtmlStreamClass
|
||||
THtmlStreamClass* = object of TGObjectClass
|
||||
THtmlStreamBufferCloseFunc* = proc (str: Pgchar, len: gint,
|
||||
user_data: gpointer){.cdecl.}
|
||||
PHtmlContext* = ptr THtmlContext
|
||||
THtmlContext* = object of TGObject
|
||||
documents*: PGSList
|
||||
standard_font*: PHtmlFontSpecification
|
||||
fixed_font*: PHtmlFontSpecification
|
||||
debug_painting*: gboolean
|
||||
|
||||
PHtmlContextClass* = ptr THtmlContextClass
|
||||
THtmlContextClass* = object of TGObjectClass
|
||||
THtmlDocumentState* = enum
|
||||
HTML_DOCUMENT_STATE_DONE, HTML_DOCUMENT_STATE_PARSING
|
||||
PHtmlDocument* = ptr THtmlDocument
|
||||
THtmlDocument* = object of TGObject
|
||||
stylesheets*: PGSList
|
||||
current_stream*: PHtmlStream
|
||||
state*: THtmlDocumentState
|
||||
|
||||
PHtmlDocumentClass* = ptr THtmlDocumentClass
|
||||
THtmlDocumentClass* = object of TGObjectClass
|
||||
request_url*: proc (document: PHtmlDocument, url: Pgchar,
|
||||
stream: PHtmlStream){.cdecl.}
|
||||
link_clicked*: proc (document: PHtmlDocument, url: Pgchar){.cdecl.}
|
||||
set_base*: proc (document: PHtmlDocument, url: Pgchar){.cdecl.}
|
||||
title_changed*: proc (document: PHtmlDocument, new_title: Pgchar){.cdecl.}
|
||||
submit*: proc (document: PHtmlDocument, `method`: Pgchar, url: Pgchar,
|
||||
encoding: Pgchar){.cdecl.}
|
||||
|
||||
PHtmlView* = ptr THtmlView
|
||||
THtmlView* = object of TLayout
|
||||
document*: PHtmlDocument
|
||||
node_table*: PGHashTable
|
||||
relayout_idle_id*: guint
|
||||
relayout_timeout_id*: guint
|
||||
mouse_down_x*: gint
|
||||
mouse_down_y*: gint
|
||||
mouse_detail*: gint
|
||||
sel_start_ypos*: gint
|
||||
sel_start_index*: gint
|
||||
sel_end_ypos*: gint
|
||||
sel_end_index*: gint
|
||||
sel_flag*: gboolean
|
||||
sel_backwards*: gboolean
|
||||
sel_start_found*: gboolean
|
||||
sel_list*: PGSList
|
||||
jump_to_anchor*: pgchar
|
||||
magnification*: gdouble
|
||||
magnification_modified*: gboolean
|
||||
on_url*: gboolean
|
||||
|
||||
PHtmlViewClass* = ptr THtmlViewClass
|
||||
THtmlViewClass* = object of TLayoutClass
|
||||
move_cursor*: proc (html_view: PHtmlView, step: TMovementStep, count: gint,
|
||||
extend_selection: gboolean){.cdecl.}
|
||||
on_url*: proc (html_view: PHtmlView, url: Pgchar)
|
||||
activate*: proc (html_view: PHtmlView)
|
||||
move_focus_out*: proc (html_view: PHtmlView, direction: TDirectionType)
|
||||
|
||||
|
||||
proc DOM_TYPE_NODE*(): GType
|
||||
proc DOM_NODE*(theobject: pointer): PDomNode
|
||||
proc DOM_NODE_CLASS*(klass: pointer): PDomNodeClass
|
||||
proc DOM_IS_NODE*(theobject: pointer): bool
|
||||
proc DOM_IS_NODE_CLASS*(klass: pointer): bool
|
||||
proc DOM_NODE_GET_CLASS*(obj: pointer): int32
|
||||
proc dom_node_get_type*(): GType{.cdecl, dynlib: htmllib,
|
||||
importc: "dom_node_get_type".}
|
||||
proc dom_Node_mkref*(node: pointer): PDomNode{.cdecl, dynlib: htmllib,
|
||||
importc: "dom_Node_mkref".}
|
||||
proc dom_Node__get_childNodes*(node: PDomNode): PDomNodeList{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_childNodes".}
|
||||
proc dom_Node_removeChild*(node: PDomNode, oldChild: PDomNode,
|
||||
exc: PDomException): PDomNode{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node_removeChild".}
|
||||
proc dom_Node__get_nodeValue*(node: PDomNode, exc: PDomException): PDomString{.
|
||||
cdecl, dynlib: htmllib, importc: "dom_Node__get_nodeValue".}
|
||||
proc dom_Node__get_firstChild*(node: PDomNode): PDomNode{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_firstChild".}
|
||||
proc dom_Node__get_nodeName*(node: PDomNode): PDomString{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_nodeName".}
|
||||
proc dom_Node__get_attributes*(node: PDomNode): PDomNamedNodeMap{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_attributes".}
|
||||
proc dom_Document__get_doctype*(doc: PDomDocument): PDomDocumentType{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Document__get_doctype".}
|
||||
proc dom_Node_hasChildNodes*(node: PDomNode): DomBoolean{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node_hasChildNodes".}
|
||||
proc dom_Node__get_parentNode*(node: PDomNode): PDomNode{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_parentNode".}
|
||||
proc dom_Node__get_nextSibling*(node: PDomNode): PDomNode{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_nextSibling".}
|
||||
proc dom_Node__get_nodeType*(node: PDomNode): gushort{.cdecl, dynlib: htmllib,
|
||||
importc: "dom_Node__get_nodeType".}
|
||||
proc dom_Node_hasAttributes*(node: PDomNode): DomBoolean{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node_hasAttributes".}
|
||||
proc dom_Node_cloneNode*(node: PDomNode, deep: DomBoolean): PDomNode{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node_cloneNode".}
|
||||
proc dom_Node_appendChild*(node: PDomNode, newChild: PDomNode,
|
||||
exc: PDomException): PDomNode{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node_appendChild".}
|
||||
proc dom_Node__get_localName*(node: PDomNode): PDomString{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_localName".}
|
||||
proc dom_Node__get_namespaceURI*(node: PDomNode): PDomString{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_namespaceURI".}
|
||||
proc dom_Node__get_previousSibling*(node: PDomNode): PDomNode{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_previousSibling".}
|
||||
proc dom_Node__get_lastChild*(node: PDomNode): PDomNode{.cdecl, dynlib: htmllib,
|
||||
importc: "dom_Node__get_lastChild".}
|
||||
proc dom_Node__set_nodeValue*(node: PDomNode, value: PDomString,
|
||||
exc: PDomException){.cdecl, dynlib: htmllib,
|
||||
importc: "dom_Node__set_nodeValue".}
|
||||
proc dom_Node__get_ownerDocument*(node: PDomNode): PDomDocument{.cdecl,
|
||||
dynlib: htmllib, importc: "dom_Node__get_ownerDocument".}
|
||||
proc dom_Node_hasAttributes*(node: PDomNode): gboolean{.cdecl, dynlib: htmllib,
|
||||
importc: "dom_Node_hasAttributes".}
|
||||
proc DOM_TYPE_DOCUMENT*(): GType
|
||||
proc DOM_DOCUMENT*(theobject: pointer): PDomDocument
|
||||
proc DOM_DOCUMENT_CLASS*(klass: pointer): PDomDocumentClass
|
||||
proc DOM_IS_DOCUMENT*(theobject: pointer): bool
|
||||
proc DOM_IS_DOCUMENT_CLASS*(klass: pointer): bool
|
||||
proc DOM_DOCUMENT_GET_CLASS*(obj: pointer): PDomDocumentClass
|
||||
proc dom_document_get_type*(): GType
|
||||
proc dom_Document__get_documentElement*(doc: PDomDocument): PDomElement
|
||||
proc dom_Document_createElement*(doc: PDomDocument, tagName: PDomString): PDomElement
|
||||
proc dom_Document_createTextNode*(doc: PDomDocument, data: PDomString): PDomText
|
||||
proc dom_Document_createComment*(doc: PDomDocument, data: PDomString): PDomComment
|
||||
proc dom_Document_importNode*(doc: PDomDocument, importedNode: PDomNode,
|
||||
deep: DomBoolean, exc: PDomException): PDomNode
|
||||
proc HTML_TYPE_FOCUS_ITERATOR*(): GType
|
||||
proc HTML_FOCUS_ITERATOR*(theobject: pointer): PHtmlFocusIterator
|
||||
proc HTML_FOCUS_ITERATOR_CLASS*(klass: pointer): PHtmlFocusIteratorClass
|
||||
proc HTML_IS_FOCUS_ITERATOR*(theobject: pointer): bool
|
||||
proc HTML_IS_FOCUS_ITERATOR_CLASS*(klass: pointer): bool
|
||||
proc HTML_FOCUS_ITERATOR_GET_CLASS*(obj: pointer): PHtmlFocusIteratorClass
|
||||
proc html_focus_iterator_next_element*(document: PDomDocument,
|
||||
element: PDomElement): PDomElement{.
|
||||
cdecl, dynlib: htmllib, importc: "html_focus_iterator_next_element".}
|
||||
proc html_focus_iterator_prev_element*(document: PDomDocument,
|
||||
element: PDomElement): PDomElement{.
|
||||
cdecl, dynlib: htmllib, importc: "html_focus_iterator_prev_element".}
|
||||
proc HTML_PARSER_TYPE*(): GType
|
||||
proc HTML_PARSER*(obj: pointer): PHtmlParser
|
||||
proc HTML_PARSER_CLASS*(klass: pointer): PHtmlParserClass
|
||||
proc HTML_IS_PARSER*(obj: pointer): bool
|
||||
proc html_parser_get_type*(): GType
|
||||
proc html_parser_new*(document: PHtmlDocument, parser_type: THtmlParserType): PHtmlParser
|
||||
proc HTML_TYPE_STREAM*(): GType
|
||||
proc HTML_STREAM*(obj: pointer): PHtmlStream
|
||||
proc HTML_STREAM_CLASS*(klass: pointer): PHtmlStreamClass
|
||||
proc HTML_IS_STREAM*(obj: pointer): bool
|
||||
proc HTML_IS_STREAM_CLASS*(klass: pointer): bool
|
||||
proc HTML_STREAM_GET_CLASS*(obj: pointer): PHtmlStreamClass
|
||||
proc html_stream_get_type*(): GType{.cdecl, dynlib: htmllib,
|
||||
importc: "html_stream_get_type".}
|
||||
proc html_stream_new*(write_func: THtmlStreamWriteFunc,
|
||||
close_func: THtmlStreamCloseFunc, user_data: gpointer): PHtmlStream{.
|
||||
cdecl, dynlib: htmllib, importc: "html_stream_new".}
|
||||
proc html_stream_write*(stream: PHtmlStream, buffer: Pgchar, size: guint){.
|
||||
cdecl, dynlib: htmllib, importc: "html_stream_write".}
|
||||
proc html_stream_close*(stream: PHtmlStream){.cdecl, dynlib: htmllib,
|
||||
importc: "html_stream_close".}
|
||||
proc html_stream_destroy*(stream: PHtmlStream){.cdecl, dynlib: htmllib,
|
||||
importc: "html_stream_destroy".}
|
||||
proc html_stream_get_written*(stream: PHtmlStream): gint{.cdecl,
|
||||
dynlib: htmllib, importc: "html_stream_get_written".}
|
||||
proc html_stream_cancel*(stream: PHtmlStream){.cdecl, dynlib: htmllib,
|
||||
importc: "html_stream_cancel".}
|
||||
proc html_stream_set_cancel_func*(stream: PHtmlStream,
|
||||
abort_func: THtmlStreamCancelFunc,
|
||||
cancel_data: gpointer){.cdecl,
|
||||
dynlib: htmllib, importc: "html_stream_set_cancel_func".}
|
||||
proc html_stream_get_mime_type*(stream: PHtmlStream): cstring{.cdecl,
|
||||
dynlib: htmllib, importc: "html_stream_get_mime_type".}
|
||||
proc html_stream_set_mime_type*(stream: PHtmlStream, mime_type: cstring){.cdecl,
|
||||
dynlib: htmllib, importc: "html_stream_set_mime_type".}
|
||||
proc html_stream_buffer_new*(close_func: THtmlStreamBufferCloseFunc,
|
||||
user_data: gpointer): PHtmlStream{.cdecl,
|
||||
dynlib: htmllib, importc: "html_stream_buffer_new".}
|
||||
proc html_event_mouse_move*(view: PHtmlView, event: PGdkEventMotion){.cdecl,
|
||||
dynlib: htmllib, importc: "html_event_mouse_move".}
|
||||
proc html_event_button_press*(view: PHtmlView, button: PGdkEventButton){.cdecl,
|
||||
dynlib: htmllib, importc: "html_event_button_press".}
|
||||
proc html_event_button_release*(view: PHtmlView, event: PGdkEventButton){.cdecl,
|
||||
dynlib: htmllib, importc: "html_event_button_release".}
|
||||
proc html_event_activate*(view: PHtmlView){.cdecl, dynlib: htmllib,
|
||||
importc: "html_event_activate".}
|
||||
proc html_event_key_press*(view: PHtmlView, event: PGdkEventKey): gboolean{.
|
||||
cdecl, dynlib: htmllib, importc: "html_event_key_press".}
|
||||
proc html_event_find_root_box*(self: PHtmlBox, x: gint, y: gint): PHtmlBox{.
|
||||
cdecl, dynlib: htmllib, importc: "html_event_find_root_box".}
|
||||
proc html_selection_start*(view: PHtmlView, event: PGdkEventButton){.cdecl,
|
||||
dynlib: htmllib, importc: "html_selection_start".}
|
||||
proc html_selection_end*(view: PHtmlView, event: PGdkEventButton){.cdecl,
|
||||
dynlib: htmllib, importc: "html_selection_end".}
|
||||
proc html_selection_update*(view: PHtmlView, event: PGdkEventMotion){.cdecl,
|
||||
dynlib: htmllib, importc: "html_selection_update".}
|
||||
proc html_selection_clear*(view: PHtmlView){.cdecl, dynlib: htmllib,
|
||||
importc: "html_selection_clear".}
|
||||
proc html_selection_set*(view: PHtmlView, start: PDomNode, offset: int32,
|
||||
len: int32){.cdecl, dynlib: htmllib,
|
||||
importc: "html_selection_set".}
|
||||
proc HTML_CONTEXT_TYPE*(): GType
|
||||
proc HTML_CONTEXT*(obj: pointer): PHtmlContext
|
||||
proc HTML_CONTEXT_CLASS*(klass: pointer): PHtmlContextClass
|
||||
proc HTML_IS_CONTEXT*(obj: pointer): bool
|
||||
proc HTML_IS_CONTEXT_CLASS*(klass: pointer): bool
|
||||
proc html_context_get_type*(): GType
|
||||
proc html_context_get*(): PHtmlContext
|
||||
proc HTML_TYPE_DOCUMENT*(): GType
|
||||
proc HTML_DOCUMENT*(obj: pointer): PHtmlDocument
|
||||
proc HTML_DOCUMENT_CLASS*(klass: pointer): PHtmlDocumentClass
|
||||
proc HTML_IS_DOCUMENT*(obj: pointer): bool
|
||||
proc html_document_get_type*(): GType{.cdecl, dynlib: htmllib,
|
||||
importc: "html_document_get_type".}
|
||||
proc html_document_new*(): PHtmlDocument{.cdecl, dynlib: htmllib,
|
||||
importc: "html_document_new".}
|
||||
proc html_document_open_stream*(document: PHtmlDocument, mime_type: Pgchar): gboolean{.
|
||||
cdecl, dynlib: htmllib, importc: "html_document_open_stream".}
|
||||
proc html_document_write_stream*(document: PHtmlDocument, buffer: Pgchar,
|
||||
len: gint){.cdecl, dynlib: htmllib,
|
||||
importc: "html_document_write_stream".}
|
||||
proc html_document_close_stream*(document: PHtmlDocument){.cdecl,
|
||||
dynlib: htmllib, importc: "html_document_close_stream".}
|
||||
proc html_document_clear*(document: PHtmlDocument){.cdecl, dynlib: htmllib,
|
||||
importc: "html_document_clear".}
|
||||
proc HTML_TYPE_VIEW*(): GType
|
||||
proc HTML_VIEW*(obj: pointer): PHtmlView
|
||||
proc HTML_VIEW_CLASS*(klass: pointer): PHtmlViewClass
|
||||
proc HTML_IS_VIEW*(obj: pointer): bool
|
||||
proc html_view_get_type*(): GType{.cdecl, dynlib: htmllib,
|
||||
importc: "html_view_get_type".}
|
||||
proc html_view_new*(): PWidget{.cdecl, dynlib: htmllib, importc: "html_view_new".}
|
||||
proc html_view_set_document*(view: PHtmlView, document: PHtmlDocument){.cdecl,
|
||||
dynlib: htmllib, importc: "html_view_set_document".}
|
||||
proc html_view_jump_to_anchor*(view: PHtmlView, anchor: Pgchar){.cdecl,
|
||||
dynlib: htmllib, importc: "html_view_jump_to_anchor".}
|
||||
proc html_view_get_magnification*(view: PHtmlView): gdouble{.cdecl,
|
||||
dynlib: htmllib, importc: "html_view_get_magnification".}
|
||||
proc html_view_set_magnification*(view: PHtmlView, magnification: gdouble){.
|
||||
cdecl, dynlib: htmllib, importc: "html_view_set_magnification".}
|
||||
proc html_view_zoom_in*(view: PHtmlView){.cdecl, dynlib: htmllib,
|
||||
importc: "html_view_zoom_in".}
|
||||
proc html_view_zoom_out*(view: PHtmlView){.cdecl, dynlib: htmllib,
|
||||
importc: "html_view_zoom_out".}
|
||||
proc html_view_zoom_reset*(view: PHtmlView){.cdecl, dynlib: htmllib,
|
||||
importc: "html_view_zoom_reset".}
|
||||
proc DOM_TYPE_NODE*(): GType =
|
||||
result = dom_node_get_type()
|
||||
|
||||
proc DOM_NODE*(theobject: pointer): PDomNode =
|
||||
result = G_TYPE_CHECK_INSTANCE_CAST(theobject, DOM_TYPE_NODE(), TDomNode)
|
||||
|
||||
proc DOM_NODE_CLASS*(klass: pointer): PDomNodeClass =
|
||||
result = G_TYPE_CHECK_CLASS_CAST(klass, DOM_TYPE_NODE(), TDomNodeClass)
|
||||
|
||||
proc DOM_IS_NODE*(theobject: pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(theobject, DOM_TYPE_NODE())
|
||||
|
||||
proc DOM_IS_NODE_CLASS*(klass: pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, DOM_TYPE_NODE())
|
||||
|
||||
proc DOM_NODE_GET_CLASS*(obj: pointer): PDomNodeClass =
|
||||
result = G_TYPE_INSTANCE_GET_CLASS(obj, DOM_TYPE_NODE(), TDomNodeClass)
|
||||
|
||||
proc DOM_TYPE_DOCUMENT*(): GType =
|
||||
result = dom_document_get_type()
|
||||
|
||||
proc DOM_DOCUMENT*(theobject: pointer): PDomDocument =
|
||||
result = G_TYPE_CHECK_INSTANCE_CAST(theobject, DOM_TYPE_DOCUMENT(),
|
||||
TDomDocument)
|
||||
|
||||
proc DOM_DOCUMENT_CLASS*(klass: pointer): PDomDocumentClass =
|
||||
result = G_TYPE_CHECK_CLASS_CAST(klass, DOM_TYPE_DOCUMENT(), TDomDocumentClass)
|
||||
|
||||
proc DOM_IS_DOCUMENT*(theobject: pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(theobject, DOM_TYPE_DOCUMENT())
|
||||
|
||||
proc DOM_IS_DOCUMENT_CLASS*(klass: pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, DOM_TYPE_DOCUMENT())
|
||||
|
||||
proc DOM_DOCUMENT_GET_CLASS*(obj: pointer): PDomDocumentClass =
|
||||
result = G_TYPE_INSTANCE_GET_CLASS(obj, DOM_TYPE_DOCUMENT(), TDomDocumentClass)
|
||||
|
||||
proc HTML_TYPE_FOCUS_ITERATOR*(): GType =
|
||||
result = html_focus_iterator_get_type()
|
||||
|
||||
proc HTML_FOCUS_ITERATOR*(theobject: pointer): PHtmlFocusIterator =
|
||||
result = G_TYPE_CHECK_INSTANCE_CAST(theobject, HTML_TYPE_FOCUS_ITERATOR(),
|
||||
HtmlFocusIterator)
|
||||
|
||||
proc HTML_FOCUS_ITERATOR_CLASS*(klass: pointer): PHtmlFocusIteratorClass =
|
||||
result = G_TYPE_CHECK_CLASS_CAST(klass, HTML_TYPE_FOCUS_ITERATOR(),
|
||||
HtmlFocusIteratorClass)
|
||||
|
||||
proc HTML_IS_FOCUS_ITERATOR*(theobject: pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(theobject, HTML_TYPE_FOCUS_ITERATOR())
|
||||
|
||||
proc HTML_IS_FOCUS_ITERATOR_CLASS*(klass: pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, HTML_TYPE_FOCUS_ITERATOR())
|
||||
|
||||
proc HTML_FOCUS_ITERATOR_GET_CLASS*(obj: pointer): PHtmlFocusIteratorClass =
|
||||
result = G_TYPE_INSTANCE_GET_CLASS(obj, HTML_TYPE_FOCUS_ITERATOR(),
|
||||
HtmlFocusIteratorClass)
|
||||
|
||||
proc HTML_PARSER_TYPE*(): GType =
|
||||
result = html_parser_get_type()
|
||||
|
||||
proc HTML_PARSER*(obj: pointer): PHtmlParser =
|
||||
result = CHECK_CAST(obj, HTML_PARSER_TYPE(), THtmlParser)
|
||||
|
||||
proc HTML_PARSER_CLASS*(klass: pointer): PHtmlParserClass =
|
||||
result = CHECK_CLASS_CAST(klass, HTML_PARSER_TYPE(), THtmlParserClass)
|
||||
|
||||
proc HTML_IS_PARSER*(obj: pointer): bool =
|
||||
result = CHECK_TYPE(obj, HTML_PARSER_TYPE())
|
||||
|
||||
proc HTML_TYPE_STREAM*(): GType =
|
||||
result = html_stream_get_type()
|
||||
|
||||
proc HTML_STREAM*(obj: pointer): PHtmlStream =
|
||||
result = PHtmlStream(G_TYPE_CHECK_INSTANCE_CAST(obj, HTML_TYPE_STREAM()))
|
||||
|
||||
proc HTML_STREAM_CLASS*(klass: pointer): PHtmlStreamClass =
|
||||
result = G_TYPE_CHECK_CLASS_CAST(klass, HTML_TYPE_STREAM())
|
||||
|
||||
proc HTML_IS_STREAM*(obj: pointer): bool =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(obj, HTML_TYPE_STREAM())
|
||||
|
||||
proc HTML_IS_STREAM_CLASS*(klass: pointer): bool =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, HTML_TYPE_STREAM())
|
||||
|
||||
proc HTML_STREAM_GET_CLASS*(obj: pointer): PHtmlStreamClass =
|
||||
result = PHtmlStreamClass(G_TYPE_INSTANCE_GET_CLASS(obj, HTML_TYPE_STREAM()))
|
||||
|
||||
proc HTML_CONTEXT_TYPE*(): GType =
|
||||
result = html_context_get_type()
|
||||
|
||||
proc HTML_CONTEXT*(obj: pointer): PHtmlContext =
|
||||
result = CHECK_CAST(obj, HTML_CONTEXT_TYPE(), THtmlContext)
|
||||
|
||||
proc HTML_CONTEXT_CLASS*(klass: pointer): PHtmlContextClass =
|
||||
result = CHECK_CLASS_CAST(klass, HTML_CONTEXT_TYPE(), THtmlContextClass)
|
||||
|
||||
proc HTML_IS_CONTEXT*(obj: pointer): bool =
|
||||
result = CHECK_TYPE(obj, HTML_CONTEXT_TYPE())
|
||||
|
||||
proc HTML_IS_CONTEXT_CLASS*(klass: pointer): bool =
|
||||
result = CHECK_CLASS_TYPE(klass, HTML_CONTEXT_TYPE())
|
||||
|
||||
proc HTML_TYPE_DOCUMENT*(): GType =
|
||||
result = html_document_get_type()
|
||||
|
||||
proc HTML_DOCUMENT*(obj: pointer): PHtmlDocument =
|
||||
result = PHtmlDocument(CHECK_CAST(obj, HTML_TYPE_DOCUMENT()))
|
||||
|
||||
proc HTML_DOCUMENT_CLASS*(klass: pointer): PHtmlDocumentClass =
|
||||
result = CHECK_CLASS_CAST(klass, HTML_TYPE_DOCUMENT())
|
||||
|
||||
proc HTML_IS_DOCUMENT*(obj: pointer): bool =
|
||||
result = CHECK_TYPE(obj, HTML_TYPE_DOCUMENT())
|
||||
|
||||
proc HTML_TYPE_VIEW*(): GType =
|
||||
result = html_view_get_type()
|
||||
|
||||
proc HTML_VIEW*(obj: pointer): PHtmlView =
|
||||
result = PHtmlView(CHECK_CAST(obj, HTML_TYPE_VIEW()))
|
||||
|
||||
proc HTML_VIEW_CLASS*(klass: pointer): PHtmlViewClass =
|
||||
result = PHtmlViewClass(CHECK_CLASS_CAST(klass, HTML_TYPE_VIEW()))
|
||||
|
||||
proc HTML_IS_VIEW*(obj: pointer): bool =
|
||||
result = CHECK_TYPE(obj, HTML_TYPE_VIEW())
|
||||
111
lib/newwrap/gtk/libglade2.nim
Normal file
111
lib/newwrap/gtk/libglade2.nim
Normal file
@@ -0,0 +1,111 @@
|
||||
{.deadCodeElim: on.}
|
||||
import
|
||||
glib2, gtk2
|
||||
|
||||
when defined(win32):
|
||||
const
|
||||
LibGladeLib = "libglade-2.0-0.dll"
|
||||
else:
|
||||
const
|
||||
LibGladeLib = "libglade-2.0.so"
|
||||
type
|
||||
PLongint* = ptr int32
|
||||
PSmallInt* = ptr int16
|
||||
PByte* = ptr int8
|
||||
PWord* = ptr int16
|
||||
PDWord* = ptr int32
|
||||
PDouble* = ptr float64
|
||||
|
||||
proc init*(){.cdecl, dynlib: LibGladeLib, importc: "glade_init".}
|
||||
proc require*(TheLibrary: cstring){.cdecl, dynlib: LibGladeLib,
|
||||
importc: "glade_require".}
|
||||
proc provide*(TheLibrary: cstring){.cdecl, dynlib: LibGladeLib,
|
||||
importc: "glade_provide".}
|
||||
type
|
||||
PXMLPrivate* = pointer
|
||||
PXML* = ptr TXML
|
||||
TXML* = object of TGObject
|
||||
filename*: cstring
|
||||
priv*: PXMLPrivate
|
||||
|
||||
PXMLClass* = ptr TXMLClass
|
||||
TXMLClass* = object of TGObjectClass
|
||||
TXMLConnectFunc* = proc (handler_name: cstring, anObject: PGObject,
|
||||
signal_name: cstring, signal_data: cstring,
|
||||
connect_object: PGObject, after: gboolean,
|
||||
user_data: gpointer){.cdecl.}
|
||||
|
||||
proc TYPE_XML*(): GType
|
||||
proc XML*(obj: pointer): PXML
|
||||
proc XML_CLASS*(klass: pointer): PXMLClass
|
||||
proc IS_XML*(obj: pointer): gboolean
|
||||
proc IS_XML_CLASS*(klass: pointer): gboolean
|
||||
proc XML_GET_CLASS*(obj: pointer): PXMLClass
|
||||
proc xml_get_type*(): GType{.cdecl, dynlib: LibGladeLib,
|
||||
importc: "glade_xml_get_type".}
|
||||
proc xml_new*(fname: cstring, root: cstring, domain: cstring): PXML{.cdecl,
|
||||
dynlib: LibGladeLib, importc: "glade_xml_new".}
|
||||
proc xml_new_from_buffer*(buffer: cstring, size: int32, root: cstring,
|
||||
domain: cstring): PXML{.cdecl, dynlib: LibGladeLib,
|
||||
importc: "glade_xml_new_from_buffer".}
|
||||
proc xml_construct*(self: PXML, fname: cstring, root: cstring, domain: cstring): gboolean{.
|
||||
cdecl, dynlib: LibGladeLib, importc: "glade_xml_construct".}
|
||||
proc xml_signal_connect*(self: PXML, handlername: cstring, func: TGCallback){.
|
||||
cdecl, dynlib: LibGladeLib, importc: "glade_xml_signal_connect".}
|
||||
proc xml_signal_connect_data*(self: PXML, handlername: cstring,
|
||||
func: TGCallback, user_data: gpointer){.cdecl,
|
||||
dynlib: LibGladeLib, importc: "glade_xml_signal_connect_data".}
|
||||
proc xml_signal_autoconnect*(self: PXML){.cdecl, dynlib: LibGladeLib,
|
||||
importc: "glade_xml_signal_autoconnect".}
|
||||
proc xml_signal_connect_full*(self: PXML, handler_name: cstring,
|
||||
func: TXMLConnectFunc, user_data: gpointer){.
|
||||
cdecl, dynlib: LibGladeLib, importc: "glade_xml_signal_connect_full".}
|
||||
proc xml_signal_autoconnect_full*(self: PXML, func: TXMLConnectFunc,
|
||||
user_data: gpointer){.cdecl,
|
||||
dynlib: LibGladeLib, importc: "glade_xml_signal_autoconnect_full".}
|
||||
proc xml_get_widget*(self: PXML, name: cstring): PGtkWidget{.cdecl,
|
||||
dynlib: LibGladeLib, importc: "glade_xml_get_widget".}
|
||||
proc xml_get_widget_prefix*(self: PXML, name: cstring): PGList{.cdecl,
|
||||
dynlib: LibGladeLib, importc: "glade_xml_get_widget_prefix".}
|
||||
proc xml_relative_file*(self: PXML, filename: cstring): cstring{.cdecl,
|
||||
dynlib: LibGladeLib, importc: "glade_xml_relative_file".}
|
||||
proc get_widget_name*(widget: PGtkWidget): cstring{.cdecl, dynlib: LibGladeLib,
|
||||
importc: "glade_get_widget_name".}
|
||||
proc get_widget_tree*(widget: PGtkWidget): PXML{.cdecl, dynlib: LibGladeLib,
|
||||
importc: "glade_get_widget_tree".}
|
||||
type
|
||||
PXMLCustomWidgetHandler* = ptr TXMLCustomWidgetHandler
|
||||
TXMLCustomWidgetHandler* = TGtkWidget
|
||||
|
||||
proc set_custom_handler*(handler: TXMLCustomWidgetHandler, user_data: gpointer){.
|
||||
cdecl, dynlib: LibGladeLib, importc: "glade_set_custom_handler".}
|
||||
proc gnome_init*() =
|
||||
init()
|
||||
|
||||
proc bonobo_init*() =
|
||||
init()
|
||||
|
||||
proc xml_new_with_domain*(fname: cstring, root: cstring, domain: cstring): PXML =
|
||||
result = xml_new(fname, root, domain)
|
||||
|
||||
proc xml_new_from_memory*(buffer: cstring, size: int32, root: cstring,
|
||||
domain: cstring): PXML =
|
||||
result = xml_new_from_buffer(buffer, size, root, domain)
|
||||
|
||||
proc TYPE_XML*(): GType =
|
||||
result = xml_get_type()
|
||||
|
||||
proc XML*(obj: pointer): PXML =
|
||||
result = cast[PXML](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_XML()))
|
||||
|
||||
proc XML_CLASS*(klass: pointer): PXMLClass =
|
||||
result = cast[PXMLClass](G_TYPE_CHECK_CLASS_CAST(klass, TYPE_XML()))
|
||||
|
||||
proc IS_XML*(obj: pointer): gboolean =
|
||||
result = G_TYPE_CHECK_INSTANCE_TYPE(obj, TYPE_XML())
|
||||
|
||||
proc IS_XML_CLASS*(klass: pointer): gboolean =
|
||||
result = G_TYPE_CHECK_CLASS_TYPE(klass, TYPE_XML())
|
||||
|
||||
proc XML_GET_CLASS*(obj: pointer): PXMLClass =
|
||||
result = cast[PXMLClass](G_TYPE_INSTANCE_GET_CLASS(obj, TYPE_XML()))
|
||||
1183
lib/newwrap/gtk/pango.nim
Normal file
1183
lib/newwrap/gtk/pango.nim
Normal file
File diff suppressed because it is too large
Load Diff
45
lib/newwrap/gtk/pangoutils.nim
Normal file
45
lib/newwrap/gtk/pangoutils.nim
Normal file
@@ -0,0 +1,45 @@
|
||||
{.deadCodeElim: on.}
|
||||
import
|
||||
glib2, pango
|
||||
|
||||
type
|
||||
pint32* = ptr int32
|
||||
|
||||
proc pango_split_file_list*(str: cstring): PPchar{.cdecl, dynlib: pangolib,
|
||||
importc: "pango_split_file_list".}
|
||||
proc pango_trim_string*(str: cstring): cstring{.cdecl, dynlib: pangolib,
|
||||
importc: "pango_trim_string".}
|
||||
proc pango_read_line*(stream: TFile, str: PGString): gint{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_read_line".}
|
||||
proc pango_skip_space*(pos: PPchar): gboolean{.cdecl, dynlib: pangolib,
|
||||
importc: "pango_skip_space".}
|
||||
proc pango_scan_word*(pos: PPchar, OutStr: PGString): gboolean{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_scan_word".}
|
||||
proc pango_scan_string*(pos: PPchar, OutStr: PGString): gboolean{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_scan_string".}
|
||||
proc pango_scan_int*(pos: PPchar, OutInt: pint32): gboolean{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_scan_int".}
|
||||
proc pango_config_key_get(key: cstring): cstring{.cdecl, dynlib: pangolib,
|
||||
importc: "pango_config_key_get".}
|
||||
proc pango_lookup_aliases(fontname: cstring, families: PPPchar,
|
||||
n_families: pint32){.cdecl, dynlib: pangolib,
|
||||
importc: "pango_lookup_aliases".}
|
||||
proc pango_parse_style*(str: cstring, style: PStyle, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_parse_style".}
|
||||
proc pango_parse_variant*(str: cstring, variant: PVariant, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_parse_variant".}
|
||||
proc pango_parse_weight*(str: cstring, weight: PWeight, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_parse_weight".}
|
||||
proc pango_parse_stretch*(str: cstring, stretch: PStretch, warn: gboolean): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_parse_stretch".}
|
||||
proc pango_get_sysconf_subdirectory(): cstring{.cdecl, dynlib: pangolib,
|
||||
importc: "pango_get_sysconf_subdirectory".}
|
||||
proc pango_get_lib_subdirectory(): cstring{.cdecl, dynlib: pangolib,
|
||||
importc: "pango_get_lib_subdirectory".}
|
||||
proc pango_log2vis_get_embedding_levels*(str: Pgunichar, len: int32,
|
||||
pbase_dir: PDirection, embedding_level_list: Pguint8): gboolean{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_log2vis_get_embedding_levels".}
|
||||
proc pango_get_mirror_char*(ch: gunichar, mirrored_ch: Pgunichar): gboolean{.
|
||||
cdecl, dynlib: pangolib, importc: "pango_get_mirror_char".}
|
||||
proc pango_language_get_sample_string*(language: PLanguage): cstring{.cdecl,
|
||||
dynlib: pangolib, importc: "pango_language_get_sample_string".}
|
||||
491
lib/newwrap/libcurl.nim
Normal file
491
lib/newwrap/libcurl.nim
Normal file
@@ -0,0 +1,491 @@
|
||||
#
|
||||
# $Id: header,v 1.1 2000/07/13 06:33:45 michael Exp $
|
||||
# This file is part of the Free Pascal packages
|
||||
# Copyright (c) 1999-2000 by the Free Pascal development team
|
||||
#
|
||||
# See the file COPYING.FPC, included in this distribution,
|
||||
# for details about the copyright.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# **********************************************************************
|
||||
#
|
||||
# the curl library is governed by its own copyright, see the curl
|
||||
# website for this.
|
||||
#
|
||||
|
||||
import
|
||||
times
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
libname = "libcurl.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
libname = "libcurl-7.19.3.dylib"
|
||||
elif defined(unix):
|
||||
const
|
||||
libname = "libcurl.so.4"
|
||||
type
|
||||
Pcalloc_callback* = ptr Tcalloc_callback
|
||||
Pclosepolicy* = ptr Tclosepolicy
|
||||
Pforms* = ptr Tforms
|
||||
Pftpauth* = ptr Tftpauth
|
||||
Pftpmethod* = ptr Tftpmethod
|
||||
Pftpssl* = ptr Tftpssl
|
||||
PHTTP_VERSION* = ptr THTTP_VERSION
|
||||
Phttppost* = ptr Thttppost
|
||||
PPcurl_httppost* = ptr Phttppost
|
||||
Pinfotype* = ptr Tinfotype
|
||||
Plock_access* = ptr Tlock_access
|
||||
Plock_data* = ptr Tlock_data
|
||||
Pmalloc_callback* = ptr tmalloc_callback
|
||||
PNETRC_OPTION* = ptr TNETRC_OPTION
|
||||
Pproxytype* = ptr Tproxytype
|
||||
Prealloc_callback* = ptr trealloc_callback
|
||||
Pslist* = ptr Tslist
|
||||
Psocket* = ptr Tsocket
|
||||
PSSL_VERSION* = ptr TSSL_VERSION
|
||||
Pstrdup_callback* = ptr Tstrdup_callback
|
||||
PTIMECOND* = ptr TTIMECOND
|
||||
Pversion_info_data* = ptr Tversion_info_data
|
||||
Pcode* = ptr Tcode
|
||||
PFORMcode* = ptr TFORMcode
|
||||
Pformoption* = ptr Tformoption
|
||||
PINFO* = ptr TINFO
|
||||
Piocmd* = ptr Tiocmd
|
||||
Pioerr* = ptr Tioerr
|
||||
PM* = ptr TM
|
||||
PMcode* = ptr TMcode
|
||||
PMoption* = ptr TMoption
|
||||
PMSG* = ptr TMSG
|
||||
Poption* = ptr Toption
|
||||
PSH* = ptr TSH
|
||||
PSHcode* = ptr TSHcode
|
||||
PSHoption* = ptr TSHoption
|
||||
Pversion* = ptr Tversion
|
||||
Pfd_set* = pointer
|
||||
P* = ptr T
|
||||
T* = pointer
|
||||
Thttppost*{.final, pure.} = object
|
||||
next*: Phttppost
|
||||
name*: cstring
|
||||
namelength*: int32
|
||||
contents*: cstring
|
||||
contentslength*: int32
|
||||
buffer*: cstring
|
||||
bufferlength*: int32
|
||||
contenttype*: cstring
|
||||
contentheader*: Pslist
|
||||
more*: Phttppost
|
||||
flags*: int32
|
||||
showfilename*: cstring
|
||||
|
||||
Tprogress_callback* = proc (clientp: pointer, dltotal: float64,
|
||||
dlnow: float64, ultotal: float64, ulnow: float64): int32{.
|
||||
cdecl.}
|
||||
Twrite_callback* = proc (buffer: cstring, size: int, nitems: int,
|
||||
outstream: pointer): int{.cdecl.}
|
||||
Tread_callback* = proc (buffer: cstring, size: int, nitems: int,
|
||||
instream: pointer): int{.cdecl.}
|
||||
Tpasswd_callback* = proc (clientp: pointer, prompt: cstring, buffer: cstring,
|
||||
buflen: int32): int32{.cdecl.}
|
||||
Tioerr* = enum
|
||||
IOE_OK, IOE_UNKNOWNCMD, IOE_FAILRESTART, IOE_LAST
|
||||
Tiocmd* = enum
|
||||
IOCMD_NOP, IOCMD_RESTARTREAD, IOCMD_LAST
|
||||
Tioctl_callback* = proc (handle: P, cmd: int32, clientp: pointer): Tioerr{.
|
||||
cdecl.}
|
||||
Tmalloc_callback* = proc (size: int): pointer{.cdecl.}
|
||||
Tfree_callback* = proc (p: pointer){.cdecl.}
|
||||
Trealloc_callback* = proc (p: pointer, size: int): pointer{.cdecl.}
|
||||
Tstrdup_callback* = proc (str: cstring): cstring{.cdecl.}
|
||||
Tcalloc_callback* = proc (nmemb: int, size: int): pointer
|
||||
Tinfotype* = enum
|
||||
INFO_TEXT = 0, INFO_HEADER_IN, INFO_HEADER_OUT, INFO_DATA_IN, INFO_DATA_OUT,
|
||||
INFO_SSL_DATA_IN, INFO_SSL_DATA_OUT, INFO_END
|
||||
Tdebug_callback* = proc (handle: P, theType: Tinfotype, data: cstring,
|
||||
size: int, userptr: pointer): int32{.cdecl.}
|
||||
Tcode* = enum
|
||||
E_OK = 0, E_UNSUPPORTED_PROTOCOL, E_FAILED_INIT, E_URL_MALFORMAT,
|
||||
E_URL_MALFORMAT_USER, E_COULDNT_RESOLVE_PROXY, E_COULDNT_RESOLVE_HOST,
|
||||
E_COULDNT_CONNECT, E_FTP_WEIRD_SERVER_REPLY, E_FTP_ACCESS_DENIED,
|
||||
E_FTP_USER_PASSWORD_INCORRECT, E_FTP_WEIRD_PASS_REPLY,
|
||||
E_FTP_WEIRD_USER_REPLY, E_FTP_WEIRD_PASV_REPLY, E_FTP_WEIRD_227_FORMAT,
|
||||
E_FTP_CANT_GET_HOST, E_FTP_CANT_RECONNECT, E_FTP_COULDNT_SET_BINARY,
|
||||
E_PARTIAL_FILE, E_FTP_COULDNT_RETR_FILE, E_FTP_WRITE_ERROR,
|
||||
E_FTP_QUOTE_ERROR, E_HTTP_RETURNED_ERROR, E_WRITE_ERROR, E_MALFORMAT_USER,
|
||||
E_FTP_COULDNT_STOR_FILE, E_READ_ERROR, E_OUT_OF_MEMORY,
|
||||
E_OPERATION_TIMEOUTED, E_FTP_COULDNT_SET_ASCII, E_FTP_PORT_FAILED,
|
||||
E_FTP_COULDNT_USE_REST, E_FTP_COULDNT_GET_SIZE, E_HTTP_RANGE_ERROR,
|
||||
E_HTTP_POST_ERROR, E_SSL_CONNECT_ERROR, E_BAD_DOWNLOAD_RESUME,
|
||||
E_FILE_COULDNT_READ_FILE, E_LDAP_CANNOT_BIND, E_LDAP_SEARCH_FAILED,
|
||||
E_LIBRARY_NOT_FOUND, E_FUNCTION_NOT_FOUND, E_ABORTED_BY_CALLBACK,
|
||||
E_BAD_FUNCTION_ARGUMENT, E_BAD_CALLING_ORDER, E_INTERFACE_FAILED,
|
||||
E_BAD_PASSWORD_ENTERED, E_TOO_MANY_REDIRECTS, E_UNKNOWN_TELNET_OPTION,
|
||||
E_TELNET_OPTION_SYNTAX, E_OBSOLETE, E_SSL_PEER_CERTIFICATE, E_GOT_NOTHING,
|
||||
E_SSL_ENGINE_NOTFOUND, E_SSL_ENGINE_SETFAILED, E_SEND_ERROR, E_RECV_ERROR,
|
||||
E_SHARE_IN_USE, E_SSL_CERTPROBLEM, E_SSL_CIPHER, E_SSL_CACERT,
|
||||
E_BAD_CONTENT_ENCODING, E_LDAP_INVALID_URL, E_FILESIZE_EXCEEDED,
|
||||
E_FTP_SSL_FAILED, E_SEND_FAIL_REWIND, E_SSL_ENGINE_INITFAILED,
|
||||
E_LOGIN_DENIED, E_TFTP_NOTFOUND, E_TFTP_PERM, E_TFTP_DISKFULL,
|
||||
E_TFTP_ILLEGAL, E_TFTP_UNKNOWNID, E_TFTP_EXISTS, E_TFTP_NOSUCHUSER,
|
||||
E_CONV_FAILED, E_CONV_REQD, LAST
|
||||
Tconv_callback* = proc (buffer: cstring, len: int): Tcode{.cdecl.}
|
||||
Tssl_ctx_callback* = proc (: P, ssl_ctx, userptr: pointer): Tcode{.cdecl.}
|
||||
Tproxytype* = enum
|
||||
PROXY_HTTP = 0, PROXY_SOCKS4 = 4, PROXY_SOCKS5 = 5
|
||||
Tftpssl* = enum
|
||||
FTPSSL_NONE, FTPSSL_TRY, FTPSSL_CONTROL, FTPSSL_ALL, FTPSSL_LAST
|
||||
Tftpauth* = enum
|
||||
FTPAUTH_DEFAULT, FTPAUTH_SSL, FTPAUTH_TLS, FTPAUTH_LAST
|
||||
Tftpmethod* = enum
|
||||
FTPMETHOD_DEFAULT, FTPMETHOD_MULTICWD, FTPMETHOD_NOCWD, FTPMETHOD_SINGLECWD,
|
||||
FTPMETHOD_LAST
|
||||
Toption* = enum
|
||||
OPT_PORT = 0 + 3, OPT_TIMEOUT = 0 + 13, OPT_INFILESIZE = 0 + 14,
|
||||
OPT_LOW_SPEED_LIMIT = 0 + 19, OPT_LOW_SPEED_TIME = 0 + 20,
|
||||
OPT_RESUME_FROM = 0 + 21, OPT_CRLF = 0 + 27, OPT_SSLVERSION = 0 + 32,
|
||||
OPT_TIMECONDITION = 0 + 33, OPT_TIMEVALUE = 0 + 34, OPT_VERBOSE = 0 + 41,
|
||||
OPT_HEADER = 0 + 42, OPT_NOPROGRESS = 0 + 43, OPT_NOBODY = 0 + 44,
|
||||
OPT_FAILONERROR = 0 + 45, OPT_UPLOAD = 0 + 46, OPT_POST = 0 + 47,
|
||||
OPT_FTPLISTONLY = 0 + 48, OPT_FTPAPPEND = 0 + 50, OPT_NETRC = 0 + 51,
|
||||
OPT_FOLLOWLOCATION = 0 + 52, OPT_TRANSFERTEXT = 0 + 53, OPT_PUT = 0 + 54,
|
||||
OPT_AUTOREFERER = 0 + 58, OPT_PROXYPORT = 0 + 59,
|
||||
OPT_POSTFIELDSIZE = 0 + 60, OPT_HTTPPROXYTUNNEL = 0 + 61,
|
||||
OPT_SSL_VERIFYPEER = 0 + 64, OPT_MAXREDIRS = 0 + 68, OPT_FILETIME = 0 + 69,
|
||||
OPT_MAXCONNECTS = 0 + 71, OPT_CLOSEPOLICY = 0 + 72,
|
||||
OPT_FRESH_CONNECT = 0 + 74, OPT_FORBID_REUSE = 0 + 75,
|
||||
OPT_CONNECTTIMEOUT = 0 + 78, OPT_HTTPGET = 0 + 80,
|
||||
OPT_SSL_VERIFYHOST = 0 + 81, OPT_HTTP_VERSION = 0 + 84,
|
||||
OPT_FTP_USE_EPSV = 0 + 85, OPT_SSLENGINE_DEFAULT = 0 + 90,
|
||||
OPT_DNS_USE_GLOBAL_CACHE = 0 + 91, OPT_DNS_CACHE_TIMEOUT = 0 + 92,
|
||||
OPT_COOKIESESSION = 0 + 96, OPT_BUFFERSIZE = 0 + 98, OPT_NOSIGNAL = 0 + 99,
|
||||
OPT_PROXYTYPE = 0 + 101, OPT_UNRESTRICTED_AUTH = 0 + 105,
|
||||
OPT_FTP_USE_EPRT = 0 + 106, OPT_HTTPAUTH = 0 + 107,
|
||||
OPT_FTP_CREATE_MISSING_DIRS = 0 + 110, OPT_PROXYAUTH = 0 + 111,
|
||||
OPT_FTP_RESPONSE_TIMEOUT = 0 + 112, OPT_IPRESOLVE = 0 + 113,
|
||||
OPT_MAXFILESIZE = 0 + 114, OPT_FTP_SSL = 0 + 119, OPT_TCP_NODELAY = 0 + 121,
|
||||
OPT_FTPSSLAUTH = 0 + 129, OPT_IGNORE_CONTENT_LENGTH = 0 + 136,
|
||||
OPT_FTP_SKIP_PASV_IP = 0 + 137, OPT_FTP_FILEMETHOD = 0 + 138,
|
||||
OPT_LOCALPORT = 0 + 139, OPT_LOCALPORTRANGE = 0 + 140,
|
||||
OPT_CONNECT_ONLY = 0 + 141, OPT_FILE = 10000 + 1, OPT_URL = 10000 + 2,
|
||||
OPT_PROXY = 10000 + 4, OPT_USERPWD = 10000 + 5,
|
||||
OPT_PROXYUSERPWD = 10000 + 6, OPT_RANGE = 10000 + 7, OPT_INFILE = 10000 + 9,
|
||||
OPT_ERRORBUFFER = 10000 + 10, OPT_POSTFIELDS = 10000 + 15,
|
||||
OPT_REFERER = 10000 + 16, OPT_FTPPORT = 10000 + 17,
|
||||
OPT_USERAGENT = 10000 + 18, OPT_COOKIE = 10000 + 22,
|
||||
OPT_HTTPHEADER = 10000 + 23, OPT_HTTPPOST = 10000 + 24,
|
||||
OPT_SSLCERT = 10000 + 25, OPT_SSLCERTPASSWD = 10000 + 26,
|
||||
OPT_QUOTE = 10000 + 28, OPT_WRITEHEADER = 10000 + 29,
|
||||
OPT_COOKIEFILE = 10000 + 31, OPT_CUSTOMREQUEST = 10000 + 36,
|
||||
OPT_STDERR = 10000 + 37, OPT_POSTQUOTE = 10000 + 39,
|
||||
OPT_WRITEINFO = 10000 + 40, OPT_PROGRESSDATA = 10000 + 57,
|
||||
OPT_INTERFACE = 10000 + 62, OPT_KRB4LEVEL = 10000 + 63,
|
||||
OPT_CAINFO = 10000 + 65, OPT_TELNETOPTIONS = 10000 + 70,
|
||||
OPT_RANDOM_FILE = 10000 + 76, OPT_EGDSOCKET = 10000 + 77,
|
||||
OPT_COOKIEJAR = 10000 + 82, OPT_SSL_CIPHER_LIST = 10000 + 83,
|
||||
OPT_SSLCERTTYPE = 10000 + 86, OPT_SSLKEY = 10000 + 87,
|
||||
OPT_SSLKEYTYPE = 10000 + 88, OPT_SSLENGINE = 10000 + 89,
|
||||
OPT_PREQUOTE = 10000 + 93, OPT_DEBUGDATA = 10000 + 95,
|
||||
OPT_CAPATH = 10000 + 97, OPT_SHARE = 10000 + 100,
|
||||
OPT_ENCODING = 10000 + 102, OPT_PRIVATE = 10000 + 103,
|
||||
OPT_HTTP200ALIASES = 10000 + 104, OPT_SSL_CTX_DATA = 10000 + 109,
|
||||
OPT_NETRC_FILE = 10000 + 118, OPT_SOURCE_USERPWD = 10000 + 123,
|
||||
OPT_SOURCE_PREQUOTE = 10000 + 127, OPT_SOURCE_POSTQUOTE = 10000 + 128,
|
||||
OPT_IOCTLDATA = 10000 + 131, OPT_SOURCE_URL = 10000 + 132,
|
||||
OPT_SOURCE_QUOTE = 10000 + 133, OPT_FTP_ACCOUNT = 10000 + 134,
|
||||
OPT_COOKIELIST = 10000 + 135, OPT_FTP_ALTERNATIVE_TO_USER = 10000 + 147,
|
||||
OPT_LASTENTRY = 10000 + 148, OPT_WRITEFUNCTION = 20000 + 11,
|
||||
OPT_READFUNCTION = 20000 + 12, OPT_PROGRESSFUNCTION = 20000 + 56,
|
||||
OPT_HEADERFUNCTION = 20000 + 79, OPT_DEBUGFUNCTION = 20000 + 94,
|
||||
OPT_SSL_CTX_FUNCTION = 20000 + 108, OPT_IOCTLFUNCTION = 20000 + 130,
|
||||
OPT_CONV_FROM_NETWORK_FUNCTION = 20000 + 142,
|
||||
OPT_CONV_TO_NETWORK_FUNCTION = 20000 + 143,
|
||||
OPT_CONV_FROM_UTF8_FUNCTION = 20000 + 144,
|
||||
OPT_INFILESIZE_LARGE = 30000 + 115, OPT_RESUME_FROM_LARGE = 30000 + 116,
|
||||
OPT_MAXFILESIZE_LARGE = 30000 + 117, OPT_POSTFIELDSIZE_LARGE = 30000 + 120,
|
||||
OPT_MAX_SEND_SPEED_LARGE = 30000 + 145,
|
||||
OPT_MAX_RECV_SPEED_LARGE = 30000 + 146
|
||||
THTTP_VERSION* = enum
|
||||
HTTP_VERSION_NONE, HTTP_VERSION_1_0, HTTP_VERSION_1_1, HTTP_VERSION_LAST
|
||||
TNETRC_OPTION* = enum
|
||||
NETRC_IGNORED, NETRC_OPTIONAL, NETRC_REQUIRED, NETRC_LAST
|
||||
TSSL_VERSION* = enum
|
||||
SSLVERSION_DEFAULT, SSLVERSION_TLSv1, SSLVERSION_SSLv2, SSLVERSION_SSLv3,
|
||||
SSLVERSION_LAST
|
||||
TTIMECOND* = enum
|
||||
TIMECOND_NONE, TIMECOND_IFMODSINCE, TIMECOND_IFUNMODSINCE, TIMECOND_LASTMOD,
|
||||
TIMECOND_LAST
|
||||
Tformoption* = enum
|
||||
FORM_NOTHING, FORM_COPYNAME, FORM_PTRNAME, FORM_NAMELENGTH,
|
||||
FORM_COPYCONTENTS, FORM_PTRCONTENTS, FORM_CONTENTSLENGTH, FORM_FILECONTENT,
|
||||
FORM_ARRAY, FORM_OBSOLETE, FORM_FILE, FORM_BUFFER, FORM_BUFFERPTR,
|
||||
FORM_BUFFERLENGTH, FORM_CONTENTTYPE, FORM_CONTENTHEADER, FORM_FILENAME,
|
||||
FORM_END, FORM_OBSOLETE2, FORM_LASTENTRY
|
||||
Tforms*{.pure, final.} = object
|
||||
option*: Tformoption
|
||||
value*: cstring
|
||||
|
||||
TFORMcode* = enum
|
||||
FORMADD_OK, FORMADD_MEMORY, FORMADD_OPTION_TWICE, FORMADD_NULL,
|
||||
FORMADD_UNKNOWN_OPTION, FORMADD_INCOMPLETE, FORMADD_ILLEGAL_ARRAY,
|
||||
FORMADD_DISABLED, FORMADD_LAST
|
||||
Tformget_callback* = proc (arg: pointer, buf: cstring, length: int): int{.
|
||||
cdecl.}
|
||||
Tslist*{.pure, final.} = object
|
||||
data*: cstring
|
||||
next*: Pslist
|
||||
|
||||
TINFO* = enum
|
||||
INFO_NONE = 0, INFO_LASTONE = 30, INFO_EFFECTIVE_URL = 0x00100000 + 1,
|
||||
INFO_CONTENT_TYPE = 0x00100000 + 18, INFO_PRIVATE = 0x00100000 + 21,
|
||||
INFO_FTP_ENTRY_PATH = 0x00100000 + 30, INFO_RESPONSE_CODE = 0x00200000 + 2,
|
||||
INFO_HEADER_SIZE = 0x00200000 + 11, INFO_REQUEST_SIZE = 0x00200000 + 12,
|
||||
INFO_SSL_VERIFYRESULT = 0x00200000 + 13, INFO_FILETIME = 0x00200000 + 14,
|
||||
INFO_REDIRECT_COUNT = 0x00200000 + 20,
|
||||
INFO_HTTP_CONNECTCODE = 0x00200000 + 22,
|
||||
INFO_HTTPAUTH_AVAIL = 0x00200000 + 23,
|
||||
INFO_PROXYAUTH_AVAIL = 0x00200000 + 24, INFO_OS_ERRNO = 0x00200000 + 25,
|
||||
INFO_NUM_CONNECTS = 0x00200000 + 26, INFO_LASTSOCKET = 0x00200000 + 29,
|
||||
INFO_TOTAL_TIME = 0x00300000 + 3, INFO_NAMELOOKUP_TIME = 0x00300000 + 4,
|
||||
INFO_CONNECT_TIME = 0x00300000 + 5, INFO_PRETRANSFER_TIME = 0x00300000 + 6,
|
||||
INFO_SIZE_UPLOAD = 0x00300000 + 7, INFO_SIZE_DOWNLOAD = 0x00300000 + 8,
|
||||
INFO_SPEED_DOWNLOAD = 0x00300000 + 9, INFO_SPEED_UPLOAD = 0x00300000 + 10,
|
||||
INFO_CONTENT_LENGTH_DOWNLOAD = 0x00300000 + 15,
|
||||
INFO_CONTENT_LENGTH_UPLOAD = 0x00300000 + 16,
|
||||
INFO_STARTTRANSFER_TIME = 0x00300000 + 17,
|
||||
INFO_REDIRECT_TIME = 0x00300000 + 19, INFO_SSL_ENGINES = 0x00400000 + 27,
|
||||
INFO_COOKIELIST = 0x00400000 + 28
|
||||
Tclosepolicy* = enum
|
||||
CLOSEPOLICY_NONE, CLOSEPOLICY_OLDEST, CLOSEPOLICY_LEAST_RECENTLY_USED,
|
||||
CLOSEPOLICY_LEAST_TRAFFIC, CLOSEPOLICY_SLOWEST, CLOSEPOLICY_CALLBACK,
|
||||
CLOSEPOLICY_LAST
|
||||
Tlock_data* = enum
|
||||
LOCK_DATA_NONE = 0, LOCK_DATA_SHARE, LOCK_DATA_COOKIE, LOCK_DATA_DNS,
|
||||
LOCK_DATA_SSL_SESSION, LOCK_DATA_CONNECT, LOCK_DATA_LAST
|
||||
Tlock_access* = enum
|
||||
LOCK_ACCESS_NONE = 0, LOCK_ACCESS_SHARED = 1, LOCK_ACCESS_SINGLE = 2,
|
||||
LOCK_ACCESS_LAST
|
||||
Tlock_function* = proc (handle: P, data: Tlock_data, locktype: Tlock_access,
|
||||
userptr: pointer){.cdecl.}
|
||||
Tunlock_function* = proc (handle: P, data: Tlock_data, userptr: pointer){.
|
||||
cdecl.}
|
||||
TSH* = pointer
|
||||
TSHcode* = enum
|
||||
SHE_OK, SHE_BAD_OPTION, SHE_IN_USE, SHE_INVALID, SHE_NOMEM, SHE_LAST
|
||||
TSHoption* = enum
|
||||
SHOPT_NONE, SHOPT_SHARE, SHOPT_UNSHARE, SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC,
|
||||
SHOPT_USERDATA, SHOPT_LAST
|
||||
Tversion* = enum
|
||||
VERSION_FIRST, VERSION_SECOND, VERSION_THIRD, VERSION_LAST
|
||||
Tversion_info_data*{.pure, final.} = object
|
||||
age*: Tversion
|
||||
version*: cstring
|
||||
version_num*: int32
|
||||
host*: cstring
|
||||
features*: int32
|
||||
ssl_version*: cstring
|
||||
ssl_version_num*: int32
|
||||
libz_version*: cstring
|
||||
protocols*: cstringArray
|
||||
ares*: cstring
|
||||
ares_num*: int32
|
||||
libidn*: cstring
|
||||
iconv_ver_num*: int32
|
||||
|
||||
TM* = pointer
|
||||
Tsocket* = int32
|
||||
TMcode* = enum
|
||||
M_CALL_MULTI_PERFORM = - 1, M_OK = 0, M_BAD_HANDLE, M_BAD_EASY_HANDLE,
|
||||
M_OUT_OF_MEMORY, M_INTERNAL_ERROR, M_BAD_SOCKET, M_UNKNOWN_OPTION, M_LAST
|
||||
TMSGEnum* = enum
|
||||
MSG_NONE, MSG_DONE, MSG_LAST
|
||||
TMsg*{.pure, final.} = object
|
||||
msg*: TMSGEnum
|
||||
easy_handle*: P
|
||||
whatever*: Pointer #data : record
|
||||
# case longint of
|
||||
# 0 : ( whatever : pointer );
|
||||
# 1 : ( result : CURLcode );
|
||||
# end;
|
||||
|
||||
Tsocket_callback* = proc (easy: P, s: Tsocket, what: int32,
|
||||
userp, socketp: pointer): int32{.cdecl.}
|
||||
TMoption* = enum
|
||||
MOPT_SOCKETDATA = 10000 + 2, MOPT_LASTENTRY = 10000 + 3,
|
||||
MOPT_SOCKETFUNCTION = 20000 + 1
|
||||
|
||||
const
|
||||
OPT_SSLKEYPASSWD* = OPT_SSLCERTPASSWD
|
||||
AUTH_ANY* = not (0)
|
||||
AUTH_BASIC* = 1 shl 0
|
||||
AUTH_ANYSAFE* = not (AUTH_BASIC)
|
||||
AUTH_DIGEST* = 1 shl 1
|
||||
AUTH_GSSNEGOTIATE* = 1 shl 2
|
||||
AUTH_NONE* = 0
|
||||
AUTH_NTLM* = 1 shl 3
|
||||
E_ALREADY_COMPLETE* = 99999
|
||||
E_FTP_BAD_DOWNLOAD_RESUME* = E_BAD_DOWNLOAD_RESUME
|
||||
E_FTP_PARTIAL_FILE* = E_PARTIAL_FILE
|
||||
E_HTTP_NOT_FOUND* = E_HTTP_RETURNED_ERROR
|
||||
E_HTTP_PORT_FAILED* = E_INTERFACE_FAILED
|
||||
E_OPERATION_TIMEDOUT* = E_OPERATION_TIMEOUTED
|
||||
ERROR_SIZE* = 256
|
||||
FORMAT_OFF_T* = "%ld"
|
||||
GLOBAL_NOTHING* = 0
|
||||
GLOBAL_SSL* = 1 shl 0
|
||||
GLOBAL_WIN32* = 1 shl 1
|
||||
GLOBAL_ALL* = GLOBAL_SSL or GLOBAL_WIN32
|
||||
GLOBAL_DEFAULT* = GLOBAL_ALL
|
||||
INFO_DOUBLE* = 0x00300000
|
||||
INFO_HTTP_CODE* = INFO_RESPONSE_CODE
|
||||
INFO_LONG* = 0x00200000
|
||||
INFO_MASK* = 0x000FFFFF
|
||||
INFO_SLIST* = 0x00400000
|
||||
INFO_STRING* = 0x00100000
|
||||
INFO_TYPEMASK* = 0x00F00000
|
||||
IPRESOLVE_V4* = 1
|
||||
IPRESOLVE_V6* = 2
|
||||
IPRESOLVE_WHATEVER* = 0
|
||||
MAX_WRITE_SIZE* = 16384
|
||||
M_CALL_MULTI_SOCKET* = M_CALL_MULTI_PERFORM
|
||||
OPT_CLOSEFUNCTION* = - (5)
|
||||
OPT_FTPASCII* = OPT_TRANSFERTEXT
|
||||
OPT_HEADERDATA* = OPT_WRITEHEADER
|
||||
OPT_HTTPREQUEST* = - (1)
|
||||
OPT_MUTE* = - (2)
|
||||
OPT_PASSWDDATA* = - (4)
|
||||
OPT_PASSWDFUNCTION* = - (3)
|
||||
OPT_PASV_HOST* = - (9)
|
||||
OPT_READDATA* = OPT_INFILE
|
||||
OPT_SOURCE_HOST* = - (6)
|
||||
OPT_SOURCE_PATH* = - (7)
|
||||
OPT_SOURCE_PORT* = - (8)
|
||||
OPTTYPE_FUNCTIONPOINT* = 20000
|
||||
OPTTYPE_LONG* = 0
|
||||
OPTTYPE_OBJECTPOINT* = 10000
|
||||
OPTTYPE_OFF_T* = 30000
|
||||
OPT_WRITEDATA* = OPT_FILE
|
||||
POLL_IN* = 1
|
||||
POLL_INOUT* = 3
|
||||
POLL_NONE* = 0
|
||||
POLL_OUT* = 2
|
||||
POLL_REMOVE* = 4
|
||||
READFUNC_ABORT* = 0x10000000
|
||||
SOCKET_BAD* = - (1)
|
||||
SOCKET_TIMEOUT* = SOCKET_BAD
|
||||
VERSION_ASYNCHDNS* = 1 shl 7
|
||||
VERSION_CONV* = 1 shl 12
|
||||
VERSION_DEBUG* = 1 shl 6
|
||||
VERSION_GSSNEGOTIATE* = 1 shl 5
|
||||
VERSION_IDN* = 1 shl 10
|
||||
VERSION_IPV6* = 1 shl 0
|
||||
VERSION_KERBEROS4* = 1 shl 1
|
||||
VERSION_LARGEFILE* = 1 shl 9
|
||||
VERSION_LIBZ* = 1 shl 3
|
||||
VERSION_NOW* = VERSION_THIRD
|
||||
VERSION_NTLM* = 1 shl 4
|
||||
VERSION_SPNEGO* = 1 shl 8
|
||||
VERSION_SSL* = 1 shl 2
|
||||
VERSION_SSPI* = 1 shl 11
|
||||
FILE_OFFSET_BITS* = 0
|
||||
FILESIZEBITS* = 0
|
||||
FUNCTIONPOINT* = OPTTYPE_FUNCTIONPOINT
|
||||
HTTPPOST_BUFFER* = 1 shl 4
|
||||
HTTPPOST_FILENAME* = 1 shl 0
|
||||
HTTPPOST_PTRBUFFER* = 1 shl 5
|
||||
HTTPPOST_PTRCONTENTS* = 1 shl 3
|
||||
HTTPPOST_PTRNAME* = 1 shl 2
|
||||
HTTPPOST_READFILE* = 1 shl 1
|
||||
LIBCURL_VERSION* = "7.15.5"
|
||||
LIBCURL_VERSION_MAJOR* = 7
|
||||
LIBCURL_VERSION_MINOR* = 15
|
||||
LIBCURL_VERSION_NUM* = 0x00070F05
|
||||
LIBCURL_VERSION_PATCH* = 5
|
||||
|
||||
proc strequal*(s1, s2: cstring): int32{.cdecl, dynlib: libname,
|
||||
importc: "curl_strequal".}
|
||||
proc strnequal*(s1, s2: cstring, n: int): int32{.cdecl, dynlib: libname,
|
||||
importc: "curl_strnequal".}
|
||||
proc formadd*(httppost, last_post: PPcurl_httppost): TFORMcode{.cdecl, varargs,
|
||||
dynlib: libname, importc: "curl_formadd".}
|
||||
proc formget*(form: Phttppost, arg: pointer, append: Tformget_callback): int32{.
|
||||
cdecl, dynlib: libname, importc: "curl_formget".}
|
||||
proc formfree*(form: Phttppost){.cdecl, dynlib: libname,
|
||||
importc: "curl_formfree".}
|
||||
proc getenv*(variable: cstring): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_getenv".}
|
||||
proc version*(): cstring{.cdecl, dynlib: libname, importc: "curl_version".}
|
||||
proc easy_escape*(handle: P, str: cstring, len: int32): cstring{.cdecl,
|
||||
dynlib: libname, importc: "curl_easy_escape".}
|
||||
proc escape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_escape".}
|
||||
proc easy_unescape*(handle: P, str: cstring, len: int32, outlength: var int32): cstring{.
|
||||
cdecl, dynlib: libname, importc: "curl_easy_unescape".}
|
||||
proc unescape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_unescape".}
|
||||
proc free*(p: pointer){.cdecl, dynlib: libname, importc: "curl_free".}
|
||||
proc global_init*(flags: int32): Tcode{.cdecl, dynlib: libname,
|
||||
importc: "curl_global_init".}
|
||||
proc global_init_mem*(flags: int32, m: Tmalloc_callback, f: Tfree_callback,
|
||||
r: Trealloc_callback, s: Tstrdup_callback,
|
||||
c: Tcalloc_callback): Tcode{.cdecl, dynlib: libname,
|
||||
importc: "curl_global_init_mem".}
|
||||
proc global_cleanup*(){.cdecl, dynlib: libname, importc: "curl_global_cleanup".}
|
||||
proc slist_append*(slist: Pslist, P: cstring): Pslist{.cdecl, dynlib: libname,
|
||||
importc: "curl_slist_append".}
|
||||
proc slist_free_all*(para1: Pslist){.cdecl, dynlib: libname,
|
||||
importc: "curl_slist_free_all".}
|
||||
proc getdate*(p: cstring, unused: ptr TTime): TTime{.cdecl, dynlib: libname,
|
||||
importc: "curl_getdate".}
|
||||
proc share_init*(): PSH{.cdecl, dynlib: libname, importc: "curl_share_init".}
|
||||
proc share_setopt*(para1: PSH, option: TSHoption): TSHcode{.cdecl, varargs,
|
||||
dynlib: libname, importc: "curl_share_setopt".}
|
||||
proc share_cleanup*(para1: PSH): TSHcode{.cdecl, dynlib: libname,
|
||||
importc: "curl_share_cleanup".}
|
||||
proc version_info*(para1: Tversion): Pversion_info_data{.cdecl, dynlib: libname,
|
||||
importc: "curl_version_info".}
|
||||
proc easy_strerror*(para1: Tcode): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_strerror".}
|
||||
proc share_strerror*(para1: TSHcode): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_share_strerror".}
|
||||
proc easy_init*(): P{.cdecl, dynlib: libname, importc: "curl_easy_init".}
|
||||
proc easy_setopt*(: P, option: Toption): Tcode{.cdecl, varargs, dynlib: libname,
|
||||
importc: "curl_easy_setopt".}
|
||||
proc easy_perform*(: P): Tcode{.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_perform".}
|
||||
proc easy_cleanup*(: P){.cdecl, dynlib: libname, importc: "curl_easy_cleanup".}
|
||||
proc easy_getinfo*(: P, info: TINFO): Tcode{.cdecl, varargs, dynlib: libname,
|
||||
importc: "curl_easy_getinfo".}
|
||||
proc easy_duphandle*(: P): P{.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_duphandle".}
|
||||
proc easy_reset*(: P){.cdecl, dynlib: libname, importc: "curl_easy_reset".}
|
||||
proc multi_init*(): PM{.cdecl, dynlib: libname, importc: "curl_multi_init".}
|
||||
proc multi_add_handle*(multi_handle: PM, handle: P): TMcode{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_add_handle".}
|
||||
proc multi_remove_handle*(multi_handle: PM, handle: P): TMcode{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_remove_handle".}
|
||||
proc multi_fdset*(multi_handle: PM, read_fd_set: Pfd_set, write_fd_set: Pfd_set,
|
||||
exc_fd_set: Pfd_set, max_fd: var int32): TMcode{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_fdset".}
|
||||
proc multi_perform*(multi_handle: PM, running_handles: var int32): TMcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_perform".}
|
||||
proc multi_cleanup*(multi_handle: PM): TMcode{.cdecl, dynlib: libname,
|
||||
importc: "curl_multi_cleanup".}
|
||||
proc multi_info_read*(multi_handle: PM, msgs_in_queue: var int32): PMsg{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_info_read".}
|
||||
proc multi_strerror*(para1: TMcode): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_multi_strerror".}
|
||||
proc multi_socket*(multi_handle: PM, s: Tsocket, running_handles: var int32): TMcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_socket".}
|
||||
proc multi_socket_all*(multi_handle: PM, running_handles: var int32): TMcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_socket_all".}
|
||||
proc multi_timeout*(multi_handle: PM, milliseconds: var int32): TMcode{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_timeout".}
|
||||
proc multi_setopt*(multi_handle: PM, option: TMoption): TMcode{.cdecl, varargs,
|
||||
dynlib: libname, importc: "curl_multi_setopt".}
|
||||
proc multi_assign*(multi_handle: PM, sockfd: Tsocket, sockp: pointer): TMcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_assign".}
|
||||
229
lib/newwrap/lua/lauxlib.nim
Normal file
229
lib/newwrap/lua/lauxlib.nim
Normal file
@@ -0,0 +1,229 @@
|
||||
#*****************************************************************************
|
||||
# * *
|
||||
# * File: lauxlib.pas *
|
||||
# * Authors: TeCGraf (C headers + actual Lua libraries) *
|
||||
# * Lavergne Thomas (original translation to Pascal) *
|
||||
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
|
||||
# * Description: Lua auxiliary library *
|
||||
# * *
|
||||
# *****************************************************************************
|
||||
#
|
||||
#** $Id: lauxlib.h,v 1.59 2003/03/18 12:25:32 roberto Exp $
|
||||
#** Auxiliary functions for building Lua libraries
|
||||
#** See Copyright Notice in lua.h
|
||||
#
|
||||
#
|
||||
#** Translated to pascal by Lavergne Thomas
|
||||
#** Notes :
|
||||
#** - Pointers type was prefixed with 'P'
|
||||
#** Bug reports :
|
||||
#** - thomas.lavergne@laposte.net
|
||||
#** In french or in english
|
||||
#
|
||||
|
||||
import
|
||||
lua
|
||||
|
||||
proc lua_pushstring*(L: Plua_State, s: string)
|
||||
# compatibilty macros
|
||||
proc getn*(L: Plua_State, n: int): int
|
||||
# calls lua_objlen
|
||||
proc setn*(L: Plua_State, t, n: int)
|
||||
# does nothing!
|
||||
type
|
||||
Treg*{.final.} = object
|
||||
name*: cstring
|
||||
func*: lua_CFunction
|
||||
|
||||
Preg* = ptr Treg
|
||||
|
||||
proc openlib*(L: Plua_State, libname: cstring, lr: Preg, nup: int){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_openlib".}
|
||||
proc register*(L: Plua_State, libname: cstring, lr: Preg){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_register".}
|
||||
proc getmetafield*(L: Plua_State, obj: int, e: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_getmetafield".}
|
||||
proc callmeta*(L: Plua_State, obj: int, e: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_callmeta".}
|
||||
proc typerror*(L: Plua_State, narg: int, tname: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_typerror".}
|
||||
proc argerror*(L: Plua_State, numarg: int, extramsg: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_argerror".}
|
||||
proc checklstring*(L: Plua_State, numArg: int, l_: Psize_t): cstring{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checklstring".}
|
||||
proc optlstring*(L: Plua_State, numArg: int, def: cstring, l_: Psize_t): cstring{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_optlstring".}
|
||||
proc checknumber*(L: Plua_State, numArg: int): lua_Number{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checknumber".}
|
||||
proc optnumber*(L: Plua_State, nArg: int, def: lua_Number): lua_Number{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_optnumber".}
|
||||
proc checkinteger*(L: Plua_State, numArg: int): lua_Integer{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checkinteger".}
|
||||
proc optinteger*(L: Plua_State, nArg: int, def: lua_Integer): lua_Integer{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_optinteger".}
|
||||
proc checkstack*(L: Plua_State, sz: int, msg: cstring){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checkstack".}
|
||||
proc checktype*(L: Plua_State, narg, t: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_checktype".}
|
||||
proc checkany*(L: Plua_State, narg: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_checkany".}
|
||||
proc newmetatable*(L: Plua_State, tname: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_newmetatable".}
|
||||
proc checkudata*(L: Plua_State, ud: int, tname: cstring): Pointer{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_checkudata".}
|
||||
proc where*(L: Plua_State, lvl: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_where".}
|
||||
proc error*(L: Plua_State, fmt: cstring): int{.cdecl, varargs,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_error".}
|
||||
proc checkoption*(L: Plua_State, narg: int, def: cstring, lst: cstringArray): int{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_checkoption".}
|
||||
proc ref*(L: Plua_State, t: int): int{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_ref".}
|
||||
proc unref*(L: Plua_State, t, theref: int){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_unref".}
|
||||
proc loadfile*(L: Plua_State, filename: cstring): int{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_loadfile".}
|
||||
proc loadbuffer*(L: Plua_State, buff: cstring, size: size_t, name: cstring): int{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_loadbuffer".}
|
||||
proc loadstring*(L: Plua_State, s: cstring): int{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_loadstring".}
|
||||
proc newstate*(): Plua_State{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_newstate".}
|
||||
proc lua_open*(): Plua_State
|
||||
# compatibility; moved from unit lua to lauxlib because it needs luaL_newstate
|
||||
#
|
||||
#** ===============================================================
|
||||
#** some useful macros
|
||||
#** ===============================================================
|
||||
#
|
||||
proc argcheck*(L: Plua_State, cond: bool, numarg: int, extramsg: cstring)
|
||||
proc checkstring*(L: Plua_State, n: int): cstring
|
||||
proc optstring*(L: Plua_State, n: int, d: cstring): cstring
|
||||
proc checkint*(L: Plua_State, n: int): int
|
||||
proc checklong*(L: Plua_State, n: int): int32
|
||||
proc optint*(L: Plua_State, n: int, d: float64): int
|
||||
proc optlong*(L: Plua_State, n: int, d: float64): int32
|
||||
proc typename*(L: Plua_State, i: int): cstring
|
||||
proc lua_dofile*(L: Plua_State, filename: cstring): int
|
||||
proc lua_dostring*(L: Plua_State, str: cstring): int
|
||||
proc lua_Lgetmetatable*(L: Plua_State, tname: cstring)
|
||||
# not translated:
|
||||
# #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
|
||||
#
|
||||
#** =======================================================
|
||||
#** Generic Buffer manipulation
|
||||
#** =======================================================
|
||||
#
|
||||
const # note: this is just arbitrary, as it related to the BUFSIZ defined in stdio.h ...
|
||||
BUFFERSIZE* = 4096
|
||||
|
||||
type
|
||||
Buffer*{.final.} = object
|
||||
p*: cstring # current position in buffer
|
||||
lvl*: int # number of strings in the stack (level)
|
||||
L*: Plua_State
|
||||
buffer*: array[0..BUFFERSIZE - 1, Char] # warning: see note above about LUAL_BUFFERSIZE
|
||||
|
||||
PBuffer* = ptr Buffer
|
||||
|
||||
proc addchar*(B: PBuffer, c: Char)
|
||||
# warning: see note above about LUAL_BUFFERSIZE
|
||||
# compatibility only (alias for luaL_addchar)
|
||||
proc putchar*(B: PBuffer, c: Char)
|
||||
# warning: see note above about LUAL_BUFFERSIZE
|
||||
proc addsize*(B: PBuffer, n: int)
|
||||
proc buffinit*(L: Plua_State, B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_buffinit".}
|
||||
proc prepbuffer*(B: PBuffer): cstring{.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_prepbuffer".}
|
||||
proc addlstring*(B: PBuffer, s: cstring, L: size_t){.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_addlstring".}
|
||||
proc addstring*(B: PBuffer, s: cstring){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_addstring".}
|
||||
proc addvalue*(B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_addvalue".}
|
||||
proc pushresult*(B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME,
|
||||
importc: "luaL_pushresult".}
|
||||
proc gsub*(L: Plua_State, s, p, r: cstring): cstring{.cdecl,
|
||||
dynlib: LUA_LIB_NAME, importc: "luaL_gsub".}
|
||||
proc findtable*(L: Plua_State, idx: int, fname: cstring, szhint: int): cstring{.
|
||||
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_findtable".}
|
||||
# compatibility with ref system
|
||||
# pre-defined references
|
||||
const
|
||||
LUA_NOREF* = - 2
|
||||
LUA_REFNIL* = - 1
|
||||
|
||||
proc lua_unref*(L: Plua_State, theref: int)
|
||||
proc lua_getref*(L: Plua_State, theref: int)
|
||||
#
|
||||
#** Compatibility macros and functions
|
||||
#
|
||||
# implementation
|
||||
|
||||
proc lua_pushstring(L: Plua_State, s: string) =
|
||||
lua_pushlstring(L, cstring(s), len(s))
|
||||
|
||||
proc getn(L: Plua_State, n: int): int =
|
||||
Result = lua_objlen(L, n)
|
||||
|
||||
proc setn(L: Plua_State, t, n: int) =
|
||||
# does nothing as this operation is deprecated
|
||||
nil
|
||||
|
||||
proc lua_open(): Plua_State =
|
||||
Result = newstate()
|
||||
|
||||
proc typename(L: Plua_State, i: int): cstring =
|
||||
Result = lua_typename(L, lua_type(L, i))
|
||||
|
||||
proc lua_dofile(L: Plua_State, filename: cstring): int =
|
||||
Result = loadfile(L, filename)
|
||||
if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
|
||||
|
||||
proc lua_dostring(L: Plua_State, str: cstring): int =
|
||||
Result = loadstring(L, str)
|
||||
if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
|
||||
|
||||
proc lua_Lgetmetatable(L: Plua_State, tname: cstring) =
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, tname)
|
||||
|
||||
proc argcheck(L: Plua_State, cond: bool, numarg: int, extramsg: cstring) =
|
||||
if not cond:
|
||||
discard argerror(L, numarg, extramsg)
|
||||
|
||||
proc checkstring(L: Plua_State, n: int): cstring =
|
||||
Result = checklstring(L, n, nil)
|
||||
|
||||
proc optstring(L: Plua_State, n: int, d: cstring): cstring =
|
||||
Result = optlstring(L, n, d, nil)
|
||||
|
||||
proc checkint(L: Plua_State, n: int): int =
|
||||
Result = toInt(checknumber(L, n))
|
||||
|
||||
proc checklong(L: Plua_State, n: int): int32 =
|
||||
Result = int32(ToInt(checknumber(L, n)))
|
||||
|
||||
proc optint(L: Plua_State, n: int, d: float64): int =
|
||||
Result = int(ToInt(optnumber(L, n, d)))
|
||||
|
||||
proc optlong(L: Plua_State, n: int, d: float64): int32 =
|
||||
Result = int32(ToInt(optnumber(L, n, d)))
|
||||
|
||||
proc addchar(B: PBuffer, c: Char) =
|
||||
if cast[int](addr((B.p))) < (cast[int](addr((B.buffer[0]))) + BUFFERSIZE):
|
||||
discard prepbuffer(B)
|
||||
B.p[1] = c
|
||||
B.p = cast[cstring](cast[int](B.p) + 1)
|
||||
|
||||
proc putchar(B: PBuffer, c: Char) =
|
||||
addchar(B, c)
|
||||
|
||||
proc addsize(B: PBuffer, n: int) =
|
||||
B.p = cast[cstring](cast[int](B.p) + n)
|
||||
|
||||
proc lua_unref(L: Plua_State, theref: int) =
|
||||
unref(L, LUA_REGISTRYINDEX, theref)
|
||||
|
||||
proc lua_getref(L: Plua_State, theref: int) =
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, theref)
|
||||
401
lib/newwrap/lua/lua.nim
Normal file
401
lib/newwrap/lua/lua.nim
Normal file
@@ -0,0 +1,401 @@
|
||||
#*****************************************************************************
|
||||
# * *
|
||||
# * File: lua.pas *
|
||||
# * Authors: TeCGraf (C headers + actual Lua libraries) *
|
||||
# * Lavergne Thomas (original translation to Pascal) *
|
||||
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
|
||||
# * Description: Basic Lua library *
|
||||
# * *
|
||||
# *****************************************************************************
|
||||
#
|
||||
#** $Id: lua.h,v 1.175 2003/03/18 12:31:39 roberto Exp $
|
||||
#** Lua - An Extensible Extension Language
|
||||
#** TeCGraf: Computer Graphics Technology Group, PUC-Rio, Brazil
|
||||
#** http://www.lua.org mailto:info@lua.org
|
||||
#** See Copyright Notice at the end of this file
|
||||
#
|
||||
#
|
||||
#** Updated to Lua 5.1.1 by Bram Kuijvenhoven (bram at kuijvenhoven dot net),
|
||||
#** Hexis BV (http://www.hexis.nl), the Netherlands
|
||||
#** Notes:
|
||||
#** - Only tested with FPC (FreePascal Compiler)
|
||||
#** - Using LuaBinaries styled DLL/SO names, which include version names
|
||||
#** - LUA_YIELD was suffixed by '_' for avoiding name collision
|
||||
#
|
||||
#
|
||||
#** Translated to pascal by Lavergne Thomas
|
||||
#** Notes :
|
||||
#** - Pointers type was prefixed with 'P'
|
||||
#** - lua_upvalueindex constant was transformed to function
|
||||
#** - Some compatibility function was isolated because with it you must have
|
||||
#** lualib.
|
||||
#** - LUA_VERSION was suffixed by '_' for avoiding name collision.
|
||||
#** Bug reports :
|
||||
#** - thomas.lavergne@laposte.net
|
||||
#** In french or in english
|
||||
#
|
||||
|
||||
when defined(MACOSX):
|
||||
const
|
||||
NAME* = "liblua(|5.2|5.1|5.0).dylib"
|
||||
LIB_NAME* = "liblua(|5.2|5.1|5.0).dylib"
|
||||
elif defined(UNIX):
|
||||
const
|
||||
NAME* = "liblua(|5.2|5.1|5.0).so(|.0)"
|
||||
LIB_NAME* = "liblua(|5.2|5.1|5.0).so(|.0)"
|
||||
else:
|
||||
const
|
||||
NAME* = "lua(|5.2|5.1|5.0).dll"
|
||||
LIB_NAME* = "lua(|5.2|5.1|5.0).dll"
|
||||
type
|
||||
size_t* = int
|
||||
Psize_t* = ptr size_t
|
||||
|
||||
const
|
||||
VERSION* = "Lua 5.1"
|
||||
RELEASE* = "Lua 5.1.1"
|
||||
VERSION_NUM* = 501
|
||||
COPYRIGHT* = "Copyright (C) 1994-2006 Lua.org, PUC-Rio"
|
||||
AUTHORS* = "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
|
||||
# option for multiple returns in `lua_pcall' and `lua_call'
|
||||
MULTRET* = - 1 #
|
||||
#** pseudo-indices
|
||||
#
|
||||
REGISTRYINDEX* = - 10000
|
||||
ENVIRONINDEX* = - 10001
|
||||
GLOBALSINDEX* = - 10002
|
||||
|
||||
proc upvalueindex*(I: int): int
|
||||
const # thread status; 0 is OK
|
||||
YIELD_* = 1
|
||||
ERRRUN* = 2
|
||||
ERRSYNTAX* = 3
|
||||
ERRMEM* = 4
|
||||
ERRERR* = 5
|
||||
|
||||
type
|
||||
PState* = Pointer
|
||||
CFunction* = proc (L: PState): int{.cdecl.}
|
||||
|
||||
#
|
||||
#** functions that read/write blocks when loading/dumping Lua chunks
|
||||
#
|
||||
|
||||
type
|
||||
Reader* = proc (L: PState, ud: Pointer, sz: Psize_t): cstring{.cdecl.}
|
||||
Writer* = proc (L: PState, p: Pointer, sz: size_t, ud: Pointer): int{.cdecl.}
|
||||
Alloc* = proc (ud, theptr: Pointer, osize, nsize: size_t){.cdecl.}
|
||||
|
||||
const
|
||||
TNONE* = - 1
|
||||
TNIL* = 0
|
||||
TBOOLEAN* = 1
|
||||
TLIGHTUSERDATA* = 2
|
||||
TNUMBER* = 3
|
||||
TSTRING* = 4
|
||||
TTABLE* = 5
|
||||
TFUNCTION* = 6
|
||||
TUSERDATA* = 7
|
||||
TTHREAD* = 8 # minimum Lua stack available to a C function
|
||||
MINSTACK* = 20
|
||||
|
||||
type # Type of Numbers in Lua
|
||||
Number* = float
|
||||
Integer* = int
|
||||
|
||||
proc newstate*(f: Alloc, ud: Pointer): PState{.cdecl, dynlib: NAME,
|
||||
importc: "lua_newstate".}
|
||||
proc close*(L: PState){.cdecl, dynlib: NAME, importc: "lua_close".}
|
||||
proc newthread*(L: PState): PState{.cdecl, dynlib: NAME,
|
||||
importc: "lua_newthread".}
|
||||
proc atpanic*(L: PState, panicf: CFunction): CFunction{.cdecl, dynlib: NAME,
|
||||
importc: "lua_atpanic".}
|
||||
proc gettop*(L: PState): int{.cdecl, dynlib: NAME, importc: "lua_gettop".}
|
||||
proc settop*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_settop".}
|
||||
proc pushvalue*(L: PState, Idx: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushvalue".}
|
||||
proc remove*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_remove".}
|
||||
proc insert*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_insert".}
|
||||
proc replace*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_replace".}
|
||||
proc checkstack*(L: PState, sz: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_checkstack".}
|
||||
proc xmove*(`from`, `to`: PState, n: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_xmove".}
|
||||
proc isnumber*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_isnumber".}
|
||||
proc isstring*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_isstring".}
|
||||
proc iscfunction*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_iscfunction".}
|
||||
proc isuserdata*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_isuserdata".}
|
||||
proc type*(L: PState, idx: int): int{.cdecl, dynlib: NAME, importc: "lua_type".}
|
||||
proc typename*(L: PState, tp: int): cstring{.cdecl, dynlib: NAME,
|
||||
importc: "lua_typename".}
|
||||
proc equal*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_equal".}
|
||||
proc rawequal*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_rawequal".}
|
||||
proc lessthan*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_lessthan".}
|
||||
proc tonumber*(L: PState, idx: int): Number{.cdecl, dynlib: NAME,
|
||||
importc: "lua_tonumber".}
|
||||
proc tointeger*(L: PState, idx: int): Integer{.cdecl, dynlib: NAME,
|
||||
importc: "lua_tointeger".}
|
||||
proc toboolean*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
|
||||
importc: "lua_toboolean".}
|
||||
proc tolstring*(L: PState, idx: int, length: Psize_t): cstring{.cdecl,
|
||||
dynlib: NAME, importc: "lua_tolstring".}
|
||||
proc objlen*(L: PState, idx: int): size_t{.cdecl, dynlib: NAME,
|
||||
importc: "lua_objlen".}
|
||||
proc tocfunction*(L: PState, idx: int): CFunction{.cdecl, dynlib: NAME,
|
||||
importc: "lua_tocfunction".}
|
||||
proc touserdata*(L: PState, idx: int): Pointer{.cdecl, dynlib: NAME,
|
||||
importc: "lua_touserdata".}
|
||||
proc tothread*(L: PState, idx: int): PState{.cdecl, dynlib: NAME,
|
||||
importc: "lua_tothread".}
|
||||
proc topointer*(L: PState, idx: int): Pointer{.cdecl, dynlib: NAME,
|
||||
importc: "lua_topointer".}
|
||||
proc pushnil*(L: PState){.cdecl, dynlib: NAME, importc: "lua_pushnil".}
|
||||
proc pushnumber*(L: PState, n: Number){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushnumber".}
|
||||
proc pushinteger*(L: PState, n: Integer){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushinteger".}
|
||||
proc pushlstring*(L: PState, s: cstring, l_: size_t){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushlstring".}
|
||||
proc pushstring*(L: PState, s: cstring){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushstring".}
|
||||
proc pushvfstring*(L: PState, fmt: cstring, argp: Pointer): cstring{.cdecl,
|
||||
dynlib: NAME, importc: "lua_pushvfstring".}
|
||||
proc pushfstring*(L: PState, fmt: cstring): cstring{.cdecl, varargs,
|
||||
dynlib: NAME, importc: "lua_pushfstring".}
|
||||
proc pushcclosure*(L: PState, fn: CFunction, n: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushcclosure".}
|
||||
proc pushboolean*(L: PState, b: cint){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushboolean".}
|
||||
proc pushlightuserdata*(L: PState, p: Pointer){.cdecl, dynlib: NAME,
|
||||
importc: "lua_pushlightuserdata".}
|
||||
proc pushthread*(L: PState){.cdecl, dynlib: NAME, importc: "lua_pushthread".}
|
||||
proc gettable*(L: PState, idx: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_gettable".}
|
||||
proc getfield*(L: Pstate, idx: int, k: cstring){.cdecl, dynlib: NAME,
|
||||
importc: "lua_getfield".}
|
||||
proc rawget*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_rawget".}
|
||||
proc rawgeti*(L: PState, idx, n: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_rawgeti".}
|
||||
proc createtable*(L: PState, narr, nrec: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_createtable".}
|
||||
proc newuserdata*(L: PState, sz: size_t): Pointer{.cdecl, dynlib: NAME,
|
||||
importc: "lua_newuserdata".}
|
||||
proc getmetatable*(L: PState, objindex: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_getmetatable".}
|
||||
proc getfenv*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_getfenv".}
|
||||
proc settable*(L: PState, idx: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_settable".}
|
||||
proc setfield*(L: PState, idx: int, k: cstring){.cdecl, dynlib: NAME,
|
||||
importc: "lua_setfield".}
|
||||
proc rawset*(L: PState, idx: int){.cdecl, dynlib: NAME, importc: "lua_rawset".}
|
||||
proc rawseti*(L: PState, idx, n: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_rawseti".}
|
||||
proc setmetatable*(L: PState, objindex: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_setmetatable".}
|
||||
proc setfenv*(L: PState, idx: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_setfenv".}
|
||||
proc call*(L: PState, nargs, nresults: int){.cdecl, dynlib: NAME,
|
||||
importc: "lua_call".}
|
||||
proc pcall*(L: PState, nargs, nresults, errf: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_pcall".}
|
||||
proc cpcall*(L: PState, func: CFunction, ud: Pointer): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_cpcall".}
|
||||
proc load*(L: PState, reader: Reader, dt: Pointer, chunkname: cstring): int{.
|
||||
cdecl, dynlib: NAME, importc: "lua_load".}
|
||||
proc dump*(L: PState, writer: Writer, data: Pointer): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_dump".}
|
||||
proc yield*(L: PState, nresults: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_yield".}
|
||||
proc resume*(L: PState, narg: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_resume".}
|
||||
proc status*(L: PState): int{.cdecl, dynlib: NAME, importc: "lua_status".}
|
||||
proc gc*(L: PState, what, data: int): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_gc".}
|
||||
proc error*(L: PState): int{.cdecl, dynlib: NAME, importc: "lua_error".}
|
||||
proc next*(L: PState, idx: int): int{.cdecl, dynlib: NAME, importc: "lua_next".}
|
||||
proc concat*(L: PState, n: int){.cdecl, dynlib: NAME, importc: "lua_concat".}
|
||||
proc getallocf*(L: PState, ud: ptr Pointer): Alloc{.cdecl, dynlib: NAME,
|
||||
importc: "lua_getallocf".}
|
||||
proc setallocf*(L: PState, f: Alloc, ud: Pointer){.cdecl, dynlib: NAME,
|
||||
importc: "lua_setallocf".}
|
||||
#
|
||||
#** Garbage-collection functions and options
|
||||
#
|
||||
|
||||
const
|
||||
GCSTOP* = 0
|
||||
GCRESTART* = 1
|
||||
GCCOLLECT* = 2
|
||||
GCCOUNT* = 3
|
||||
GCCOUNTB* = 4
|
||||
GCSTEP* = 5
|
||||
GCSETPAUSE* = 6
|
||||
GCSETSTEPMUL* = 7
|
||||
|
||||
#
|
||||
#** ===============================================================
|
||||
#** some useful macros
|
||||
#** ===============================================================
|
||||
#
|
||||
|
||||
proc pop*(L: PState, n: int)
|
||||
proc newtable*(L: Pstate)
|
||||
proc register*(L: PState, n: cstring, f: CFunction)
|
||||
proc pushcfunction*(L: PState, f: CFunction)
|
||||
proc strlen*(L: Pstate, i: int): size_t
|
||||
proc isfunction*(L: PState, n: int): bool
|
||||
proc istable*(L: PState, n: int): bool
|
||||
proc islightuserdata*(L: PState, n: int): bool
|
||||
proc isnil*(L: PState, n: int): bool
|
||||
proc isboolean*(L: PState, n: int): bool
|
||||
proc isthread*(L: PState, n: int): bool
|
||||
proc isnone*(L: PState, n: int): bool
|
||||
proc isnoneornil*(L: PState, n: int): bool
|
||||
proc pushliteral*(L: PState, s: cstring)
|
||||
proc setglobal*(L: PState, s: cstring)
|
||||
proc getglobal*(L: PState, s: cstring)
|
||||
proc tostring*(L: PState, i: int): cstring
|
||||
#
|
||||
#** compatibility macros and functions
|
||||
#
|
||||
|
||||
proc getregistry*(L: PState)
|
||||
proc getgccount*(L: PState): int
|
||||
type
|
||||
Chunkreader* = Reader
|
||||
Chunkwriter* = Writer
|
||||
|
||||
#
|
||||
#** ======================================================================
|
||||
#** Debug API
|
||||
#** ======================================================================
|
||||
#
|
||||
|
||||
const
|
||||
HOOKCALL* = 0
|
||||
HOOKRET* = 1
|
||||
HOOKLINE* = 2
|
||||
HOOKCOUNT* = 3
|
||||
HOOKTAILRET* = 4
|
||||
|
||||
const
|
||||
MASKCALL* = 1 shl Ord(HOOKCALL)
|
||||
MASKRET* = 1 shl Ord(HOOKRET)
|
||||
MASKLINE* = 1 shl Ord(HOOKLINE)
|
||||
MASKCOUNT* = 1 shl Ord(HOOKCOUNT)
|
||||
|
||||
const
|
||||
IDSIZE* = 60
|
||||
|
||||
type
|
||||
Debug*{.final.} = object # activation record
|
||||
event*: int
|
||||
name*: cstring # (n)
|
||||
namewhat*: cstring # (n) `global', `local', `field', `method'
|
||||
what*: cstring # (S) `Lua', `C', `main', `tail'
|
||||
source*: cstring # (S)
|
||||
currentline*: int # (l)
|
||||
nups*: int # (u) number of upvalues
|
||||
linedefined*: int # (S)
|
||||
lastlinedefined*: int # (S)
|
||||
short_src*: array[0..IDSIZE - 1, Char] # (S)
|
||||
# private part
|
||||
i_ci*: int # active function
|
||||
|
||||
PDebug* = ptr Debug
|
||||
Hook* = proc (L: PState, ar: PDebug){.cdecl.}
|
||||
|
||||
#
|
||||
#** ======================================================================
|
||||
#** Debug API
|
||||
#** ======================================================================
|
||||
#
|
||||
|
||||
proc getstack*(L: PState, level: int, ar: PDebug): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_getstack".}
|
||||
proc getinfo*(L: PState, what: cstring, ar: PDebug): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_getinfo".}
|
||||
proc getlocal*(L: PState, ar: PDebug, n: int): cstring{.cdecl, dynlib: NAME,
|
||||
importc: "lua_getlocal".}
|
||||
proc setlocal*(L: PState, ar: PDebug, n: int): cstring{.cdecl, dynlib: NAME,
|
||||
importc: "lua_setlocal".}
|
||||
proc getupvalue*(L: PState, funcindex: int, n: int): cstring{.cdecl,
|
||||
dynlib: NAME, importc: "lua_getupvalue".}
|
||||
proc setupvalue*(L: PState, funcindex: int, n: int): cstring{.cdecl,
|
||||
dynlib: NAME, importc: "lua_setupvalue".}
|
||||
proc sethook*(L: PState, func: Hook, mask: int, count: int): int{.cdecl,
|
||||
dynlib: NAME, importc: "lua_sethook".}
|
||||
proc gethook*(L: PState): Hook{.cdecl, dynlib: NAME, importc: "lua_gethook".}
|
||||
proc gethookmask*(L: PState): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_gethookmask".}
|
||||
proc gethookcount*(L: PState): int{.cdecl, dynlib: NAME,
|
||||
importc: "lua_gethookcount".}
|
||||
# implementation
|
||||
|
||||
proc upvalueindex(I: int): int =
|
||||
Result = GLOBALSINDEX - i
|
||||
|
||||
proc pop(L: PState, n: int) =
|
||||
settop(L, - n - 1)
|
||||
|
||||
proc newtable(L: PState) =
|
||||
createtable(L, 0, 0)
|
||||
|
||||
proc register(L: PState, n: cstring, f: CFunction) =
|
||||
pushcfunction(L, f)
|
||||
setglobal(L, n)
|
||||
|
||||
proc pushcfunction(L: PState, f: CFunction) =
|
||||
pushcclosure(L, f, 0)
|
||||
|
||||
proc strlen(L: PState, i: int): size_t =
|
||||
Result = objlen(L, i)
|
||||
|
||||
proc isfunction(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TFUNCTION
|
||||
|
||||
proc istable(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TTABLE
|
||||
|
||||
proc islightuserdata(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TLIGHTUSERDATA
|
||||
|
||||
proc isnil(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TNIL
|
||||
|
||||
proc isboolean(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TBOOLEAN
|
||||
|
||||
proc isthread(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TTHREAD
|
||||
|
||||
proc isnone(L: PState, n: int): bool =
|
||||
Result = type(L, n) == TNONE
|
||||
|
||||
proc isnoneornil(L: PState, n: int): bool =
|
||||
Result = type(L, n) <= 0
|
||||
|
||||
proc pushliteral(L: PState, s: cstring) =
|
||||
pushlstring(L, s, len(s))
|
||||
|
||||
proc setglobal(L: PState, s: cstring) =
|
||||
setfield(L, GLOBALSINDEX, s)
|
||||
|
||||
proc getglobal(L: PState, s: cstring) =
|
||||
getfield(L, GLOBALSINDEX, s)
|
||||
|
||||
proc tostring(L: PState, i: int): cstring =
|
||||
Result = tolstring(L, i, nil)
|
||||
|
||||
proc getregistry(L: PState) =
|
||||
pushvalue(L, REGISTRYINDEX)
|
||||
|
||||
proc getgccount(L: PState): int =
|
||||
Result = gc(L, GCCOUNT, 0)
|
||||
74
lib/newwrap/lua/lualib.nim
Normal file
74
lib/newwrap/lua/lualib.nim
Normal file
@@ -0,0 +1,74 @@
|
||||
#*****************************************************************************
|
||||
# * *
|
||||
# * File: lualib.pas *
|
||||
# * Authors: TeCGraf (C headers + actual Lua libraries) *
|
||||
# * Lavergne Thomas (original translation to Pascal) *
|
||||
# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) *
|
||||
# * Description: Standard Lua libraries *
|
||||
# * *
|
||||
# *****************************************************************************
|
||||
#
|
||||
#** $Id: lualib.h,v 1.28 2003/03/18 12:24:26 roberto Exp $
|
||||
#** Lua standard libraries
|
||||
#** See Copyright Notice in lua.h
|
||||
#
|
||||
#
|
||||
#** Translated to pascal by Lavergne Thomas
|
||||
#** Bug reports :
|
||||
#** - thomas.lavergne@laposte.net
|
||||
#** In french or in english
|
||||
#
|
||||
|
||||
import
|
||||
|
||||
|
||||
const
|
||||
COLIBNAME* = "coroutine"
|
||||
TABLIBNAME* = "table"
|
||||
IOLIBNAME* = "io"
|
||||
OSLIBNAME* = "os"
|
||||
STRLINAME* = "string"
|
||||
MATHLIBNAME* = "math"
|
||||
DBLIBNAME* = "debug"
|
||||
LOADLIBNAME* = "package"
|
||||
|
||||
proc open_base*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaopen_base".}
|
||||
proc open_table*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaopen_table".}
|
||||
proc open_io*(L: PState): cint{.cdecl, dynlib: LIB_NAME, importc: "luaopen_io".}
|
||||
proc open_string*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaopen_string".}
|
||||
proc open_math*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaopen_math".}
|
||||
proc open_debug*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaopen_debug".}
|
||||
proc open_package*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
|
||||
importc: "luaopen_package".}
|
||||
proc L_openlibs*(L: PState){.cdecl, dynlib: LIB_NAME, importc: "luaL_openlibs".}
|
||||
# compatibility code
|
||||
proc baselibopen*(L: PState): Bool
|
||||
proc tablibopen*(L: PState): Bool
|
||||
proc iolibopen*(L: PState): Bool
|
||||
proc strlibopen*(L: PState): Bool
|
||||
proc mathlibopen*(L: PState): Bool
|
||||
proc dblibopen*(L: PState): Bool
|
||||
# implementation
|
||||
|
||||
proc baselibopen(L: PState): Bool =
|
||||
Result = open_base(L) != 0'i32
|
||||
|
||||
proc tablibopen(L: PState): Bool =
|
||||
Result = open_table(L) != 0'i32
|
||||
|
||||
proc iolibopen(L: PState): Bool =
|
||||
Result = open_io(L) != 0'i32
|
||||
|
||||
proc strlibopen(L: PState): Bool =
|
||||
Result = open_string(L) != 0'i32
|
||||
|
||||
proc mathlibopen(L: PState): Bool =
|
||||
Result = open_math(L) != 0'i32
|
||||
|
||||
proc dblibopen(L: PState): Bool =
|
||||
Result = open_debug(L) != 0'i32
|
||||
1082
lib/newwrap/mysql.nim
Normal file
1082
lib/newwrap/mysql.nim
Normal file
File diff suppressed because it is too large
Load Diff
1536
lib/newwrap/opengl/gl.nim
Normal file
1536
lib/newwrap/opengl/gl.nim
Normal file
File diff suppressed because it is too large
Load Diff
4673
lib/newwrap/opengl/glext.nim
Normal file
4673
lib/newwrap/opengl/glext.nim
Normal file
File diff suppressed because it is too large
Load Diff
329
lib/newwrap/opengl/glu.nim
Normal file
329
lib/newwrap/opengl/glu.nim
Normal file
@@ -0,0 +1,329 @@
|
||||
#
|
||||
#
|
||||
# Adaption of the delphi3d.net OpenGL units to FreePascal
|
||||
# Sebastian Guenther (sg@freepascal.org) in 2002
|
||||
# These units are free to use
|
||||
#******************************************************************************
|
||||
# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
|
||||
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
GL
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
dllname = "glu32.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"
|
||||
else:
|
||||
const
|
||||
dllname = "libGLU.so.1"
|
||||
type
|
||||
TViewPortArray* = array[0..3, TGLint]
|
||||
T16dArray* = array[0..15, TGLdouble]
|
||||
TCallBack* = proc ()
|
||||
T3dArray* = array[0..2, TGLdouble]
|
||||
T4pArray* = array[0..3, Pointer]
|
||||
T4fArray* = array[0..3, TGLfloat]
|
||||
PPointer* = ptr Pointer
|
||||
|
||||
type
|
||||
GLUnurbs*{.final.} = object
|
||||
PGLUnurbs* = ptr GLUnurbs
|
||||
GLUquadric*{.final.} = object
|
||||
PGLUquadric* = ptr GLUquadric
|
||||
GLUtesselator*{.final.} = object
|
||||
PGLUtesselator* = ptr GLUtesselator # backwards compatibility:
|
||||
GLUnurbsObj* = GLUnurbs
|
||||
PGLUnurbsObj* = PGLUnurbs
|
||||
GLUquadricObj* = GLUquadric
|
||||
PGLUquadricObj* = PGLUquadric
|
||||
GLUtesselatorObj* = GLUtesselator
|
||||
PGLUtesselatorObj* = PGLUtesselator
|
||||
GLUtriangulatorObj* = GLUtesselator
|
||||
PGLUtriangulatorObj* = PGLUtesselator
|
||||
TGLUnurbs* = GLUnurbs
|
||||
TGLUquadric* = GLUquadric
|
||||
TGLUtesselator* = GLUtesselator
|
||||
TGLUnurbsObj* = GLUnurbsObj
|
||||
TGLUquadricObj* = GLUquadricObj
|
||||
TGLUtesselatorObj* = GLUtesselatorObj
|
||||
TGLUtriangulatorObj* = GLUtriangulatorObj
|
||||
|
||||
proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname,
|
||||
importc: "gluErrorString".}
|
||||
proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname,
|
||||
importc: "gluErrorUnicodeStringEXT".}
|
||||
proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname,
|
||||
importc: "gluGetString".}
|
||||
proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname,
|
||||
importc: "gluOrtho2D".}
|
||||
proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname,
|
||||
importc: "gluPerspective".}
|
||||
proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){.
|
||||
dynlib: dllname, importc: "gluPickMatrix".}
|
||||
proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){.
|
||||
dynlib: dllname, importc: "gluLookAt".}
|
||||
proc gluProject*(objx, objy, objz: TGLdouble,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{.
|
||||
dynlib: dllname, importc: "gluProject".}
|
||||
proc gluUnProject*(winx, winy, winz: TGLdouble,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{.
|
||||
dynlib: dllname, importc: "gluUnProject".}
|
||||
proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum,
|
||||
datain: Pointer, widthout, heightout: TGLint,
|
||||
typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname,
|
||||
importc: "gluScaleImage".}
|
||||
proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint,
|
||||
format, atype: TGLenum, data: Pointer): int{.
|
||||
dynlib: dllname, importc: "gluBuild1DMipmaps".}
|
||||
proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint,
|
||||
format, atype: TGLenum, data: Pointer): int{.
|
||||
dynlib: dllname, importc: "gluBuild2DMipmaps".}
|
||||
proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc: "gluNewQuadric".}
|
||||
proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname,
|
||||
importc: "gluDeleteQuadric".}
|
||||
proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){.
|
||||
dynlib: dllname, importc: "gluQuadricNormals".}
|
||||
proc gluQuadricTexture*(quadObject: PGLUquadric, textureCoords: TGLboolean){.
|
||||
dynlib: dllname, importc: "gluQuadricTexture".}
|
||||
proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){.
|
||||
dynlib: dllname, importc: "gluQuadricOrientation".}
|
||||
proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){.
|
||||
dynlib: dllname, importc: "gluQuadricDrawStyle".}
|
||||
proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble,
|
||||
slices, stacks: TGLint){.dynlib: dllname,
|
||||
importc: "gluCylinder".}
|
||||
proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
|
||||
slices, loops: TGLint){.dynlib: dllname, importc: "gluDisk".}
|
||||
proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
|
||||
slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){.
|
||||
dynlib: dllname, importc: "gluPartialDisk".}
|
||||
proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){.
|
||||
dynlib: dllname, importc: "gluSphere".}
|
||||
proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){.
|
||||
dynlib: dllname, importc: "gluQuadricCallback".}
|
||||
proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc: "gluNewTess".}
|
||||
proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluDeleteTess".}
|
||||
proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){.
|
||||
dynlib: dllname, importc: "gluTessBeginPolygon".}
|
||||
proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluTessBeginContour".}
|
||||
proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){.
|
||||
dynlib: dllname, importc: "gluTessVertex".}
|
||||
proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluTessEndContour".}
|
||||
proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluTessEndPolygon".}
|
||||
proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){.
|
||||
dynlib: dllname, importc: "gluTessProperty".}
|
||||
proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname,
|
||||
importc: "gluTessNormal".}
|
||||
proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){.
|
||||
dynlib: dllname, importc: "gluTessCallback".}
|
||||
proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){.
|
||||
dynlib: dllname, importc: "gluGetTessProperty".}
|
||||
proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname,
|
||||
importc: "gluNewNurbsRenderer".}
|
||||
proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname,
|
||||
importc: "gluDeleteNurbsRenderer".}
|
||||
proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname,
|
||||
importc: "gluBeginSurface".}
|
||||
proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginCurve".}
|
||||
proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndCurve".}
|
||||
proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndSurface".}
|
||||
proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginTrim".}
|
||||
proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndTrim".}
|
||||
proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat,
|
||||
stride: TGLint, atype: TGLenum){.dynlib: dllname,
|
||||
importc: "gluPwlCurve".}
|
||||
proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat,
|
||||
stride: TGLint, ctlarray: PGLfloat, order: TGLint,
|
||||
atype: TGLenum){.dynlib: dllname, importc: "gluNurbsCurve".}
|
||||
proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat,
|
||||
tknot_count: TGLint, tknot: PGLfloat,
|
||||
s_stride, t_stride: TGLint, ctlarray: PGLfloat,
|
||||
sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname,
|
||||
importc: "gluNurbsSurface".}
|
||||
proc gluLoadSamplingMatrices*(nobj: PGLUnurbs,
|
||||
modelMatrix, projMatrix: var T16dArray,
|
||||
viewport: var TViewPortArray){.dynlib: dllname,
|
||||
importc: "gluLoadSamplingMatrices".}
|
||||
proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){.
|
||||
dynlib: dllname, importc: "gluNurbsProperty".}
|
||||
proc gluGetNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: PGLfloat){.
|
||||
dynlib: dllname, importc: "gluGetNurbsProperty".}
|
||||
proc gluNurbsCallback*(nobj: PGLUnurbs, which: TGLenum, fn: TCallBack){.
|
||||
dynlib: dllname, importc: "gluNurbsCallback".}
|
||||
#*** Callback function prototypes ***
|
||||
type # gluQuadricCallback
|
||||
GLUquadricErrorProc* = proc (p: TGLenum) # gluTessCallback
|
||||
GLUtessBeginProc* = proc (p: TGLenum)
|
||||
GLUtessEdgeFlagProc* = proc (p: TGLboolean)
|
||||
GLUtessVertexProc* = proc (p: Pointer)
|
||||
GLUtessEndProc* = proc ()
|
||||
GLUtessErrorProc* = proc (p: TGLenum)
|
||||
GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray,
|
||||
p4: PPointer)
|
||||
GLUtessBeginDataProc* = proc (p1: TGLenum, p2: Pointer)
|
||||
GLUtessEdgeFlagDataProc* = proc (p1: TGLboolean, p2: Pointer)
|
||||
GLUtessVertexDataProc* = proc (p1, p2: Pointer)
|
||||
GLUtessEndDataProc* = proc (p: Pointer)
|
||||
GLUtessErrorDataProc* = proc (p1: TGLenum, p2: Pointer)
|
||||
GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray,
|
||||
p3: var T4fArray, p4: PPointer, p5: Pointer) #
|
||||
#
|
||||
# gluNurbsCallback
|
||||
GLUnurbsErrorProc* = proc (p: TGLenum) #*** Generic constants ****/
|
||||
|
||||
const # Version
|
||||
GLU_VERSION_1_1* = 1
|
||||
GLU_VERSION_1_2* = 1 # Errors: (return value 0 = no error)
|
||||
GLU_INVALID_ENUM* = 100900
|
||||
GLU_INVALID_VALUE* = 100901
|
||||
GLU_OUT_OF_MEMORY* = 100902
|
||||
GLU_INCOMPATIBLE_GL_VERSION* = 100903 # StringName
|
||||
GLU_VERSION* = 100800
|
||||
GLU_EXTENSIONS* = 100801 # Boolean
|
||||
GLU_TRUE* = GL_TRUE
|
||||
GLU_FALSE* = GL_FALSE #*** Quadric constants ****/
|
||||
# QuadricNormal
|
||||
GLU_SMOOTH* = 100000
|
||||
GLU_FLAT* = 100001
|
||||
GLU_NONE* = 100002 # QuadricDrawStyle
|
||||
GLU_POINT* = 100010
|
||||
GLU_LINE* = 100011
|
||||
GLU_FILL* = 100012
|
||||
GLU_SILHOUETTE* = 100013 # QuadricOrientation
|
||||
GLU_OUTSIDE* = 100020
|
||||
GLU_INSIDE* = 100021 # Callback types:
|
||||
# GLU_ERROR = 100103;
|
||||
#*** Tesselation constants ****/
|
||||
GLU_TESS_MAX_COORD* = 1.00000e+150 # TessProperty
|
||||
GLU_TESS_WINDING_RULE* = 100140
|
||||
GLU_TESS_BOUNDARY_ONLY* = 100141
|
||||
GLU_TESS_TOLERANCE* = 100142 # TessWinding
|
||||
GLU_TESS_WINDING_ODD* = 100130
|
||||
GLU_TESS_WINDING_NONZERO* = 100131
|
||||
GLU_TESS_WINDING_POSITIVE* = 100132
|
||||
GLU_TESS_WINDING_NEGATIVE* = 100133
|
||||
GLU_TESS_WINDING_ABS_GEQ_TWO* = 100134 # TessCallback
|
||||
GLU_TESS_BEGIN* = 100100 # void (CALLBACK*)(TGLenum type)
|
||||
constGLU_TESS_VERTEX* = 100101 # void (CALLBACK*)(void *data)
|
||||
GLU_TESS_END* = 100102 # void (CALLBACK*)(void)
|
||||
GLU_TESS_ERROR* = 100103 # void (CALLBACK*)(TGLenum errno)
|
||||
GLU_TESS_EDGE_FLAG* = 100104 # void (CALLBACK*)(TGLboolean boundaryEdge)
|
||||
GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(TGLdouble coords[3],
|
||||
# void *data[4],
|
||||
# TGLfloat weight[4],
|
||||
# void **dataOut)
|
||||
GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(TGLenum type,
|
||||
# void *polygon_data)
|
||||
GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data,
|
||||
# void *polygon_data)
|
||||
GLU_TESS_END_DATA* = 100108 # void (CALLBACK*)(void *polygon_data)
|
||||
GLU_TESS_ERROR_DATA* = 100109 # void (CALLBACK*)(TGLenum errno,
|
||||
# void *polygon_data)
|
||||
GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(TGLboolean boundaryEdge,
|
||||
# void *polygon_data)
|
||||
GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(TGLdouble coords[3],
|
||||
# void *data[4],
|
||||
# TGLfloat weight[4],
|
||||
# void **dataOut,
|
||||
# void *polygon_data)
|
||||
# TessError
|
||||
GLU_TESS_ERROR1* = 100151
|
||||
GLU_TESS_ERROR2* = 100152
|
||||
GLU_TESS_ERROR3* = 100153
|
||||
GLU_TESS_ERROR4* = 100154
|
||||
GLU_TESS_ERROR5* = 100155
|
||||
GLU_TESS_ERROR6* = 100156
|
||||
GLU_TESS_ERROR7* = 100157
|
||||
GLU_TESS_ERROR8* = 100158
|
||||
GLU_TESS_MISSING_BEGIN_POLYGON* = GLU_TESS_ERROR1
|
||||
GLU_TESS_MISSING_BEGIN_CONTOUR* = GLU_TESS_ERROR2
|
||||
GLU_TESS_MISSING_END_POLYGON* = GLU_TESS_ERROR3
|
||||
GLU_TESS_MISSING_END_CONTOUR* = GLU_TESS_ERROR4
|
||||
GLU_TESS_COORD_TOO_LARGE* = GLU_TESS_ERROR5
|
||||
GLU_TESS_NEED_COMBINE_CALLBACK* = GLU_TESS_ERROR6 #*** NURBS constants ****/
|
||||
# NurbsProperty
|
||||
GLU_AUTO_LOAD_MATRIX* = 100200
|
||||
GLU_CULLING* = 100201
|
||||
GLU_SAMPLING_TOLERANCE* = 100203
|
||||
GLU_DISPLAY_MODE* = 100204
|
||||
GLU_PARAMETRIC_TOLERANCE* = 100202
|
||||
GLU_SAMPLING_METHOD* = 100205
|
||||
GLU_U_STEP* = 100206
|
||||
GLU_V_STEP* = 100207 # NurbsSampling
|
||||
GLU_PATH_LENGTH* = 100215
|
||||
GLU_PARAMETRIC_ERROR* = 100216
|
||||
GLU_DOMAIN_DISTANCE* = 100217 # NurbsTrim
|
||||
GLU_MAP1_TRIM_2* = 100210
|
||||
GLU_MAP1_TRIM_3* = 100211 # NurbsDisplay
|
||||
# GLU_FILL = 100012;
|
||||
GLU_OUTLINE_POLYGON* = 100240
|
||||
GLU_OUTLINE_PATCH* = 100241 # NurbsCallback
|
||||
# GLU_ERROR = 100103;
|
||||
# NurbsErrors
|
||||
GLU_NURBS_ERROR1* = 100251
|
||||
GLU_NURBS_ERROR2* = 100252
|
||||
GLU_NURBS_ERROR3* = 100253
|
||||
GLU_NURBS_ERROR4* = 100254
|
||||
GLU_NURBS_ERROR5* = 100255
|
||||
GLU_NURBS_ERROR6* = 100256
|
||||
GLU_NURBS_ERROR7* = 100257
|
||||
GLU_NURBS_ERROR8* = 100258
|
||||
GLU_NURBS_ERROR9* = 100259
|
||||
GLU_NURBS_ERROR10* = 100260
|
||||
GLU_NURBS_ERROR11* = 100261
|
||||
GLU_NURBS_ERROR12* = 100262
|
||||
GLU_NURBS_ERROR13* = 100263
|
||||
GLU_NURBS_ERROR14* = 100264
|
||||
GLU_NURBS_ERROR15* = 100265
|
||||
GLU_NURBS_ERROR16* = 100266
|
||||
GLU_NURBS_ERROR17* = 100267
|
||||
GLU_NURBS_ERROR18* = 100268
|
||||
GLU_NURBS_ERROR19* = 100269
|
||||
GLU_NURBS_ERROR20* = 100270
|
||||
GLU_NURBS_ERROR21* = 100271
|
||||
GLU_NURBS_ERROR22* = 100272
|
||||
GLU_NURBS_ERROR23* = 100273
|
||||
GLU_NURBS_ERROR24* = 100274
|
||||
GLU_NURBS_ERROR25* = 100275
|
||||
GLU_NURBS_ERROR26* = 100276
|
||||
GLU_NURBS_ERROR27* = 100277
|
||||
GLU_NURBS_ERROR28* = 100278
|
||||
GLU_NURBS_ERROR29* = 100279
|
||||
GLU_NURBS_ERROR30* = 100280
|
||||
GLU_NURBS_ERROR31* = 100281
|
||||
GLU_NURBS_ERROR32* = 100282
|
||||
GLU_NURBS_ERROR33* = 100283
|
||||
GLU_NURBS_ERROR34* = 100284
|
||||
GLU_NURBS_ERROR35* = 100285
|
||||
GLU_NURBS_ERROR36* = 100286
|
||||
GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/
|
||||
|
||||
proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluBeginPolygon".}
|
||||
proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname,
|
||||
importc: "gluNextContour".}
|
||||
proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
|
||||
importc: "gluEndPolygon".}
|
||||
const # Contours types -- obsolete!
|
||||
GLU_CW* = 100120
|
||||
GLU_CCW* = 100121
|
||||
GLU_INTERIOR* = 100122
|
||||
GLU_EXTERIOR* = 100123
|
||||
GLU_UNKNOWN* = 100124 # Names without "TESS_" prefix
|
||||
GLU_BEGIN* = GLU_TESS_BEGIN
|
||||
GLU_VERTEX* = constGLU_TESS_VERTEX
|
||||
GLU_END* = GLU_TESS_END
|
||||
GLU_ERROR* = GLU_TESS_ERROR
|
||||
GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG
|
||||
|
||||
# implementation
|
||||
432
lib/newwrap/opengl/glut.nim
Normal file
432
lib/newwrap/opengl/glut.nim
Normal file
@@ -0,0 +1,432 @@
|
||||
#
|
||||
#
|
||||
# Adaption of the delphi3d.net OpenGL units to FreePascal
|
||||
# Sebastian Guenther (sg@freepascal.org) in 2002
|
||||
# These units are free to use
|
||||
#
|
||||
|
||||
# Copyright (c) Mark J. Kilgard, 1994, 1995, 1996.
|
||||
# This program is freely distributable without licensing fees and is
|
||||
# provided without guarantee or warrantee expressed or implied. This
|
||||
# program is -not- in the public domain.
|
||||
#******************************************************************************
|
||||
# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
|
||||
# Contributions by Igor Karpov (glygrik@hotbox.ru)
|
||||
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
GL
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
dllname = "glut32.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllname = "/System/Library/Frameworks/GLUT.framework/GLUT"
|
||||
else:
|
||||
const
|
||||
dllname = "libglut.so.3"
|
||||
type
|
||||
PInteger* = ptr int
|
||||
PPChar* = ptr cstring
|
||||
TGlutVoidCallback* = proc (){.cdecl.}
|
||||
TGlut1IntCallback* = proc (value: cint){.cdecl.}
|
||||
TGlut2IntCallback* = proc (v1, v2: cint){.cdecl.}
|
||||
TGlut3IntCallback* = proc (v1, v2, v3: cint){.cdecl.}
|
||||
TGlut4IntCallback* = proc (v1, v2, v3, v4: cint){.cdecl.}
|
||||
TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.}
|
||||
TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.}
|
||||
|
||||
const
|
||||
GLUT_API_VERSION* = 3
|
||||
GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks.
|
||||
GLUT_RGB* = 0
|
||||
GLUT_RGBA* = GLUT_RGB
|
||||
GLUT_INDEX* = 1
|
||||
GLUT_SINGLE* = 0
|
||||
GLUT_DOUBLE* = 2
|
||||
GLUT_ACCUM* = 4
|
||||
GLUT_ALPHA* = 8
|
||||
GLUT_DEPTH* = 16
|
||||
GLUT_STENCIL* = 32
|
||||
GLUT_MULTISAMPLE* = 128
|
||||
GLUT_STEREO* = 256
|
||||
GLUT_LUMINANCE* = 512 # Mouse buttons.
|
||||
GLUT_LEFT_BUTTON* = 0
|
||||
GLUT_MIDDLE_BUTTON* = 1
|
||||
GLUT_RIGHT_BUTTON* = 2 # Mouse button state.
|
||||
GLUT_DOWN* = 0
|
||||
GLUT_UP* = 1 # function keys
|
||||
GLUT_KEY_F1* = 1
|
||||
GLUT_KEY_F2* = 2
|
||||
GLUT_KEY_F3* = 3
|
||||
GLUT_KEY_F4* = 4
|
||||
GLUT_KEY_F5* = 5
|
||||
GLUT_KEY_F6* = 6
|
||||
GLUT_KEY_F7* = 7
|
||||
GLUT_KEY_F8* = 8
|
||||
GLUT_KEY_F9* = 9
|
||||
GLUT_KEY_F10* = 10
|
||||
GLUT_KEY_F11* = 11
|
||||
GLUT_KEY_F12* = 12 # directional keys
|
||||
GLUT_KEY_LEFT* = 100
|
||||
GLUT_KEY_UP* = 101
|
||||
GLUT_KEY_RIGHT* = 102
|
||||
GLUT_KEY_DOWN* = 103
|
||||
GLUT_KEY_PAGE_UP* = 104
|
||||
GLUT_KEY_PAGE_DOWN* = 105
|
||||
GLUT_KEY_HOME* = 106
|
||||
GLUT_KEY_END* = 107
|
||||
GLUT_KEY_INSERT* = 108 # Entry/exit state.
|
||||
GLUT_LEFT* = 0
|
||||
GLUT_ENTERED* = 1 # Menu usage state.
|
||||
GLUT_MENU_NOT_IN_USE* = 0
|
||||
GLUT_MENU_IN_USE* = 1 # Visibility state.
|
||||
GLUT_NOT_VISIBLE* = 0
|
||||
GLUT_VISIBLE* = 1 # Window status state.
|
||||
GLUT_HIDDEN* = 0
|
||||
GLUT_FULLY_RETAINED* = 1
|
||||
GLUT_PARTIALLY_RETAINED* = 2
|
||||
GLUT_FULLY_COVERED* = 3 # Color index component selection values.
|
||||
GLUT_RED* = 0
|
||||
GLUT_GREEN* = 1
|
||||
GLUT_BLUE* = 2 # Layers for use.
|
||||
GLUT_NORMAL* = 0
|
||||
GLUT_OVERLAY* = 1
|
||||
|
||||
when defined(Windows):
|
||||
const # Stroke font constants (use these in GLUT program).
|
||||
GLUT_STROKE_ROMAN* = cast[Pointer](0)
|
||||
GLUT_STROKE_MONO_ROMAN* = cast[Pointer](1) # Bitmap font constants (use these in GLUT program).
|
||||
GLUT_BITMAP_9_BY_15* = cast[Pointer](2)
|
||||
GLUT_BITMAP_8_BY_13* = cast[Pointer](3)
|
||||
GLUT_BITMAP_TIMES_ROMAN_10* = cast[Pointer](4)
|
||||
GLUT_BITMAP_TIMES_ROMAN_24* = cast[Pointer](5)
|
||||
GLUT_BITMAP_HELVETICA_10* = cast[Pointer](6)
|
||||
GLUT_BITMAP_HELVETICA_12* = cast[Pointer](7)
|
||||
GLUT_BITMAP_HELVETICA_18* = cast[Pointer](8)
|
||||
else:
|
||||
var # Stroke font constants (use these in GLUT program).
|
||||
GLUT_STROKE_ROMAN*: Pointer
|
||||
GLUT_STROKE_MONO_ROMAN*: Pointer # Bitmap font constants (use these in GLUT program).
|
||||
GLUT_BITMAP_9_BY_15*: Pointer
|
||||
GLUT_BITMAP_8_BY_13*: Pointer
|
||||
GLUT_BITMAP_TIMES_ROMAN_10*: Pointer
|
||||
GLUT_BITMAP_TIMES_ROMAN_24*: Pointer
|
||||
GLUT_BITMAP_HELVETICA_10*: Pointer
|
||||
GLUT_BITMAP_HELVETICA_12*: Pointer
|
||||
GLUT_BITMAP_HELVETICA_18*: Pointer
|
||||
const # glutGet parameters.
|
||||
GLUT_WINDOW_X* = 100
|
||||
GLUT_WINDOW_Y* = 101
|
||||
GLUT_WINDOW_WIDTH* = 102
|
||||
GLUT_WINDOW_HEIGHT* = 103
|
||||
GLUT_WINDOW_BUFFER_SIZE* = 104
|
||||
GLUT_WINDOW_STENCIL_SIZE* = 105
|
||||
GLUT_WINDOW_DEPTH_SIZE* = 106
|
||||
GLUT_WINDOW_RED_SIZE* = 107
|
||||
GLUT_WINDOW_GREEN_SIZE* = 108
|
||||
GLUT_WINDOW_BLUE_SIZE* = 109
|
||||
GLUT_WINDOW_ALPHA_SIZE* = 110
|
||||
GLUT_WINDOW_ACCUM_RED_SIZE* = 111
|
||||
GLUT_WINDOW_ACCUM_GREEN_SIZE* = 112
|
||||
GLUT_WINDOW_ACCUM_BLUE_SIZE* = 113
|
||||
GLUT_WINDOW_ACCUM_ALPHA_SIZE* = 114
|
||||
GLUT_WINDOW_DOUBLEBUFFER* = 115
|
||||
GLUT_WINDOW_RGBA* = 116
|
||||
GLUT_WINDOW_PARENT* = 117
|
||||
GLUT_WINDOW_NUM_CHILDREN* = 118
|
||||
GLUT_WINDOW_COLORMAP_SIZE* = 119
|
||||
GLUT_WINDOW_NUM_SAMPLES* = 120
|
||||
GLUT_WINDOW_STEREO* = 121
|
||||
GLUT_WINDOW_CURSOR* = 122
|
||||
GLUT_SCREEN_WIDTH* = 200
|
||||
GLUT_SCREEN_HEIGHT* = 201
|
||||
GLUT_SCREEN_WIDTH_MM* = 202
|
||||
GLUT_SCREEN_HEIGHT_MM* = 203
|
||||
GLUT_MENU_NUM_ITEMS* = 300
|
||||
GLUT_DISPLAY_MODE_POSSIBLE* = 400
|
||||
GLUT_INIT_WINDOW_X* = 500
|
||||
GLUT_INIT_WINDOW_Y* = 501
|
||||
GLUT_INIT_WINDOW_WIDTH* = 502
|
||||
GLUT_INIT_WINDOW_HEIGHT* = 503
|
||||
constGLUT_INIT_DISPLAY_MODE* = 504
|
||||
GLUT_ELAPSED_TIME* = 700
|
||||
GLUT_WINDOW_FORMAT_ID* = 123 # glutDeviceGet parameters.
|
||||
GLUT_HAS_KEYBOARD* = 600
|
||||
GLUT_HAS_MOUSE* = 601
|
||||
GLUT_HAS_SPACEBALL* = 602
|
||||
GLUT_HAS_DIAL_AND_BUTTON_BOX* = 603
|
||||
GLUT_HAS_TABLET* = 604
|
||||
GLUT_NUM_MOUSE_BUTTONS* = 605
|
||||
GLUT_NUM_SPACEBALL_BUTTONS* = 606
|
||||
GLUT_NUM_BUTTON_BOX_BUTTONS* = 607
|
||||
GLUT_NUM_DIALS* = 608
|
||||
GLUT_NUM_TABLET_BUTTONS* = 609
|
||||
GLUT_DEVICE_IGNORE_KEY_REPEAT* = 610
|
||||
GLUT_DEVICE_KEY_REPEAT* = 611
|
||||
GLUT_HAS_JOYSTICK* = 612
|
||||
GLUT_OWNS_JOYSTICK* = 613
|
||||
GLUT_JOYSTICK_BUTTONS* = 614
|
||||
GLUT_JOYSTICK_AXES* = 615
|
||||
GLUT_JOYSTICK_POLL_RATE* = 616 # glutLayerGet parameters.
|
||||
GLUT_OVERLAY_POSSIBLE* = 800
|
||||
GLUT_LAYER_IN_USE* = 801
|
||||
GLUT_HAS_OVERLAY* = 802
|
||||
GLUT_TRANSPARENT_INDEX* = 803
|
||||
GLUT_NORMAL_DAMAGED* = 804
|
||||
GLUT_OVERLAY_DAMAGED* = 805 # glutVideoResizeGet parameters.
|
||||
GLUT_VIDEO_RESIZE_POSSIBLE* = 900
|
||||
GLUT_VIDEO_RESIZE_IN_USE* = 901
|
||||
GLUT_VIDEO_RESIZE_X_DELTA* = 902
|
||||
GLUT_VIDEO_RESIZE_Y_DELTA* = 903
|
||||
GLUT_VIDEO_RESIZE_WIDTH_DELTA* = 904
|
||||
GLUT_VIDEO_RESIZE_HEIGHT_DELTA* = 905
|
||||
GLUT_VIDEO_RESIZE_X* = 906
|
||||
GLUT_VIDEO_RESIZE_Y* = 907
|
||||
GLUT_VIDEO_RESIZE_WIDTH* = 908
|
||||
GLUT_VIDEO_RESIZE_HEIGHT* = 909 # glutGetModifiers return mask.
|
||||
GLUT_ACTIVE_SHIFT* = 1
|
||||
GLUT_ACTIVE_CTRL* = 2
|
||||
GLUT_ACTIVE_ALT* = 4 # glutSetCursor parameters.
|
||||
# Basic arrows.
|
||||
GLUT_CURSOR_RIGHT_ARROW* = 0
|
||||
GLUT_CURSOR_LEFT_ARROW* = 1 # Symbolic cursor shapes.
|
||||
GLUT_CURSOR_INFO* = 2
|
||||
GLUT_CURSOR_DESTROY* = 3
|
||||
GLUT_CURSOR_HELP* = 4
|
||||
GLUT_CURSOR_CYCLE* = 5
|
||||
GLUT_CURSOR_SPRAY* = 6
|
||||
GLUT_CURSOR_WAIT* = 7
|
||||
GLUT_CURSOR_TEXT* = 8
|
||||
GLUT_CURSOR_CROSSHAIR* = 9 # Directional cursors.
|
||||
GLUT_CURSOR_UP_DOWN* = 10
|
||||
GLUT_CURSOR_LEFT_RIGHT* = 11 # Sizing cursors.
|
||||
GLUT_CURSOR_TOP_SIDE* = 12
|
||||
GLUT_CURSOR_BOTTOM_SIDE* = 13
|
||||
GLUT_CURSOR_LEFT_SIDE* = 14
|
||||
GLUT_CURSOR_RIGHT_SIDE* = 15
|
||||
GLUT_CURSOR_TOP_LEFT_CORNER* = 16
|
||||
GLUT_CURSOR_TOP_RIGHT_CORNER* = 17
|
||||
GLUT_CURSOR_BOTTOM_RIGHT_CORNER* = 18
|
||||
GLUT_CURSOR_BOTTOM_LEFT_CORNER* = 19 # Inherit from parent window.
|
||||
GLUT_CURSOR_INHERIT* = 100 # Blank cursor.
|
||||
GLUT_CURSOR_NONE* = 101 # Fullscreen crosshair (if available).
|
||||
GLUT_CURSOR_FULL_CROSSHAIR* = 102 # GLUT device control sub-API.
|
||||
# glutSetKeyRepeat modes.
|
||||
GLUT_KEY_REPEAT_OFF* = 0
|
||||
GLUT_KEY_REPEAT_ON* = 1
|
||||
GLUT_KEY_REPEAT_DEFAULT* = 2 # Joystick button masks.
|
||||
GLUT_JOYSTICK_BUTTON_A* = 1
|
||||
GLUT_JOYSTICK_BUTTON_B* = 2
|
||||
GLUT_JOYSTICK_BUTTON_C* = 4
|
||||
GLUT_JOYSTICK_BUTTON_D* = 8 # GLUT game mode sub-API.
|
||||
# glutGameModeGet.
|
||||
GLUT_GAME_MODE_ACTIVE* = 0
|
||||
GLUT_GAME_MODE_POSSIBLE* = 1
|
||||
GLUT_GAME_MODE_WIDTH* = 2
|
||||
GLUT_GAME_MODE_HEIGHT* = 3
|
||||
GLUT_GAME_MODE_PIXEL_DEPTH* = 4
|
||||
GLUT_GAME_MODE_REFRESH_RATE* = 5
|
||||
GLUT_GAME_MODE_DISPLAY_CHANGED* = 6 # GLUT initialization sub-API.
|
||||
|
||||
proc glutInit*(argcp: PInteger, argv: PPChar){.dynlib: dllname,
|
||||
importc: "glutInit".}
|
||||
proc glutInitDisplayMode*(mode: int16){.dynlib: dllname,
|
||||
importc: "glutInitDisplayMode".}
|
||||
proc glutInitDisplayString*(str: cstring){.dynlib: dllname,
|
||||
importc: "glutInitDisplayString".}
|
||||
proc glutInitWindowPosition*(x, y: int){.dynlib: dllname,
|
||||
importc: "glutInitWindowPosition".}
|
||||
proc glutInitWindowSize*(width, height: int){.dynlib: dllname,
|
||||
importc: "glutInitWindowSize".}
|
||||
proc glutMainLoop*(){.dynlib: dllname, importc: "glutMainLoop".}
|
||||
# GLUT window sub-API.
|
||||
proc glutCreateWindow*(title: cstring): int{.dynlib: dllname,
|
||||
importc: "glutCreateWindow".}
|
||||
proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname,
|
||||
importc: "glutCreateSubWindow".}
|
||||
proc glutDestroyWindow*(win: int){.dynlib: dllname, importc: "glutDestroyWindow".}
|
||||
proc glutPostRedisplay*(){.dynlib: dllname, importc: "glutPostRedisplay".}
|
||||
proc glutPostWindowRedisplay*(win: int){.dynlib: dllname,
|
||||
importc: "glutPostWindowRedisplay".}
|
||||
proc glutSwapBuffers*(){.dynlib: dllname, importc: "glutSwapBuffers".}
|
||||
proc glutGetWindow*(): int{.dynlib: dllname, importc: "glutGetWindow".}
|
||||
proc glutSetWindow*(win: int){.dynlib: dllname, importc: "glutSetWindow".}
|
||||
proc glutSetWindowTitle*(title: cstring){.dynlib: dllname,
|
||||
importc: "glutSetWindowTitle".}
|
||||
proc glutSetIconTitle*(title: cstring){.dynlib: dllname,
|
||||
importc: "glutSetIconTitle".}
|
||||
proc glutPositionWindow*(x, y: int){.dynlib: dllname,
|
||||
importc: "glutPositionWindow".}
|
||||
proc glutReshapeWindow*(width, height: int){.dynlib: dllname,
|
||||
importc: "glutReshapeWindow".}
|
||||
proc glutPopWindow*(){.dynlib: dllname, importc: "glutPopWindow".}
|
||||
proc glutPushWindow*(){.dynlib: dllname, importc: "glutPushWindow".}
|
||||
proc glutIconifyWindow*(){.dynlib: dllname, importc: "glutIconifyWindow".}
|
||||
proc glutShowWindow*(){.dynlib: dllname, importc: "glutShowWindow".}
|
||||
proc glutHideWindow*(){.dynlib: dllname, importc: "glutHideWindow".}
|
||||
proc glutFullScreen*(){.dynlib: dllname, importc: "glutFullScreen".}
|
||||
proc glutSetCursor*(cursor: int){.dynlib: dllname, importc: "glutSetCursor".}
|
||||
proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc: "glutWarpPointer".}
|
||||
# GLUT overlay sub-API.
|
||||
proc glutEstablishOverlay*(){.dynlib: dllname, importc: "glutEstablishOverlay".}
|
||||
proc glutRemoveOverlay*(){.dynlib: dllname, importc: "glutRemoveOverlay".}
|
||||
proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc: "glutUseLayer".}
|
||||
proc glutPostOverlayRedisplay*(){.dynlib: dllname,
|
||||
importc: "glutPostOverlayRedisplay".}
|
||||
proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname,
|
||||
importc: "glutPostWindowOverlayRedisplay".}
|
||||
proc glutShowOverlay*(){.dynlib: dllname, importc: "glutShowOverlay".}
|
||||
proc glutHideOverlay*(){.dynlib: dllname, importc: "glutHideOverlay".}
|
||||
# GLUT menu sub-API.
|
||||
proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname,
|
||||
importc: "glutCreateMenu".}
|
||||
proc glutDestroyMenu*(menu: int){.dynlib: dllname, importc: "glutDestroyMenu".}
|
||||
proc glutGetMenu*(): int{.dynlib: dllname, importc: "glutGetMenu".}
|
||||
proc glutSetMenu*(menu: int){.dynlib: dllname, importc: "glutSetMenu".}
|
||||
proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname,
|
||||
importc: "glutAddMenuEntry".}
|
||||
proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname,
|
||||
importc: "glutAddSubMenu".}
|
||||
proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int){.
|
||||
dynlib: dllname, importc: "glutChangeToMenuEntry".}
|
||||
proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int){.
|
||||
dynlib: dllname, importc: "glutChangeToSubMenu".}
|
||||
proc glutRemoveMenuItem*(item: int){.dynlib: dllname,
|
||||
importc: "glutRemoveMenuItem".}
|
||||
proc glutAttachMenu*(button: int){.dynlib: dllname, importc: "glutAttachMenu".}
|
||||
proc glutDetachMenu*(button: int){.dynlib: dllname, importc: "glutDetachMenu".}
|
||||
# GLUT window callback sub-API.
|
||||
proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
importc: "glutDisplayFunc".}
|
||||
proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutReshapeFunc".}
|
||||
proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname,
|
||||
importc: "glutKeyboardFunc".}
|
||||
proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname,
|
||||
importc: "glutMouseFunc".}
|
||||
proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutMotionFunc".}
|
||||
proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutPassiveMotionFunc".}
|
||||
proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
importc: "glutEntryFunc".}
|
||||
proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
importc: "glutVisibilityFunc".}
|
||||
proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
importc: "glutIdleFunc".}
|
||||
proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int){.
|
||||
dynlib: dllname, importc: "glutTimerFunc".}
|
||||
proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
importc: "glutMenuStateFunc".}
|
||||
proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpecialFunc".}
|
||||
proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpaceballMotionFunc".}
|
||||
proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpaceballRotateFunc".}
|
||||
proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpaceballButtonFunc".}
|
||||
proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutButtonBoxFunc".}
|
||||
proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutDialsFunc".}
|
||||
proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname,
|
||||
importc: "glutTabletMotionFunc".}
|
||||
proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname,
|
||||
importc: "glutTabletButtonFunc".}
|
||||
proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutMenuStatusFunc".}
|
||||
proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname,
|
||||
importc: "glutOverlayDisplayFunc".}
|
||||
proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname,
|
||||
importc: "glutWindowStatusFunc".}
|
||||
proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname,
|
||||
importc: "glutKeyboardUpFunc".}
|
||||
proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname,
|
||||
importc: "glutSpecialUpFunc".}
|
||||
proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int){.
|
||||
dynlib: dllname, importc: "glutJoystickFunc".}
|
||||
# GLUT color index sub-API.
|
||||
proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname,
|
||||
importc: "glutSetColor".}
|
||||
proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname,
|
||||
importc: "glutGetColor".}
|
||||
proc glutCopyColormap*(win: int){.dynlib: dllname, importc: "glutCopyColormap".}
|
||||
# GLUT state retrieval sub-API.
|
||||
proc glutGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutGet".}
|
||||
proc glutDeviceGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutDeviceGet".}
|
||||
# GLUT extension support sub-API
|
||||
proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname,
|
||||
importc: "glutExtensionSupported".}
|
||||
proc glutGetModifiers*(): int{.dynlib: dllname, importc: "glutGetModifiers".}
|
||||
proc glutLayerGet*(t: TGLenum): int{.dynlib: dllname, importc: "glutLayerGet".}
|
||||
# GLUT font sub-API
|
||||
proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname,
|
||||
importc: "glutBitmapCharacter".}
|
||||
proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname,
|
||||
importc: "glutBitmapWidth".}
|
||||
proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname,
|
||||
importc: "glutStrokeCharacter".}
|
||||
proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname,
|
||||
importc: "glutStrokeWidth".}
|
||||
proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname,
|
||||
importc: "glutBitmapLength".}
|
||||
proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname,
|
||||
importc: "glutStrokeLength".}
|
||||
# GLUT pre-built models sub-API
|
||||
proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){.
|
||||
dynlib: dllname, importc: "glutWireSphere".}
|
||||
proc glutSolidSphere*(radius: TGLdouble, slices, stacks: TGLint){.
|
||||
dynlib: dllname, importc: "glutSolidSphere".}
|
||||
proc glutWireCone*(base, height: TGLdouble, slices, stacks: TGLint){.
|
||||
dynlib: dllname, importc: "glutWireCone".}
|
||||
proc glutSolidCone*(base, height: TGLdouble, slices, stacks: TGLint){.
|
||||
dynlib: dllname, importc: "glutSolidCone".}
|
||||
proc glutWireCube*(size: TGLdouble){.dynlib: dllname, importc: "glutWireCube".}
|
||||
proc glutSolidCube*(size: TGLdouble){.dynlib: dllname, importc: "glutSolidCube".}
|
||||
proc glutWireTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
|
||||
dynlib: dllname, importc: "glutWireTorus".}
|
||||
proc glutSolidTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){.
|
||||
dynlib: dllname, importc: "glutSolidTorus".}
|
||||
proc glutWireDodecahedron*(){.dynlib: dllname, importc: "glutWireDodecahedron".}
|
||||
proc glutSolidDodecahedron*(){.dynlib: dllname, importc: "glutSolidDodecahedron".}
|
||||
proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname,
|
||||
importc: "glutWireTeapot".}
|
||||
proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname,
|
||||
importc: "glutSolidTeapot".}
|
||||
proc glutWireOctahedron*(){.dynlib: dllname, importc: "glutWireOctahedron".}
|
||||
proc glutSolidOctahedron*(){.dynlib: dllname, importc: "glutSolidOctahedron".}
|
||||
proc glutWireTetrahedron*(){.dynlib: dllname, importc: "glutWireTetrahedron".}
|
||||
proc glutSolidTetrahedron*(){.dynlib: dllname, importc: "glutSolidTetrahedron".}
|
||||
proc glutWireIcosahedron*(){.dynlib: dllname, importc: "glutWireIcosahedron".}
|
||||
proc glutSolidIcosahedron*(){.dynlib: dllname, importc: "glutSolidIcosahedron".}
|
||||
# GLUT video resize sub-API.
|
||||
proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname,
|
||||
importc: "glutVideoResizeGet".}
|
||||
proc glutSetupVideoResizing*(){.dynlib: dllname,
|
||||
importc: "glutSetupVideoResizing".}
|
||||
proc glutStopVideoResizing*(){.dynlib: dllname, importc: "glutStopVideoResizing".}
|
||||
proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname,
|
||||
importc: "glutVideoResize".}
|
||||
proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname,
|
||||
importc: "glutVideoPan".}
|
||||
# GLUT debugging sub-API.
|
||||
proc glutReportErrors*(){.dynlib: dllname, importc: "glutReportErrors".}
|
||||
# GLUT device control sub-API.
|
||||
proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname,
|
||||
importc: "glutIgnoreKeyRepeat".}
|
||||
proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname,
|
||||
importc: "glutSetKeyRepeat".}
|
||||
proc glutForceJoystickFunc*(){.dynlib: dllname, importc: "glutForceJoystickFunc".}
|
||||
# GLUT game mode sub-API.
|
||||
#example glutGameModeString('1280x1024:32@75');
|
||||
proc glutGameModeString*(AString: cstring){.dynlib: dllname,
|
||||
importc: "glutGameModeString".}
|
||||
proc glutEnterGameMode*(): int{.dynlib: dllname, importc: "glutEnterGameMode".}
|
||||
proc glutLeaveGameMode*(){.dynlib: dllname, importc: "glutLeaveGameMode".}
|
||||
proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname,
|
||||
importc: "glutGameModeGet".}
|
||||
# implementation
|
||||
153
lib/newwrap/opengl/glx.nim
Normal file
153
lib/newwrap/opengl/glx.nim
Normal file
@@ -0,0 +1,153 @@
|
||||
#
|
||||
#
|
||||
# Translation of the Mesa GLX headers for FreePascal
|
||||
# Copyright (C) 1999 Sebastian Guenther
|
||||
#
|
||||
#
|
||||
# Mesa 3-D graphics library
|
||||
# Version: 3.0
|
||||
# Copyright (C) 1995-1998 Brian Paul
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
|
||||
import
|
||||
X, XLib, XUtil, gl
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
dllname = "GL.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllname = "/usr/X11R6/lib/libGL.dylib"
|
||||
else:
|
||||
const
|
||||
dllname = "libGL.so"
|
||||
const
|
||||
GLX_USE_GL* = 1
|
||||
GLX_BUFFER_SIZE* = 2
|
||||
GLX_LEVEL* = 3
|
||||
GLX_RGBA* = 4
|
||||
GLX_DOUBLEBUFFER* = 5
|
||||
GLX_STEREO* = 6
|
||||
GLX_AUX_BUFFERS* = 7
|
||||
GLX_RED_SIZE* = 8
|
||||
GLX_GREEN_SIZE* = 9
|
||||
GLX_BLUE_SIZE* = 10
|
||||
GLX_ALPHA_SIZE* = 11
|
||||
GLX_DEPTH_SIZE* = 12
|
||||
GLX_STENCIL_SIZE* = 13
|
||||
GLX_ACCUM_RED_SIZE* = 14
|
||||
GLX_ACCUM_GREEN_SIZE* = 15
|
||||
GLX_ACCUM_BLUE_SIZE* = 16
|
||||
GLX_ACCUM_ALPHA_SIZE* = 17 # GLX_EXT_visual_info extension
|
||||
GLX_X_VISUAL_TYPE_EXT* = 0x00000022
|
||||
GLX_TRANSPARENT_TYPE_EXT* = 0x00000023
|
||||
GLX_TRANSPARENT_INDEX_VALUE_EXT* = 0x00000024
|
||||
GLX_TRANSPARENT_RED_VALUE_EXT* = 0x00000025
|
||||
GLX_TRANSPARENT_GREEN_VALUE_EXT* = 0x00000026
|
||||
GLX_TRANSPARENT_BLUE_VALUE_EXT* = 0x00000027
|
||||
GLX_TRANSPARENT_ALPHA_VALUE_EXT* = 0x00000028 # Error codes returned by glXGetConfig:
|
||||
GLX_BAD_SCREEN* = 1
|
||||
GLX_BAD_ATTRIBUTE* = 2
|
||||
GLX_NO_EXTENSION* = 3
|
||||
GLX_BAD_VISUAL* = 4
|
||||
GLX_BAD_CONTEXT* = 5
|
||||
GLX_BAD_VALUE* = 6
|
||||
GLX_BAD_ENUM* = 7 # GLX 1.1 and later:
|
||||
GLX_VENDOR* = 1
|
||||
GLX_VERSION* = 2
|
||||
GLX_EXTENSIONS* = 3 # GLX_visual_info extension
|
||||
GLX_TRUE_COLOR_EXT* = 0x00008002
|
||||
GLX_DIRECT_COLOR_EXT* = 0x00008003
|
||||
GLX_PSEUDO_COLOR_EXT* = 0x00008004
|
||||
GLX_STATIC_COLOR_EXT* = 0x00008005
|
||||
GLX_GRAY_SCALE_EXT* = 0x00008006
|
||||
GLX_STATIC_GRAY_EXT* = 0x00008007
|
||||
GLX_NONE_EXT* = 0x00008000
|
||||
GLX_TRANSPARENT_RGB_EXT* = 0x00008008
|
||||
GLX_TRANSPARENT_INDEX_EXT* = 0x00008009
|
||||
|
||||
type # From XLib:
|
||||
XPixmap* = TXID
|
||||
XFont* = TXID
|
||||
XColormap* = TXID
|
||||
GLXContext* = Pointer
|
||||
GLXPixmap* = TXID
|
||||
GLXDrawable* = TXID
|
||||
GLXContextID* = TXID
|
||||
TXPixmap* = XPixmap
|
||||
TXFont* = XFont
|
||||
TXColormap* = XColormap
|
||||
TGLXContext* = GLXContext
|
||||
TGLXPixmap* = GLXPixmap
|
||||
TGLXDrawable* = GLXDrawable
|
||||
TGLXContextID* = GLXContextID
|
||||
|
||||
proc glXChooseVisual*(dpy: PDisplay, screen: int, attribList: ptr int32): PXVisualInfo{.
|
||||
cdecl, dynlib: dllname, importc: "glXChooseVisual".}
|
||||
proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext,
|
||||
direct: bool): GLXContext{.cdecl, dynlib: dllname,
|
||||
importc: "glXCreateContext".}
|
||||
proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname,
|
||||
importc: "glXDestroyContext".}
|
||||
proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{.
|
||||
cdecl, dynlib: dllname, importc: "glXMakeCurrent".}
|
||||
proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl,
|
||||
dynlib: dllname, importc: "glXCopyContext".}
|
||||
proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl,
|
||||
dynlib: dllname, importc: "glXSwapBuffers".}
|
||||
proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{.
|
||||
cdecl, dynlib: dllname, importc: "glXCreateGLXPixmap".}
|
||||
proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl,
|
||||
dynlib: dllname, importc: "glXDestroyGLXPixmap".}
|
||||
proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl,
|
||||
dynlib: dllname, importc: "glXQueryExtension".}
|
||||
proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl,
|
||||
dynlib: dllname, importc: "glXQueryVersion".}
|
||||
proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname,
|
||||
importc: "glXIsDirect".}
|
||||
proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int,
|
||||
value: var int): int{.cdecl, dynlib: dllname,
|
||||
importc: "glXGetConfig".}
|
||||
proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname,
|
||||
importc: "glXGetCurrentContext".}
|
||||
proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname,
|
||||
importc: "glXGetCurrentDrawable".}
|
||||
proc glXWaitGL*(){.cdecl, dynlib: dllname, importc: "glXWaitGL".}
|
||||
proc glXWaitX*(){.cdecl, dynlib: dllname, importc: "glXWaitX".}
|
||||
proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname,
|
||||
importc: "glXUseXFont".}
|
||||
# GLX 1.1 and later
|
||||
proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc: "glXQueryExtensionsString".}
|
||||
proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc: "glXQueryServerString".}
|
||||
proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl,
|
||||
dynlib: dllname, importc: "glXGetClientString".}
|
||||
# Mesa GLX Extensions
|
||||
proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo,
|
||||
pixmap: XPixmap, cmap: XColormap): GLXPixmap{.
|
||||
cdecl, dynlib: dllname, importc: "glXCreateGLXPixmapMESA".}
|
||||
proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl,
|
||||
dynlib: dllname, importc: "glXReleaseBufferMESA".}
|
||||
proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable,
|
||||
x, y, width, height: int){.cdecl, dynlib: dllname,
|
||||
importc: "glXCopySubBufferMESA".}
|
||||
proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname,
|
||||
importc: "glXGetVideoSyncSGI".}
|
||||
proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{.
|
||||
cdecl, dynlib: dllname, importc: "glXWaitVideoSyncSGI".}
|
||||
# implementation
|
||||
368
lib/newwrap/opengl/wingl.nim
Normal file
368
lib/newwrap/opengl/wingl.nim
Normal file
@@ -0,0 +1,368 @@
|
||||
import
|
||||
gl, windows
|
||||
|
||||
proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname,
|
||||
importc: "wglGetExtensionsStringARB".}
|
||||
const
|
||||
WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001
|
||||
WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002
|
||||
WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004
|
||||
WGL_STENCIL_BUFFER_BIT_ARB* = 0x00000008
|
||||
|
||||
proc WinChoosePixelFormat*(DC: HDC, p2: PPixelFormatDescriptor): int{.
|
||||
dynlib: "gdi32", importc: "ChoosePixelFormat".}
|
||||
proc wglCreateBufferRegionARB*(hDC: HDC, iLayerPlane: TGLint, uType: TGLuint): THandle{.
|
||||
dynlib: dllname, importc: "wglCreateBufferRegionARB".}
|
||||
proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname,
|
||||
importc: "wglDeleteBufferRegionARB".}
|
||||
proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||
width: TGLint, height: TGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglSaveBufferRegionARB".}
|
||||
proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||
width: TGLint, height: TGLint, xSrc: TGLint,
|
||||
ySrc: TGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglRestoreBufferRegionARB".}
|
||||
proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat,
|
||||
writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{.
|
||||
dynlib: dllname, importc: "wglAllocateMemoryNV".}
|
||||
proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname,
|
||||
importc: "wglFreeMemoryNV".}
|
||||
const
|
||||
WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001
|
||||
WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002
|
||||
|
||||
proc wglCreateImageBufferI3D*(hDC: HDC, dwSize: DWORD, uFlags: UINT): PGLvoid{.
|
||||
dynlib: dllname, importc: "wglCreateImageBufferI3D".}
|
||||
proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{.
|
||||
dynlib: dllname, importc: "wglDestroyImageBufferI3D".}
|
||||
proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle,
|
||||
pAddress: PGLvoid, pSize: PDWORD,
|
||||
count: UINT): BOOL{.dynlib: dllname,
|
||||
importc: "wglAssociateImageBufferEventsI3D".}
|
||||
proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglReleaseImageBufferEventsI3D".}
|
||||
proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname,
|
||||
importc: "wglEnableFrameLockI3D".}
|
||||
proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname,
|
||||
importc: "wglDisableFrameLockI3D".}
|
||||
proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
importc: "wglIsEnabledFrameLockI3D".}
|
||||
proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
importc: "wglQueryFrameLockMasterI3D".}
|
||||
proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname,
|
||||
importc: "wglGetFrameUsageI3D".}
|
||||
proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname,
|
||||
importc: "wglBeginFrameTrackingI3D".}
|
||||
proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname,
|
||||
importc: "wglEndFrameTrackingI3D".}
|
||||
proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD,
|
||||
pLastMissedUsage: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc: "wglQueryFrameTrackingI3D".}
|
||||
const
|
||||
WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000
|
||||
WGL_DRAW_TO_WINDOW_ARB* = 0x00002001
|
||||
WGL_DRAW_TO_BITMAP_ARB* = 0x00002002
|
||||
WGL_ACCELERATION_ARB* = 0x00002003
|
||||
WGL_NEED_PALETTE_ARB* = 0x00002004
|
||||
WGL_NEED_SYSTEM_PALETTE_ARB* = 0x00002005
|
||||
WGL_SWAP_LAYER_BUFFERS_ARB* = 0x00002006
|
||||
WGL_SWAP_METHOD_ARB* = 0x00002007
|
||||
WGL_NUMBER_OVERLAYS_ARB* = 0x00002008
|
||||
WGL_NUMBER_UNDERLAYS_ARB* = 0x00002009
|
||||
WGL_TRANSPARENT_ARB* = 0x0000200A
|
||||
WGL_TRANSPARENT_RED_VALUE_ARB* = 0x00002037
|
||||
WGL_TRANSPARENT_GREEN_VALUE_ARB* = 0x00002038
|
||||
WGL_TRANSPARENT_BLUE_VALUE_ARB* = 0x00002039
|
||||
WGL_TRANSPARENT_ALPHA_VALUE_ARB* = 0x0000203A
|
||||
WGL_TRANSPARENT_INDEX_VALUE_ARB* = 0x0000203B
|
||||
WGL_SHARE_DEPTH_ARB* = 0x0000200C
|
||||
WGL_SHARE_STENCIL_ARB* = 0x0000200D
|
||||
WGL_SHARE_ACCUM_ARB* = 0x0000200E
|
||||
WGL_SUPPORT_GDI_ARB* = 0x0000200F
|
||||
WGL_SUPPORT_OPENGL_ARB* = 0x00002010
|
||||
WGL_DOUBLE_BUFFER_ARB* = 0x00002011
|
||||
WGL_STEREO_ARB* = 0x00002012
|
||||
WGL_PIXEL_TYPE_ARB* = 0x00002013
|
||||
WGL_COLOR_BITS_ARB* = 0x00002014
|
||||
WGL_RED_BITS_ARB* = 0x00002015
|
||||
WGL_RED_SHIFT_ARB* = 0x00002016
|
||||
WGL_GREEN_BITS_ARB* = 0x00002017
|
||||
WGL_GREEN_SHIFT_ARB* = 0x00002018
|
||||
WGL_BLUE_BITS_ARB* = 0x00002019
|
||||
WGL_BLUE_SHIFT_ARB* = 0x0000201A
|
||||
WGL_ALPHA_BITS_ARB* = 0x0000201B
|
||||
WGL_ALPHA_SHIFT_ARB* = 0x0000201C
|
||||
WGL_ACCUM_BITS_ARB* = 0x0000201D
|
||||
WGL_ACCUM_RED_BITS_ARB* = 0x0000201E
|
||||
WGL_ACCUM_GREEN_BITS_ARB* = 0x0000201F
|
||||
WGL_ACCUM_BLUE_BITS_ARB* = 0x00002020
|
||||
WGL_ACCUM_ALPHA_BITS_ARB* = 0x00002021
|
||||
WGL_DEPTH_BITS_ARB* = 0x00002022
|
||||
WGL_STENCIL_BITS_ARB* = 0x00002023
|
||||
WGL_AUX_BUFFERS_ARB* = 0x00002024
|
||||
WGL_NO_ACCELERATION_ARB* = 0x00002025
|
||||
WGL_GENERIC_ACCELERATION_ARB* = 0x00002026
|
||||
WGL_FULL_ACCELERATION_ARB* = 0x00002027
|
||||
WGL_SWAP_EXCHANGE_ARB* = 0x00002028
|
||||
WGL_SWAP_COPY_ARB* = 0x00002029
|
||||
WGL_SWAP_UNDEFINED_ARB* = 0x0000202A
|
||||
WGL_TYPE_RGBA_ARB* = 0x0000202B
|
||||
WGL_TYPE_COLORINDEX_ARB* = 0x0000202C
|
||||
|
||||
proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, piValues: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetPixelFormatAttribivARB".}
|
||||
proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetPixelFormatAttribfvARB".}
|
||||
proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint,
|
||||
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
|
||||
dynlib: dllname, importc: "wglChoosePixelFormatARB".}
|
||||
const
|
||||
WGL_ERROR_INVALID_PIXEL_TYPE_ARB* = 0x00002043
|
||||
WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB* = 0x00002054
|
||||
|
||||
proc wglMakeContextCurrentARB*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
|
||||
dynlib: dllname, importc: "wglMakeContextCurrentARB".}
|
||||
proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname,
|
||||
importc: "wglGetCurrentReadDCARB".}
|
||||
const
|
||||
WGL_DRAW_TO_PBUFFER_ARB* = 0x0000202D # WGL_DRAW_TO_PBUFFER_ARB { already defined }
|
||||
WGL_MAX_PBUFFER_PIXELS_ARB* = 0x0000202E
|
||||
WGL_MAX_PBUFFER_WIDTH_ARB* = 0x0000202F
|
||||
WGL_MAX_PBUFFER_HEIGHT_ARB* = 0x00002030
|
||||
WGL_PBUFFER_LARGEST_ARB* = 0x00002033
|
||||
WGL_PBUFFER_WIDTH_ARB* = 0x00002034
|
||||
WGL_PBUFFER_HEIGHT_ARB* = 0x00002035
|
||||
WGL_PBUFFER_LOST_ARB* = 0x00002036
|
||||
|
||||
proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
|
||||
iHeight: TGLint, piAttribList: PGLint): THandle{.
|
||||
dynlib: dllname, importc: "wglCreatePbufferARB".}
|
||||
proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname,
|
||||
importc: "wglGetPbufferDCARB".}
|
||||
proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{.
|
||||
dynlib: dllname, importc: "wglReleasePbufferDCARB".}
|
||||
proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname,
|
||||
importc: "wglDestroyPbufferARB".}
|
||||
proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglQueryPbufferARB".}
|
||||
proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglSwapIntervalEXT".}
|
||||
proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname,
|
||||
importc: "wglGetSwapIntervalEXT".}
|
||||
const
|
||||
WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070
|
||||
WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071
|
||||
WGL_TEXTURE_FORMAT_ARB* = 0x00002072
|
||||
WGL_TEXTURE_TARGET_ARB* = 0x00002073
|
||||
WGL_MIPMAP_TEXTURE_ARB* = 0x00002074
|
||||
WGL_TEXTURE_RGB_ARB* = 0x00002075
|
||||
WGL_TEXTURE_RGBA_ARB* = 0x00002076
|
||||
WGL_NO_TEXTURE_ARB* = 0x00002077
|
||||
WGL_TEXTURE_CUBE_MAP_ARB* = 0x00002078
|
||||
WGL_TEXTURE_1D_ARB* = 0x00002079
|
||||
WGL_TEXTURE_2D_ARB* = 0x0000207A # WGL_NO_TEXTURE_ARB { already defined }
|
||||
WGL_MIPMAP_LEVEL_ARB* = 0x0000207B
|
||||
WGL_CUBE_MAP_FACE_ARB* = 0x0000207C
|
||||
WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x0000207D
|
||||
WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x0000207E
|
||||
WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x0000207F
|
||||
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00002080
|
||||
WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00002081
|
||||
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x00002082
|
||||
WGL_FRONT_LEFT_ARB* = 0x00002083
|
||||
WGL_FRONT_RIGHT_ARB* = 0x00002084
|
||||
WGL_BACK_LEFT_ARB* = 0x00002085
|
||||
WGL_BACK_RIGHT_ARB* = 0x00002086
|
||||
WGL_AUX0_ARB* = 0x00002087
|
||||
WGL_AUX1_ARB* = 0x00002088
|
||||
WGL_AUX2_ARB* = 0x00002089
|
||||
WGL_AUX3_ARB* = 0x0000208A
|
||||
WGL_AUX4_ARB* = 0x0000208B
|
||||
WGL_AUX5_ARB* = 0x0000208C
|
||||
WGL_AUX6_ARB* = 0x0000208D
|
||||
WGL_AUX7_ARB* = 0x0000208E
|
||||
WGL_AUX8_ARB* = 0x0000208F
|
||||
WGL_AUX9_ARB* = 0x00002090
|
||||
|
||||
proc wglBindTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglBindTexImageARB".}
|
||||
proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglReleaseTexImageARB".}
|
||||
proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglSetPbufferAttribARB".}
|
||||
proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname,
|
||||
importc: "wglGetExtensionsStringEXT".}
|
||||
proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
|
||||
dynlib: dllname, importc: "wglMakeContextCurrentEXT".}
|
||||
proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname,
|
||||
importc: "wglGetCurrentReadDCEXT".}
|
||||
const
|
||||
WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D
|
||||
WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E
|
||||
WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F
|
||||
WGL_MAX_PBUFFER_HEIGHT_EXT* = 0x00002030
|
||||
WGL_OPTIMAL_PBUFFER_WIDTH_EXT* = 0x00002031
|
||||
WGL_OPTIMAL_PBUFFER_HEIGHT_EXT* = 0x00002032
|
||||
WGL_PBUFFER_LARGEST_EXT* = 0x00002033
|
||||
WGL_PBUFFER_WIDTH_EXT* = 0x00002034
|
||||
WGL_PBUFFER_HEIGHT_EXT* = 0x00002035
|
||||
|
||||
proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
|
||||
iHeight: TGLint, piAttribList: PGLint): THandle{.
|
||||
dynlib: dllname, importc: "wglCreatePbufferEXT".}
|
||||
proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname,
|
||||
importc: "wglGetPbufferDCEXT".}
|
||||
proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{.
|
||||
dynlib: dllname, importc: "wglReleasePbufferDCEXT".}
|
||||
proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname,
|
||||
importc: "wglDestroyPbufferEXT".}
|
||||
proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglQueryPbufferEXT".}
|
||||
const
|
||||
WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000
|
||||
WGL_DRAW_TO_WINDOW_EXT* = 0x00002001
|
||||
WGL_DRAW_TO_BITMAP_EXT* = 0x00002002
|
||||
WGL_ACCELERATION_EXT* = 0x00002003
|
||||
WGL_NEED_PALETTE_EXT* = 0x00002004
|
||||
WGL_NEED_SYSTEM_PALETTE_EXT* = 0x00002005
|
||||
WGL_SWAP_LAYER_BUFFERS_EXT* = 0x00002006
|
||||
WGL_SWAP_METHOD_EXT* = 0x00002007
|
||||
WGL_NUMBER_OVERLAYS_EXT* = 0x00002008
|
||||
WGL_NUMBER_UNDERLAYS_EXT* = 0x00002009
|
||||
WGL_TRANSPARENT_EXT* = 0x0000200A
|
||||
WGL_TRANSPARENT_VALUE_EXT* = 0x0000200B
|
||||
WGL_SHARE_DEPTH_EXT* = 0x0000200C
|
||||
WGL_SHARE_STENCIL_EXT* = 0x0000200D
|
||||
WGL_SHARE_ACCUM_EXT* = 0x0000200E
|
||||
WGL_SUPPORT_GDI_EXT* = 0x0000200F
|
||||
WGL_SUPPORT_OPENGL_EXT* = 0x00002010
|
||||
WGL_DOUBLE_BUFFER_EXT* = 0x00002011
|
||||
WGL_STEREO_EXT* = 0x00002012
|
||||
WGL_PIXEL_TYPE_EXT* = 0x00002013
|
||||
WGL_COLOR_BITS_EXT* = 0x00002014
|
||||
WGL_RED_BITS_EXT* = 0x00002015
|
||||
WGL_RED_SHIFT_EXT* = 0x00002016
|
||||
WGL_GREEN_BITS_EXT* = 0x00002017
|
||||
WGL_GREEN_SHIFT_EXT* = 0x00002018
|
||||
WGL_BLUE_BITS_EXT* = 0x00002019
|
||||
WGL_BLUE_SHIFT_EXT* = 0x0000201A
|
||||
WGL_ALPHA_BITS_EXT* = 0x0000201B
|
||||
WGL_ALPHA_SHIFT_EXT* = 0x0000201C
|
||||
WGL_ACCUM_BITS_EXT* = 0x0000201D
|
||||
WGL_ACCUM_RED_BITS_EXT* = 0x0000201E
|
||||
WGL_ACCUM_GREEN_BITS_EXT* = 0x0000201F
|
||||
WGL_ACCUM_BLUE_BITS_EXT* = 0x00002020
|
||||
WGL_ACCUM_ALPHA_BITS_EXT* = 0x00002021
|
||||
WGL_DEPTH_BITS_EXT* = 0x00002022
|
||||
WGL_STENCIL_BITS_EXT* = 0x00002023
|
||||
WGL_AUX_BUFFERS_EXT* = 0x00002024
|
||||
WGL_NO_ACCELERATION_EXT* = 0x00002025
|
||||
WGL_GENERIC_ACCELERATION_EXT* = 0x00002026
|
||||
WGL_FULL_ACCELERATION_EXT* = 0x00002027
|
||||
WGL_SWAP_EXCHANGE_EXT* = 0x00002028
|
||||
WGL_SWAP_COPY_EXT* = 0x00002029
|
||||
WGL_SWAP_UNDEFINED_EXT* = 0x0000202A
|
||||
WGL_TYPE_RGBA_EXT* = 0x0000202B
|
||||
WGL_TYPE_COLORINDEX_EXT* = 0x0000202C
|
||||
|
||||
proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, piValues: PGLint): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetPixelFormatAttribivEXT".}
|
||||
proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetPixelFormatAttribfvEXT".}
|
||||
proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint,
|
||||
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
|
||||
dynlib: dllname, importc: "wglChoosePixelFormatEXT".}
|
||||
const
|
||||
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D* = 0x00002050
|
||||
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D* = 0x00002051
|
||||
WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D* = 0x00002052
|
||||
WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D* = 0x00002053
|
||||
|
||||
proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGetDigitalVideoParametersI3D".}
|
||||
proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglSetDigitalVideoParametersI3D".}
|
||||
const
|
||||
WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E
|
||||
WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F
|
||||
|
||||
proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGetGammaTableParametersI3D".}
|
||||
proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||
importc: "wglSetGammaTableParametersI3D".}
|
||||
proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetGammaTableI3D".}
|
||||
proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
|
||||
dynlib: dllname, importc: "wglSetGammaTableI3D".}
|
||||
const
|
||||
WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044
|
||||
WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045
|
||||
WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046
|
||||
WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D* = 0x00002047
|
||||
WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D* = 0x00002048
|
||||
WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D* = 0x00002049
|
||||
WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D* = 0x0000204A
|
||||
WGL_GENLOCK_SOURCE_EDGE_RISING_I3D* = 0x0000204B
|
||||
WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D* = 0x0000204C
|
||||
WGL_FLOAT_COMPONENTS_NV* = 0x000020B0
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV* = 0x000020B1
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV* = 0x000020B2
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV* = 0x000020B3
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV* = 0x000020B4
|
||||
WGL_TEXTURE_FLOAT_R_NV* = 0x000020B5
|
||||
WGL_TEXTURE_FLOAT_RG_NV* = 0x000020B6
|
||||
WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7
|
||||
WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8
|
||||
|
||||
proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
|
||||
importc: "wglEnableGenlockI3D".}
|
||||
proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
|
||||
importc: "wglDisableGenlockI3D".}
|
||||
proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||
importc: "wglIsEnabledGenlockI3D".}
|
||||
proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGenlockSourceI3D".}
|
||||
proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname,
|
||||
importc: "wglGetGenlockSourceI3D".}
|
||||
proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGenlockSourceEdgeI3D".}
|
||||
proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetGenlockSourceEdgeI3D".}
|
||||
proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname,
|
||||
importc: "wglGenlockSampleRateI3D".}
|
||||
proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetGenlockSampleRateI3D".}
|
||||
proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{.
|
||||
dynlib: dllname, importc: "wglGenlockSourceDelayI3D".}
|
||||
proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglGetGenlockSourceDelayI3D".}
|
||||
proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT,
|
||||
uMaxPixelDelay: PGLUINT): BOOL{.
|
||||
dynlib: dllname, importc: "wglQueryGenlockMaxSourceDelayI3D".}
|
||||
const
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0
|
||||
WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1
|
||||
WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2
|
||||
|
||||
const
|
||||
WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820
|
||||
WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835
|
||||
WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0
|
||||
|
||||
# implementation
|
||||
259
lib/newwrap/pcre/pcre.nim
Normal file
259
lib/newwrap/pcre/pcre.nim
Normal file
@@ -0,0 +1,259 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
{.compile: "pcre_all.c".}
|
||||
type
|
||||
Pbyte = ptr byte
|
||||
PPchar = ptr cstring
|
||||
Pint = ptr cint
|
||||
P* = ptr T
|
||||
Pcallout_block* = ptr tcallout_block
|
||||
Pextra* = ptr Textra
|
||||
T{.final, pure.} = object
|
||||
# The structure for passing additional data to pcre_exec(). This is defined
|
||||
# in such as way as to be extensible.
|
||||
# Bits for which fields are set
|
||||
# Opaque data from pcre_study()
|
||||
# Maximum number of calls to match()
|
||||
# Data passed back in callouts
|
||||
# Const before type ignored
|
||||
# Pointer to character tables
|
||||
Textra*{.final, pure.} = object # The structure for passing out data via the pcre_callout_function. We use a
|
||||
# structure so that new fields can be added on the end in future versions,
|
||||
# without changing the API of the function, thereby allowing old clients to
|
||||
# work without modification.
|
||||
# Identifies version of block
|
||||
# ------------------------ Version 0 -------------------------------
|
||||
# Number compiled into pattern
|
||||
# The offset vector
|
||||
# Const before type ignored
|
||||
# The subject being matched
|
||||
# The length of the subject
|
||||
# Offset to start of this match attempt
|
||||
# Where we currently are in the subject
|
||||
# Max current capture
|
||||
# Most recently closed capture
|
||||
# Data passed in with the call
|
||||
# ------------------- Added for Version 1 --------------------------
|
||||
# Offset to next item in the pattern
|
||||
# Length of next item in the pattern
|
||||
#
|
||||
# ------------------------------------------------------------------
|
||||
flags: cint
|
||||
study_data: pointer
|
||||
match_limit: cint
|
||||
callout_data: pointer
|
||||
tables: ptr byte
|
||||
|
||||
Tcallout_block*{.final, pure.} = object
|
||||
version: cint
|
||||
callout_number: cint
|
||||
offset_vector: ptr cint
|
||||
subject: ptr char
|
||||
subject_length: cint
|
||||
start_match: cint
|
||||
current_position: cint
|
||||
capture_top: cint
|
||||
capture_last: cint
|
||||
callout_data: pointer
|
||||
pattern_position: cint
|
||||
next_item_length: cint
|
||||
|
||||
|
||||
#************************************************
|
||||
#* Perl-Compatible Regular Expressions *
|
||||
#************************************************
|
||||
#
|
||||
# Modified by Andreas Rumpf for h2pas.
|
||||
|
||||
# In its original form, this is the .in file that is transformed by
|
||||
# "configure" into pcre.h.
|
||||
#
|
||||
# Copyright (c) 1997-2005 University of Cambridge
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of the University of Cambridge nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# The file pcre.h is build by "configure". Do not edit it; instead
|
||||
# make changes to pcre.in.
|
||||
|
||||
const
|
||||
PCRE_MAJOR* = 6
|
||||
PCRE_MINOR* = 3
|
||||
PCRE_DATE* = "2005/11/29"
|
||||
# Options
|
||||
PCRE_CASELESS* = 0x00000001
|
||||
PCRE_MULTILINE* = 0x00000002
|
||||
PCRE_DOTALL* = 0x00000004
|
||||
PCRE_EXTENDED* = 0x00000008
|
||||
PCRE_ANCHORED* = 0x00000010
|
||||
PCRE_DOLLAR_ENDONLY* = 0x00000020
|
||||
PCRE_EXTRA* = 0x00000040
|
||||
PCRE_NOTBOL* = 0x00000080
|
||||
PCRE_NOTEOL* = 0x00000100
|
||||
PCRE_UNGREEDY* = 0x00000200
|
||||
PCRE_NOTEMPTY* = 0x00000400
|
||||
PCRE_UTF8* = 0x00000800
|
||||
PCRE_NO_AUTO_CAPTURE* = 0x00001000
|
||||
PCRE_NO_UTF8_CHECK* = 0x00002000
|
||||
PCRE_AUTO_CALLOUT* = 0x00004000
|
||||
PCRE_PARTIAL* = 0x00008000
|
||||
PCRE_DFA_SHORTEST* = 0x00010000
|
||||
PCRE_DFA_RESTART* = 0x00020000
|
||||
PCRE_FIRSTLINE* = 0x00040000
|
||||
# Exec-time and get/set-time error codes
|
||||
PCRE_ERROR_NOMATCH* = - (1)
|
||||
PCRE_ERROR_NULL* = - (2)
|
||||
PCRE_ERROR_BADOPTION* = - (3)
|
||||
PCRE_ERROR_BADMAGIC* = - (4)
|
||||
PCRE_ERROR_UNKNOWN_NODE* = - (5)
|
||||
PCRE_ERROR_NOMEMORY* = - (6)
|
||||
PCRE_ERROR_NOSUBSTRING* = - (7)
|
||||
PCRE_ERROR_MATCHLIMIT* = - (8)
|
||||
# Never used by PCRE itself
|
||||
PCRE_ERROR_CALLOUT* = - (9)
|
||||
PCRE_ERROR_BADUTF8* = - (10)
|
||||
PCRE_ERROR_BADUTF8_OFFSET* = - (11)
|
||||
PCRE_ERROR_PARTIAL* = - (12)
|
||||
PCRE_ERROR_BADPARTIAL* = - (13)
|
||||
PCRE_ERROR_INTERNAL* = - (14)
|
||||
PCRE_ERROR_BADCOUNT* = - (15)
|
||||
PCRE_ERROR_DFA_UITEM* = - (16)
|
||||
PCRE_ERROR_DFA_UCOND* = - (17)
|
||||
PCRE_ERROR_DFA_UMLIMIT* = - (18)
|
||||
PCRE_ERROR_DFA_WSSIZE* = - (19)
|
||||
PCRE_ERROR_DFA_RECURSE* = - (20)
|
||||
# Request types for pcre_fullinfo()
|
||||
PCRE_INFO_OPTIONS* = 0
|
||||
PCRE_INFO_SIZE* = 1
|
||||
PCRE_INFO_CAPTURECOUNT* = 2
|
||||
PCRE_INFO_BACKREFMAX* = 3
|
||||
PCRE_INFO_FIRSTBYTE* = 4
|
||||
# For backwards compatibility
|
||||
PCRE_INFO_FIRSTCHAR* = 4
|
||||
PCRE_INFO_FIRSTTABLE* = 5
|
||||
PCRE_INFO_LASTLITERAL* = 6
|
||||
PCRE_INFO_NAMEENTRYSIZE* = 7
|
||||
PCRE_INFO_NAMECOUNT* = 8
|
||||
PCRE_INFO_NAMETABLE* = 9
|
||||
PCRE_INFO_STUDYSIZE* = 10
|
||||
PCRE_INFO_DEFAULT_TABLES* = 11
|
||||
# Request types for pcre_config()
|
||||
PCRE_CONFIG_UTF8* = 0
|
||||
PCRE_CONFIG_NEWLINE* = 1
|
||||
PCRE_CONFIG_LINK_SIZE* = 2
|
||||
PCRE_CONFIG_POSIX_MALLOC_THRESHOLD* = 3
|
||||
PCRE_CONFIG_MATCH_LIMIT* = 4
|
||||
PCRE_CONFIG_STACKRECURSE* = 5
|
||||
PCRE_CONFIG_UNICODE_PROPERTIES* = 6
|
||||
# Bit flags for the pcre_extra structure
|
||||
PCRE_EXTRA_STUDY_DATA* = 0x00000001
|
||||
PCRE_EXTRA_MATCH_LIMIT* = 0x00000002
|
||||
PCRE_EXTRA_CALLOUT_DATA* = 0x00000004
|
||||
PCRE_EXTRA_TABLES* = 0x00000008
|
||||
|
||||
# Exported PCRE functions
|
||||
|
||||
proc pcre_compile*(para1: cstring, para2: cint, para3: ptr cstring,
|
||||
para4: ptr int, para5: Pbyte): P{.importc: "pcre_compile",
|
||||
noconv.}
|
||||
proc pcre_compile2*(para1: cstring, para2: cint, para3: Pint, para4: PPchar,
|
||||
para5: ptr int, para6: Pbyte): P{.importc: "pcre_compile2",
|
||||
noconv.}
|
||||
proc pcre_config*(para1: cint, para2: pointer): cint{.importc: "pcre_config",
|
||||
noconv.}
|
||||
proc pcre_copy_named_substring*(para1: P, para2: cstring, para3: Pint,
|
||||
para4: cint, para5: cstring, para6: cstring,
|
||||
para7: cint): cint{.
|
||||
importc: "pcre_copy_named_substring", noconv.}
|
||||
proc pcre_copy_substring*(para1: cstring, para2: Pint, para3: cint, para4: cint,
|
||||
para5: cstring, para6: cint): cint{.
|
||||
importc: "pcre_copy_substring", noconv.}
|
||||
proc pcre_dfa_exec*(para1: P, para2: Pextra, para3: cstring, para4: cint,
|
||||
para5: cint, para6: cint, para7: Pint, para8: cint,
|
||||
para9: Pint, para10: cint): cint{.importc: "pcre_dfa_exec",
|
||||
noconv.}
|
||||
proc pcre_exec*(para1: P, para2: Pextra, para3: cstring, para4: cint,
|
||||
para5: cint, para6: cint, para7: Pint, para8: cint): cint{.
|
||||
importc: "pcre_exec", noconv.}
|
||||
proc pcre_free_substring*(para1: cstring){.importc: "pcre_free_substring",
|
||||
noconv.}
|
||||
proc pcre_free_substring_list*(para1: PPchar){.
|
||||
importc: "pcre_free_substring_list", noconv.}
|
||||
proc pcre_fullinfo*(para1: P, para2: Pextra, para3: cint, para4: pointer): cint{.
|
||||
importc: "pcre_fullinfo", noconv.}
|
||||
proc pcre_get_named_substring*(para1: P, para2: cstring, para3: Pint,
|
||||
para4: cint, para5: cstring, para6: PPchar): cint{.
|
||||
importc: "pcre_get_named_substring", noconv.}
|
||||
proc pcre_get_stringnumber*(para1: P, para2: cstring): cint{.
|
||||
importc: "pcre_get_stringnumber", noconv.}
|
||||
proc pcre_get_substring*(para1: cstring, para2: Pint, para3: cint, para4: cint,
|
||||
para5: PPchar): cint{.importc: "pcre_get_substring",
|
||||
noconv.}
|
||||
proc pcre_get_substring_list*(para1: cstring, para2: Pint, para3: cint,
|
||||
para4: ptr PPchar): cint{.
|
||||
importc: "pcre_get_substring_list", noconv.}
|
||||
proc pcre_info*(para1: P, para2: Pint, para3: Pint): cint{.importc: "pcre_info",
|
||||
noconv.}
|
||||
proc pcre_maketables*(): ptr byte{.importc: "pcre_maketables", noconv.}
|
||||
proc pcre_refcount*(para1: P, para2: cint): cint{.importc: "pcre_refcount",
|
||||
noconv.}
|
||||
proc pcre_study*(para1: P, para2: cint, para3: ptr CString): Pextra{.
|
||||
importc: "pcre_study", noconv.}
|
||||
proc pcre_version*(): CString{.importc: "pcre_version", noconv.}
|
||||
# Indirection for store get and free functions. These can be set to
|
||||
# alternative malloc/free functions if required. Special ones are used in the
|
||||
# non-recursive case for "frames". There is also an optional callout function
|
||||
# that is triggered by the (?) regex item.
|
||||
#
|
||||
|
||||
# we use Nimrod's memory manager (but not GC!) for these functions:
|
||||
|
||||
type
|
||||
TMalloc = proc (para1: int): pointer{.noconv.}
|
||||
TFree = proc (para1: pointer){.noconv.}
|
||||
|
||||
var
|
||||
pcre_malloc{.importc: "pcre_malloc".}: TMalloc
|
||||
pcre_free{.importc: "pcre_free".}: TFree
|
||||
pcre_stack_malloc{.importc: "pcre_stack_malloc".}: TMalloc
|
||||
pcre_stack_free{.importc: "pcre_stack_free".}: TFree
|
||||
pcre_callout{.importc: "pcre_callout".}: proc (para1: Pcallout_block): cint{.
|
||||
noconv.}
|
||||
|
||||
pcre_malloc = cast[TMalloc](system.alloc)
|
||||
pcre_free = cast[TFree](system.dealloc)
|
||||
pcre_stack_malloc = cast[TMalloc](system.alloc)
|
||||
pcre_stack_free = cast[TFree](system.dealloc)
|
||||
pcre_callout = nil
|
||||
348
lib/newwrap/postgres.nim
Normal file
348
lib/newwrap/postgres.nim
Normal file
@@ -0,0 +1,348 @@
|
||||
# This module contains the definitions for structures and externs for
|
||||
# functions used by frontend postgres applications. It is based on
|
||||
# Postgresql's libpq-fe.h.
|
||||
#
|
||||
# It is for postgreSQL version 7.4 and higher with support for the v3.0
|
||||
# connection-protocol.
|
||||
#
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
dllName = "pq.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllName = "libpq.dylib"
|
||||
else:
|
||||
const
|
||||
dllName = "libpq.so(.5|)"
|
||||
type
|
||||
POid* = ptr Oid
|
||||
Oid* = int32
|
||||
|
||||
const
|
||||
ERROR_MSG_LENGTH* = 4096
|
||||
CMDSTATUS_LEN* = 40
|
||||
|
||||
type
|
||||
TSockAddr* = array[1..112, int8]
|
||||
TPGresAttDesc*{.pure, final.} = object
|
||||
name*: cstring
|
||||
adtid*: Oid
|
||||
adtsize*: int
|
||||
|
||||
PPGresAttDesc* = ptr TPGresAttDesc
|
||||
PPPGresAttDesc* = ptr PPGresAttDesc
|
||||
TPGresAttValue*{.pure, final.} = object
|
||||
length*: int32
|
||||
value*: cstring
|
||||
|
||||
PPGresAttValue* = ptr TPGresAttValue
|
||||
PPPGresAttValue* = ptr PPGresAttValue
|
||||
PExecStatusType* = ptr TExecStatusType
|
||||
TExecStatusType* = enum
|
||||
PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT,
|
||||
PGRES_COPY_IN, PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR
|
||||
TPGlobjfuncs*{.pure, final.} = object
|
||||
fn_lo_open*: Oid
|
||||
fn_lo_close*: Oid
|
||||
fn_lo_creat*: Oid
|
||||
fn_lo_unlink*: Oid
|
||||
fn_lo_lseek*: Oid
|
||||
fn_lo_tell*: Oid
|
||||
fn_lo_read*: Oid
|
||||
fn_lo_write*: Oid
|
||||
|
||||
PPGlobjfuncs* = ptr TPGlobjfuncs
|
||||
PConnStatusType* = ptr TConnStatusType
|
||||
TConnStatusType* = enum
|
||||
CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE,
|
||||
CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV,
|
||||
CONNECTION_SSL_STARTUP, CONNECTION_NEEDED
|
||||
TPGconn*{.pure, final.} = object
|
||||
pghost*: cstring
|
||||
pgtty*: cstring
|
||||
pgport*: cstring
|
||||
pgoptions*: cstring
|
||||
dbName*: cstring
|
||||
status*: TConnStatusType
|
||||
errorMessage*: array[0..(ERROR_MSG_LENGTH) - 1, char]
|
||||
Pfin*: TFile
|
||||
Pfout*: TFile
|
||||
Pfdebug*: TFile
|
||||
sock*: int32
|
||||
laddr*: TSockAddr
|
||||
raddr*: TSockAddr
|
||||
salt*: array[0..(2) - 1, char]
|
||||
asyncNotifyWaiting*: int32
|
||||
notifyList*: pointer
|
||||
pguser*: cstring
|
||||
pgpass*: cstring
|
||||
lobjfuncs*: PPGlobjfuncs
|
||||
|
||||
PPGconn* = ptr TPGconn
|
||||
TPGresult*{.pure, final.} = object
|
||||
ntups*: int32
|
||||
numAttributes*: int32
|
||||
attDescs*: PPGresAttDesc
|
||||
tuples*: PPPGresAttValue
|
||||
tupArrSize*: int32
|
||||
resultStatus*: TExecStatusType
|
||||
cmdStatus*: array[0..(CMDSTATUS_LEN) - 1, char]
|
||||
binary*: int32
|
||||
conn*: PPGconn
|
||||
|
||||
PPGresult* = ptr TPGresult
|
||||
PPostgresPollingStatusType* = ptr PostgresPollingStatusType
|
||||
PostgresPollingStatusType* = enum
|
||||
PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING,
|
||||
PGRES_POLLING_OK, PGRES_POLLING_ACTIVE
|
||||
PPGTransactionStatusType* = ptr PGTransactionStatusType
|
||||
PGTransactionStatusType* = enum
|
||||
PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR,
|
||||
PQTRANS_UNKNOWN
|
||||
PPGVerbosity* = ptr PGVerbosity
|
||||
PGVerbosity* = enum
|
||||
PQERRORS_TERSE, PQERRORS_DEFAULT, PQERRORS_VERBOSE
|
||||
PpgNotify* = ptr pgNotify
|
||||
pgNotify*{.pure, final.} = object
|
||||
relname*: cstring
|
||||
be_pid*: int32
|
||||
extra*: cstring
|
||||
|
||||
PQnoticeReceiver* = proc (arg: pointer, res: PPGresult){.cdecl.}
|
||||
PQnoticeProcessor* = proc (arg: pointer, message: cstring){.cdecl.}
|
||||
Ppqbool* = ptr pqbool
|
||||
pqbool* = char
|
||||
P_PQprintOpt* = ptr PQprintOpt
|
||||
PQprintOpt*{.pure, final.} = object
|
||||
header*: pqbool
|
||||
align*: pqbool
|
||||
standard*: pqbool
|
||||
html3*: pqbool
|
||||
expanded*: pqbool
|
||||
pager*: pqbool
|
||||
fieldSep*: cstring
|
||||
tableOpt*: cstring
|
||||
caption*: cstring
|
||||
fieldName*: ptr cstring
|
||||
|
||||
P_PQconninfoOption* = ptr PQconninfoOption
|
||||
PQconninfoOption*{.pure, final.} = object
|
||||
keyword*: cstring
|
||||
envvar*: cstring
|
||||
compiled*: cstring
|
||||
val*: cstring
|
||||
label*: cstring
|
||||
dispchar*: cstring
|
||||
dispsize*: int32
|
||||
|
||||
PPQArgBlock* = ptr PQArgBlock
|
||||
PQArgBlock*{.pure, final.} = object
|
||||
length*: int32
|
||||
isint*: int32
|
||||
p*: pointer
|
||||
|
||||
|
||||
proc PQconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
importc: "PQconnectStart".}
|
||||
proc PQconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQconnectPoll".}
|
||||
proc PQconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
importc: "PQconnectdb".}
|
||||
proc PQsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring,
|
||||
pgtty: cstring, dbName: cstring, login: cstring, pwd: cstring): PPGconn{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetdbLogin".}
|
||||
proc PQsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn
|
||||
proc PQfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
|
||||
proc PQconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName,
|
||||
importc: "PQconndefaults".}
|
||||
proc PQconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName,
|
||||
importc: "PQconninfoFree".}
|
||||
proc PQresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQresetStart".}
|
||||
proc PQresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQresetPoll".}
|
||||
proc PQreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
|
||||
proc PQrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQrequestCancel".}
|
||||
proc PQdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
|
||||
proc PQuser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
|
||||
proc PQpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".}
|
||||
proc PQhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
|
||||
proc PQport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
|
||||
proc PQtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
|
||||
proc PQoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQoptions".}
|
||||
proc PQstatus*(conn: PPGconn): TConnStatusType{.cdecl, dynlib: dllName,
|
||||
importc: "PQstatus".}
|
||||
proc PQtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQtransactionStatus".}
|
||||
proc PQparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQparameterStatus".}
|
||||
proc PQprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQprotocolVersion".}
|
||||
proc PQerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQerrorMessage".}
|
||||
proc PQsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsocket".}
|
||||
proc PQbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQbackendPID".}
|
||||
proc PQclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQclientEncoding".}
|
||||
proc PQsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetClientEncoding".}
|
||||
when defined(USE_SSL):
|
||||
# Get the SSL structure associated with a connection
|
||||
proc PQgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName,
|
||||
importc: "PQgetssl".}
|
||||
proc PQsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity".}
|
||||
proc PQtrace*(conn: PPGconn, debug_port: TFile){.cdecl, dynlib: dllName,
|
||||
importc: "PQtrace".}
|
||||
proc PQuntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
|
||||
proc PQsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetNoticeReceiver".}
|
||||
proc PQsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor,
|
||||
arg: pointer): PQnoticeProcessor{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetNoticeProcessor".}
|
||||
proc PQexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName,
|
||||
importc: "PQexec".}
|
||||
proc PQexecParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
paramTypes: POid, paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQexecParams".}
|
||||
proc PQexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQexecPrepared".}
|
||||
proc PQsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQuery".}
|
||||
proc PQsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
paramTypes: POid, paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32,
|
||||
resultFormat: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQueryParams".}
|
||||
proc PQsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32,
|
||||
resultFormat: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQueryPrepared".}
|
||||
proc PQgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName,
|
||||
importc: "PQgetResult".}
|
||||
proc PQisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQisBusy".}
|
||||
proc PQconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQconsumeInput".}
|
||||
proc PQnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName,
|
||||
importc: "PQnotifies".}
|
||||
proc PQputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQputCopyData".}
|
||||
proc PQputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQputCopyEnd".}
|
||||
proc PQgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetCopyData".}
|
||||
proc PQgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQgetline".}
|
||||
proc PQputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQputline".}
|
||||
proc PQgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetlineAsync".}
|
||||
proc PQputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQputnbytes".}
|
||||
proc PQendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQendcopy".}
|
||||
proc PQsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetnonblocking".}
|
||||
proc PQisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQisnonblocking".}
|
||||
proc PQflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
|
||||
proc PQfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32,
|
||||
result_is_int: int32, args: PPQArgBlock, nargs: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQfn".}
|
||||
proc PQresultStatus*(res: PPGresult): TExecStatusType{.cdecl, dynlib: dllName,
|
||||
importc: "PQresultStatus".}
|
||||
proc PQresStatus*(status: TExecStatusType): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQresStatus".}
|
||||
proc PQresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQresultErrorMessage".}
|
||||
proc PQresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQresultErrorField".}
|
||||
proc PQntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQntuples".}
|
||||
proc PQnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQnfields".}
|
||||
proc PQbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQbinaryTuples".}
|
||||
proc PQfname*(res: PPGresult, field_num: int32): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQfname".}
|
||||
proc PQfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQfnumber".}
|
||||
proc PQftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQftable".}
|
||||
proc PQftablecol*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQftablecol".}
|
||||
proc PQfformat*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQfformat".}
|
||||
proc PQftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQftype".}
|
||||
proc PQfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQfsize".}
|
||||
proc PQfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQfmod".}
|
||||
proc PQcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQcmdStatus".}
|
||||
proc PQoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQoidStatus".}
|
||||
proc PQoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQoidValue".}
|
||||
proc PQcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQcmdTuples".}
|
||||
proc PQgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetvalue".}
|
||||
proc PQgetlength*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetlength".}
|
||||
proc PQgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetisnull".}
|
||||
proc PQclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
|
||||
proc PQfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
|
||||
proc PQmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult".}
|
||||
proc PQescapeString*(till, `from`: cstring, len: int): int{.cdecl,
|
||||
dynlib: dllName, importc: "PQescapeString".}
|
||||
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,
|
||||
dynlib: dllName, importc: "PQprint".}
|
||||
proc PQdisplayTuples*(res: PPGresult, fp: TFile, fillAlign: int32,
|
||||
fieldSep: cstring, printHeader: int32, quiet: int32){.
|
||||
cdecl, dynlib: dllName, importc: "PQdisplayTuples".}
|
||||
proc PQprintTuples*(res: PPGresult, fout: TFile, printAttName: int32,
|
||||
terseOutput: int32, width: int32){.cdecl, dynlib: dllName,
|
||||
importc: "PQprintTuples".}
|
||||
proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "lo_open".}
|
||||
proc lo_close*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "lo_close".}
|
||||
proc lo_read*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
|
||||
cdecl, dynlib: dllName, importc: "lo_read".}
|
||||
proc lo_write*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
|
||||
cdecl, dynlib: dllName, importc: "lo_write".}
|
||||
proc lo_lseek*(conn: PPGconn, fd: int32, offset: int32, whence: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "lo_lseek".}
|
||||
proc lo_creat*(conn: PPGconn, mode: int32): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "lo_creat".}
|
||||
proc lo_tell*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "lo_tell".}
|
||||
proc lo_unlink*(conn: PPGconn, lobjId: Oid): int32{.cdecl, dynlib: dllName,
|
||||
importc: "lo_unlink".}
|
||||
proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "lo_import".}
|
||||
proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "lo_export".}
|
||||
proc PQmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQmblen".}
|
||||
proc PQenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
|
||||
proc PQsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn =
|
||||
result = PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")
|
||||
2583
lib/newwrap/sdl/sdl.nim
Normal file
2583
lib/newwrap/sdl/sdl.nim
Normal file
File diff suppressed because it is too large
Load Diff
452
lib/newwrap/sdl/sdl_gfx.nim
Normal file
452
lib/newwrap/sdl/sdl_gfx.nim
Normal file
@@ -0,0 +1,452 @@
|
||||
#
|
||||
# $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# $Log: sdl_gfx.pas,v $
|
||||
# Revision 1.3 2007/05/29 21:31:04 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.2 2007/05/20 20:30:18 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.1 2005/01/03 19:08:32 savage
|
||||
# Header for the SDL_Gfx library.
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
import
|
||||
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
gfxLibName = "SDL_gfx.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
gfxLibName = "libSDL_gfx.dylib"
|
||||
else:
|
||||
const
|
||||
gfxLibName = "libSDL_gfx.so"
|
||||
const # Some rates in Hz
|
||||
FPS_UPPER_LIMIT* = 200
|
||||
FPS_LOWER_LIMIT* = 1
|
||||
FPS_DEFAULT* = 30 # ---- Defines
|
||||
SMOOTHING_OFF* = 0
|
||||
SMOOTHING_ON* = 1
|
||||
|
||||
type
|
||||
PFPSmanager* = ptr TFPSmanager
|
||||
TFPSmanager*{.final.} = object # ---- Structures
|
||||
framecount*: Uint32
|
||||
rateticks*: float32
|
||||
lastticks*: Uint32
|
||||
rate*: Uint32
|
||||
|
||||
PColorRGBA* = ptr TColorRGBA
|
||||
TColorRGBA*{.final.} = object
|
||||
r*: Uint8
|
||||
g*: Uint8
|
||||
b*: Uint8
|
||||
a*: Uint8
|
||||
|
||||
PColorY* = ptr TColorY
|
||||
TColorY*{.final.} = object #
|
||||
#
|
||||
# SDL_framerate: framerate manager
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
y*: Uint8
|
||||
|
||||
|
||||
proc initFramerate*(manager: PFPSmanager){.cdecl, importc: "SDL_initFramerate",
|
||||
dynlib: gfxLibName.}
|
||||
proc setFramerate*(manager: PFPSmanager, rate: int): int{.cdecl,
|
||||
importc: "SDL_setFramerate", dynlib: gfxLibName.}
|
||||
proc getFramerate*(manager: PFPSmanager): int{.cdecl,
|
||||
importc: "SDL_getFramerate", dynlib: gfxLibName.}
|
||||
proc framerateDelay*(manager: PFPSmanager){.cdecl,
|
||||
importc: "SDL_framerateDelay", dynlib: gfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_gfxPrimitives: graphics primitives for SDL
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
# Note: all ___Color routines expect the color to be in format 0xRRGGBBAA
|
||||
# Pixel
|
||||
proc pixelColor*(dst: PSurface, x: Sint16, y: Sint16, color: Uint32): int{.
|
||||
cdecl, importc: "pixelColor", dynlib: gfxLibName.}
|
||||
proc pixelRGBA*(dst: PSurface, x: Sint16, y: Sint16, r: Uint8, g: Uint8,
|
||||
b: Uint8, a: Uint8): int{.cdecl, importc: "pixelRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Horizontal line
|
||||
proc hlineColor*(dst: PSurface, x1: Sint16, x2: Sint16, y: Sint16, color: Uint32): int{.
|
||||
cdecl, importc: "hlineColor", dynlib: gfxLibName.}
|
||||
proc hlineRGBA*(dst: PSurface, x1: Sint16, x2: Sint16, y: Sint16, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc: "hlineRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Vertical line
|
||||
proc vlineColor*(dst: PSurface, x: Sint16, y1: Sint16, y2: Sint16, color: Uint32): int{.
|
||||
cdecl, importc: "vlineColor", dynlib: gfxLibName.}
|
||||
proc vlineRGBA*(dst: PSurface, x: Sint16, y1: Sint16, y2: Sint16, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc: "vlineRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Rectangle
|
||||
proc rectangleColor*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, color: Uint32): int{.cdecl,
|
||||
importc: "rectangleColor", dynlib: gfxLibName.}
|
||||
proc rectangleRGBA*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc: "rectangleRGBA", dynlib: gfxLibName.}
|
||||
# Filled rectangle (Box)
|
||||
proc boxColor*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
color: Uint32): int{.cdecl, importc: "boxColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc boxRGBA*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "boxRGBA", dynlib: gfxLibName.}
|
||||
# Line
|
||||
proc lineColor*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
color: Uint32): int{.cdecl, importc: "lineColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc lineRGBA*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "lineRGBA", dynlib: gfxLibName.}
|
||||
# AA Line
|
||||
proc aalineColor*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
color: Uint32): int{.cdecl, importc: "aalineColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc aalineRGBA*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "aalineRGBA", dynlib: gfxLibName.}
|
||||
# Circle
|
||||
proc circleColor*(dst: PSurface, x: Sint16, y: Sint16, r: Sint16, color: Uint32): int{.
|
||||
cdecl, importc: "circleColor", dynlib: gfxLibName.}
|
||||
proc circleRGBA*(dst: PSurface, x: Sint16, y: Sint16, rad: Sint16, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "circleRGBA", dynlib: gfxLibName.}
|
||||
# AA Circle
|
||||
proc aacircleColor*(dst: PSurface, x: Sint16, y: Sint16, r: Sint16,
|
||||
color: Uint32): int{.cdecl, importc: "aacircleColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc aacircleRGBA*(dst: PSurface, x: Sint16, y: Sint16, rad: Sint16, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "aacircleRGBA", dynlib: gfxLibName.}
|
||||
# Filled Circle
|
||||
proc filledCircleColor*(dst: PSurface, x: Sint16, y: Sint16, r: Sint16,
|
||||
color: Uint32): int{.cdecl,
|
||||
importc: "filledCircleColor", dynlib: gfxLibName.}
|
||||
proc filledCircleRGBA*(dst: PSurface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "filledCircleRGBA", dynlib: gfxLibName.}
|
||||
# Ellipse
|
||||
proc ellipseColor*(dst: PSurface, x: Sint16, y: Sint16, rx: Sint16, ry: Sint16,
|
||||
color: Uint32): int{.cdecl, importc: "ellipseColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc ellipseRGBA*(dst: PSurface, x: Sint16, y: Sint16, rx: Sint16, ry: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "ellipseRGBA", dynlib: gfxLibName.}
|
||||
# AA Ellipse
|
||||
proc aaellipseColor*(dst: PSurface, xc: Sint16, yc: Sint16, rx: Sint16,
|
||||
ry: Sint16, color: Uint32): int{.cdecl,
|
||||
importc: "aaellipseColor", dynlib: gfxLibName.}
|
||||
proc aaellipseRGBA*(dst: PSurface, x: Sint16, y: Sint16, rx: Sint16, ry: Sint16,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "aaellipseRGBA", dynlib: gfxLibName.}
|
||||
# Filled Ellipse
|
||||
proc filledEllipseColor*(dst: PSurface, x: Sint16, y: Sint16, rx: Sint16,
|
||||
ry: Sint16, color: Uint32): int{.cdecl,
|
||||
importc: "filledEllipseColor", dynlib: gfxLibName.}
|
||||
proc filledEllipseRGBA*(dst: PSurface, x: Sint16, y: Sint16, rx: Sint16,
|
||||
ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc: "filledEllipseRGBA", dynlib: gfxLibName.}
|
||||
# Pie
|
||||
proc pieColor*(dst: PSurface, x: Sint16, y: Sint16, rad: Sint16, start: Sint16,
|
||||
finish: Sint16, color: Uint32): int{.cdecl, importc: "pieColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc pieRGBA*(dst: PSurface, x: Sint16, y: Sint16, rad: Sint16, start: Sint16,
|
||||
finish: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc: "pieRGBA", dynlib: gfxLibName.}
|
||||
# Filled Pie
|
||||
proc filledPieColor*(dst: PSurface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
start: Sint16, finish: Sint16, color: Uint32): int{.cdecl,
|
||||
importc: "filledPieColor", dynlib: gfxLibName.}
|
||||
proc filledPieRGBA*(dst: PSurface, x: Sint16, y: Sint16, rad: Sint16,
|
||||
start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8,
|
||||
a: Uint8): int{.cdecl, importc: "filledPieRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Trigon
|
||||
proc trigonColor*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
x3: Sint16, y3: Sint16, color: Uint32): int{.cdecl,
|
||||
importc: "trigonColor", dynlib: gfxLibName.}
|
||||
proc trigonRGBA*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16,
|
||||
x3: Sint16, y3: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.
|
||||
cdecl, importc: "trigonRGBA", dynlib: gfxLibName.}
|
||||
# AA-Trigon
|
||||
proc aatrigonColor*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
|
||||
cdecl, importc: "aatrigonColor", dynlib: gfxLibName.}
|
||||
proc aatrigonRGBA*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8,
|
||||
b: Uint8, a: Uint8): int{.cdecl, importc: "aatrigonRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Filled Trigon
|
||||
proc filledTrigonColor*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{.
|
||||
cdecl, importc: "filledTrigonColor", dynlib: gfxLibName.}
|
||||
proc filledTrigonRGBA*(dst: PSurface, x1: Sint16, y1: Sint16, x2: Sint16,
|
||||
y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8,
|
||||
b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "filledTrigonRGBA", dynlib: gfxLibName.}
|
||||
# Polygon
|
||||
proc polygonColor*(dst: PSurface, vx: PSint16, vy: PSint16, n: int,
|
||||
color: Uint32): int{.cdecl, importc: "polygonColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc polygonRGBA*(dst: PSurface, vx: PSint16, vy: PSint16, n: int, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "polygonRGBA", dynlib: gfxLibName.}
|
||||
# AA-Polygon
|
||||
proc aapolygonColor*(dst: PSurface, vx: PSint16, vy: PSint16, n: int,
|
||||
color: Uint32): int{.cdecl, importc: "aapolygonColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc aapolygonRGBA*(dst: PSurface, vx: PSint16, vy: PSint16, n: int, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "aapolygonRGBA", dynlib: gfxLibName.}
|
||||
# Filled Polygon
|
||||
proc filledPolygonColor*(dst: PSurface, vx: PSint16, vy: PSint16, n: int,
|
||||
color: Uint32): int{.cdecl,
|
||||
importc: "filledPolygonColor", dynlib: gfxLibName.}
|
||||
proc filledPolygonRGBA*(dst: PSurface, vx: PSint16, vy: PSint16, n: int,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "filledPolygonRGBA", dynlib: gfxLibName.}
|
||||
# Bezier
|
||||
# s = number of steps
|
||||
proc bezierColor*(dst: PSurface, vx: PSint16, vy: PSint16, n: int, s: int,
|
||||
color: Uint32): int{.cdecl, importc: "bezierColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc bezierRGBA*(dst: PSurface, vx: PSint16, vy: PSint16, n: int, s: int,
|
||||
r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "bezierRGBA", dynlib: gfxLibName.}
|
||||
# Characters/Strings
|
||||
proc characterColor*(dst: PSurface, x: Sint16, y: Sint16, c: char, color: Uint32): int{.
|
||||
cdecl, importc: "characterColor", dynlib: gfxLibName.}
|
||||
proc characterRGBA*(dst: PSurface, x: Sint16, y: Sint16, c: char, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "characterRGBA", dynlib: gfxLibName.}
|
||||
proc stringColor*(dst: PSurface, x: Sint16, y: Sint16, c: cstring, color: Uint32): int{.
|
||||
cdecl, importc: "stringColor", dynlib: gfxLibName.}
|
||||
proc stringRGBA*(dst: PSurface, x: Sint16, y: Sint16, c: cstring, r: Uint8,
|
||||
g: Uint8, b: Uint8, a: Uint8): int{.cdecl,
|
||||
importc: "stringRGBA", dynlib: gfxLibName.}
|
||||
proc gfxPrimitivesSetFont*(fontdata: Pointer, cw: int, ch: int){.cdecl,
|
||||
importc: "gfxPrimitivesSetFont", dynlib: gfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_imageFilter - bytes-image "filter" routines
|
||||
# (uses inline x86 MMX optimizations if available)
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
# Comments:
|
||||
# 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary.
|
||||
# 2.) Data that is not within an 8 byte boundary is processed using the C routine.
|
||||
# 3.) Convolution routines do not have C routines at this time.
|
||||
# Detect MMX capability in CPU
|
||||
proc imageFilterMMXdetect*(): int{.cdecl, importc: "SDL_imageFilterMMXdetect",
|
||||
dynlib: gfxLibName.}
|
||||
# Force use of MMX off (or turn possible use back on)
|
||||
proc imageFilterMMXoff*(){.cdecl, importc: "SDL_imageFilterMMXoff",
|
||||
dynlib: gfxLibName.}
|
||||
proc imageFilterMMXon*(){.cdecl, importc: "SDL_imageFilterMMXon",
|
||||
dynlib: gfxLibName.}
|
||||
#
|
||||
# All routines return:
|
||||
# 0 OK
|
||||
# -1 Error (internal error, parameter error)
|
||||
#
|
||||
# SDL_imageFilterAdd: D = saturation255(S1 + S2)
|
||||
proc imageFilterAdd*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterAdd", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMean: D = S1/2 + S2/2
|
||||
proc imageFilterMean*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterMean", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSub: D = saturation0(S1 - S2)
|
||||
proc imageFilterSub*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterSub", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterAbsDiff: D = | S1 - S2 |
|
||||
proc imageFilterAbsDiff*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterAbsDiff", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMult: D = saturation(S1 * S2)
|
||||
proc imageFilterMult*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterMult", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
|
||||
proc imageFilterMultNor*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterMultNor", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
|
||||
proc imageFilterMultDivby2*(Src1: cstring, Src2: cstring, Dest: cstring,
|
||||
len: int): int{.cdecl,
|
||||
importc: "SDL_imageFilterMultDivby2", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
|
||||
proc imageFilterMultDivby4*(Src1: cstring, Src2: cstring, Dest: cstring,
|
||||
len: int): int{.cdecl,
|
||||
importc: "SDL_imageFilterMultDivby4", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterBitAnd: D = S1 & S2
|
||||
proc imageFilterBitAnd*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterBitAnd", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterBitOr: D = S1 | S2
|
||||
proc imageFilterBitOr*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterBitOr", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
|
||||
proc imageFilterDiv*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterDiv", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterBitNegation: D = !S
|
||||
proc imageFilterBitNegation*(Src1: cstring, Dest: cstring, len: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterBitNegation", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterAddByte: D = saturation255(S + C)
|
||||
proc imageFilterAddByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterAddByte", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
|
||||
proc imageFilterAddUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterAddUint", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
|
||||
proc imageFilterAddByteToHalf*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterAddByteToHalf", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSubByte: D = saturation0(S - C)
|
||||
proc imageFilterSubByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterSubByte", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
|
||||
proc imageFilterSubUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterSubUint", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftRight: D = saturation0(S >> N)
|
||||
proc imageFilterShiftRight*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
|
||||
proc imageFilterShiftRightUint*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterShiftRightUint", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMultByByte: D = saturation255(S * C)
|
||||
proc imageFilterMultByByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterMultByByte", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
|
||||
proc imageFilterShiftRightAndMultByByte*(Src1: cstring, Dest: cstring, len: int,
|
||||
N: char, C: char): int{.cdecl,
|
||||
importc: "SDL_imageFilterShiftRightAndMultByByte",
|
||||
dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftLeftByte: D = (S << N)
|
||||
proc imageFilterShiftLeftByte*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterShiftLeftByte", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
|
||||
proc imageFilterShiftLeftUint*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterShiftLeftUint", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftLeft: D = saturation255(S << N)
|
||||
proc imageFilterShiftLeft*(Src1: cstring, Dest: cstring, len: int, N: char): int{.
|
||||
cdecl, importc: "SDL_imageFilterShiftLeft", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
|
||||
proc imageFilterBinarizeUsingThreshold*(Src1: cstring, Dest: cstring, len: int,
|
||||
T: char): int{.cdecl,
|
||||
importc: "SDL_imageFilterBinarizeUsingThreshold", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
|
||||
proc imageFilterClipToRange*(Src1: cstring, Dest: cstring, len: int, Tmin: int8,
|
||||
Tmax: int8): int{.cdecl,
|
||||
importc: "SDL_imageFilterClipToRange", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
|
||||
proc imageFilterNormalizeLinear*(Src1: cstring, Dest: cstring, len: int,
|
||||
Cmin: int, Cmax: int, Nmin: int, Nmax: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterNormalizeLinear", dynlib: gfxLibName.}
|
||||
# !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!!
|
||||
# SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel3x3Divide*(Src: cstring, Dest: cstring, rows: int,
|
||||
columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel3x3Divide", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel5x5Divide*(Src: cstring, Dest: cstring, rows: int,
|
||||
columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel5x5Divide", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel7x7Divide*(Src: cstring, Dest: cstring, rows: int,
|
||||
columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel7x7Divide", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel9x9Divide*(Src: cstring, Dest: cstring, rows: int,
|
||||
columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel9x9Divide", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel3x3ShiftRight*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel3x3ShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel5x5ShiftRight*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel5x5ShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel7x7ShiftRight*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel7x7ShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel9x9ShiftRight*(Src: cstring, Dest: cstring,
|
||||
rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel9x9ShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSobelX: Dij = saturation255( ... )
|
||||
proc imageFilterSobelX*(Src: cstring, Dest: cstring, rows: int, columns: int): int{.
|
||||
cdecl, importc: "SDL_imageFilterSobelX", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
|
||||
proc imageFilterSobelXShiftRight*(Src: cstring, Dest: cstring, rows: int,
|
||||
columns: int, NRightShift: char): int{.cdecl,
|
||||
importc: "SDL_imageFilterSobelXShiftRight", dynlib: gfxLibName.}
|
||||
# Align/restore stack to 32 byte boundary -- Functionality untested! --
|
||||
proc imageFilterAlignStack*(){.cdecl, importc: "SDL_imageFilterAlignStack",
|
||||
dynlib: gfxLibName.}
|
||||
proc imageFilterRestoreStack*(){.cdecl, importc: "SDL_imageFilterRestoreStack",
|
||||
dynlib: gfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_rotozoom - rotozoomer
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# rotozoomSurface()
|
||||
#
|
||||
# Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
|
||||
# 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
|
||||
# then the destination 32bit surface is anti-aliased. If the surface is not 8bit
|
||||
# or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
|
||||
#
|
||||
#
|
||||
proc rotozoomSurface*(src: PSurface, angle: float64, zoom: float64, smooth: int): PSurface{.
|
||||
cdecl, importc: "rotozoomSurface", dynlib: gfxLibName.}
|
||||
proc rotozoomSurfaceXY*(src: PSurface, angle: float64, zoomx: float64,
|
||||
zoomy: float64, smooth: int): PSurface{.cdecl,
|
||||
importc: "rotozoomSurfaceXY", dynlib: gfxLibName.}
|
||||
# Returns the size of the target surface for a rotozoomSurface() call
|
||||
proc rotozoomSurfaceSize*(width: int, height: int, angle: float64,
|
||||
zoom: float64, dstwidth: var int, dstheight: var int){.
|
||||
cdecl, importc: "rotozoomSurfaceSize", dynlib: gfxLibName.}
|
||||
proc rotozoomSurfaceSizeXY*(width: int, height: int, angle: float64,
|
||||
zoomx: float64, zoomy: float64, dstwidth: var int,
|
||||
dstheight: var int){.cdecl,
|
||||
importc: "rotozoomSurfaceSizeXY", dynlib: gfxLibName.}
|
||||
#
|
||||
#
|
||||
# zoomSurface()
|
||||
#
|
||||
# Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
|
||||
# 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
|
||||
# then the destination 32bit surface is anti-aliased. If the surface is not 8bit
|
||||
# or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
|
||||
#
|
||||
#
|
||||
proc zoomSurface*(src: PSurface, zoomx: float64, zoomy: float64, smooth: int): PSurface{.
|
||||
cdecl, importc: "zoomSurface", dynlib: gfxLibName.}
|
||||
# Returns the size of the target surface for a zoomSurface() call
|
||||
proc zoomSurfaceSize*(width: int, height: int, zoomx: float64, zoomy: float64,
|
||||
dstwidth: var int, dstheight: var int){.cdecl,
|
||||
importc: "zoomSurfaceSize", dynlib: gfxLibName.}
|
||||
# implementation
|
||||
242
lib/newwrap/sdl/sdl_image.nim
Normal file
242
lib/newwrap/sdl/sdl_image.nim
Normal file
@@ -0,0 +1,242 @@
|
||||
#
|
||||
# $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# Borland Delphi SDL_Image - An example image loading library for use
|
||||
# with SDL
|
||||
# Conversion of the Simple DirectMedia Layer Image Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_image.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Portions created by Matthias Thoma are
|
||||
# Copyright (C) 2000 - 2001 Matthias Thoma.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Dominique Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
# A simple library to load images of various formats as SDL surfaces
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas in your search path.
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
# See the Aliens Demo on how to make use of this libaray
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 02 2001 - MT : Initial Translation
|
||||
#
|
||||
# May 08 2001 - DL : Added ExternalSym derectives and copyright header
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_image.pas,v $
|
||||
# Revision 1.14 2007/05/29 21:31:13 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.13 2007/05/20 20:30:54 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.12 2006/12/02 00:14:40 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.11 2005/04/10 18:22:59 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.10 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.9 2005/01/05 01:47:07 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.8 2005/01/04 23:14:44 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.7 2005/01/01 02:03:12 savage
|
||||
# Updated to v1.2.4
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
ImageLibName = "SDL_Image.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
ImageLibName = "libSDL_image-1.2.0.dylib"
|
||||
else:
|
||||
const
|
||||
ImageLibName = "libSDL_image.so"
|
||||
const
|
||||
IMAGE_MAJOR_VERSION* = 1'i8
|
||||
IMAGE_MINOR_VERSION* = 2'i8
|
||||
IMAGE_PATCHLEVEL* = 5'i8
|
||||
|
||||
# This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_image library.
|
||||
|
||||
proc IMAGE_VERSION*(X: var TVersion)
|
||||
# This function gets the version of the dynamically linked SDL_image library.
|
||||
# it should NOT be used to fill a version structure, instead you should
|
||||
# use the SDL_IMAGE_VERSION() macro.
|
||||
#
|
||||
proc IMG_Linked_Version*(): Pversion{.importc: "IMG_Linked_Version",
|
||||
dynlib: ImageLibName.}
|
||||
# Load an image from an SDL data source.
|
||||
# The 'type' may be one of: "BMP", "GIF", "PNG", etc.
|
||||
#
|
||||
# If the image format supports a transparent pixel, SDL will set the
|
||||
# colorkey for the surface. You can enable RLE acceleration on the
|
||||
# surface afterwards by calling:
|
||||
# SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
|
||||
#
|
||||
proc IMG_LoadTyped_RW*(src: PRWops, freesrc: int, theType: cstring): PSurface{.
|
||||
cdecl, importc: "IMG_LoadTyped_RW", dynlib: ImageLibName.}
|
||||
# Convenience functions
|
||||
proc IMG_Load*(theFile: cstring): PSurface{.cdecl, importc: "IMG_Load",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_Load_RW*(src: PRWops, freesrc: int): PSurface{.cdecl,
|
||||
importc: "IMG_Load_RW", dynlib: ImageLibName.}
|
||||
# Invert the alpha of a surface for use with OpenGL
|
||||
# This function is now a no-op, and only provided for backwards compatibility.
|
||||
proc IMG_InvertAlpha*(theOn: int): int{.cdecl, importc: "IMG_InvertAlpha",
|
||||
dynlib: ImageLibName.}
|
||||
# Functions to detect a file type, given a seekable source
|
||||
proc IMG_isBMP*(src: PRWops): int{.cdecl, importc: "IMG_isBMP",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isGIF*(src: PRWops): int{.cdecl, importc: "IMG_isGIF",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isJPG*(src: PRWops): int{.cdecl, importc: "IMG_isJPG",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isLBM*(src: PRWops): int{.cdecl, importc: "IMG_isLBM",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isPCX*(src: PRWops): int{.cdecl, importc: "IMG_isPCX",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isPNG*(src: PRWops): int{.cdecl, importc: "IMG_isPNG",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isPNM*(src: PRWops): int{.cdecl, importc: "IMG_isPNM",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isTIF*(src: PRWops): int{.cdecl, importc: "IMG_isTIF",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isXCF*(src: PRWops): int{.cdecl, importc: "IMG_isXCF",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isXPM*(src: PRWops): int{.cdecl, importc: "IMG_isXPM",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_isXV*(src: PRWops): int{.cdecl, importc: "IMG_isXV",
|
||||
dynlib: ImageLibName.}
|
||||
# Individual loading functions
|
||||
proc IMG_LoadBMP_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadBMP_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadGIF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadGIF_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadJPG_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadJPG_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadLBM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadLBM_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadPCX_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPCX_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadPNM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPNM_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadPNG_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPNG_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadTGA_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadTGA_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadTIF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadTIF_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadXCF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXCF_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadXPM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXPM_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadXV_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXV_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_ReadXPMFromArray*(xpm: cstringArray): PSurface{.cdecl,
|
||||
importc: "IMG_ReadXPMFromArray", dynlib: ImageLibName.}
|
||||
# Error Macros
|
||||
# We'll use SDL for reporting errors
|
||||
proc IMG_SetError*(fmt: cstring)
|
||||
proc IMG_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc IMAGE_VERSION(X: var TVersion) =
|
||||
X.major = IMAGE_MAJOR_VERSION
|
||||
X.minor = IMAGE_MINOR_VERSION
|
||||
X.patch = IMAGE_PATCHLEVEL
|
||||
|
||||
proc IMG_SetError(fmt: cstring) =
|
||||
SetError(fmt)
|
||||
|
||||
proc IMG_GetError(): cstring =
|
||||
result = GetError()
|
||||
763
lib/newwrap/sdl/sdl_mixer.nim
Normal file
763
lib/newwrap/sdl/sdl_mixer.nim
Normal file
@@ -0,0 +1,763 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library
|
||||
# Conversion of the Simple DirectMedia Layer Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_mixer.h
|
||||
# music_cmd.h
|
||||
# wavestream.h
|
||||
# timidity.h
|
||||
# playmidi.h
|
||||
# music_ogg.h
|
||||
# mikmod.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas & SMPEG.pas somewhere within your search path.
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
# See the Aliens Demo to see how this library is used
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 02 2001 - DL : Initial Translation
|
||||
#
|
||||
# February 02 2002 - DL : Update to version 1.2.1
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_mixer.pas,v $
|
||||
# Revision 1.18 2007/05/29 21:31:44 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.17 2007/05/20 20:31:17 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.16 2006/12/02 00:16:17 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.15 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.14 2005/02/24 20:20:07 savage
|
||||
# Changed definition of MusicType and added GetMusicType function
|
||||
#
|
||||
# Revision 1.13 2005/01/05 01:47:09 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.12 2005/01/04 23:14:56 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.11 2005/01/01 02:05:19 savage
|
||||
# Updated to v1.2.6
|
||||
#
|
||||
# Revision 1.10 2004/09/12 21:45:17 savage
|
||||
# Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added.
|
||||
#
|
||||
# Revision 1.9 2004/08/27 21:48:24 savage
|
||||
# IFDEFed out Smpeg support on MacOS X
|
||||
#
|
||||
# Revision 1.8 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.7 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.6 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.5 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.4 2004/03/31 22:20:02 savage
|
||||
# Windows unit not used in this file, so it was removed to keep the code tidy.
|
||||
#
|
||||
# Revision 1.3 2004/03/31 10:05:08 savage
|
||||
# Better defines for Endianess under FreePascal and Borland compilers.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
, smpeg
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
MixerLibName = "SDL_mixer.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
MixerLibName = "libSDL_mixer-1.2.0.dylib"
|
||||
else:
|
||||
const
|
||||
MixerLibName = "libSDL_mixer.so"
|
||||
const
|
||||
MIXER_MAJOR_VERSION* = 1'i8
|
||||
MIXER_MINOR_VERSION* = 2'i8
|
||||
MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility
|
||||
MIX_MAJOR_VERSION* = MIXER_MAJOR_VERSION
|
||||
MIX_MINOR_VERSION* = MIXER_MINOR_VERSION
|
||||
MIX_PATCHLEVEL* = MIXER_PATCHLEVEL # SDL_Mixer.h constants
|
||||
# The default mixer has 8 simultaneous mixing channels
|
||||
MIX_CHANNELS* = 8 # Good default values for a PC soundcard
|
||||
MIX_DEFAULT_FREQUENCY* = 22050
|
||||
|
||||
when defined(IA32):
|
||||
const
|
||||
MIX_DEFAULT_FORMAT* = AUDIO_S16LSB
|
||||
else:
|
||||
const
|
||||
MIX_DEFAULT_FORMAT* = AUDIO_S16MSB
|
||||
const
|
||||
MIX_DEFAULT_CHANNELS* = 2
|
||||
MIX_MAX_VOLUME* = 128 # Volume of a chunk
|
||||
PATH_MAX* = 255 # mikmod.h constants
|
||||
#*
|
||||
# * Library version
|
||||
# *
|
||||
LIBMIKMOD_VERSION_MAJOR* = 3
|
||||
LIBMIKMOD_VERSION_MINOR* = 1
|
||||
LIBMIKMOD_REVISION* = 8
|
||||
LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
|
||||
(LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
|
||||
|
||||
type #music_cmd.h types
|
||||
PMusicCMD* = ptr TMusicCMD
|
||||
TMusicCMD*{.final.} = object #wavestream.h types
|
||||
filename*: array[0..PATH_MAX - 1, char]
|
||||
cmd*: array[0..PATH_MAX - 1, char]
|
||||
pid*: TSYS_ThreadHandle
|
||||
|
||||
PWAVStream* = ptr TWAVStream
|
||||
TWAVStream*{.final.} = object #playmidi.h types
|
||||
wavefp*: Pointer
|
||||
start*: int32
|
||||
stop*: int32
|
||||
cvt*: TAudioCVT
|
||||
|
||||
PMidiEvent* = ptr TMidiEvent
|
||||
TMidiEvent*{.final.} = object
|
||||
time*: int32
|
||||
channel*: uint8
|
||||
type_*: uint8
|
||||
a*: uint8
|
||||
b*: uint8
|
||||
|
||||
PMidiSong* = ptr TMidiSong
|
||||
TMidiSong*{.final.} = object #music_ogg.h types
|
||||
samples*: int32
|
||||
events*: PMidiEvent
|
||||
|
||||
POGG_Music* = ptr TOGG_Music
|
||||
TOGG_Music*{.final.} = object # mikmod.h types
|
||||
#*
|
||||
# * Error codes
|
||||
# *
|
||||
playing*: int
|
||||
volume*: int #vf: OggVorbis_File;
|
||||
section*: int
|
||||
cvt*: TAudioCVT
|
||||
len_available*: int
|
||||
snd_available*: PUint8
|
||||
|
||||
TErrorEnum* = enum
|
||||
MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
|
||||
MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
|
||||
MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
|
||||
MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
|
||||
MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
|
||||
MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
|
||||
MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
|
||||
MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
|
||||
MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
|
||||
MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
|
||||
MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
|
||||
MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
|
||||
MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
|
||||
MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
|
||||
MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
|
||||
MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
|
||||
MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
|
||||
MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
|
||||
MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
|
||||
PMODULE* = ptr TMODULE
|
||||
TMODULE*{.final.} = object
|
||||
PUNIMOD* = ptr TUNIMOD
|
||||
TUNIMOD* = TMODULE #SDL_mixer.h types
|
||||
# The internal format for an audio chunk
|
||||
PMix_Chunk* = ptr TMix_Chunk
|
||||
TMix_Chunk*{.final.} = object
|
||||
allocated*: int
|
||||
abuf*: PUint8
|
||||
alen*: Uint32
|
||||
volume*: Uint8 # Per-sample volume, 0-128
|
||||
|
||||
Mix_Chunk* = TMix_Chunk # The different fading types supported
|
||||
TMix_Fading* = enum
|
||||
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
|
||||
Mix_Fading* = TMix_Fading
|
||||
TMix_MusicType* = enum
|
||||
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3
|
||||
Mix_MusicType* = TMix_MusicType #
|
||||
# TMusicUnion = record
|
||||
# case XXX: Byte of
|
||||
# 0 : ( cmd : PMusicCMD );
|
||||
# 1 : ( wave : PWAVStream );
|
||||
# 2 : ( module : PUNIMOD );
|
||||
# 3 : ( midi : TMidiSong );
|
||||
# 4 : ( ogg : POGG_music );
|
||||
# {$IFNDEF DARWIN}
|
||||
# 5 : ( mp3 : PSMPEG );
|
||||
# {$ENDIF}
|
||||
# end;
|
||||
PMix_Music* = ptr TMix_Music
|
||||
TMix_Music*{.final.} = object # The internal format for a music chunk interpreted via mikmod
|
||||
type_*: TMix_MusicType # other fields are not aviable
|
||||
# data : TMusicUnion;
|
||||
# fading : TMix_Fading;
|
||||
# fade_volume : integer;
|
||||
# fade_step : integer;
|
||||
# fade_steps : integer;
|
||||
# error : integer;
|
||||
|
||||
TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
|
||||
cdecl.} # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_mixer library.
|
||||
|
||||
proc MIXER_VERSION*(X: var TVersion)
|
||||
# This function gets the version of the dynamically linked SDL_mixer library.
|
||||
# It should NOT be used to fill a version structure, instead you should use the
|
||||
# SDL_MIXER_VERSION() macro.
|
||||
proc Mix_Linked_Version*(): Pversion{.cdecl, importc: "Mix_Linked_Version",
|
||||
dynlib: MixerLibName.}
|
||||
# Open the mixer with a certain audio format
|
||||
proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
|
||||
chunksize: int): int{.cdecl, importc: "Mix_OpenAudio",
|
||||
dynlib: MixerLibName.}
|
||||
# Dynamically change the number of channels managed by the mixer.
|
||||
# If decreasing the number of channels, the upper channels are
|
||||
# stopped.
|
||||
# This function returns the new number of allocated channels.
|
||||
#
|
||||
proc Mix_AllocateChannels*(numchannels: int): int{.cdecl,
|
||||
importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
|
||||
# Find out what the actual audio device parameters are.
|
||||
# This function returns 1 if the audio has been opened, 0 otherwise.
|
||||
#
|
||||
proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
|
||||
cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
|
||||
# Load a wave file or a music (.mod .s3m .it .xm) file
|
||||
proc Mix_LoadWAV_RW*(src: PRWops, freesrc: int): PMix_Chunk{.cdecl,
|
||||
importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
|
||||
proc Mix_LoadWAV*(filename: cstring): PMix_Chunk
|
||||
proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl, importc: "Mix_LoadMUS",
|
||||
dynlib: MixerLibName.}
|
||||
# Load a wave file of the mixer format from a memory buffer
|
||||
proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl,
|
||||
importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
|
||||
# Free an audio chunk previously loaded
|
||||
proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc: "Mix_FreeChunk",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc: "Mix_FreeMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Find out the music format of a mixer music, or the currently playing
|
||||
# music, if 'music' is NULL.
|
||||
proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl,
|
||||
importc: "Mix_GetMusicType", dynlib: MixerLibName.}
|
||||
# Set a function that is called after all mixing is performed.
|
||||
# This can be used to provide real-time visual display of the audio stream
|
||||
# or add a custom mixer filter for the stream data.
|
||||
#
|
||||
proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl,
|
||||
importc: "Mix_SetPostMix", dynlib: MixerLibName.}
|
||||
# Add your own music player or additional mixer function.
|
||||
# If 'mix_func' is NULL, the default music player is re-enabled.
|
||||
#
|
||||
proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
|
||||
importc: "Mix_HookMusic", dynlib: MixerLibName.}
|
||||
# Add your own callback when the music has finished playing.
|
||||
#
|
||||
proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl,
|
||||
importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
|
||||
# Get a pointer to the user data for the current music hook
|
||||
proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData",
|
||||
dynlib: MixerLibName.}
|
||||
#* Add your own callback when a channel has finished playing. NULL
|
||||
# * to disable callback.*
|
||||
type
|
||||
TChannel_finished* = proc (channel: int){.cdecl.}
|
||||
|
||||
proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
|
||||
importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
|
||||
const
|
||||
MIX_CHANNEL_POST* = - 2 # This is the format of a special effect callback:
|
||||
# myeffect(int chan, void *stream, int len, void *udata);
|
||||
#
|
||||
# (chan) is the channel number that your effect is affecting. (stream) is
|
||||
# the buffer of data to work upon. (len) is the size of (stream), and
|
||||
# (udata) is a user-defined bit of data, which you pass as the last arg of
|
||||
# Mix_RegisterEffect(), and is passed back unmolested to your callback.
|
||||
# Your effect changes the contents of (stream) based on whatever parameters
|
||||
# are significant, or just leaves it be, if you prefer. You can do whatever
|
||||
# you like to the buffer, though, and it will continue in its changed state
|
||||
# down the mixing pipeline, through any other effect functions, then finally
|
||||
# to be mixed with the rest of the channels and music for the final output
|
||||
# stream.
|
||||
#
|
||||
|
||||
type
|
||||
TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int,
|
||||
udata: Pointer): Pointer{.cdecl.} # * This is a callback that signifies that a channel has finished all its
|
||||
# * loops and has completed playback. This gets called if the buffer
|
||||
# * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
|
||||
# * a channel via
|
||||
# Mix_AllocateChannels(), or unregister a callback while
|
||||
# * it's still playing.
|
||||
TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.} #* Register a special effect function. At mixing time, the channel data is
|
||||
# * copied into a buffer and passed through each registered effect function.
|
||||
# * After it passes through all the functions, it is mixed into the final
|
||||
# * output stream. The copy to buffer is performed once, then each effect
|
||||
# * function performs on the output of the previous effect. Understand that
|
||||
# * this extra copy to a buffer is not performed if there are no effects
|
||||
# * registered for a given chunk, which saves CPU cycles, and any given
|
||||
# * effect will be extra cycles, too, so it is crucial that your code run
|
||||
# * fast. Also note that the data that your function is given is in the
|
||||
# * format of the sound device, and not the format you gave to Mix_OpenAudio(),
|
||||
# * although they may in reality be the same. This is an unfortunate but
|
||||
# * necessary speed concern. Use Mix_QuerySpec() to determine if you can
|
||||
# * handle the data before you register your effect, and take appropriate
|
||||
# * actions.
|
||||
# * You may also specify a callback (Mix_EffectDone_t) that is called when
|
||||
# * the channel finishes playing. This gives you a more fine-grained control
|
||||
# * than Mix_ChannelFinished(), in case you need to free effect-specific
|
||||
# * resources, etc. If you don't need this, you can specify NULL.
|
||||
# * You may set the callbacks before or after calling Mix_PlayChannel().
|
||||
# * Things like Mix_SetPanning() are just internal special effect functions,
|
||||
# * so if you are using that, you've already incurred the overhead of a copy
|
||||
# * to a separate buffer, and that these effects will be in the queue with
|
||||
# * any functions you've registered. The list of registered effects for a
|
||||
# * channel is reset when a chunk finishes playing, so you need to explicitly
|
||||
# * set them with each call to Mix_PlayChannel*().
|
||||
# * You may also register a special effect function that is to be run after
|
||||
# * final mixing occurs. The rules for these callbacks are identical to those
|
||||
# * in Mix_RegisterEffect, but they are run after all the channels and the
|
||||
# * music have been mixed into a single stream, whereas channel-specific
|
||||
# * effects run on a given channel before any other mixing occurs. These
|
||||
# * global effect callbacks are call "posteffects". Posteffects only have
|
||||
# * their Mix_EffectDone_t function called when they are unregistered (since
|
||||
# * the main output stream is never "done" in the same sense as a channel).
|
||||
# * You must unregister them manually when you've had enough. Your callback
|
||||
# * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
|
||||
# * processing is considered a posteffect.
|
||||
# *
|
||||
# * After all these effects have finished processing, the callback registered
|
||||
# * through Mix_SetPostMix() runs, and then the stream goes to the audio
|
||||
# * device.
|
||||
# *
|
||||
# * returns zero if error (no such channel), nonzero if added.
|
||||
# * Error messages can be retrieved from Mix_GetError().
|
||||
# *
|
||||
|
||||
proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone,
|
||||
arg: Pointer): int{.cdecl,
|
||||
importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
|
||||
#* You may not need to call this explicitly, unless you need to stop an
|
||||
# * effect from processing in the middle of a chunk's playback.
|
||||
# * Posteffects are never implicitly unregistered as they are for channels,
|
||||
# * but they may be explicitly unregistered through this function by
|
||||
# * specifying MIX_CHANNEL_POST for a channel.
|
||||
# * returns zero if error (no such channel or effect), nonzero if removed.
|
||||
# * Error messages can be retrieved from Mix_GetError().
|
||||
# *
|
||||
proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
|
||||
importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
|
||||
#* You may not need to call this explicitly, unless you need to stop all
|
||||
# * effects from processing in the middle of a chunk's playback. Note that
|
||||
# * this will also shut off some internal effect processing, since
|
||||
# * Mix_SetPanning( ) and others may use this API under the hood.This is
|
||||
# * called internally when a channel completes playback.
|
||||
# * Posteffects are never implicitly unregistered as they are for channels,
|
||||
# * but they may be explicitly unregistered through this function by
|
||||
# * specifying MIX_CHANNEL_POST for a channel.
|
||||
# * returns zero if error( no such channel ), nonzero if all effects removed.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
|
||||
importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
|
||||
const
|
||||
MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" # * These are the internally - defined mixing effects.They use the same API that
|
||||
# * effects defined in the application use, but are provided here as a
|
||||
# * convenience.Some effects can reduce their quality or use more memory in
|
||||
# * the name of speed; to enable this, make sure the environment variable
|
||||
# * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
|
||||
# * Mix_OpenAudio( ).
|
||||
# *
|
||||
#* set the panning of a channel.The left and right channels are specified
|
||||
# * as integers between 0 and 255, quietest to loudest, respectively.
|
||||
# *
|
||||
# * Technically, this is just individual volume control for a sample with
|
||||
# * two( stereo )channels, so it can be used for more than just panning.
|
||||
# * if you want real panning, call it like this :
|
||||
# *
|
||||
# * Mix_SetPanning( channel, left, 255 - left );
|
||||
# *
|
||||
# * ...which isn't so hard.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the panning will be done to the final mixed stream before passing it on
|
||||
# * to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally, and returns without
|
||||
# * registering the effect function if the audio device is not configured
|
||||
# * for stereo output.Setting both( left ) and ( right ) to 255 causes this
|
||||
# * effect to be unregistered, since that is the data's normal state.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if panning effect enabled.Note that an audio device in mono
|
||||
# * mode is a no - op, but this call will return successful in that case .
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
|
||||
proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
|
||||
importc: "Mix_SetPanning", dynlib: MixerLibName.}
|
||||
# * set the position ofa channel.( angle ) is an integer from 0 to 360, that
|
||||
# * specifies the location of the sound in relation to the listener.( angle )
|
||||
# * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
|
||||
# * Angle 0 is due north, and rotates clockwise as the value increases.
|
||||
# * for efficiency, the precision of this effect may be limited( angles 1
|
||||
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
|
||||
# * ( distance ) is an integer between 0 and 255 that specifies the space
|
||||
# * between the sound and the listener.The larger the number, the further
|
||||
# * away the sound is .Using 255 does not guarantee that the channel will be
|
||||
# * culled from the mixing process or be completely silent.For efficiency,
|
||||
# * the precision of this effect may be limited( distance 0 through 5 might
|
||||
# * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
|
||||
# * and ( distance ) to 0 unregisters this effect, since the data would be
|
||||
# * unchanged.
|
||||
# *
|
||||
# * if you need more precise positional audio, consider using OpenAL for
|
||||
# * spatialized effects instead of SDL_mixer.This is only meant to be a
|
||||
# * basic effect for simple "3D" games.
|
||||
# *
|
||||
# * if the audio device is configured for mono output, then you won't get
|
||||
# * any effectiveness from the angle; however, distance attenuation on the
|
||||
# * channel will still occur.While this effect will function with stereo
|
||||
# * voices, it makes more sense to use voices with only one channel of sound,
|
||||
# * so when they are mixed through this effect, the positioning will sound
|
||||
# * correct.You can convert them to mono through SDL before giving them to
|
||||
# * the mixer in the first place if you like.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the positioning will be done to the final mixed stream before passing it
|
||||
# * on to the audio device.
|
||||
# *
|
||||
# * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if position effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
|
||||
importc: "Mix_SetPosition", dynlib: MixerLibName.}
|
||||
#* set the "distance" of a channel.( distance ) is an integer from 0 to 255
|
||||
# * that specifies the location of the sound in relation to the listener.
|
||||
# * Distance 0 is overlapping the listener, and 255 is as far away as possible
|
||||
# * A distance of 255 does not guarantee silence; in such a case , you might
|
||||
# * want to try changing the chunk's volume, or just cull the sample from the
|
||||
# * mixing process with Mix_HaltChannel( ).
|
||||
# * for efficiency, the precision of this effect may be limited( distances 1
|
||||
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
|
||||
# * ( distance ) is an integer between 0 and 255 that specifies the space
|
||||
# * between the sound and the listener.The larger the number, the further
|
||||
# * away the sound is .
|
||||
# * Setting( distance ) to 0 unregisters this effect, since the data would be
|
||||
# * unchanged.
|
||||
# * if you need more precise positional audio, consider using OpenAL for
|
||||
# * spatialized effects instead of SDL_mixer.This is only meant to be a
|
||||
# * basic effect for simple "3D" games.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the distance attenuation will be done to the final mixed stream before
|
||||
# * passing it on to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if position effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
|
||||
importc: "Mix_SetDistance", dynlib: MixerLibName.}
|
||||
# *
|
||||
# * !!! FIXME : Haven't implemented, since the effect goes past the
|
||||
# * end of the sound buffer.Will have to think about this.
|
||||
# * - -ryan.
|
||||
# * /
|
||||
# { if 0
|
||||
# { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
|
||||
# * of echo to mix.0 is no echo, 255 is infinite( and probably not
|
||||
# * what you want ).
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the reverbing will be done to the final mixed stream before passing it on
|
||||
# * to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
|
||||
# * of zero, the effect is unregistered, as the data is already in that state.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if reversing effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
# extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
|
||||
# #E ndif
|
||||
# * Causes a channel to reverse its stereo.This is handy if the user has his
|
||||
# * speakers hooked up backwards, or you would like to have a minor bit of
|
||||
# * psychedelia in your sound code. : )Calling this function with ( flip )
|
||||
# * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
|
||||
# * the effect is unregistered.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally, and thus is probably
|
||||
# * more CPU intensive than having the user just plug in his speakers
|
||||
# * correctly.Mix_SetReverseStereo( )returns without registering the effect
|
||||
# * function if the audio device is not configured for stereo output.
|
||||
# *
|
||||
# * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
|
||||
# * on the final mixed stream before sending it on to the audio device( a
|
||||
# * posteffect ).
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if reversing effect is enabled.Note that an audio device in mono
|
||||
# * mode is a no - op, but this call will return successful in that case .
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
|
||||
importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
|
||||
# end of effects API. - -ryan. *
|
||||
# Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
|
||||
# them dynamically to the next sample if requested with a -1 value below.
|
||||
# Returns the number of reserved channels.
|
||||
#
|
||||
proc Mix_ReserveChannels*(num: int): int{.cdecl, importc: "Mix_ReserveChannels",
|
||||
dynlib: MixerLibName.}
|
||||
# Channel grouping functions
|
||||
# Attach a tag to a channel. A tag can be assigned to several mixer
|
||||
# channels, to form groups of channels.
|
||||
# If 'tag' is -1, the tag is removed (actually -1 is the tag used to
|
||||
# represent the group of all the channels).
|
||||
# Returns true if everything was OK.
|
||||
#
|
||||
proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
|
||||
importc: "Mix_GroupChannel", dynlib: MixerLibName.}
|
||||
# Assign several consecutive channels to a group
|
||||
proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
|
||||
importc: "Mix_GroupChannels", dynlib: MixerLibName.}
|
||||
# Finds the first available channel in a group of channels
|
||||
proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc: "Mix_GroupAvailable",
|
||||
dynlib: MixerLibName.}
|
||||
# Returns the number of channels in a group. This is also a subtle
|
||||
# way to get the total number of channels when 'tag' is -1
|
||||
#
|
||||
proc Mix_GroupCount*(tag: int): int{.cdecl, importc: "Mix_GroupCount",
|
||||
dynlib: MixerLibName.}
|
||||
# Finds the "oldest" sample playing in a group of channels
|
||||
proc Mix_GroupOldest*(tag: int): int{.cdecl, importc: "Mix_GroupOldest",
|
||||
dynlib: MixerLibName.}
|
||||
# Finds the "most recent" (i.e. last) sample playing in a group of channels
|
||||
proc Mix_GroupNewer*(tag: int): int{.cdecl, importc: "Mix_GroupNewer",
|
||||
dynlib: MixerLibName.}
|
||||
# The same as above, but the sound is played at most 'ticks' milliseconds
|
||||
proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
|
||||
ticks: int): int{.cdecl,
|
||||
importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
|
||||
# Play an audio chunk on a specific channel.
|
||||
# If the specified channel is -1, play on the first free channel.
|
||||
# If 'loops' is greater than zero, loop the sound that many times.
|
||||
# If 'loops' is -1, loop inifinitely (~65000 times).
|
||||
# Returns which channel was used to play the sound.
|
||||
#
|
||||
proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
|
||||
proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
|
||||
importc: "Mix_PlayMusic", dynlib: MixerLibName.}
|
||||
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
|
||||
proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl,
|
||||
importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
|
||||
proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
|
||||
ms: int, ticks: int): int{.cdecl,
|
||||
importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
|
||||
proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int
|
||||
# Set the volume in the range of 0-128 of a specific channel or chunk.
|
||||
# If the specified channel is -1, set volume for all channels.
|
||||
# Returns the original volume.
|
||||
# If the specified volume is -1, just return the current volume.
|
||||
#
|
||||
proc Mix_Volume*(channel: int, volume: int): int{.cdecl, importc: "Mix_Volume",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl,
|
||||
importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
|
||||
proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc: "Mix_VolumeMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Halt playing of a particular channel
|
||||
proc Mix_HaltChannel*(channel: int): int{.cdecl, importc: "Mix_HaltChannel",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_HaltGroup*(tag: int): int{.cdecl, importc: "Mix_HaltGroup",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_HaltMusic*(): int{.cdecl, importc: "Mix_HaltMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Change the expiration delay for a particular channel.
|
||||
# The sample will stop playing after the 'ticks' milliseconds have elapsed,
|
||||
# or remove the expiration if 'ticks' is -1
|
||||
#
|
||||
proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl,
|
||||
importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
|
||||
# Halt a channel, fading it out progressively till it's silent
|
||||
# The ms parameter indicates the number of milliseconds the fading
|
||||
# will take.
|
||||
#
|
||||
proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl,
|
||||
importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
|
||||
proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl,
|
||||
importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
|
||||
proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc: "Mix_FadeOutMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Query the fading status of a channel
|
||||
proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc: "Mix_FadingMusic",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl,
|
||||
importc: "Mix_FadingChannel", dynlib: MixerLibName.}
|
||||
# Pause/Resume a particular channel
|
||||
proc Mix_Pause*(channel: int){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
|
||||
proc Mix_Resume*(channel: int){.cdecl, importc: "Mix_Resume",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_Paused*(channel: int): int{.cdecl, importc: "Mix_Paused",
|
||||
dynlib: MixerLibName.}
|
||||
# Pause/Resume the music stream
|
||||
proc Mix_PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
|
||||
proc Mix_ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
|
||||
proc Mix_RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
|
||||
proc Mix_PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Set the current position in the music stream.
|
||||
# This returns 0 if successful, or -1 if it failed or isn't implemented.
|
||||
# This function is only implemented for MOD music formats (set pattern
|
||||
# order number) and for OGG music (set position in seconds), at the
|
||||
# moment.
|
||||
#
|
||||
proc Mix_SetMusicPosition*(position: float64): int{.cdecl,
|
||||
importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
|
||||
# Check the status of a specific channel.
|
||||
# If the specified channel is -1, check all channels.
|
||||
#
|
||||
proc Mix_Playing*(channel: int): int{.cdecl, importc: "Mix_Playing",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_PlayingMusic*(): int{.cdecl, importc: "Mix_PlayingMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Stop music and set external music playback command
|
||||
proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc: "Mix_SetMusicCMD",
|
||||
dynlib: MixerLibName.}
|
||||
# Synchro value is set by MikMod from modules while playing
|
||||
proc Mix_SetSynchroValue*(value: int): int{.cdecl,
|
||||
importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
|
||||
proc Mix_GetSynchroValue*(): int{.cdecl, importc: "Mix_GetSynchroValue",
|
||||
dynlib: MixerLibName.}
|
||||
#
|
||||
# Get the Mix_Chunk currently associated with a mixer channel
|
||||
# Returns nil if it's an invalid channel, or there's no chunk associated.
|
||||
#
|
||||
proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc: "Mix_GetChunk",
|
||||
dynlib: MixerLibName.}
|
||||
# Close the mixer, halting all playing audio
|
||||
proc Mix_CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
|
||||
# We'll use SDL for reporting errors
|
||||
proc Mix_SetError*(fmt: cstring)
|
||||
proc Mix_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc MIXER_VERSION(X: var Tversion) =
|
||||
X.major = MIXER_MAJOR_VERSION
|
||||
X.minor = MIXER_MINOR_VERSION
|
||||
X.patch = MIXER_PATCHLEVEL
|
||||
|
||||
proc Mix_LoadWAV(filename: cstring): PMix_Chunk =
|
||||
result = Mix_LoadWAV_RW(RWFromFile(filename, "rb"), 1)
|
||||
|
||||
proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int =
|
||||
result = Mix_PlayChannelTimed(channel, chunk, loops, - 1)
|
||||
|
||||
proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int =
|
||||
result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1)
|
||||
|
||||
proc Mix_SetError(fmt: cstring) =
|
||||
SetError(fmt)
|
||||
|
||||
proc Mix_GetError(): cstring =
|
||||
result = GetError()
|
||||
598
lib/newwrap/sdl/sdl_mixer_nosmpeg.nim
Normal file
598
lib/newwrap/sdl/sdl_mixer_nosmpeg.nim
Normal file
@@ -0,0 +1,598 @@
|
||||
#******************************************************************************
|
||||
# Copy of SDL_Mixer without smpeg dependency and mp3 support
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
MixerLibName = "SDL_mixer.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
MixerLibName = "libSDL_mixer-1.2.0.dylib"
|
||||
else:
|
||||
const
|
||||
MixerLibName = "libSDL_mixer.so"
|
||||
const
|
||||
MIXER_MAJOR_VERSION* = 1'i8
|
||||
MIXER_MINOR_VERSION* = 2'i8
|
||||
MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility
|
||||
MIX_MAJOR_VERSION* = MIXER_MAJOR_VERSION
|
||||
MIX_MINOR_VERSION* = MIXER_MINOR_VERSION
|
||||
MIX_PATCHLEVEL* = MIXER_PATCHLEVEL # SDL_Mixer.h constants
|
||||
# The default mixer has 8 simultaneous mixing channels
|
||||
MIX_CHANNELS* = 8 # Good default values for a PC soundcard
|
||||
MIX_DEFAULT_FREQUENCY* = 22050
|
||||
|
||||
when defined(IA32):
|
||||
const
|
||||
MIX_DEFAULT_FORMAT* = AUDIO_S16LSB
|
||||
else:
|
||||
const
|
||||
MIX_DEFAULT_FORMAT* = AUDIO_S16MSB
|
||||
const
|
||||
MIX_DEFAULT_CHANNELS* = 2
|
||||
MIX_MAX_VOLUME* = 128 # Volume of a chunk
|
||||
PATH_MAX* = 255 # mikmod.h constants
|
||||
#*
|
||||
# * Library version
|
||||
# *
|
||||
LIBMIKMOD_VERSION_MAJOR* = 3
|
||||
LIBMIKMOD_VERSION_MINOR* = 1
|
||||
LIBMIKMOD_REVISION* = 8
|
||||
LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
|
||||
(LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
|
||||
|
||||
type #music_cmd.h types
|
||||
PMusicCMD* = ptr TMusicCMD
|
||||
TMusicCMD*{.final.} = object #wavestream.h types
|
||||
filename*: array[0..PATH_MAX - 1, char]
|
||||
cmd*: array[0..PATH_MAX - 1, char]
|
||||
pid*: TSYS_ThreadHandle
|
||||
|
||||
PWAVStream* = ptr TWAVStream
|
||||
TWAVStream*{.final.} = object #playmidi.h types
|
||||
wavefp*: Pointer
|
||||
start*: int32
|
||||
stop*: int32
|
||||
cvt*: TAudioCVT
|
||||
|
||||
PMidiEvent* = ptr TMidiEvent
|
||||
TMidiEvent*{.final.} = object
|
||||
time*: int32
|
||||
channel*: uint8
|
||||
type_*: uint8
|
||||
a*: uint8
|
||||
b*: uint8
|
||||
|
||||
PMidiSong* = ptr TMidiSong
|
||||
TMidiSong*{.final.} = object #music_ogg.h types
|
||||
samples*: int32
|
||||
events*: PMidiEvent
|
||||
|
||||
POGG_Music* = ptr TOGG_Music
|
||||
TOGG_Music*{.final.} = object # mikmod.h types
|
||||
#*
|
||||
# * Error codes
|
||||
# *
|
||||
playing*: int
|
||||
volume*: int #vf: OggVorbis_File;
|
||||
section*: int
|
||||
cvt*: TAudioCVT
|
||||
len_available*: int
|
||||
snd_available*: PUint8
|
||||
|
||||
TErrorEnum* = enum
|
||||
MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
|
||||
MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
|
||||
MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
|
||||
MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
|
||||
MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
|
||||
MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
|
||||
MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
|
||||
MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
|
||||
MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
|
||||
MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
|
||||
MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
|
||||
MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
|
||||
MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
|
||||
MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
|
||||
MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
|
||||
MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
|
||||
MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
|
||||
MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
|
||||
MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
|
||||
PMODULE* = ptr TMODULE
|
||||
TMODULE*{.final.} = object
|
||||
PUNIMOD* = ptr TUNIMOD
|
||||
TUNIMOD* = TMODULE #SDL_mixer.h types
|
||||
# The internal format for an audio chunk
|
||||
PMix_Chunk* = ptr TMix_Chunk
|
||||
TMix_Chunk*{.final.} = object
|
||||
allocated*: int
|
||||
abuf*: PUint8
|
||||
alen*: Uint32
|
||||
volume*: Uint8 # Per-sample volume, 0-128
|
||||
|
||||
Mix_Chunk* = TMix_Chunk # The different fading types supported
|
||||
TMix_Fading* = enum
|
||||
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
|
||||
Mix_Fading* = TMix_Fading
|
||||
TMix_MusicType* = enum
|
||||
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG
|
||||
PMix_Music* = ptr TMix_Music
|
||||
TMix_Music*{.final.} = object
|
||||
type_*: TMix_MusicType
|
||||
|
||||
TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
|
||||
cdecl.} # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_mixer library.
|
||||
|
||||
proc MIXER_VERSION*(X: var TVersion)
|
||||
# This function gets the version of the dynamically linked SDL_mixer library.
|
||||
# It should NOT be used to fill a version structure, instead you should use the
|
||||
# SDL_MIXER_VERSION() macro.
|
||||
proc Mix_Linked_Version*(): Pversion{.cdecl, importc: "Mix_Linked_Version",
|
||||
dynlib: MixerLibName.}
|
||||
# Open the mixer with a certain audio format
|
||||
proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
|
||||
chunksize: int): int{.cdecl, importc: "Mix_OpenAudio",
|
||||
dynlib: MixerLibName.}
|
||||
# Dynamically change the number of channels managed by the mixer.
|
||||
# If decreasing the number of channels, the upper channels are
|
||||
# stopped.
|
||||
# This function returns the new number of allocated channels.
|
||||
#
|
||||
proc Mix_AllocateChannels*(numchannels: int): int{.cdecl,
|
||||
importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
|
||||
# Find out what the actual audio device parameters are.
|
||||
# This function returns 1 if the audio has been opened, 0 otherwise.
|
||||
#
|
||||
proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
|
||||
cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
|
||||
# Load a wave file or a music (.mod .s3m .it .xm) file
|
||||
proc Mix_LoadWAV_RW*(src: PRWops, freesrc: int): PMix_Chunk{.cdecl,
|
||||
importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
|
||||
proc Mix_LoadWAV*(filename: cstring): PMix_Chunk
|
||||
proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl, importc: "Mix_LoadMUS",
|
||||
dynlib: MixerLibName.}
|
||||
# Load a wave file of the mixer format from a memory buffer
|
||||
proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl,
|
||||
importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
|
||||
# Free an audio chunk previously loaded
|
||||
proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc: "Mix_FreeChunk",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc: "Mix_FreeMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Find out the music format of a mixer music, or the currently playing
|
||||
# music, if 'music' is NULL.
|
||||
proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl,
|
||||
importc: "Mix_GetMusicType", dynlib: MixerLibName.}
|
||||
# Set a function that is called after all mixing is performed.
|
||||
# This can be used to provide real-time visual display of the audio stream
|
||||
# or add a custom mixer filter for the stream data.
|
||||
#
|
||||
proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl,
|
||||
importc: "Mix_SetPostMix", dynlib: MixerLibName.}
|
||||
# Add your own music player or additional mixer function.
|
||||
# If 'mix_func' is NULL, the default music player is re-enabled.
|
||||
#
|
||||
proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
|
||||
importc: "Mix_HookMusic", dynlib: MixerLibName.}
|
||||
# Add your own callback when the music has finished playing.
|
||||
#
|
||||
proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl,
|
||||
importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
|
||||
# Get a pointer to the user data for the current music hook
|
||||
proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData",
|
||||
dynlib: MixerLibName.}
|
||||
#* Add your own callback when a channel has finished playing. NULL
|
||||
# * to disable callback.*
|
||||
type
|
||||
TChannel_finished* = proc (channel: int){.cdecl.}
|
||||
|
||||
proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
|
||||
importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
|
||||
const
|
||||
MIX_CHANNEL_POST* = - 2 #* This is the format of a special effect callback:
|
||||
# *
|
||||
# * myeffect(int chan, void *stream, int len, void *udata);
|
||||
# *
|
||||
# * (chan) is the channel number that your effect is affecting. (stream) is
|
||||
# * the buffer of data to work upon. (len) is the size of (stream), and
|
||||
# * (udata) is a user-defined bit of data, which you pass as the last arg of
|
||||
# * Mix_RegisterEffect(), and is passed back unmolested to your callback.
|
||||
# * Your effect changes the contents of (stream) based on whatever parameters
|
||||
# * are significant, or just leaves it be, if you prefer. You can do whatever
|
||||
# * you like to the buffer, though, and it will continue in its changed state
|
||||
# * down the mixing pipeline, through any other effect functions, then finally
|
||||
# * to be mixed with the rest of the channels and music for the final output
|
||||
# * stream.
|
||||
# *
|
||||
|
||||
type
|
||||
TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int,
|
||||
udata: Pointer): Pointer{.cdecl.} # * This is a callback that signifies that a channel has finished all its
|
||||
# * loops and has completed playback. This gets called if the buffer
|
||||
# * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
|
||||
# * a channel via
|
||||
# Mix_AllocateChannels(), or unregister a callback while
|
||||
# * it's still playing.
|
||||
TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.} #* Register a special effect function. At mixing time, the channel data is
|
||||
# * copied into a buffer and passed through each registered effect function.
|
||||
# * After it passes through all the functions, it is mixed into the final
|
||||
# * output stream. The copy to buffer is performed once, then each effect
|
||||
# * function performs on the output of the previous effect. Understand that
|
||||
# * this extra copy to a buffer is not performed if there are no effects
|
||||
# * registered for a given chunk, which saves CPU cycles, and any given
|
||||
# * effect will be extra cycles, too, so it is crucial that your code run
|
||||
# * fast. Also note that the data that your function is given is in the
|
||||
# * format of the sound device, and not the format you gave to Mix_OpenAudio(),
|
||||
# * although they may in reality be the same. This is an unfortunate but
|
||||
# * necessary speed concern. Use Mix_QuerySpec() to determine if you can
|
||||
# * handle the data before you register your effect, and take appropriate
|
||||
# * actions.
|
||||
# * You may also specify a callback (Mix_EffectDone_t) that is called when
|
||||
# * the channel finishes playing. This gives you a more fine-grained control
|
||||
# * than Mix_ChannelFinished(), in case you need to free effect-specific
|
||||
# * resources, etc. If you don't need this, you can specify NULL.
|
||||
# * You may set the callbacks before or after calling Mix_PlayChannel().
|
||||
# * Things like Mix_SetPanning() are just internal special effect functions,
|
||||
# * so if you are using that, you've already incurred the overhead of a copy
|
||||
# * to a separate buffer, and that these effects will be in the queue with
|
||||
# * any functions you've registered. The list of registered effects for a
|
||||
# * channel is reset when a chunk finishes playing, so you need to explicitly
|
||||
# * set them with each call to Mix_PlayChannel*().
|
||||
# * You may also register a special effect function that is to be run after
|
||||
# * final mixing occurs. The rules for these callbacks are identical to those
|
||||
# * in Mix_RegisterEffect, but they are run after all the channels and the
|
||||
# * music have been mixed into a single stream, whereas channel-specific
|
||||
# * effects run on a given channel before any other mixing occurs. These
|
||||
# * global effect callbacks are call "posteffects". Posteffects only have
|
||||
# * their Mix_EffectDone_t function called when they are unregistered (since
|
||||
# * the main output stream is never "done" in the same sense as a channel).
|
||||
# * You must unregister them manually when you've had enough. Your callback
|
||||
# * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
|
||||
# * processing is considered a posteffect.
|
||||
# *
|
||||
# * After all these effects have finished processing, the callback registered
|
||||
# * through Mix_SetPostMix() runs, and then the stream goes to the audio
|
||||
# * device.
|
||||
# *
|
||||
# * returns zero if error (no such channel), nonzero if added.
|
||||
# * Error messages can be retrieved from Mix_GetError().
|
||||
|
||||
proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone,
|
||||
arg: Pointer): int{.cdecl,
|
||||
importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
|
||||
#* You may not need to call this explicitly, unless you need to stop an
|
||||
# * effect from processing in the middle of a chunk's playback.
|
||||
# * Posteffects are never implicitly unregistered as they are for channels,
|
||||
# * but they may be explicitly unregistered through this function by
|
||||
# * specifying MIX_CHANNEL_POST for a channel.
|
||||
# * returns zero if error (no such channel or effect), nonzero if removed.
|
||||
# * Error messages can be retrieved from Mix_GetError().
|
||||
# *
|
||||
proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
|
||||
importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
|
||||
#* You may not need to call this explicitly, unless you need to stop all
|
||||
# * effects from processing in the middle of a chunk's playback. Note that
|
||||
# * this will also shut off some internal effect processing, since
|
||||
# * Mix_SetPanning( ) and others may use this API under the hood.This is
|
||||
# * called internally when a channel completes playback.
|
||||
# * Posteffects are never implicitly unregistered as they are for channels,
|
||||
# * but they may be explicitly unregistered through this function by
|
||||
# * specifying MIX_CHANNEL_POST for a channel.
|
||||
# * returns zero if error( no such channel ), nonzero if all effects removed.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
|
||||
importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
|
||||
const
|
||||
MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" # * These are the internally - defined mixing effects.They use the same API that
|
||||
# * effects defined in the application use, but are provided here as a
|
||||
# * convenience.Some effects can reduce their quality or use more memory in
|
||||
# * the name of speed; to enable this, make sure the environment variable
|
||||
# * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
|
||||
# * Mix_OpenAudio( ).
|
||||
# *
|
||||
#* set the panning of a channel.The left and right channels are specified
|
||||
# * as integers between 0 and 255, quietest to loudest, respectively.
|
||||
# *
|
||||
# * Technically, this is just individual volume control for a sample with
|
||||
# * two( stereo )channels, so it can be used for more than just panning.
|
||||
# * if you want real panning, call it like this :
|
||||
# *
|
||||
# * Mix_SetPanning( channel, left, 255 - left );
|
||||
# *
|
||||
# * ...which isn't so hard.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the panning will be done to the final mixed stream before passing it on
|
||||
# * to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally, and returns without
|
||||
# * registering the effect function if the audio device is not configured
|
||||
# * for stereo output.Setting both( left ) and ( right ) to 255 causes this
|
||||
# * effect to be unregistered, since that is the data's normal state.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if panning effect enabled.Note that an audio device in mono
|
||||
# * mode is a no - op, but this call will return successful in that case .
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
|
||||
proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
|
||||
importc: "Mix_SetPanning", dynlib: MixerLibName.}
|
||||
# * set the position ofa channel.( angle ) is an integer from 0 to 360, that
|
||||
# * specifies the location of the sound in relation to the listener.( angle )
|
||||
# * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
|
||||
# * Angle 0 is due north, and rotates clockwise as the value increases.
|
||||
# * for efficiency, the precision of this effect may be limited( angles 1
|
||||
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
|
||||
# * ( distance ) is an integer between 0 and 255 that specifies the space
|
||||
# * between the sound and the listener.The larger the number, the further
|
||||
# * away the sound is .Using 255 does not guarantee that the channel will be
|
||||
# * culled from the mixing process or be completely silent.For efficiency,
|
||||
# * the precision of this effect may be limited( distance 0 through 5 might
|
||||
# * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
|
||||
# * and ( distance ) to 0 unregisters this effect, since the data would be
|
||||
# * unchanged.
|
||||
# *
|
||||
# * if you need more precise positional audio, consider using OpenAL for
|
||||
# * spatialized effects instead of SDL_mixer.This is only meant to be a
|
||||
# * basic effect for simple "3D" games.
|
||||
# *
|
||||
# * if the audio device is configured for mono output, then you won't get
|
||||
# * any effectiveness from the angle; however, distance attenuation on the
|
||||
# * channel will still occur.While this effect will function with stereo
|
||||
# * voices, it makes more sense to use voices with only one channel of sound,
|
||||
# * so when they are mixed through this effect, the positioning will sound
|
||||
# * correct.You can convert them to mono through SDL before giving them to
|
||||
# * the mixer in the first place if you like.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the positioning will be done to the final mixed stream before passing it
|
||||
# * on to the audio device.
|
||||
# *
|
||||
# * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if position effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
|
||||
importc: "Mix_SetPosition", dynlib: MixerLibName.}
|
||||
#* set the "distance" of a channel.( distance ) is an integer from 0 to 255
|
||||
# * that specifies the location of the sound in relation to the listener.
|
||||
# * Distance 0 is overlapping the listener, and 255 is as far away as possible
|
||||
# * A distance of 255 does not guarantee silence; in such a case , you might
|
||||
# * want to try changing the chunk's volume, or just cull the sample from the
|
||||
# * mixing process with Mix_HaltChannel( ).
|
||||
# * for efficiency, the precision of this effect may be limited( distances 1
|
||||
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
|
||||
# * ( distance ) is an integer between 0 and 255 that specifies the space
|
||||
# * between the sound and the listener.The larger the number, the further
|
||||
# * away the sound is .
|
||||
# * Setting( distance ) to 0 unregisters this effect, since the data would be
|
||||
# * unchanged.
|
||||
# * if you need more precise positional audio, consider using OpenAL for
|
||||
# * spatialized effects instead of SDL_mixer.This is only meant to be a
|
||||
# * basic effect for simple "3D" games.
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the distance attenuation will be done to the final mixed stream before
|
||||
# * passing it on to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if position effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
|
||||
importc: "Mix_SetDistance", dynlib: MixerLibName.}
|
||||
# *
|
||||
# * !!! FIXME : Haven't implemented, since the effect goes past the
|
||||
# * end of the sound buffer.Will have to think about this.
|
||||
# * - -ryan.
|
||||
# * /
|
||||
# { if 0
|
||||
# { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
|
||||
# * of echo to mix.0 is no echo, 255 is infinite( and probably not
|
||||
# * what you want ).
|
||||
# *
|
||||
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
|
||||
# * the reverbing will be done to the final mixed stream before passing it on
|
||||
# * to the audio device.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
|
||||
# * of zero, the effect is unregistered, as the data is already in that state.
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if reversing effect is enabled.
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
# extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
|
||||
# #E ndif
|
||||
# * Causes a channel to reverse its stereo.This is handy if the user has his
|
||||
# * speakers hooked up backwards, or you would like to have a minor bit of
|
||||
# * psychedelia in your sound code. : )Calling this function with ( flip )
|
||||
# * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
|
||||
# * the effect is unregistered.
|
||||
# *
|
||||
# * This uses the Mix_RegisterEffect( )API internally, and thus is probably
|
||||
# * more CPU intensive than having the user just plug in his speakers
|
||||
# * correctly.Mix_SetReverseStereo( )returns without registering the effect
|
||||
# * function if the audio device is not configured for stereo output.
|
||||
# *
|
||||
# * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
|
||||
# * on the final mixed stream before sending it on to the audio device( a
|
||||
# * posteffect ).
|
||||
# *
|
||||
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
|
||||
# * nonzero if reversing effect is enabled.Note that an audio device in mono
|
||||
# * mode is a no - op, but this call will return successful in that case .
|
||||
# * Error messages can be retrieved from Mix_GetError( ).
|
||||
# *
|
||||
proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
|
||||
importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
|
||||
# end of effects API. - -ryan. *
|
||||
# Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
|
||||
# them dynamically to the next sample if requested with a -1 value below.
|
||||
# Returns the number of reserved channels.
|
||||
#
|
||||
proc Mix_ReserveChannels*(num: int): int{.cdecl, importc: "Mix_ReserveChannels",
|
||||
dynlib: MixerLibName.}
|
||||
# Channel grouping functions
|
||||
# Attach a tag to a channel. A tag can be assigned to several mixer
|
||||
# channels, to form groups of channels.
|
||||
# If 'tag' is -1, the tag is removed (actually -1 is the tag used to
|
||||
# represent the group of all the channels).
|
||||
# Returns true if everything was OK.
|
||||
#
|
||||
proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
|
||||
importc: "Mix_GroupChannel", dynlib: MixerLibName.}
|
||||
# Assign several consecutive channels to a group
|
||||
proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
|
||||
importc: "Mix_GroupChannels", dynlib: MixerLibName.}
|
||||
# Finds the first available channel in a group of channels
|
||||
proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc: "Mix_GroupAvailable",
|
||||
dynlib: MixerLibName.}
|
||||
# Returns the number of channels in a group. This is also a subtle
|
||||
# way to get the total number of channels when 'tag' is -1
|
||||
#
|
||||
proc Mix_GroupCount*(tag: int): int{.cdecl, importc: "Mix_GroupCount",
|
||||
dynlib: MixerLibName.}
|
||||
# Finds the "oldest" sample playing in a group of channels
|
||||
proc Mix_GroupOldest*(tag: int): int{.cdecl, importc: "Mix_GroupOldest",
|
||||
dynlib: MixerLibName.}
|
||||
# Finds the "most recent" (i.e. last) sample playing in a group of channels
|
||||
proc Mix_GroupNewer*(tag: int): int{.cdecl, importc: "Mix_GroupNewer",
|
||||
dynlib: MixerLibName.}
|
||||
# The same as above, but the sound is played at most 'ticks' milliseconds
|
||||
proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
|
||||
ticks: int): int{.cdecl,
|
||||
importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
|
||||
# Play an audio chunk on a specific channel.
|
||||
# If the specified channel is -1, play on the first free channel.
|
||||
# If 'loops' is greater than zero, loop the sound that many times.
|
||||
# If 'loops' is -1, loop inifinitely (~65000 times).
|
||||
# Returns which channel was used to play the sound.
|
||||
#
|
||||
proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
|
||||
proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
|
||||
importc: "Mix_PlayMusic", dynlib: MixerLibName.}
|
||||
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
|
||||
proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl,
|
||||
importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
|
||||
proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
|
||||
ms: int, ticks: int): int{.cdecl,
|
||||
importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
|
||||
proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int
|
||||
# Set the volume in the range of 0-128 of a specific channel or chunk.
|
||||
# If the specified channel is -1, set volume for all channels.
|
||||
# Returns the original volume.
|
||||
# If the specified volume is -1, just return the current volume.
|
||||
#
|
||||
proc Mix_Volume*(channel: int, volume: int): int{.cdecl, importc: "Mix_Volume",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl,
|
||||
importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
|
||||
proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc: "Mix_VolumeMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Halt playing of a particular channel
|
||||
proc Mix_HaltChannel*(channel: int): int{.cdecl, importc: "Mix_HaltChannel",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_HaltGroup*(tag: int): int{.cdecl, importc: "Mix_HaltGroup",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_HaltMusic*(): int{.cdecl, importc: "Mix_HaltMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Change the expiration delay for a particular channel.
|
||||
# The sample will stop playing after the 'ticks' milliseconds have elapsed,
|
||||
# or remove the expiration if 'ticks' is -1
|
||||
#
|
||||
proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl,
|
||||
importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
|
||||
# Halt a channel, fading it out progressively till it's silent
|
||||
# The ms parameter indicates the number of milliseconds the fading
|
||||
# will take.
|
||||
#
|
||||
proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl,
|
||||
importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
|
||||
proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl,
|
||||
importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
|
||||
proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc: "Mix_FadeOutMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Query the fading status of a channel
|
||||
proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc: "Mix_FadingMusic",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl,
|
||||
importc: "Mix_FadingChannel", dynlib: MixerLibName.}
|
||||
# Pause/Resume a particular channel
|
||||
proc Mix_Pause*(channel: int){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
|
||||
proc Mix_Resume*(channel: int){.cdecl, importc: "Mix_Resume",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_Paused*(channel: int): int{.cdecl, importc: "Mix_Paused",
|
||||
dynlib: MixerLibName.}
|
||||
# Pause/Resume the music stream
|
||||
proc Mix_PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
|
||||
proc Mix_ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
|
||||
proc Mix_RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
|
||||
proc Mix_PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Set the current position in the music stream.
|
||||
# This returns 0 if successful, or -1 if it failed or isn't implemented.
|
||||
# This function is only implemented for MOD music formats (set pattern
|
||||
# order number) and for OGG music (set position in seconds), at the
|
||||
# moment.
|
||||
#
|
||||
proc Mix_SetMusicPosition*(position: float64): int{.cdecl,
|
||||
importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
|
||||
# Check the status of a specific channel.
|
||||
# If the specified channel is -1, check all channels.
|
||||
#
|
||||
proc Mix_Playing*(channel: int): int{.cdecl, importc: "Mix_Playing",
|
||||
dynlib: MixerLibName.}
|
||||
proc Mix_PlayingMusic*(): int{.cdecl, importc: "Mix_PlayingMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Stop music and set external music playback command
|
||||
proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc: "Mix_SetMusicCMD",
|
||||
dynlib: MixerLibName.}
|
||||
# Synchro value is set by MikMod from modules while playing
|
||||
proc Mix_SetSynchroValue*(value: int): int{.cdecl,
|
||||
importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
|
||||
proc Mix_GetSynchroValue*(): int{.cdecl, importc: "Mix_GetSynchroValue",
|
||||
dynlib: MixerLibName.}
|
||||
#
|
||||
# Get the Mix_Chunk currently associated with a mixer channel
|
||||
# Returns nil if it's an invalid channel, or there's no chunk associated.
|
||||
#
|
||||
proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc: "Mix_GetChunk",
|
||||
dynlib: MixerLibName.}
|
||||
# Close the mixer, halting all playing audio
|
||||
proc Mix_CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
|
||||
# We'll use SDL for reporting errors
|
||||
proc Mix_SetError*(fmt: cstring)
|
||||
proc Mix_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc MIXER_VERSION(X: var Tversion) =
|
||||
X.major = MIXER_MAJOR_VERSION
|
||||
X.minor = MIXER_MINOR_VERSION
|
||||
X.patch = MIXER_PATCHLEVEL
|
||||
|
||||
proc Mix_LoadWAV(filename: cstring): PMix_Chunk =
|
||||
result = Mix_LoadWAV_RW(RWFromFile(filename, "rb"), 1)
|
||||
|
||||
proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int =
|
||||
result = Mix_PlayChannelTimed(channel, chunk, loops, - 1)
|
||||
|
||||
proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int =
|
||||
result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1)
|
||||
|
||||
proc Mix_SetError(fmt: cstring) =
|
||||
SetError(fmt)
|
||||
|
||||
proc Mix_GetError(): cstring =
|
||||
result = GetError()
|
||||
442
lib/newwrap/sdl/sdl_net.nim
Normal file
442
lib/newwrap/sdl/sdl_net.nim
Normal file
@@ -0,0 +1,442 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: sdl_net.pas,v 1.7 2005/01/01 02:14:21 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SDL_Net - A x-platform network library for use with SDL.
|
||||
# Conversion of the Simple DirectMedia Layer Network Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_net.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas somehere in your search path
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 09 2001 - DL : Initial Translation
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_net.pas,v $
|
||||
# Revision 1.7 2005/01/01 02:14:21 savage
|
||||
# Updated to v1.2.5
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/16 22:16:40 savage
|
||||
# v1.0 changes
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
NetLibName = "SDL_net.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
NetLibName = "libSDL_net.dylib"
|
||||
else:
|
||||
const
|
||||
NetLibName = "libSDL_net.so"
|
||||
const #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *
|
||||
NET_MAJOR_VERSION* = 1'i8
|
||||
NET_MINOR_VERSION* = 2'i8
|
||||
NET_PATCHLEVEL* = 5'i8 # SDL_Net.h constants
|
||||
#* Resolve a host name and port to an IP address in network form.
|
||||
# If the function succeeds, it will return 0.
|
||||
# If the host couldn't be resolved, the host portion of the returned
|
||||
# address will be INADDR_NONE, and the function will return -1.
|
||||
# If 'host' is NULL, the resolved host will be set to INADDR_ANY.
|
||||
# *
|
||||
INADDR_ANY* = 0x00000000
|
||||
INADDR_NONE* = 0xFFFFFFFF #***********************************************************************
|
||||
#* UDP network API *
|
||||
#***********************************************************************
|
||||
#* The maximum channels on a a UDP socket *
|
||||
NET_MAX_UDPCHANNELS* = 32 #* The maximum addresses bound to a single UDP socket channel *
|
||||
NET_MAX_UDPADDRESSES* = 4
|
||||
|
||||
type # SDL_net.h types
|
||||
#***********************************************************************
|
||||
#* IPv4 hostname resolution API *
|
||||
#***********************************************************************
|
||||
PIPAddress* = ptr TIPAddress
|
||||
TIPAddress*{.final.} = object #* TCP network API
|
||||
host*: Uint32 # 32-bit IPv4 host address */
|
||||
port*: Uint16 # 16-bit protocol port */
|
||||
|
||||
PTCPSocket* = ptr TTCPSocket
|
||||
TTCPSocket*{.final.} = object #***********************************************************************
|
||||
#* UDP network API *
|
||||
#***********************************************************************
|
||||
ready*: int
|
||||
channel*: int
|
||||
remoteAddress*: TIPaddress
|
||||
localAddress*: TIPaddress
|
||||
sflag*: int
|
||||
|
||||
PUDP_Channel* = ptr TUDP_Channel
|
||||
TUDP_Channel*{.final.} = object
|
||||
numbound*: int
|
||||
address*: array[0..NET_MAX_UDPADDRESSES - 1, TIPAddress]
|
||||
|
||||
PUDPSocket* = ptr TUDPSocket
|
||||
TUDPSocket*{.final.} = object
|
||||
ready*: int
|
||||
channel*: int
|
||||
address*: TIPAddress
|
||||
binding*: array[0..NET_MAX_UDPCHANNELS - 1, TUDP_Channel]
|
||||
|
||||
PUDPpacket* = ptr TUDPpacket
|
||||
PPUDPpacket* = ptr PUDPpacket
|
||||
TUDPpacket*{.final.} = object #***********************************************************************
|
||||
#* Hooks for checking sockets for available data *
|
||||
#***********************************************************************
|
||||
channel*: int #* The src/dst channel of the packet *
|
||||
data*: PUint8 #* The packet data *
|
||||
length*: int #* The length of the packet data *
|
||||
maxlen*: int #* The size of the data buffer *
|
||||
status*: int #* packet status after sending *
|
||||
address*: TIPAddress #* The source/dest address of an incoming/outgoing packet *
|
||||
|
||||
PNet_Socket* = ptr TNet_Socket
|
||||
TNet_Socket*{.final.} = object
|
||||
ready*: int
|
||||
channel*: int
|
||||
|
||||
PNet_SocketSet* = ptr TNet_SocketSet
|
||||
TNet_SocketSet*{.final.} = object #* Any network socket can be safely cast to this socket type *
|
||||
numsockets*: int
|
||||
maxsockets*: int
|
||||
sockets*: PNet_Socket
|
||||
|
||||
PNet_GenericSocket* = ptr TNet_GenericSocket
|
||||
TNet_GenericSocket*{.final.} = object # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_net library.
|
||||
ready*: int
|
||||
|
||||
|
||||
proc NET_VERSION*(X: var Tversion)
|
||||
#* Initialize/Cleanup the network API
|
||||
# SDL must be initialized before calls to functions in this library,
|
||||
# because this library uses utility functions from the SDL library.
|
||||
#*
|
||||
proc Net_Init*(): int{.cdecl, importc: "SDLNet_Init", dynlib: NetLibName.}
|
||||
proc Net_Quit*(){.cdecl, importc: "SDLNet_Quit", dynlib: NetLibName.}
|
||||
#* Resolve a host name and port to an IP address in network form.
|
||||
# If the function succeeds, it will return 0.
|
||||
# If the host couldn't be resolved, the host portion of the returned
|
||||
# address will be INADDR_NONE, and the function will return -1.
|
||||
# If 'host' is NULL, the resolved host will be set to INADDR_ANY.
|
||||
# *
|
||||
proc Net_ResolveHost*(address: var TIPaddress, host: cstring, port: Uint16): int{.
|
||||
cdecl, importc: "SDLNet_ResolveHost", dynlib: NetLibName.}
|
||||
#* Resolve an ip address to a host name in canonical form.
|
||||
# If the ip couldn't be resolved, this function returns NULL,
|
||||
# otherwise a pointer to a static buffer containing the hostname
|
||||
# is returned. Note that this function is not thread-safe.
|
||||
#*
|
||||
proc Net_ResolveIP*(ip: var TIPaddress): cstring{.cdecl,
|
||||
importc: "SDLNet_ResolveIP", dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* TCP network API *
|
||||
#***********************************************************************
|
||||
#* Open a TCP network socket
|
||||
# If ip.host is INADDR_NONE, this creates a local server socket on the
|
||||
# given port, otherwise a TCP connection to the remote host and port is
|
||||
# attempted. The address passed in should already be swapped to network
|
||||
# byte order (addresses returned from SDLNet_ResolveHost() are already
|
||||
# in the correct form).
|
||||
# The newly created socket is returned, or NULL if there was an error.
|
||||
#*
|
||||
proc Net_TCP_Open*(ip: var TIPaddress): PTCPSocket{.cdecl,
|
||||
importc: "SDLNet_TCP_Open", dynlib: NetLibName.}
|
||||
#* Accept an incoming connection on the given server socket.
|
||||
# The newly created socket is returned, or NULL if there was an error.
|
||||
#*
|
||||
proc Net_TCP_Accept*(server: PTCPsocket): PTCPSocket{.cdecl,
|
||||
importc: "SDLNet_TCP_Accept", dynlib: NetLibName.}
|
||||
#* Get the IP address of the remote system associated with the socket.
|
||||
# If the socket is a server socket, this function returns NULL.
|
||||
#*
|
||||
proc Net_TCP_GetPeerAddress*(sock: PTCPsocket): PIPAddress{.cdecl,
|
||||
importc: "SDLNet_TCP_GetPeerAddress", dynlib: NetLibName.}
|
||||
#* Send 'len' bytes of 'data' over the non-server socket 'sock'
|
||||
# This function returns the actual amount of data sent. If the return value
|
||||
# is less than the amount of data sent, then either the remote connection was
|
||||
# closed, or an unknown socket error occurred.
|
||||
#*
|
||||
proc Net_TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl,
|
||||
importc: "SDLNet_TCP_Send", dynlib: NetLibName.}
|
||||
#* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
|
||||
# and store them in the buffer pointed to by 'data'.
|
||||
# This function returns the actual amount of data received. If the return
|
||||
# value is less than or equal to zero, then either the remote connection was
|
||||
# closed, or an unknown socket error occurred.
|
||||
#*
|
||||
proc Net_TCP_Recv*(sock: PTCPsocket, data: Pointer, maxlen: int): int{.cdecl,
|
||||
importc: "SDLNet_TCP_Recv", dynlib: NetLibName.}
|
||||
#* Close a TCP network socket *
|
||||
proc Net_TCP_Close*(sock: PTCPsocket){.cdecl, importc: "SDLNet_TCP_Close",
|
||||
dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* UDP network API *
|
||||
#***********************************************************************
|
||||
#* Allocate/resize/free a single UDP packet 'size' bytes long.
|
||||
# The new packet is returned, or NULL if the function ran out of memory.
|
||||
# *
|
||||
proc Net_AllocPacket*(size: int): PUDPpacket{.cdecl,
|
||||
importc: "SDLNet_AllocPacket", dynlib: NetLibName.}
|
||||
proc Net_ResizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl,
|
||||
importc: "SDLNet_ResizePacket", dynlib: NetLibName.}
|
||||
proc Net_FreePacket*(packet: PUDPpacket){.cdecl, importc: "SDLNet_FreePacket",
|
||||
dynlib: NetLibName.}
|
||||
#* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
|
||||
# each 'size' bytes long.
|
||||
# A pointer to the first packet in the array is returned, or NULL if the
|
||||
# function ran out of memory.
|
||||
# *
|
||||
proc Net_AllocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl,
|
||||
importc: "SDLNet_AllocPacketV", dynlib: NetLibName.}
|
||||
proc Net_FreePacketV*(packetV: PUDPpacket){.cdecl,
|
||||
importc: "SDLNet_FreePacketV", dynlib: NetLibName.}
|
||||
#* Open a UDP network socket
|
||||
# If 'port' is non-zero, the UDP socket is bound to a local port.
|
||||
# This allows other systems to send to this socket via a known port.
|
||||
#*
|
||||
proc Net_UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc: "SDLNet_UDP_Open",
|
||||
dynlib: NetLibName.}
|
||||
#* Bind the address 'address' to the requested channel on the UDP socket.
|
||||
# If the channel is -1, then the first unbound channel will be bound with
|
||||
# the given address as it's primary address.
|
||||
# If the channel is already bound, this new address will be added to the
|
||||
# list of valid source addresses for packets arriving on the channel.
|
||||
# If the channel is not already bound, then the address becomes the primary
|
||||
# address, to which all outbound packets on the channel are sent.
|
||||
# This function returns the channel which was bound, or -1 on error.
|
||||
#*
|
||||
proc Net_UDP_Bind*(sock: PUDPsocket, channel: int, address: var TIPaddress): int{.
|
||||
cdecl, importc: "SDLNet_UDP_Bind", dynlib: NetLibName.}
|
||||
#* Unbind all addresses from the given channel *
|
||||
proc Net_UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl,
|
||||
importc: "SDLNet_UDP_Unbind", dynlib: NetLibName.}
|
||||
#* Get the primary IP address of the remote system associated with the
|
||||
# socket and channel. If the channel is -1, then the primary IP port
|
||||
# of the UDP socket is returned -- this is only meaningful for sockets
|
||||
# opened with a specific port.
|
||||
# If the channel is not bound and not -1, this function returns NULL.
|
||||
# *
|
||||
proc Net_UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{.cdecl,
|
||||
importc: "SDLNet_UDP_GetPeerAddress", dynlib: NetLibName.}
|
||||
#* Send a vector of packets to the the channels specified within the packet.
|
||||
# If the channel specified in the packet is -1, the packet will be sent to
|
||||
# the address in the 'src' member of the packet.
|
||||
# Each packet will be updated with the status of the packet after it has
|
||||
# been sent, -1 if the packet send failed.
|
||||
# This function returns the number of packets sent.
|
||||
#*
|
||||
proc Net_UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{.
|
||||
cdecl, importc: "SDLNet_UDP_SendV", dynlib: NetLibName.}
|
||||
#* Send a single packet to the specified channel.
|
||||
# If the channel specified in the packet is -1, the packet will be sent to
|
||||
# the address in the 'src' member of the packet.
|
||||
# The packet will be updated with the status of the packet after it has
|
||||
# been sent.
|
||||
# This function returns 1 if the packet was sent, or 0 on error.
|
||||
#*
|
||||
proc Net_UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{.
|
||||
cdecl, importc: "SDLNet_UDP_Send", dynlib: NetLibName.}
|
||||
#* Receive a vector of pending packets from the UDP socket.
|
||||
# The returned packets contain the source address and the channel they arrived
|
||||
# on. If they did not arrive on a bound channel, the the channel will be set
|
||||
# to -1.
|
||||
# The channels are checked in highest to lowest order, so if an address is
|
||||
# bound to multiple channels, the highest channel with the source address
|
||||
# bound will be returned.
|
||||
# This function returns the number of packets read from the network, or -1
|
||||
# on error. This function does not block, so can return 0 packets pending.
|
||||
#*
|
||||
proc Net_UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl,
|
||||
importc: "SDLNet_UDP_RecvV", dynlib: NetLibName.}
|
||||
#* Receive a single packet from the UDP socket.
|
||||
# The returned packet contains the source address and the channel it arrived
|
||||
# on. If it did not arrive on a bound channel, the the channel will be set
|
||||
# to -1.
|
||||
# The channels are checked in highest to lowest order, so if an address is
|
||||
# bound to multiple channels, the highest channel with the source address
|
||||
# bound will be returned.
|
||||
# This function returns the number of packets read from the network, or -1
|
||||
# on error. This function does not block, so can return 0 packets pending.
|
||||
#*
|
||||
proc Net_UDP_Recv*(sock: PUDPsocket, packet: PUDPpacket): int{.cdecl,
|
||||
importc: "SDLNet_UDP_Recv", dynlib: NetLibName.}
|
||||
#* Close a UDP network socket *
|
||||
proc Net_UDP_Close*(sock: PUDPsocket){.cdecl, importc: "SDLNet_UDP_Close",
|
||||
dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* Hooks for checking sockets for available data *
|
||||
#***********************************************************************
|
||||
#* Allocate a socket set for use with SDLNet_CheckSockets()
|
||||
# This returns a socket set for up to 'maxsockets' sockets, or NULL if
|
||||
# the function ran out of memory.
|
||||
# *
|
||||
proc Net_AllocSocketSet*(maxsockets: int): PNet_SocketSet{.cdecl,
|
||||
importc: "SDLNet_AllocSocketSet", dynlib: NetLibName.}
|
||||
#* Add a socket to a set of sockets to be checked for available data *
|
||||
proc Net_AddSocket*(theSet: PNet_SocketSet, sock: PNet_GenericSocket): int{.
|
||||
cdecl, importc: "SDLNet_AddSocket", dynlib: NetLibName.}
|
||||
proc Net_TCP_AddSocket*(theSet: PNet_SocketSet, sock: PTCPSocket): int
|
||||
proc Net_UDP_AddSocket*(theSet: PNet_SocketSet, sock: PUDPSocket): int
|
||||
#* Remove a socket from a set of sockets to be checked for available data *
|
||||
proc Net_DelSocket*(theSet: PNet_SocketSet, sock: PNet_GenericSocket): int{.
|
||||
cdecl, importc: "SDLNet_DelSocket", dynlib: NetLibName.}
|
||||
proc Net_TCP_DelSocket*(theSet: PNet_SocketSet, sock: PTCPSocket): int
|
||||
# SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
|
||||
proc Net_UDP_DelSocket*(theSet: PNet_SocketSet, sock: PUDPSocket): int
|
||||
#SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
|
||||
#* This function checks to see if data is available for reading on the
|
||||
# given set of sockets. If 'timeout' is 0, it performs a quick poll,
|
||||
# otherwise the function returns when either data is available for
|
||||
# reading, or the timeout in milliseconds has elapsed, which ever occurs
|
||||
# first. This function returns the number of sockets ready for reading,
|
||||
# or -1 if there was an error with the select() system call.
|
||||
#*
|
||||
proc Net_CheckSockets*(theSet: PNet_SocketSet, timeout: Sint32): int{.cdecl,
|
||||
importc: "SDLNet_CheckSockets", dynlib: NetLibName.}
|
||||
#* After calling SDLNet_CheckSockets(), you can use this function on a
|
||||
# socket that was in the socket set, to find out if data is available
|
||||
# for reading.
|
||||
#*
|
||||
proc Net_SocketReady*(sock: PNet_GenericSocket): bool
|
||||
#* Free a set of sockets allocated by SDL_NetAllocSocketSet() *
|
||||
proc Net_FreeSocketSet*(theSet: PNet_SocketSet){.cdecl,
|
||||
importc: "SDLNet_FreeSocketSet", dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* Platform-independent data conversion functions *
|
||||
#***********************************************************************
|
||||
#* Write a 16/32 bit value to network packet buffer *
|
||||
proc Net_Write16*(value: Uint16, area: Pointer){.cdecl,
|
||||
importc: "SDLNet_Write16", dynlib: NetLibName.}
|
||||
proc Net_Write32*(value: Uint32, area: Pointer){.cdecl,
|
||||
importc: "SDLNet_Write32", dynlib: NetLibName.}
|
||||
#* Read a 16/32 bit value from network packet buffer *
|
||||
proc Net_Read16*(area: Pointer): Uint16{.cdecl, importc: "SDLNet_Read16",
|
||||
dynlib: NetLibName.}
|
||||
proc Net_Read32*(area: Pointer): Uint32{.cdecl, importc: "SDLNet_Read32",
|
||||
dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* Error reporting functions *
|
||||
#***********************************************************************
|
||||
#* We'll use SDL's functions for error reporting *
|
||||
proc Net_SetError*(fmt: cstring)
|
||||
proc Net_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc NET_VERSION(X: var Tversion) =
|
||||
X.major = NET_MAJOR_VERSION
|
||||
X.minor = NET_MINOR_VERSION
|
||||
X.patch = NET_PATCHLEVEL
|
||||
|
||||
proc Net_TCP_AddSocket(theSet: PNet_SocketSet, sock: PTCPSocket): int =
|
||||
result = Net_AddSocket(theSet, cast[PNet_GenericSocket](sock))
|
||||
|
||||
proc Net_UDP_AddSocket(theSet: PNet_SocketSet, sock: PUDPSocket): int =
|
||||
result = Net_AddSocket(theSet, cast[PNet_GenericSocket](sock))
|
||||
|
||||
proc Net_TCP_DelSocket(theSet: PNet_SocketSet, sock: PTCPSocket): int =
|
||||
result = Net_DelSocket(theSet, cast[PNet_GenericSocket](sock))
|
||||
|
||||
proc Net_UDP_DelSocket(theSet: PNet_SocketSet, sock: PUDPSocket): int =
|
||||
result = Net_DelSocket(theSet, cast[PNet_GenericSocket](sock))
|
||||
|
||||
proc Net_SocketReady(sock: PNet_GenericSocket): bool =
|
||||
result = ((sock != nil) and (sock.ready == 1))
|
||||
|
||||
proc Net_SetError(fmt: cstring) =
|
||||
SetError(fmt)
|
||||
|
||||
proc Net_GetError(): cstring =
|
||||
result = GetError()
|
||||
357
lib/newwrap/sdl/sdl_ttf.nim
Normal file
357
lib/newwrap/sdl/sdl_ttf.nim
Normal file
@@ -0,0 +1,357 @@
|
||||
#
|
||||
# $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer
|
||||
# Conversion of the Simple DirectMedia Layer Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_ttf.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so
|
||||
# They are available from...
|
||||
# http://www.libsdl.org .
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_ttf.pas,v $
|
||||
# Revision 1.18 2007/06/01 11:16:33 savage
|
||||
# Added IFDEF UNIX for Workaround.
|
||||
#
|
||||
# Revision 1.17 2007/06/01 08:38:21 savage
|
||||
# Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis
|
||||
#
|
||||
# Revision 1.16 2007/05/29 21:32:14 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.15 2007/05/20 20:32:45 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.14 2006/12/02 00:19:01 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.13 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.12 2005/01/05 01:47:14 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.11 2005/01/04 23:14:57 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.10 2005/01/02 19:07:32 savage
|
||||
# Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis )
|
||||
#
|
||||
# Revision 1.9 2005/01/01 02:15:20 savage
|
||||
# Updated to v2.0.7
|
||||
#
|
||||
# Revision 1.8 2004/10/07 21:02:32 savage
|
||||
# Fix for FPC
|
||||
#
|
||||
# Revision 1.7 2004/09/30 22:39:50 savage
|
||||
# Added a true type font class which contains a wrap text function.
|
||||
# Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:24 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/16 22:16:40 savage
|
||||
# v1.0 changes
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# Define this to workaround a known bug in some freetype versions.
|
||||
# The error manifests as TTF_RenderGlyph_Solid returning nil (error)
|
||||
# and error message (in SDL_Error) is
|
||||
# "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable"
|
||||
# See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html]
|
||||
#
|
||||
|
||||
import
|
||||
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
ttfLibName = "SDL_ttf.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
ttfLibName = "libSDL_ttf-2.0.0.dylib"
|
||||
else:
|
||||
const
|
||||
ttfLibName = "libSDL_ttf.so"
|
||||
const
|
||||
TTF_MAJOR_VERSION* = 2'i8
|
||||
TTF_MINOR_VERSION* = 0'i8
|
||||
TTF_PATCHLEVEL* = 8'i8 # Backwards compatibility
|
||||
TTF_MAJOR_VERSION* = TTF_MAJOR_VERSION
|
||||
TTF_MINOR_VERSION* = TTF_MINOR_VERSION
|
||||
TTF_PATCHLEVEL* = TTF_PATCHLEVEL #*
|
||||
# Set and retrieve the font style
|
||||
# This font style is implemented by modifying the font glyphs, and
|
||||
# doesn't reflect any inherent properties of the truetype font file.
|
||||
#*
|
||||
TTF_STYLE_NORMAL* = 0x00000000
|
||||
TTF_STYLE_BOLD* = 0x00000001
|
||||
TTF_STYLE_ITALIC* = 0x00000002
|
||||
TTF_STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
|
||||
UNICODE_BOM_NATIVE* = 0x0000FEFF
|
||||
UNICODE_BOM_SWAPPED* = 0x0000FFFE
|
||||
|
||||
type
|
||||
PTTF_Font* = ptr TTTF_font
|
||||
TTTF_Font*{.final.} = object # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_ttf library.
|
||||
|
||||
proc TTF_VERSION*(X: var Tversion)
|
||||
# This function gets the version of the dynamically linked SDL_ttf library.
|
||||
# It should NOT be used to fill a version structure, instead you should use the
|
||||
# SDL_TTF_VERSION() macro.
|
||||
proc TTF_Linked_Version*(): Pversion{.cdecl, importc: "TTF_Linked_Version",
|
||||
dynlib: ttfLibName.}
|
||||
# This function tells the library whether UNICODE text is generally
|
||||
# byteswapped. A UNICODE BOM character in a string will override
|
||||
# this setting for the remainder of that string.
|
||||
#
|
||||
proc TTF_ByteSwappedUNICODE*(swapped: int){.cdecl,
|
||||
importc: "TTF_ByteSwappedUNICODE", dynlib: ttfLibName.}
|
||||
#returns 0 on succes, -1 if error occurs
|
||||
proc TTF_Init*(): int{.cdecl, importc: "TTF_Init", dynlib: ttfLibName.}
|
||||
#
|
||||
# Open a font file and create a font of the specified point size.
|
||||
# Some .fon fonts will have several sizes embedded in the file, so the
|
||||
# point size becomes the index of choosing which size. If the value
|
||||
# is too high, the last indexed size will be the default.
|
||||
#
|
||||
proc TTF_OpenFont*(filename: cstring, ptsize: int): PTTF_Font{.cdecl,
|
||||
importc: "TTF_OpenFont", dynlib: ttfLibName.}
|
||||
proc TTF_OpenFontIndex*(filename: cstring, ptsize: int, index: int32): PTTF_Font{.
|
||||
cdecl, importc: "TTF_OpenFontIndex", dynlib: ttfLibName.}
|
||||
proc TTF_OpenFontRW*(src: PRWops, freesrc: int, ptsize: int): PTTF_Font{.cdecl,
|
||||
importc: "TTF_OpenFontRW", dynlib: ttfLibName.}
|
||||
proc TTF_OpenFontIndexRW*(src: PRWops, freesrc: int, ptsize: int, index: int32): PTTF_Font{.
|
||||
cdecl, importc: "TTF_OpenFontIndexRW", dynlib: ttfLibName.}
|
||||
proc TTF_GetFontStyle*(font: PTTF_Font): int{.cdecl,
|
||||
importc: "TTF_GetFontStyle", dynlib: ttfLibName.}
|
||||
proc TTF_SetFontStyle*(font: PTTF_Font, style: int){.cdecl,
|
||||
importc: "TTF_SetFontStyle", dynlib: ttfLibName.}
|
||||
# Get the total height of the font - usually equal to point size
|
||||
proc TTF_FontHeight*(font: PTTF_Font): int{.cdecl, importc: "TTF_FontHeight",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the offset from the baseline to the top of the font
|
||||
# This is a positive value, relative to the baseline.
|
||||
#
|
||||
proc TTF_FontAscent*(font: PTTF_Font): int{.cdecl, importc: "TTF_FontAscent",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the offset from the baseline to the bottom of the font
|
||||
# This is a negative value, relative to the baseline.
|
||||
#
|
||||
proc TTF_FontDescent*(font: PTTF_Font): int{.cdecl, importc: "TTF_FontDescent",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the recommended spacing between lines of text for this font
|
||||
proc TTF_FontLineSkip*(font: PTTF_Font): int{.cdecl,
|
||||
importc: "TTF_FontLineSkip", dynlib: ttfLibName.}
|
||||
# Get the number of faces of the font
|
||||
proc TTF_FontFaces*(font: PTTF_Font): int32{.cdecl, importc: "TTF_FontFaces",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the font face attributes, if any
|
||||
proc TTF_FontFaceIsFixedWidth*(font: PTTF_Font): int{.cdecl,
|
||||
importc: "TTF_FontFaceIsFixedWidth", dynlib: ttfLibName.}
|
||||
proc TTF_FontFaceFamilyName*(font: PTTF_Font): cstring{.cdecl,
|
||||
importc: "TTF_FontFaceFamilyName", dynlib: ttfLibName.}
|
||||
proc TTF_FontFaceStyleName*(font: PTTF_Font): cstring{.cdecl,
|
||||
importc: "TTF_FontFaceStyleName", dynlib: ttfLibName.}
|
||||
# Get the metrics (dimensions) of a glyph
|
||||
proc TTF_GlyphMetrics*(font: PTTF_Font, ch: Uint16, minx: var int,
|
||||
maxx: var int, miny: var int, maxy: var int,
|
||||
advance: var int): int{.cdecl,
|
||||
importc: "TTF_GlyphMetrics", dynlib: ttfLibName.}
|
||||
# Get the dimensions of a rendered string of text
|
||||
proc TTF_SizeText*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{.
|
||||
cdecl, importc: "TTF_SizeText", dynlib: ttfLibName.}
|
||||
proc TTF_SizeUTF8*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{.
|
||||
cdecl, importc: "TTF_SizeUTF8", dynlib: ttfLibName.}
|
||||
proc TTF_SizeUNICODE*(font: PTTF_Font, text: PUint16, w: var int, y: var int): int{.
|
||||
cdecl, importc: "TTF_SizeUNICODE", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given text at
|
||||
# fast quality with the given font and color. The 0 pixel is the
|
||||
# colorkey, giving a transparent background, and the 1 pixel is set
|
||||
# to the text color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderUTF8_Solid*(font: PTTF_Font, text: cstring, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.}
|
||||
proc TTF_RenderUNICODE_Solid*(font: PTTF_Font, text: PUint16, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUNICODE_Solid", dynlib: ttfLibName.}
|
||||
#
|
||||
#Create an 8-bit palettized surface and render the given glyph at
|
||||
# fast quality with the given font and color. The 0 pixel is the
|
||||
# colorkey, giving a transparent background, and the 1 pixel is set
|
||||
# to the text color. The glyph is rendered without any padding or
|
||||
# centering in the X direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderGlyph_Solid*(font: PTTF_Font, ch: Uint16, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Solid", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given text at
|
||||
# high quality with the given font and colors. The 0 pixel is background,
|
||||
# while other pixels have varying degrees of the foreground color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderText_Shaded*(font: PTTF_Font, text: cstring, fg: TColor,
|
||||
bg: TColor): PSurface{.cdecl,
|
||||
importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.}
|
||||
proc TTF_RenderUTF8_Shaded*(font: PTTF_Font, text: cstring, fg: TColor,
|
||||
bg: TColor): PSurface{.cdecl,
|
||||
importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.}
|
||||
proc TTF_RenderUNICODE_Shaded*(font: PTTF_Font, text: PUint16, fg: TColor,
|
||||
bg: TColor): PSurface{.cdecl,
|
||||
importc: "TTF_RenderUNICODE_Shaded", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given glyph at
|
||||
# high quality with the given font and colors. The 0 pixel is background,
|
||||
# while other pixels have varying degrees of the foreground color.
|
||||
# The glyph is rendered without any padding or centering in the X
|
||||
# direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderGlyph_Shaded*(font: PTTF_Font, ch: Uint16, fg: TColor, bg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Shaded", dynlib: ttfLibName.}
|
||||
# Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
# using alpha blending to dither the font with the given color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderText_Blended*(font: PTTF_Font, text: cstring, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.}
|
||||
proc TTF_RenderUTF8_Blended*(font: PTTF_Font, text: cstring, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.}
|
||||
proc TTF_RenderUNICODE_Blended*(font: PTTF_Font, text: PUint16, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUNICODE_Blended", dynlib: ttfLibName.}
|
||||
# Create a 32-bit ARGB surface and render the given glyph at high quality,
|
||||
# using alpha blending to dither the font with the given color.
|
||||
# The glyph is rendered without any padding or centering in the X
|
||||
# direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc TTF_RenderGlyph_Blended*(font: PTTF_Font, ch: Uint16, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Blended", dynlib: ttfLibName.}
|
||||
# For compatibility with previous versions, here are the old functions
|
||||
##define TTF_RenderText(font, text, fg, bg)
|
||||
# TTF_RenderText_Shaded(font, text, fg, bg)
|
||||
##define TTF_RenderUTF8(font, text, fg, bg)
|
||||
# TTF_RenderUTF8_Shaded(font, text, fg, bg)
|
||||
##define TTF_RenderUNICODE(font, text, fg, bg)
|
||||
# TTF_RenderUNICODE_Shaded(font, text, fg, bg)
|
||||
# Close an opened font file
|
||||
proc TTF_CloseFont*(font: PTTF_Font){.cdecl, importc: "TTF_CloseFont",
|
||||
dynlib: ttfLibName.}
|
||||
#De-initialize TTF engine
|
||||
proc TTF_Quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.}
|
||||
# Check if the TTF engine is initialized
|
||||
proc TTF_WasInit*(): int{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.}
|
||||
# We'll use SDL for reporting errors
|
||||
proc TTF_SetError*(fmt: cstring)
|
||||
proc TTF_GetError*(): cstring
|
||||
# implementation
|
||||
|
||||
proc TTF_VERSION(X: var Tversion) =
|
||||
X.major = TTF_MAJOR_VERSION
|
||||
X.minor = TTF_MINOR_VERSION
|
||||
X.patch = TTF_PATCHLEVEL
|
||||
|
||||
proc TTF_SetError(fmt: cstring) =
|
||||
SetError(fmt)
|
||||
|
||||
proc TTF_GetError(): cstring =
|
||||
result = GetError()
|
||||
|
||||
when not (defined(Workaround_TTF_RenderText_Solid)):
|
||||
proc TTF_RenderText_Solid*(font: PTTF_Font, text: cstring, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderText_Solid", dynlib: ttfLibName.}
|
||||
else:
|
||||
proc TTF_RenderText_Solid(font: PTTF_Font, text: cstring, fg: TColor): PSurface =
|
||||
var Black: TColor # initialized to zero
|
||||
Result = TTF_RenderText_Shaded(font, text, fg, Black)
|
||||
339
lib/newwrap/sdl/smpeg.nim
Normal file
339
lib/newwrap/sdl/smpeg.nim
Normal file
@@ -0,0 +1,339 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SMPEG - SDL MPEG Player Library
|
||||
# Conversion of the SMPEG - SDL MPEG Player Library
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : smpeg.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Portions created by Matthias Thoma are
|
||||
# Copyright (C) 2000 - 2001 Matthias Thoma.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL-1.2.so.0
|
||||
# They are available from...
|
||||
# http://www.libsdl.org .
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# May 08 2001 - MT : Initial conversion
|
||||
#
|
||||
# October 12 2001 - DA : Various changes as suggested by David Acklam
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
|
||||
# Fixed all invalid calls to DLL.
|
||||
# Changed constant names to:
|
||||
# const
|
||||
# STATUS_SMPEG_ERROR = -1;
|
||||
# STATUS_SMPEG_STOPPED = 0;
|
||||
# STATUS_SMPEG_PLAYING = 1;
|
||||
# because SMPEG_ERROR is a function (_SMPEG_error
|
||||
# isn't correct), and cannot be two elements with the
|
||||
# same name
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: smpeg.pas,v $
|
||||
# Revision 1.7 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.6 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.5 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.4 2004/04/02 10:40:55 savage
|
||||
# Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.3 2004/03/31 22:20:02 savage
|
||||
# Windows unit not used in this file, so it was removed to keep the code tidy.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
SmpegLibName = "smpeg.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
SmpegLibName = "libsmpeg.dylib"
|
||||
else:
|
||||
const
|
||||
SmpegLibName = "libsmpeg.so"
|
||||
const
|
||||
SMPEG_FILTER_INFO_MB_ERROR* = 1
|
||||
SMPEG_FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG
|
||||
|
||||
type
|
||||
SMPEG_FilterInfo*{.final.} = object
|
||||
yuv_mb_square_error*: PUint16
|
||||
yuv_pixel_square_error*: PUint16
|
||||
|
||||
TSMPEG_FilterInfo* = SMPEG_FilterInfo
|
||||
PSMPEG_FilterInfo* = ptr SMPEG_FilterInfo # MPEG filter definition
|
||||
PSMPEG_Filter* = ptr TSMPEG_Filter # Callback functions for the filter
|
||||
TSMPEG_FilterCallback* = proc (dest, source: POverlay, region: PRect,
|
||||
filter_info: PSMPEG_FilterInfo, data: Pointer): Pointer{.
|
||||
cdecl.}
|
||||
TSMPEG_FilterDestroy* = proc (Filter: PSMPEG_Filter): Pointer{.cdecl.} # The filter
|
||||
#
|
||||
# definition itself
|
||||
TSMPEG_Filter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay.
|
||||
flags*: Uint32
|
||||
data*: Pointer
|
||||
callback*: TSMPEG_FilterCallback
|
||||
destroy*: TSMPEG_FilterDestroy
|
||||
|
||||
|
||||
proc SMPEGfilter_null*(): PSMPEG_Filter{.cdecl, importc: "SMPEGfilter_null",
|
||||
dynlib: SmpegLibName.}
|
||||
# The bilinear filter. A basic low-pass filter that will produce a smoother image.
|
||||
proc SMPEGfilter_bilinear*(): PSMPEG_Filter{.cdecl,
|
||||
importc: "SMPEGfilter_bilinear", dynlib: SmpegLibName.}
|
||||
# The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness
|
||||
proc SMPEGfilter_deblocking*(): PSMPEG_Filter{.cdecl,
|
||||
importc: "SMPEGfilter_deblocking", dynlib: SmpegLibName.}
|
||||
#------------------------------------------------------------------------------
|
||||
# SMPEG.h
|
||||
#------------------------------------------------------------------------------
|
||||
const
|
||||
SMPEG_MAJOR_VERSION* = 0'i8
|
||||
SMPEG_MINOR_VERSION* = 4'i8
|
||||
SMPEG_PATCHLEVEL* = 2'i8
|
||||
|
||||
type
|
||||
SMPEG_version*{.final.} = object
|
||||
major*: UInt8
|
||||
minor*: UInt8
|
||||
patch*: UInt8
|
||||
|
||||
TSMPEG_version* = SMPEG_version
|
||||
PSMPEG_version* = ptr TSMPEG_version # This is the actual SMPEG object
|
||||
TSMPEG*{.final.} = object
|
||||
PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object
|
||||
TSMPEG_Info*{.final.} = object
|
||||
has_audio*: int
|
||||
has_video*: int
|
||||
width*: int
|
||||
height*: int
|
||||
current_frame*: int
|
||||
current_fps*: float64
|
||||
audio_string*: array[0..79, char]
|
||||
audio_current_frame*: int
|
||||
current_offset*: UInt32
|
||||
total_size*: UInt32
|
||||
current_time*: float64
|
||||
total_time*: float64
|
||||
|
||||
PSMPEG_Info* = ptr TSMPEG_Info # Possible MPEG status codes
|
||||
|
||||
const
|
||||
STATUS_SMPEG_ERROR* = - 1
|
||||
STATUS_SMPEG_STOPPED* = 0
|
||||
STATUS_SMPEG_PLAYING* = 1
|
||||
|
||||
type
|
||||
TSMPEGstatus* = int
|
||||
PSMPEGstatus* = ptr int # Matches the declaration of SDL_UpdateRect()
|
||||
TSMPEG_DisplayCallback* = proc (dst: PSurface, x, y: int, w, h: int): Pointer{.
|
||||
cdecl.} # Create a new SMPEG object from an MPEG file.
|
||||
# On return, if 'info' is not NULL, it will be filled with information
|
||||
# about the MPEG object.
|
||||
# This function returns a new SMPEG object. Use SMPEG_error() to find out
|
||||
# whether or not there was a problem building the MPEG stream.
|
||||
# The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
|
||||
# subsystem. If not, you will have to use the SMPEG_playaudio() function below
|
||||
# to extract the decoded data.
|
||||
|
||||
proc SMPEG_new*(theFile: cstring, info: PSMPEG_Info, audio: int): PSMPEG{.cdecl,
|
||||
importc: "SMPEG_new", dynlib: SmpegLibName.}
|
||||
# The same as above for a file descriptor
|
||||
proc SMPEG_new_descr*(theFile: int, info: PSMPEG_Info, audio: int): PSMPEG{.
|
||||
cdecl, importc: "SMPEG_new_descr", dynlib: SmpegLibName.}
|
||||
# The same as above but for a raw chunk of data. SMPEG makes a copy of the
|
||||
# data, so the application is free to delete after a successful call to this
|
||||
# function.
|
||||
proc SMPEG_new_data*(data: Pointer, size: int, info: PSMPEG_Info, audio: int): PSMPEG{.
|
||||
cdecl, importc: "SMPEG_new_data", dynlib: SmpegLibName.}
|
||||
# Get current information about an SMPEG object
|
||||
proc SMPEG_getinfo*(mpeg: PSMPEG, info: PSMPEG_Info){.cdecl,
|
||||
importc: "SMPEG_getinfo", dynlib: SmpegLibName.}
|
||||
#procedure SMPEG_getinfo(mpeg: PSMPEG; info: Pointer);
|
||||
#cdecl; external SmpegLibName;
|
||||
# Enable or disable audio playback in MPEG stream
|
||||
proc SMPEG_enableaudio*(mpeg: PSMPEG, enable: int){.cdecl,
|
||||
importc: "SMPEG_enableaudio", dynlib: SmpegLibName.}
|
||||
# Enable or disable video playback in MPEG stream
|
||||
proc SMPEG_enablevideo*(mpeg: PSMPEG, enable: int){.cdecl,
|
||||
importc: "SMPEG_enablevideo", dynlib: SmpegLibName.}
|
||||
# Delete an SMPEG object
|
||||
proc SMPEG_delete*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_delete",
|
||||
dynlib: SmpegLibName.}
|
||||
# Get the current status of an SMPEG object
|
||||
proc SMPEG_status*(mpeg: PSMPEG): TSMPEGstatus{.cdecl, importc: "SMPEG_status",
|
||||
dynlib: SmpegLibName.}
|
||||
# status
|
||||
# Set the audio volume of an MPEG stream, in the range 0-100
|
||||
proc SMPEG_setvolume*(mpeg: PSMPEG, volume: int){.cdecl,
|
||||
importc: "SMPEG_setvolume", dynlib: SmpegLibName.}
|
||||
# Set the destination surface for MPEG video playback
|
||||
# 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
|
||||
# 'callback' is a function called when an area of 'dst' needs to be updated.
|
||||
# If 'callback' is NULL, the default function (SDL_UpdateRect) will be used.
|
||||
proc SMPEG_setdisplay*(mpeg: PSMPEG, dst: PSurface, surfLock: Pmutex,
|
||||
callback: TSMPEG_DisplayCallback){.cdecl,
|
||||
importc: "SMPEG_setdisplay", dynlib: SmpegLibName.}
|
||||
# Set or clear looping play on an SMPEG object
|
||||
proc SMPEG_loop*(mpeg: PSMPEG, repeat_: int){.cdecl, importc: "SMPEG_loop",
|
||||
dynlib: SmpegLibName.}
|
||||
# Scale pixel display on an SMPEG object
|
||||
proc SMPEG_scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl,
|
||||
importc: "SMPEG_scaleXY", dynlib: SmpegLibName.}
|
||||
proc SMPEG_scale*(mpeg: PSMPEG, scale: int){.cdecl, importc: "SMPEG_scale",
|
||||
dynlib: SmpegLibName.}
|
||||
proc SMPEG_Double*(mpeg: PSMPEG, doubleit: bool)
|
||||
# Move the video display area within the destination surface
|
||||
proc SMPEG_move*(mpeg: PSMPEG, x, y: int){.cdecl, importc: "SMPEG_move",
|
||||
dynlib: SmpegLibName.}
|
||||
# Set the region of the video to be shown
|
||||
proc SMPEG_setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl,
|
||||
importc: "SMPEG_setdisplayregion", dynlib: SmpegLibName.}
|
||||
# Play an SMPEG object
|
||||
proc SMPEG_play*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_play",
|
||||
dynlib: SmpegLibName.}
|
||||
# Pause/Resume playback of an SMPEG object
|
||||
proc SMPEG_pause*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_pause",
|
||||
dynlib: SmpegLibName.}
|
||||
# Stop playback of an SMPEG object
|
||||
proc SMPEG_stop*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_stop",
|
||||
dynlib: SmpegLibName.}
|
||||
# Rewind the play position of an SMPEG object to the beginning of the MPEG
|
||||
proc SMPEG_rewind*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_rewind",
|
||||
dynlib: SmpegLibName.}
|
||||
# Seek 'bytes' bytes in the MPEG stream
|
||||
proc SMPEG_seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc: "SMPEG_seek",
|
||||
dynlib: SmpegLibName.}
|
||||
# Skip 'seconds' seconds in the MPEG stream
|
||||
proc SMPEG_skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc: "SMPEG_skip",
|
||||
dynlib: SmpegLibName.}
|
||||
# Render a particular frame in the MPEG video
|
||||
# API CHANGE: This function no longer takes a target surface and position.
|
||||
# Use SMPEG_setdisplay() and SMPEG_move() to set this information.
|
||||
proc SMPEG_renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl,
|
||||
importc: "SMPEG_renderFrame", dynlib: SmpegLibName.}
|
||||
# Render the last frame of an MPEG video
|
||||
proc SMPEG_renderFinal*(mpeg: PSMPEG, dst: PSurface, x, y: int){.cdecl,
|
||||
importc: "SMPEG_renderFinal", dynlib: SmpegLibName.}
|
||||
# Set video filter
|
||||
proc SMPEG_filter*(mpeg: PSMPEG, filter: PSMPEG_Filter): PSMPEG_Filter{.cdecl,
|
||||
importc: "SMPEG_filter", dynlib: SmpegLibName.}
|
||||
# Return NULL if there is no error in the MPEG stream, or an error message
|
||||
# if there was a fatal error in the MPEG stream for the SMPEG object.
|
||||
proc SMPEG_error*(mpeg: PSMPEG): cstring{.cdecl, importc: "SMPEG_error",
|
||||
dynlib: SmpegLibName.}
|
||||
# Exported callback function for audio playback.
|
||||
# The function takes a buffer and the amount of data to fill, and returns
|
||||
# the amount of data in bytes that was actually written. This will be the
|
||||
# amount requested unless the MPEG audio has finished.
|
||||
#
|
||||
proc SMPEG_playAudio*(mpeg: PSMPEG, stream: PUInt8, length: int): int{.cdecl,
|
||||
importc: "SMPEG_playAudio", dynlib: SmpegLibName.}
|
||||
# Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer
|
||||
proc SMPEG_playAudioSDL*(mpeg: Pointer, stream: PUInt8, length: int){.cdecl,
|
||||
importc: "SMPEG_playAudioSDL", dynlib: SmpegLibName.}
|
||||
# Get the best SDL audio spec for the audio stream
|
||||
proc SMPEG_wantedSpec*(mpeg: PSMPEG, wanted: PAudioSpec): int{.cdecl,
|
||||
importc: "SMPEG_wantedSpec", dynlib: SmpegLibName.}
|
||||
# Inform SMPEG of the actual SDL audio spec used for sound playback
|
||||
proc SMPEG_actualSpec*(mpeg: PSMPEG, spec: PAudioSpec){.cdecl,
|
||||
importc: "SMPEG_actualSpec", dynlib: SmpegLibName.}
|
||||
# This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL library.
|
||||
proc SMPEG_GETVERSION*(X: var TSMPEG_version)
|
||||
# implementation
|
||||
|
||||
proc SMPEG_double(mpeg: PSMPEG, doubleit: bool) =
|
||||
if doubleit: SMPEG_scale(mpeg, 2)
|
||||
else: SMPEG_scale(mpeg, 1)
|
||||
|
||||
proc SMPEG_GETVERSION(X: var TSMPEG_version) =
|
||||
X.major = SMPEG_MAJOR_VERSION
|
||||
X.minor = SMPEG_MINOR_VERSION
|
||||
X.patch = SMPEG_PATCHLEVEL
|
||||
357
lib/newwrap/sqlite3.nim
Normal file
357
lib/newwrap/sqlite3.nim
Normal file
@@ -0,0 +1,357 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
when defined(windows):
|
||||
const
|
||||
Lib = "sqlite3.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
Lib = "sqlite-3.6.13.dylib"
|
||||
else:
|
||||
const
|
||||
Lib = "libsqlite3.so"
|
||||
const
|
||||
SQLITE_INTEGER* = 1
|
||||
SQLITE_FLOAT* = 2
|
||||
SQLITE_BLOB* = 4
|
||||
SQLITE_NULL* = 5
|
||||
SQLITE_TEXT* = 3
|
||||
TEXT* = 3
|
||||
SQLITE_UTF8* = 1
|
||||
SQLITE_UTF16LE* = 2
|
||||
SQLITE_UTF16BE* = 3 # Use native byte order
|
||||
SQLITE_UTF16* = 4 # sqlite3_create_function only
|
||||
SQLITE_ANY* = 5 #sqlite_exec return values
|
||||
SQLITE_OK* = 0
|
||||
SQLITE_ERROR* = 1 # SQL error or missing database
|
||||
SQLITE_INTERNAL* = 2 # An internal logic error in SQLite
|
||||
SQLITE_PERM* = 3 # Access permission denied
|
||||
SQLITE_ABORT* = 4 # Callback routine requested an abort
|
||||
SQLITE_BUSY* = 5 # The database file is locked
|
||||
SQLITE_LOCKED* = 6 # A table in the database is locked
|
||||
SQLITE_NOMEM* = 7 # A malloc() failed
|
||||
SQLITE_READONLY* = 8 # Attempt to write a readonly database
|
||||
SQLITE_INTERRUPT* = 9 # Operation terminated by sqlite3_interrupt()
|
||||
SQLITE_IOERR* = 10 # Some kind of disk I/O error occurred
|
||||
SQLITE_CORRUPT* = 11 # The database disk image is malformed
|
||||
SQLITE_NOTFOUND* = 12 # (Internal Only) Table or record not found
|
||||
SQLITE_FULL* = 13 # Insertion failed because database is full
|
||||
SQLITE_CANTOPEN* = 14 # Unable to open the database file
|
||||
SQLITE_PROTOCOL* = 15 # Database lock protocol error
|
||||
SQLITE_EMPTY* = 16 # Database is empty
|
||||
SQLITE_SCHEMA* = 17 # The database schema changed
|
||||
SQLITE_TOOBIG* = 18 # Too much data for one row of a table
|
||||
SQLITE_CONSTRAINT* = 19 # Abort due to contraint violation
|
||||
SQLITE_MISMATCH* = 20 # Data type mismatch
|
||||
SQLITE_MISUSE* = 21 # Library used incorrectly
|
||||
SQLITE_NOLFS* = 22 # Uses OS features not supported on host
|
||||
SQLITE_AUTH* = 23 # Authorization denied
|
||||
SQLITE_FORMAT* = 24 # Auxiliary database format error
|
||||
SQLITE_RANGE* = 25 # 2nd parameter to sqlite3_bind out of range
|
||||
SQLITE_NOTADB* = 26 # File opened that is not a database file
|
||||
SQLITE_ROW* = 100 # sqlite3_step() has another row ready
|
||||
SQLITE_DONE* = 101 # sqlite3_step() has finished executing
|
||||
SQLITE_COPY* = 0
|
||||
SQLITE_CREATE_INDEX* = 1
|
||||
SQLITE_CREATE_TABLE* = 2
|
||||
SQLITE_CREATE_TEMP_INDEX* = 3
|
||||
SQLITE_CREATE_TEMP_TABLE* = 4
|
||||
SQLITE_CREATE_TEMP_TRIGGER* = 5
|
||||
SQLITE_CREATE_TEMP_VIEW* = 6
|
||||
SQLITE_CREATE_TRIGGER* = 7
|
||||
SQLITE_CREATE_VIEW* = 8
|
||||
SQLITE_DELETE* = 9
|
||||
SQLITE_DROP_INDEX* = 10
|
||||
SQLITE_DROP_TABLE* = 11
|
||||
SQLITE_DROP_TEMP_INDEX* = 12
|
||||
SQLITE_DROP_TEMP_TABLE* = 13
|
||||
SQLITE_DROP_TEMP_TRIGGER* = 14
|
||||
SQLITE_DROP_TEMP_VIEW* = 15
|
||||
SQLITE_DROP_TRIGGER* = 16
|
||||
SQLITE_DROP_VIEW* = 17
|
||||
SQLITE_INSERT* = 18
|
||||
SQLITE_PRAGMA* = 19
|
||||
SQLITE_READ* = 20
|
||||
SQLITE_SELECT* = 21
|
||||
SQLITE_TRANSACTION* = 22
|
||||
SQLITE_UPDATE* = 23
|
||||
SQLITE_ATTACH* = 24
|
||||
SQLITE_DETACH* = 25
|
||||
SQLITE_ALTER_TABLE* = 26
|
||||
SQLITE_REINDEX* = 27
|
||||
SQLITE_DENY* = 1
|
||||
SQLITE_IGNORE* = 2 # Original from sqlite3.h:
|
||||
##define SQLITE_STATIC ((void(*)(void *))0)
|
||||
##define SQLITE_TRANSIENT ((void(*)(void *))-1)
|
||||
|
||||
const
|
||||
SQLITE_STATIC* = nil
|
||||
SQLITE_TRANSIENT* = cast[pointer](- 1)
|
||||
|
||||
type
|
||||
sqlite_int64* = int64
|
||||
PPPChar* = ptr ptr cstring
|
||||
T{.pure, final.} = object
|
||||
P* = ptr T
|
||||
PPSqlite3* = ptr P
|
||||
TSqlLite3Context{.pure, final.} = object
|
||||
Pcontext* = ptr TSqlLite3Context
|
||||
Tstmt{.pure, final.} = object
|
||||
Pstmt* = ptr Tstmt
|
||||
PPsqlite3_stmt* = ptr Pstmt
|
||||
Tvalue{.pure, final.} = object
|
||||
Pvalue* = ptr Tvalue
|
||||
PPsqlite3_value* = ptr Pvalue #Callback function types
|
||||
#Notice that most functions
|
||||
#were named using as prefix the
|
||||
#function name that uses them,
|
||||
#rather than describing their functions
|
||||
Tcallback* = proc (para1: pointer, para2: int32, para3: var cstring,
|
||||
para4: var cstring): int32{.cdecl.}
|
||||
Tbind_destructor_func* = proc (para1: pointer){.cdecl.}
|
||||
Tcreate_function_step_func* = proc (para1: Pcontext, para2: int32,
|
||||
para3: PPsqlite3_value){.cdecl.}
|
||||
Tcreate_function_func_func* = proc (para1: Pcontext, para2: int32,
|
||||
para3: PPsqlite3_value){.cdecl.}
|
||||
Tcreate_function_final_func* = proc (para1: Pcontext){.cdecl.}
|
||||
Tresult_func* = proc (para1: pointer){.cdecl.}
|
||||
Tcreate_collation_func* = proc (para1: pointer, para2: int32, para3: pointer,
|
||||
para4: int32, para5: pointer): int32{.cdecl.}
|
||||
Tcollation_needed_func* = proc (para1: pointer, para2: P, eTextRep: int32,
|
||||
para4: cstring){.cdecl.}
|
||||
|
||||
proc close*(para1: P): int32{.cdecl, dynlib: Lib, importc: "sqlite3_close".}
|
||||
proc exec*(para1: P, sql: cstring, para3: Tcallback, para4: pointer,
|
||||
errmsg: var cstring): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_exec".}
|
||||
proc last_insert_rowid*(para1: P): sqlite_int64{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_last_insert_rowid".}
|
||||
proc changes*(para1: P): int32{.cdecl, dynlib: Lib, importc: "sqlite3_changes".}
|
||||
proc total_changes*(para1: P): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_total_changes".}
|
||||
proc interrupt*(para1: P){.cdecl, dynlib: Lib, importc: "sqlite3_interrupt".}
|
||||
proc complete*(sql: cstring): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_complete".}
|
||||
proc complete16*(sql: pointer): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_complete16".}
|
||||
proc busy_handler*(para1: P,
|
||||
para2: proc (para1: pointer, para2: int32): int32{.cdecl.},
|
||||
para3: pointer): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_busy_handler".}
|
||||
proc busy_timeout*(para1: P, ms: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_busy_timeout".}
|
||||
proc get_table*(para1: P, sql: cstring, resultp: var cstringArray,
|
||||
nrow, ncolumn: var cint, errmsg: ptr cstring): int32{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_get_table".}
|
||||
proc free_table*(result: cstringArray){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_free_table".}
|
||||
# Todo: see how translate sqlite3_mprintf, sqlite3_vmprintf, sqlite3_snprintf
|
||||
# function sqlite3_mprintf(_para1:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_mprintf';
|
||||
proc mprintf*(para1: cstring): cstring{.cdecl, varargs, dynlib: Lib,
|
||||
importc: "sqlite3_mprintf".}
|
||||
#function sqlite3_vmprintf(_para1:Pchar; _para2:va_list):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_vmprintf';
|
||||
proc free*(z: cstring){.cdecl, dynlib: Lib, importc: "sqlite3_free".}
|
||||
#function sqlite3_snprintf(_para1:longint; _para2:Pchar; _para3:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_snprintf';
|
||||
proc snprintf*(para1: int32, para2: cstring, para3: cstring): cstring{.cdecl,
|
||||
dynlib: Lib, varargs, importc: "sqlite3_snprintf".}
|
||||
proc set_authorizer*(para1: P, xAuth: proc (para1: pointer, para2: int32,
|
||||
para3: cstring, para4: cstring, para5: cstring, para6: cstring): int32{.
|
||||
cdecl.}, pUserData: pointer): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_set_authorizer".}
|
||||
proc trace*(para1: P, xTrace: proc (para1: pointer, para2: cstring){.cdecl.},
|
||||
para3: pointer): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_trace".}
|
||||
proc progress_handler*(para1: P, para2: int32,
|
||||
para3: proc (para1: pointer): int32{.cdecl.},
|
||||
para4: pointer){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_progress_handler".}
|
||||
proc commit_hook*(para1: P, para2: proc (para1: pointer): int32{.cdecl.},
|
||||
para3: pointer): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_commit_hook".}
|
||||
proc open*(filename: cstring, ppDb: var P): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_open".}
|
||||
proc open16*(filename: pointer, ppDb: var P): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_open16".}
|
||||
proc errcode*(db: P): int32{.cdecl, dynlib: Lib, importc: "sqlite3_errcode".}
|
||||
proc errmsg*(para1: P): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_errmsg".}
|
||||
proc errmsg16*(para1: P): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_errmsg16".}
|
||||
proc prepare*(db: P, zSql: cstring, nBytes: int32, ppStmt: PPsqlite3_stmt,
|
||||
pzTail: ptr cstring): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_prepare".}
|
||||
proc prepare16*(db: P, zSql: pointer, nBytes: int32, ppStmt: PPsqlite3_stmt,
|
||||
pzTail: var pointer): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_prepare16".}
|
||||
proc bind_blob*(para1: Pstmt, para2: int32, para3: pointer, n: int32,
|
||||
para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_bind_blob".}
|
||||
proc bind_double*(para1: Pstmt, para2: int32, para3: float64): int32{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_bind_double".}
|
||||
proc bind_int*(para1: Pstmt, para2: int32, para3: int32): int32{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_bind_int".}
|
||||
proc bind_int64*(para1: Pstmt, para2: int32, para3: sqlite_int64): int32{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_bind_int64".}
|
||||
proc bind_null*(para1: Pstmt, para2: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_bind_null".}
|
||||
proc bind_text*(para1: Pstmt, para2: int32, para3: cstring, n: int32,
|
||||
para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_bind_text".}
|
||||
proc bind_text16*(para1: Pstmt, para2: int32, para3: pointer, para4: int32,
|
||||
para5: Tbind_destructor_func): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_bind_text16".}
|
||||
#function sqlite3_bind_value(_para1:Psqlite3_stmt; _para2:longint; _para3:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_value';
|
||||
#These overloaded functions were introduced to allow the use of SQLITE_STATIC and SQLITE_TRANSIENT
|
||||
#It's the c world man ;-)
|
||||
proc bind_blob*(para1: Pstmt, para2: int32, para3: pointer, n: int32,
|
||||
para5: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_bind_blob".}
|
||||
proc bind_text*(para1: Pstmt, para2: int32, para3: cstring, n: int32,
|
||||
para5: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_bind_text".}
|
||||
proc bind_text16*(para1: Pstmt, para2: int32, para3: pointer, para4: int32,
|
||||
para5: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_bind_text16".}
|
||||
proc bind_parameter_count*(para1: Pstmt): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_bind_parameter_count".}
|
||||
proc bind_parameter_name*(para1: Pstmt, para2: int32): cstring{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_bind_parameter_name".}
|
||||
proc bind_parameter_index*(para1: Pstmt, zName: cstring): int32{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_bind_parameter_index".}
|
||||
#function sqlite3_clear_bindings(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_clear_bindings';
|
||||
proc column_count*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_count".}
|
||||
proc column_name*(para1: Pstmt, para2: int32): cstring{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_name".}
|
||||
proc column_name16*(para1: Pstmt, para2: int32): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_name16".}
|
||||
proc column_decltype*(para1: Pstmt, i: int32): cstring{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_decltype".}
|
||||
proc column_decltype16*(para1: Pstmt, para2: int32): pointer{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_column_decltype16".}
|
||||
proc step*(para1: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_step".}
|
||||
proc data_count*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_data_count".}
|
||||
proc column_blob*(para1: Pstmt, iCol: int32): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_blob".}
|
||||
proc column_bytes*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_bytes".}
|
||||
proc column_bytes16*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_bytes16".}
|
||||
proc column_double*(para1: Pstmt, iCol: int32): float64{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_double".}
|
||||
proc column_int*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_int".}
|
||||
proc column_int64*(para1: Pstmt, iCol: int32): sqlite_int64{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_int64".}
|
||||
proc column_text*(para1: Pstmt, iCol: int32): cstring{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_text".}
|
||||
proc column_text16*(para1: Pstmt, iCol: int32): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_text16".}
|
||||
proc column_type*(para1: Pstmt, iCol: int32): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_column_type".}
|
||||
proc finalize*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_finalize".}
|
||||
proc reset*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_reset".}
|
||||
proc create_function*(para1: P, zFunctionName: cstring, nArg: int32,
|
||||
eTextRep: int32, para5: pointer,
|
||||
xFunc: Tcreate_function_func_func,
|
||||
xStep: Tcreate_function_step_func,
|
||||
xFinal: Tcreate_function_final_func): int32{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_create_function".}
|
||||
proc create_function16*(para1: P, zFunctionName: pointer, nArg: int32,
|
||||
eTextRep: int32, para5: pointer,
|
||||
xFunc: Tcreate_function_func_func,
|
||||
xStep: Tcreate_function_step_func,
|
||||
xFinal: Tcreate_function_final_func): int32{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_create_function16".}
|
||||
proc aggregate_count*(para1: Pcontext): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_aggregate_count".}
|
||||
proc value_blob*(para1: Pvalue): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_blob".}
|
||||
proc value_bytes*(para1: Pvalue): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_bytes".}
|
||||
proc value_bytes16*(para1: Pvalue): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_bytes16".}
|
||||
proc value_double*(para1: Pvalue): float64{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_double".}
|
||||
proc value_int*(para1: Pvalue): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_int".}
|
||||
proc value_int64*(para1: Pvalue): sqlite_int64{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_int64".}
|
||||
proc value_text*(para1: Pvalue): cstring{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_text".}
|
||||
proc value_text16*(para1: Pvalue): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_text16".}
|
||||
proc value_text16le*(para1: Pvalue): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_text16le".}
|
||||
proc value_text16be*(para1: Pvalue): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_text16be".}
|
||||
proc value_type*(para1: Pvalue): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_value_type".}
|
||||
proc aggregate_context*(para1: Pcontext, nBytes: int32): pointer{.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_aggregate_context".}
|
||||
proc user_data*(para1: Pcontext): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_user_data".}
|
||||
proc get_auxdata*(para1: Pcontext, para2: int32): pointer{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_get_auxdata".}
|
||||
proc set_auxdata*(para1: Pcontext, para2: int32, para3: pointer,
|
||||
para4: proc (para1: pointer){.cdecl.}){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_set_auxdata".}
|
||||
proc result_blob*(para1: Pcontext, para2: pointer, para3: int32,
|
||||
para4: Tresult_func){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_blob".}
|
||||
proc result_double*(para1: Pcontext, para2: float64){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_double".}
|
||||
proc result_error*(para1: Pcontext, para2: cstring, para3: int32){.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_result_error".}
|
||||
proc result_error16*(para1: Pcontext, para2: pointer, para3: int32){.cdecl,
|
||||
dynlib: Lib, importc: "sqlite3_result_error16".}
|
||||
proc result_int*(para1: Pcontext, para2: int32){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_int".}
|
||||
proc result_int64*(para1: Pcontext, para2: sqlite_int64){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_int64".}
|
||||
proc result_null*(para1: Pcontext){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_null".}
|
||||
proc result_text*(para1: Pcontext, para2: cstring, para3: int32,
|
||||
para4: Tresult_func){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_text".}
|
||||
proc result_text16*(para1: Pcontext, para2: pointer, para3: int32,
|
||||
para4: Tresult_func){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_text16".}
|
||||
proc result_text16le*(para1: Pcontext, para2: pointer, para3: int32,
|
||||
para4: Tresult_func){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_text16le".}
|
||||
proc result_text16be*(para1: Pcontext, para2: pointer, para3: int32,
|
||||
para4: Tresult_func){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_text16be".}
|
||||
proc result_value*(para1: Pcontext, para2: Pvalue){.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_result_value".}
|
||||
proc create_collation*(para1: P, zName: cstring, eTextRep: int32,
|
||||
para4: pointer, xCompare: Tcreate_collation_func): int32{.
|
||||
cdecl, dynlib: Lib, importc: "sqlite3_create_collation".}
|
||||
proc create_collation16*(para1: P, zName: cstring, eTextRep: int32,
|
||||
para4: pointer, xCompare: Tcreate_collation_func): int32{.
|
||||
cdecl, dynlib: Lib, importc: "sqlite3_create_collation16".}
|
||||
proc collation_needed*(para1: P, para2: pointer, para3: Tcollation_needed_func): int32{.
|
||||
cdecl, dynlib: Lib, importc: "sqlite3_collation_needed".}
|
||||
proc collation_needed16*(para1: P, para2: pointer, para3: Tcollation_needed_func): int32{.
|
||||
cdecl, dynlib: Lib, importc: "sqlite3_collation_needed16".}
|
||||
proc libversion*(): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_libversion".}
|
||||
#Alias for allowing better code portability (win32 is not working with external variables)
|
||||
proc version*(): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_libversion".}
|
||||
# Not published functions
|
||||
proc libversion_number*(): int32{.cdecl, dynlib: Lib,
|
||||
importc: "sqlite3_libversion_number".}
|
||||
#function sqlite3_key(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_key';
|
||||
#function sqlite3_rekey(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_rekey';
|
||||
#function sqlite3_sleep(_para1:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_sleep';
|
||||
#function sqlite3_expired(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_expired';
|
||||
#function sqlite3_global_recover:longint;cdecl; external Sqlite3Lib name 'sqlite3_global_recover';
|
||||
# implementation
|
||||
860
lib/newwrap/tcl.nim
Normal file
860
lib/newwrap/tcl.nim
Normal file
@@ -0,0 +1,860 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module is a wrapper for the TCL programming language.
|
||||
|
||||
#
|
||||
# tcl.h --
|
||||
#
|
||||
# This header file describes the externally-visible facilities of the Tcl
|
||||
# interpreter.
|
||||
#
|
||||
# Translated to Pascal Copyright (c) 2002 by Max Artemev
|
||||
# aka Bert Raccoon (bert@furry.ru, bert_raccoon@freemail.ru)
|
||||
#
|
||||
#
|
||||
# Copyright (c) 1998-2000 by Scriptics Corporation.
|
||||
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
|
||||
# Copyright (c) 1993-1996 Lucent Technologies.
|
||||
# Copyright (c) 1987-1994 John Ousterhout, The Regents of the
|
||||
# University of California, Berkeley.
|
||||
#
|
||||
# ***********************************************************************
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# ***********************************************************************
|
||||
#
|
||||
|
||||
when defined(WIN32):
|
||||
const
|
||||
dllName = "tcl(85|84|83|82|81|80).dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllName = "libtcl(8.5|8.4|8.3|8.2|8.1).dynlib"
|
||||
else:
|
||||
const
|
||||
dllName = "libtcl(8.5|8.4|8.3|8.2|8.1).so.(1|0)"
|
||||
const
|
||||
TCL_DESTROYED* = 0xDEADDEAD
|
||||
TCL_OK* = 0
|
||||
TCL_ERROR* = 1
|
||||
TCL_RETURN* = 2
|
||||
TCL_BREAK* = 3
|
||||
TCL_CONTINUE* = 4
|
||||
TCL_RESULT_SIZE* = 200
|
||||
MAX_ARGV* = 0x00007FFF
|
||||
TCL_VERSION_MAJOR* = 0
|
||||
TCL_VERSION_MINOR* = 0
|
||||
TCL_NO_EVAL* = 0x00010000
|
||||
TCL_EVAL_GLOBAL* = 0x00020000 # Flag values passed to variable-related procedures. *
|
||||
TCL_GLOBAL_ONLY* = 1
|
||||
TCL_NAMESPACE_ONLY* = 2
|
||||
TCL_APPEND_VALUE* = 4
|
||||
TCL_LIST_ELEMENT* = 8
|
||||
TCL_TRACE_READS* = 0x00000010
|
||||
TCL_TRACE_WRITES* = 0x00000020
|
||||
TCL_TRACE_UNSETS* = 0x00000040
|
||||
TCL_TRACE_DESTROYED* = 0x00000080
|
||||
TCL_INTERP_DESTROYED* = 0x00000100
|
||||
TCL_LEAVE_ERR_MSG* = 0x00000200
|
||||
TCL_PARSE_PART1* = 0x00000400 # Types for linked variables: *
|
||||
TCL_LINK_INT* = 1
|
||||
TCL_LINK_DOUBLE* = 2
|
||||
TCL_LINK_BOOLEAN* = 3
|
||||
TCL_LINK_STRING* = 4
|
||||
TCL_LINK_READ_ONLY* = 0x00000080
|
||||
TCL_SMALL_HASH_TABLE* = 4 # Hash Table *
|
||||
TCL_STRING_KEYS* = 0
|
||||
TCL_ONE_WORD_KEYS* = 1 # Const/enums Tcl_QueuePosition *
|
||||
# typedef enum {
|
||||
TCL_QUEUE_TAIL* = 0
|
||||
TCL_QUEUE_HEAD* = 1
|
||||
TCL_QUEUE_MARK* = 2 #} Tcl_QueuePosition;
|
||||
# Event Flags
|
||||
TCL_DONT_WAIT* = 1 shl 1
|
||||
TCL_WINDOW_EVENTS* = 1 shl 2
|
||||
TCL_FILE_EVENTS* = 1 shl 3
|
||||
TCL_TIMER_EVENTS* = 1 shl 4
|
||||
TCL_IDLE_EVENTS* = 1 shl 5 # WAS 0x10 ???? *
|
||||
TCL_ALL_EVENTS* = not TCL_DONT_WAIT
|
||||
TCL_VOLATILE* = 1
|
||||
TCL_STATIC* = 0
|
||||
TCL_DYNAMIC* = 3 # Channel
|
||||
TCL_STDIN* = 1 shl 1
|
||||
TCL_STDOUT* = 1 shl 2
|
||||
TCL_STDERR* = 1 shl 3
|
||||
TCL_ENFORCE_MODE* = 1 shl 4
|
||||
TCL_READABLE* = 1 shl 1
|
||||
TCL_WRITABLE* = 1 shl 2
|
||||
TCL_EXCEPTION* = 1 shl 3 # POSIX *
|
||||
EPERM* = 1 # Operation not permitted; only the owner of the file (or other
|
||||
# resource) or processes with special privileges can perform the
|
||||
# operation.
|
||||
#
|
||||
ENOENT* = 2 # No such file or directory. This is a "file doesn't exist" error
|
||||
# for ordinary files that are referenced in contexts where they are
|
||||
# expected to already exist.
|
||||
#
|
||||
ESRCH* = 3 # No process matches the specified process ID. *
|
||||
EINTR* = 4 # Interrupted function call; an asynchronous signal occurred and
|
||||
# prevented completion of the call. When this happens, you should
|
||||
# try the call again.
|
||||
#
|
||||
EIO* = 5 # Input/output error; usually used for physical read or write errors. *
|
||||
ENXIO* = 6 # No such device or address. The system tried to use the device
|
||||
# represented by a file you specified, and it couldn't find the
|
||||
# device. This can mean that the device file was installed
|
||||
# incorrectly, or that the physical device is missing or not
|
||||
# correctly attached to the computer.
|
||||
#
|
||||
E2BIG* = 7 # Argument list too long; used when the arguments passed to a new
|
||||
# program being executed with one of the `exec' functions (*note
|
||||
# Executing a File::.) occupy too much memory space. This condition
|
||||
# never arises in the GNU system.
|
||||
#
|
||||
ENOEXEC* = 8 # Invalid executable file format. This condition is detected by the
|
||||
# `exec' functions; see *Note Executing a File::.
|
||||
#
|
||||
EBADF* = 9 # Bad file descriptor; for example, I/O on a descriptor that has been
|
||||
# closed or reading from a descriptor open only for writing (or vice
|
||||
# versa).
|
||||
#
|
||||
ECHILD* = 10 # There are no child processes. This error happens on operations
|
||||
# that are supposed to manipulate child processes, when there aren't
|
||||
# any processes to manipulate.
|
||||
#
|
||||
EDEADLK* = 11 # Deadlock avoided; allocating a system resource would have resulted
|
||||
# in a deadlock situation. The system does not guarantee that it
|
||||
# will notice all such situations. This error means you got lucky
|
||||
# and the system noticed; it might just hang. *Note File Locks::,
|
||||
# for an example.
|
||||
#
|
||||
ENOMEM* = 12 # No memory available. The system cannot allocate more virtual
|
||||
# memory because its capacity is full.
|
||||
#
|
||||
EACCES* = 13 # Permission denied; the file permissions do not allow the attempted
|
||||
# operation.
|
||||
#
|
||||
EFAULT* = 14 # Bad address; an invalid pointer was detected. In the GNU system,
|
||||
# this error never happens; you get a signal instead.
|
||||
#
|
||||
ENOTBLK* = 15 # A file that isn't a block special file was given in a situation
|
||||
# that requires one. For example, trying to mount an ordinary file
|
||||
# as a file system in Unix gives this error.
|
||||
#
|
||||
EBUSY* = 16 # Resource busy; a system resource that can't be shared is already
|
||||
# in use. For example, if you try to delete a file that is the root
|
||||
# of a currently mounted filesystem, you get this error.
|
||||
#
|
||||
EEXIST* = 17 # File exists; an existing file was specified in a context where it
|
||||
# only makes sense to specify a new file.
|
||||
#
|
||||
EXDEV* = 18 # An attempt to make an improper link across file systems was
|
||||
# detected. This happens not only when you use `link' (*note Hard
|
||||
# Links::.) but also when you rename a file with `rename' (*note
|
||||
# Renaming Files::.).
|
||||
#
|
||||
ENODEV* = 19 # The wrong type of device was given to a function that expects a
|
||||
# particular sort of device.
|
||||
#
|
||||
ENOTDIR* = 20 # A file that isn't a directory was specified when a directory is
|
||||
# required.
|
||||
#
|
||||
EISDIR* = 21 # File is a directory; you cannot open a directory for writing, or
|
||||
# create or remove hard links to it.
|
||||
#
|
||||
EINVAL* = 22 # Invalid argument. This is used to indicate various kinds of
|
||||
# problems with passing the wrong argument to a library function.
|
||||
#
|
||||
EMFILE* = 24 # The current process has too many files open and can't open any
|
||||
# more. Duplicate descriptors do count toward this limit.
|
||||
#
|
||||
# In BSD and GNU, the number of open files is controlled by a
|
||||
# resource limit that can usually be increased. If you get this
|
||||
# error, you might want to increase the `RLIMIT_NOFILE' limit or
|
||||
# make it unlimited; *note Limits on Resources::..
|
||||
#
|
||||
ENFILE* = 23 # There are too many distinct file openings in the entire system.
|
||||
# Note that any number of linked channels count as just one file
|
||||
# opening; see *Note Linked Channels::. This error never occurs in
|
||||
# the GNU system.
|
||||
#
|
||||
ENOTTY* = 25 # Inappropriate I/O control operation, such as trying to set terminal
|
||||
# modes on an ordinary file.
|
||||
#
|
||||
ETXTBSY* = 26 # An attempt to execute a file that is currently open for writing, or
|
||||
# write to a file that is currently being executed. Often using a
|
||||
# debugger to run a program is considered having it open for writing
|
||||
# and will cause this error. (The name stands for "text file
|
||||
# busy".) This is not an error in the GNU system; the text is
|
||||
# copied as necessary.
|
||||
#
|
||||
EFBIG* = 27 # File too big; the size of a file would be larger than allowed by
|
||||
# the system.
|
||||
#
|
||||
ENOSPC* = 28 # No space left on device; write operation on a file failed because
|
||||
# the disk is full.
|
||||
#
|
||||
ESPIPE* = 29 # Invalid seek operation (such as on a pipe). *
|
||||
EROFS* = 30 # An attempt was made to modify something on a read-only file system. *
|
||||
EMLINK* = 31 # Too many links; the link count of a single file would become too
|
||||
# large. `rename' can cause this error if the file being renamed
|
||||
# already has as many links as it can take (*note Renaming Files::.).
|
||||
#
|
||||
EPIPE* = 32 # Broken pipe; there is no process reading from the other end of a
|
||||
# pipe. Every library function that returns this error code also
|
||||
# generates a `SIGPIPE' signal; this signal terminates the program
|
||||
# if not handled or blocked. Thus, your program will never actually
|
||||
# see `EPIPE' unless it has handled or blocked `SIGPIPE'.
|
||||
#
|
||||
EDOM* = 33 # Domain error; used by mathematical functions when an argument
|
||||
# value does not fall into the domain over which the function is
|
||||
# defined.
|
||||
#
|
||||
ERANGE* = 34 # Range error; used by mathematical functions when the result value
|
||||
# is not representable because of overflow or underflow.
|
||||
#
|
||||
EAGAIN* = 35 # Resource temporarily unavailable; the call might work if you try
|
||||
# again later. The macro `EWOULDBLOCK' is another name for `EAGAIN';
|
||||
# they are always the same in the GNU C library.
|
||||
#
|
||||
EWOULDBLOCK* = EAGAIN # In the GNU C library, this is another name for `EAGAIN' (above).
|
||||
# The values are always the same, on every operating system.
|
||||
# C libraries in many older Unix systems have `EWOULDBLOCK' as a
|
||||
# separate error code.
|
||||
#
|
||||
EINPROGRESS* = 36 # An operation that cannot complete immediately was initiated on an
|
||||
# object that has non-blocking mode selected. Some functions that
|
||||
# must always block (such as `connect'; *note Connecting::.) never
|
||||
# return `EAGAIN'. Instead, they return `EINPROGRESS' to indicate
|
||||
# that the operation has begun and will take some time. Attempts to
|
||||
# manipulate the object before the call completes return `EALREADY'.
|
||||
# You can use the `select' function to find out when the pending
|
||||
# operation has completed; *note Waiting for I/O::..
|
||||
#
|
||||
EALREADY* = 37 # An operation is already in progress on an object that has
|
||||
# non-blocking mode selected.
|
||||
#
|
||||
ENOTSOCK* = 38 # A file that isn't a socket was specified when a socket is required. *
|
||||
EDESTADDRREQ* = 39 # No default destination address was set for the socket. You get
|
||||
# this error when you try to transmit data over a connectionless
|
||||
# socket, without first specifying a destination for the data with
|
||||
# `connect'.
|
||||
#
|
||||
EMSGSIZE* = 40 # The size of a message sent on a socket was larger than the
|
||||
# supported maximum size.
|
||||
#
|
||||
EPROTOTYPE* = 41 # The socket type does not support the requested communications
|
||||
# protocol.
|
||||
#
|
||||
ENOPROTOOPT* = 42 # You specified a socket option that doesn't make sense for the
|
||||
# particular protocol being used by the socket. *Note Socket
|
||||
# Options::.
|
||||
#
|
||||
EPROTONOSUPPORT* = 43 # The socket domain does not support the requested communications
|
||||
# protocol (perhaps because the requested protocol is completely
|
||||
# invalid.) *Note Creating a Socket::.
|
||||
#
|
||||
ESOCKTNOSUPPORT* = 44 # The socket type is not supported. *
|
||||
EOPNOTSUPP* = 45 # The operation you requested is not supported. Some socket
|
||||
# functions don't make sense for all types of sockets, and others
|
||||
# may not be implemented for all communications protocols. In the
|
||||
# GNU system, this error can happen for many calls when the object
|
||||
# does not support the particular operation; it is a generic
|
||||
# indication that the server knows nothing to do for that call.
|
||||
#
|
||||
EPFNOSUPPORT* = 46 # The socket communications protocol family you requested is not
|
||||
# supported.
|
||||
#
|
||||
EAFNOSUPPORT* = 47 # The address family specified for a socket is not supported; it is
|
||||
# inconsistent with the protocol being used on the socket. *Note
|
||||
# Sockets::.
|
||||
#
|
||||
EADDRINUSE* = 48 # The requested socket address is already in use. *Note Socket
|
||||
# Addresses::.
|
||||
#
|
||||
EADDRNOTAVAIL* = 49 # The requested socket address is not available; for example, you
|
||||
# tried to give a socket a name that doesn't match the local host
|
||||
# name. *Note Socket Addresses::.
|
||||
#
|
||||
ENETDOWN* = 50 # A socket operation failed because the network was down. *
|
||||
ENETUNREACH* = 51 # A socket operation failed because the subnet containing the remote
|
||||
# host was unreachable.
|
||||
#
|
||||
ENETRESET* = 52 # A network connection was reset because the remote host crashed. *
|
||||
ECONNABORTED* = 53 # A network connection was aborted locally. *
|
||||
ECONNRESET* = 54 # A network connection was closed for reasons outside the control of
|
||||
# the local host, such as by the remote machine rebooting or an
|
||||
# unrecoverable protocol violation.
|
||||
#
|
||||
ENOBUFS* = 55 # The kernel's buffers for I/O operations are all in use. In GNU,
|
||||
# this error is always synonymous with `ENOMEM'; you may get one or
|
||||
# the other from network operations.
|
||||
#
|
||||
EISCONN* = 56 # You tried to connect a socket that is already connected. *Note
|
||||
# Connecting::.
|
||||
#
|
||||
ENOTCONN* = 57 # The socket is not connected to anything. You get this error when
|
||||
# you try to transmit data over a socket, without first specifying a
|
||||
# destination for the data. For a connectionless socket (for
|
||||
# datagram protocols, such as UDP), you get `EDESTADDRREQ' instead.
|
||||
#
|
||||
ESHUTDOWN* = 58 # The socket has already been shut down. *
|
||||
ETOOMANYREFS* = 59 # ??? *
|
||||
ETIMEDOUT* = 60 # A socket operation with a specified timeout received no response
|
||||
# during the timeout period.
|
||||
#
|
||||
ECONNREFUSED* = 61 # A remote host refused to allow the network connection (typically
|
||||
# because it is not running the requested service).
|
||||
#
|
||||
ELOOP* = 62 # Too many levels of symbolic links were encountered in looking up a
|
||||
# file name. This often indicates a cycle of symbolic links.
|
||||
#
|
||||
ENAMETOOLONG* = 63 # Filename too long (longer than `PATH_MAX'; *note Limits for
|
||||
# Files::.) or host name too long (in `gethostname' or
|
||||
# `sethostname'; *note Host Identification::.).
|
||||
#
|
||||
EHOSTDOWN* = 64 # The remote host for a requested network connection is down. *
|
||||
EHOSTUNREACH* = 65 # The remote host for a requested network connection is not
|
||||
# reachable.
|
||||
#
|
||||
ENOTEMPTY* = 66 # Directory not empty, where an empty directory was expected.
|
||||
# Typically, this error occurs when you are trying to delete a
|
||||
# directory.
|
||||
#
|
||||
EPROCLIM* = 67 # This means that the per-user limit on new process would be
|
||||
# exceeded by an attempted `fork'. *Note Limits on Resources::, for
|
||||
# details on the `RLIMIT_NPROC' limit.
|
||||
#
|
||||
EUSERS* = 68 # The file quota system is confused because there are too many users. *
|
||||
EDQUOT* = 69 # The user's disk quota was exceeded. *
|
||||
ESTALE* = 70 # Stale NFS file handle. This indicates an internal confusion in
|
||||
# the NFS system which is due to file system rearrangements on the
|
||||
# server host. Repairing this condition usually requires unmounting
|
||||
# and remounting the NFS file system on the local host.
|
||||
#
|
||||
EREMOTE* = 71 # An attempt was made to NFS-mount a remote file system with a file
|
||||
# name that already specifies an NFS-mounted file. (This is an
|
||||
# error on some operating systems, but we expect it to work properly
|
||||
# on the GNU system, making this error code impossible.)
|
||||
#
|
||||
EBADRPC* = 72 # ??? *
|
||||
ERPCMISMATCH* = 73 # ??? *
|
||||
EPROGUNAVAIL* = 74 # ??? *
|
||||
EPROGMISMATCH* = 75 # ??? *
|
||||
EPROCUNAVAIL* = 76 # ??? *
|
||||
ENOLCK* = 77 # No locks available. This is used by the file locking facilities;
|
||||
# see *Note File Locks::. This error is never generated by the GNU
|
||||
# system, but it can result from an operation to an NFS server
|
||||
# running another operating system.
|
||||
#
|
||||
ENOSYS* = 78 # Function not implemented. Some functions have commands or options
|
||||
# defined that might not be supported in all implementations, and
|
||||
# this is the kind of error you get if you request them and they are
|
||||
# not supported.
|
||||
#
|
||||
EFTYPE* = 79 # Inappropriate file type or format. The file was the wrong type
|
||||
# for the operation, or a data file had the wrong format.
|
||||
# On some systems `chmod' returns this error if you try to set the
|
||||
# sticky bit on a non-directory file; *note Setting Permissions::..
|
||||
#
|
||||
|
||||
type
|
||||
Tcl_Argv* = cstringArray
|
||||
Tcl_ClientData* = pointer
|
||||
Tcl_FreeProc* = proc (theBlock: pointer){.cdecl.}
|
||||
PInterp* = ptr Tcl_Interp
|
||||
Tcl_Interp*{.final.} = object # Event Definitions *
|
||||
result*: cstring # Do not access this directly. Use
|
||||
# * Tcl_GetStringResult since result
|
||||
# * may be pointing to an object
|
||||
# *
|
||||
freeProc*: Tcl_FreeProc
|
||||
errorLine*: int
|
||||
|
||||
TEventSetupProc* = proc (clientData: Tcl_ClientData, flags: int){.cdecl.}
|
||||
TEventCheckProc* = TEventSetupProc
|
||||
PEvent* = ptr Tcl_Event
|
||||
TEventProc* = proc (evPtr: PEvent, flags: int): int{.cdecl.}
|
||||
Tcl_Event*{.final.} = object
|
||||
prc*: TEventProc
|
||||
nextPtr*: PEvent
|
||||
ClientData*: TObject # ClientData is just pointer.*
|
||||
|
||||
PTime* = ptr Tcl_Time
|
||||
Tcl_Time*{.final.} = object
|
||||
sec*: int32 # Seconds. *
|
||||
usec*: int32 # Microseconds. *
|
||||
|
||||
Tcl_TimerToken* = pointer
|
||||
PInteger* = ptr int
|
||||
PHashTable* = pointer
|
||||
PHashEntry* = ptr Tcl_HashEntry
|
||||
PPTcl_HashEntry* = ptr PHashEntry
|
||||
Tcl_HashEntry*{.final.} = object
|
||||
nextPtr*: PHashEntry
|
||||
tablePtr*: PHashTable
|
||||
bucketPtr*: PPTcl_HashEntry
|
||||
clientData*: Tcl_ClientData
|
||||
key*: cstring
|
||||
|
||||
Tcl_HashFindProc* = proc (tablePtr: PHashTable, key: cstring): PHashEntry{.
|
||||
cdecl.}
|
||||
Tcl_HashCreateProc* = proc (tablePtr: PHashTable, key: cstring,
|
||||
newPtr: PInteger): PHashEntry{.cdecl.}
|
||||
PHashTable* = ptr Tcl_HashTable
|
||||
Tcl_HashTable*{.final.} = object
|
||||
buckets*: ppTcl_HashEntry
|
||||
staticBuckets*: array[0..TCL_SMALL_HASH_TABLE - 1, PHashEntry]
|
||||
numBuckets*: int
|
||||
numEntries*: int
|
||||
rebuildSize*: int
|
||||
downShift*: int
|
||||
mask*: int
|
||||
keyType*: int
|
||||
findProc*: Tcl_HashFindProc
|
||||
createProc*: Tcl_HashCreateProc
|
||||
|
||||
PHashSearch* = ptr Tcl_HashSearch
|
||||
Tcl_HashSearch*{.final.} = object
|
||||
tablePtr*: PHashTable
|
||||
nextIndex*: int
|
||||
nextEntryPtr*: PHashEntry
|
||||
|
||||
TAppInitProc* = proc (interp: pInterp): int{.cdecl.}
|
||||
TPackageInitProc* = proc (interp: pInterp): int{.cdecl.}
|
||||
TCmdProc* = proc (clientData: Tcl_ClientData, interp: pInterp, argc: int,
|
||||
argv: Tcl_Argv): int{.cdecl.}
|
||||
TVarTraceProc* = proc (clientData: Tcl_ClientData, interp: pInterp,
|
||||
varName: cstring, elemName: cstring, flags: int): cstring{.
|
||||
cdecl.}
|
||||
TFreeProc* = proc (theBlock: pointer){.cdecl.}
|
||||
TInterpDeleteProc* = proc (clientData: Tcl_ClientData, interp: pInterp){.cdecl.}
|
||||
TCmdDeleteProc* = proc (clientData: Tcl_ClientData){.cdecl.}
|
||||
TNamespaceDeleteProc* = proc (clientData: Tcl_ClientData){.cdecl.}
|
||||
|
||||
const
|
||||
TCL_DSTRING_STATIC_SIZE* = 200
|
||||
|
||||
type
|
||||
PDString* = ptr Tcl_DString
|
||||
Tcl_DString*{.final.} = object
|
||||
str*: cstring
|
||||
len*: int
|
||||
spaceAvl*: int
|
||||
staticSpace*: array[0..TCL_DSTRING_STATIC_SIZE - 1, char]
|
||||
|
||||
PChannel* = ptr Tcl_Channel
|
||||
Tcl_Channel*{.final.} = object
|
||||
TDriverBlockModeProc* = proc (instanceData: Tcl_ClientData, mode: int): int{.
|
||||
cdecl.}
|
||||
TDriverCloseProc* = proc (instanceData: Tcl_ClientData, interp: PInterp): int{.
|
||||
cdecl.}
|
||||
TDriverInputProc* = proc (instanceData: Tcl_ClientData, buf: cstring,
|
||||
toRead: int, errorCodePtr: PInteger): int{.cdecl.}
|
||||
TDriverOutputProc* = proc (instanceData: Tcl_ClientData, buf: cstring,
|
||||
toWrite: int, errorCodePtr: PInteger): int{.cdecl.}
|
||||
TDriverSeekProc* = proc (instanceData: Tcl_ClientData, offset: int32,
|
||||
mode: int, errorCodePtr: PInteger): int{.cdecl.}
|
||||
TDriverSetOptionProc* = proc (instanceData: Tcl_ClientData, interp: PInterp,
|
||||
optionName: cstring, value: cstring): int{.cdecl.}
|
||||
TDriverGetOptionProc* = proc (instanceData: Tcl_ClientData, interp: pInterp,
|
||||
optionName: cstring, dsPtr: PDString): int{.
|
||||
cdecl.}
|
||||
TDriverWatchProc* = proc (instanceData: Tcl_ClientData, mask: int){.cdecl.}
|
||||
TDriverGetHandleProc* = proc (instanceData: Tcl_ClientData, direction: int,
|
||||
handlePtr: var Tcl_ClientData): int{.cdecl.}
|
||||
PChannelType* = ptr Tcl_ChannelType
|
||||
Tcl_ChannelType*{.final.} = object
|
||||
typeName*: cstring
|
||||
blockModeProc*: TDriverBlockModeProc
|
||||
closeProc*: TDriverCloseProc
|
||||
inputProc*: TDriverInputProc
|
||||
ouputProc*: TDriverOutputProc
|
||||
seekProc*: TDriverSeekProc
|
||||
setOptionProc*: TDriverSetOptionProc
|
||||
getOptionProc*: TDriverGetOptionProc
|
||||
watchProc*: TDriverWatchProc
|
||||
getHandleProc*: TDriverGetHandleProc
|
||||
|
||||
TChannelProc* = proc (clientData: Tcl_ClientData, mask: int){.cdecl.}
|
||||
PObj* = ptr Tcl_Obj
|
||||
PPTcl_Obj* = ptr PObj
|
||||
Tcl_Obj*{.final.} = object
|
||||
refCount*: int # ...
|
||||
|
||||
TObjCmdProc* = proc (clientData: Tcl_ClientData, interp: PInterp, objc: int,
|
||||
PPObj: PPTcl_Obj): int{.cdecl.}
|
||||
PNamespace* = ptr Tcl_Namespace
|
||||
Tcl_Namespace*{.final.} = object
|
||||
name*: cstring
|
||||
fullName*: cstring
|
||||
clientData*: Tcl_ClientData
|
||||
deleteProc*: TNamespaceDeleteProc
|
||||
parentPtr*: PNamespace
|
||||
|
||||
PCallFrame* = ptr Tcl_CallFrame
|
||||
Tcl_CallFrame*{.final.} = object
|
||||
nsPtr*: PNamespace
|
||||
dummy1*: int
|
||||
dummy2*: int
|
||||
dummy3*: cstring
|
||||
dummy4*: cstring
|
||||
dummy5*: cstring
|
||||
dummy6*: int
|
||||
dummy7*: cstring
|
||||
dummy8*: cstring
|
||||
dummy9*: int
|
||||
dummy10*: cstring
|
||||
|
||||
PCmdInfo* = ptr Tcl_CmdInfo
|
||||
Tcl_CmdInfo*{.final.} = object
|
||||
isNativeObjectProc*: int
|
||||
objProc*: TObjCmdProc
|
||||
objClientData*: Tcl_ClientData
|
||||
prc*: TCmdProc
|
||||
clientData*: Tcl_ClientData
|
||||
deleteProc*: TCmdDeleteProc
|
||||
deleteData*: Tcl_ClientData
|
||||
namespacePtr*: pNamespace
|
||||
|
||||
pCommand* = ptr Tcl_Command
|
||||
Tcl_Command*{.final.} = object # hPtr : pTcl_HashEntry;
|
||||
# nsPtr : pTcl_Namespace;
|
||||
# refCount : integer;
|
||||
# isCmdEpoch : integer;
|
||||
# compileProc : pointer;
|
||||
# objProc : pointer;
|
||||
# objClientData : Tcl_ClientData;
|
||||
# proc : pointer;
|
||||
# clientData : Tcl_ClientData;
|
||||
# deleteProc : TTclCmdDeleteProc;
|
||||
# deleteData : Tcl_ClientData;
|
||||
# deleted : integer;
|
||||
# importRefPtr : pointer;
|
||||
#
|
||||
|
||||
type
|
||||
TPanicProc* = proc (fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8: cstring){.
|
||||
cdecl.} # 1/15/97 orig. Tcl style
|
||||
TClientDataProc* = proc (clientData: Tcl_ClientData){.cdecl.}
|
||||
TIdleProc* = proc (clientData: Tcl_ClientData){.cdecl.}
|
||||
TTimerProc* = TIdleProc
|
||||
TCreateCloseHandler* = proc (channel: pChannel, prc: TClientDataProc,
|
||||
clientData: Tcl_ClientData){.cdecl.}
|
||||
TDeleteCloseHandler* = TCreateCloseHandler
|
||||
TEventDeleteProc* = proc (evPtr: pEvent, clientData: Tcl_ClientData): int{.
|
||||
cdecl.}
|
||||
|
||||
proc Tcl_Alloc*(size: int): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Alloc".}
|
||||
proc Tcl_CreateInterp*(): pInterp{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_CreateInterp".}
|
||||
proc Tcl_DeleteInterp*(interp: pInterp){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_DeleteInterp".}
|
||||
proc Tcl_ResetResult*(interp: pInterp){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_ResetResult".}
|
||||
proc Tcl_Eval*(interp: pInterp, script: cstring): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Eval".}
|
||||
proc Tcl_EvalFile*(interp: pInterp, filename: cstring): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_EvalFile".}
|
||||
proc Tcl_AddErrorInfo*(interp: pInterp, message: cstring){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_AddErrorInfo".}
|
||||
proc Tcl_BackgroundError*(interp: pInterp){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_BackgroundError".}
|
||||
proc Tcl_CreateCommand*(interp: pInterp, name: cstring, cmdProc: TCmdProc,
|
||||
clientData: Tcl_ClientData, deleteProc: TCmdDeleteProc): pCommand{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_CreateCommand".}
|
||||
proc Tcl_DeleteCommand*(interp: pInterp, name: cstring): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_DeleteCommand".}
|
||||
proc Tcl_CallWhenDeleted*(interp: pInterp, prc: TInterpDeleteProc,
|
||||
clientData: Tcl_ClientData){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_CallWhenDeleted".}
|
||||
proc Tcl_DontCallWhenDeleted*(interp: pInterp, prc: TInterpDeleteProc,
|
||||
clientData: Tcl_ClientData){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_DontCallWhenDeleted".}
|
||||
proc Tcl_CommandComplete*(cmd: cstring): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_CommandComplete".}
|
||||
proc Tcl_LinkVar*(interp: pInterp, varName: cstring, varAddr: pointer, typ: int): int{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_LinkVar".}
|
||||
proc Tcl_UnlinkVar*(interp: pInterp, varName: cstring){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_UnlinkVar".}
|
||||
proc Tcl_TraceVar*(interp: pInterp, varName: cstring, flags: int,
|
||||
prc: TVarTraceProc, clientData: Tcl_ClientData): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_TraceVar".}
|
||||
proc Tcl_TraceVar2*(interp: pInterp, varName: cstring, elemName: cstring,
|
||||
flags: int, prc: TVarTraceProc, clientData: Tcl_ClientData): int{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_TraceVar2".}
|
||||
proc Tcl_UntraceVar*(interp: pInterp, varName: cstring, flags: int,
|
||||
prc: TVarTraceProc, clientData: Tcl_ClientData){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_UntraceVar".}
|
||||
proc Tcl_UntraceVar2*(interp: pInterp, varName: cstring, elemName: cstring,
|
||||
flags: int, prc: TVarTraceProc, clientData: Tcl_ClientData){.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_UntraceVar2".}
|
||||
proc Tcl_GetVar*(interp: pInterp, varName: cstring, flags: int): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_GetVar".}
|
||||
proc Tcl_GetVar2*(interp: pInterp, varName: cstring, elemName: cstring,
|
||||
flags: int): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_GetVar2".}
|
||||
proc Tcl_SetVar*(interp: pInterp, varName: cstring, newValue: cstring,
|
||||
flags: int): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_SetVar".}
|
||||
proc Tcl_SetVar2*(interp: pInterp, varName: cstring, elemName: cstring,
|
||||
newValue: cstring, flags: int): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_SetVar2".}
|
||||
proc Tcl_UnsetVar*(interp: pInterp, varName: cstring, flags: int): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_UnsetVar".}
|
||||
proc Tcl_UnsetVar2*(interp: pInterp, varName: cstring, elemName: cstring,
|
||||
flags: int): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_UnsetVar2".}
|
||||
proc Tcl_SetResult*(interp: pInterp, newValue: cstring, freeProc: TFreeProc){.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_SetResult".}
|
||||
proc Tcl_FirstHashEntry*(hashTbl: pHashTable, searchInfo: var Tcl_HashSearch): pHashEntry{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_FirstHashEntry".}
|
||||
proc Tcl_NextHashEntry*(searchInfo: var Tcl_HashSearch): pHashEntry{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_NextHashEntry".}
|
||||
proc Tcl_InitHashTable*(hashTbl: pHashTable, keyType: int){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_InitHashTable".}
|
||||
proc Tcl_StringMatch*(str: cstring, pattern: cstring): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_StringMatch".}
|
||||
proc Tcl_GetErrno*(): int{.cdecl, dynlib: dllName, importc: "Tcl_GetErrno".}
|
||||
proc Tcl_SetErrno*(val: int){.cdecl, dynlib: dllName, importc: "Tcl_SetErrno".}
|
||||
proc Tcl_SetPanicProc*(prc: TPanicProc){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_SetPanicProc".}
|
||||
proc Tcl_PkgProvide*(interp: pInterp, name: cstring, version: cstring): int{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_PkgProvide".}
|
||||
proc Tcl_StaticPackage*(interp: pInterp, pkgName: cstring,
|
||||
initProc: TPackageInitProc,
|
||||
safeInitProc: TPackageInitProc){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_StaticPackage".}
|
||||
proc Tcl_CreateEventSource*(setupProc: TEventSetupProc,
|
||||
checkProc: TEventCheckProc,
|
||||
clientData: Tcl_ClientData){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_CreateEventSource".}
|
||||
proc Tcl_DeleteEventSource*(setupProc: TEventSetupProc,
|
||||
checkProc: TEventCheckProc,
|
||||
clientData: Tcl_ClientData){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_DeleteEventSource".}
|
||||
proc Tcl_QueueEvent*(evPtr: pEvent, pos: int){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_QueueEvent".}
|
||||
proc Tcl_SetMaxBlockTime*(timePtr: pTime){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_SetMaxBlockTime".}
|
||||
proc Tcl_DeleteEvents*(prc: TEventDeleteProc, clientData: Tcl_ClientData){.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_DeleteEvents".}
|
||||
proc Tcl_DoOneEvent*(flags: int): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_DoOneEvent".}
|
||||
proc Tcl_DoWhenIdle*(prc: TIdleProc, clientData: Tcl_ClientData){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_DoWhenIdle".}
|
||||
proc Tcl_CancelIdleCall*(prc: TIdleProc, clientData: Tcl_ClientData){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_CancelIdleCall".}
|
||||
proc Tcl_CreateTimerHandler*(milliseconds: int, prc: TTimerProc,
|
||||
clientData: Tcl_ClientData): Tcl_TimerToken{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_CreateTimerHandler".}
|
||||
proc Tcl_DeleteTimerHandler*(token: Tcl_TimerToken){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_DeleteTimerHandler".}
|
||||
# procedure Tcl_CreateModalTimeout(milliseconds: integer; prc: TTclTimerProc; clientData: Tcl_ClientData); cdecl; external dllName;
|
||||
# procedure Tcl_DeleteModalTimeout(prc: TTclTimerProc; clientData: Tcl_ClientData); cdecl; external dllName;
|
||||
proc Tcl_SplitList*(interp: pInterp, list: cstring, argcPtr: var int,
|
||||
argvPtr: var Tcl_Argv): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_SplitList".}
|
||||
proc Tcl_Merge*(argc: int, argv: Tcl_Argv): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Merge".}
|
||||
proc Tcl_Free*(p: cstring){.cdecl, dynlib: dllName, importc: "Tcl_Free".}
|
||||
proc Tcl_Init*(interp: pInterp): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Init".}
|
||||
# procedure Tcl_InterpDeleteProc(clientData: Tcl_ClientData; interp: pTcl_Interp); cdecl; external dllName;
|
||||
proc Tcl_GetAssocData*(interp: pInterp, key: cstring, prc: var TInterpDeleteProc): Tcl_ClientData{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_GetAssocData".}
|
||||
proc Tcl_DeleteAssocData*(interp: pInterp, key: cstring){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_DeleteAssocData".}
|
||||
proc Tcl_SetAssocData*(interp: pInterp, key: cstring, prc: TInterpDeleteProc,
|
||||
clientData: Tcl_ClientData){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_SetAssocData".}
|
||||
proc Tcl_IsSafe*(interp: pInterp): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_IsSafe".}
|
||||
proc Tcl_MakeSafe*(interp: pInterp): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_MakeSafe".}
|
||||
proc Tcl_CreateSlave*(interp: pInterp, slaveName: cstring, isSafe: int): pInterp{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_CreateSlave".}
|
||||
proc Tcl_GetSlave*(interp: pInterp, slaveName: cstring): pInterp{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_GetSlave".}
|
||||
proc Tcl_GetMaster*(interp: pInterp): pInterp{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_GetMaster".}
|
||||
proc Tcl_GetInterpPath*(askingInterp: pInterp, slaveInterp: pInterp): int{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_GetInterpPath".}
|
||||
proc Tcl_CreateAlias*(slaveInterp: pInterp, srcCmd: cstring,
|
||||
targetInterp: pInterp, targetCmd: cstring, argc: int,
|
||||
argv: Tcl_Argv): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_CreateAlias".}
|
||||
proc Tcl_GetAlias*(interp: pInterp, srcCmd: cstring, targetInterp: var pInterp,
|
||||
targetCmd: var cstring, argc: var int, argv: var Tcl_Argv): int{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_GetAlias".}
|
||||
proc Tcl_ExposeCommand*(interp: pInterp, hiddenCmdName: cstring,
|
||||
cmdName: cstring): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_ExposeCommand".}
|
||||
proc Tcl_HideCommand*(interp: pInterp, cmdName: cstring, hiddenCmdName: cstring): int{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_HideCommand".}
|
||||
proc Tcl_EventuallyFree*(clientData: Tcl_ClientData, freeProc: TFreeProc){.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_EventuallyFree".}
|
||||
proc Tcl_Preserve*(clientData: Tcl_ClientData){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Preserve".}
|
||||
proc Tcl_Release*(clientData: Tcl_ClientData){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Release".}
|
||||
proc Tcl_InterpDeleted*(interp: pInterp): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_InterpDeleted".}
|
||||
proc Tcl_GetCommandInfo*(interp: pInterp, cmdName: cstring,
|
||||
info: var Tcl_CmdInfo): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_GetCommandInfo".}
|
||||
proc Tcl_SetCommandInfo*(interp: pInterp, cmdName: cstring,
|
||||
info: var Tcl_CmdInfo): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_SetCommandInfo".}
|
||||
proc Tcl_FindExecutable*(path: cstring){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_FindExecutable".}
|
||||
proc Tcl_GetStringResult*(interp: pInterp): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_GetStringResult".}
|
||||
#v1.0
|
||||
proc Tcl_FindCommand*(interp: pInterp, cmdName: cstring,
|
||||
contextNsPtr: pNamespace, flags: int): Tcl_Command{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_FindCommand".}
|
||||
#v1.0
|
||||
proc Tcl_DeleteCommandFromToken*(interp: pInterp, cmd: pCommand): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_DeleteCommandFromToken".}
|
||||
proc Tcl_CreateNamespace*(interp: pInterp, name: cstring,
|
||||
clientData: Tcl_ClientData,
|
||||
deleteProc: TNamespaceDeleteProc): pNamespace{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_CreateNamespace".}
|
||||
#v1.0
|
||||
proc Tcl_DeleteNamespace*(namespacePtr: pNamespace){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_DeleteNamespace".}
|
||||
proc Tcl_FindNamespace*(interp: pInterp, name: cstring,
|
||||
contextNsPtr: pNamespace, flags: int): pNamespace{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_FindNamespace".}
|
||||
proc Tcl_Export*(interp: pInterp, namespacePtr: pNamespace, pattern: cstring,
|
||||
resetListFirst: int): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Export".}
|
||||
proc Tcl_Import*(interp: pInterp, namespacePtr: pNamespace, pattern: cstring,
|
||||
allowOverwrite: int): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Import".}
|
||||
proc Tcl_GetCurrentNamespace*(interp: pInterp): pNamespace{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_GetCurrentNamespace".}
|
||||
proc Tcl_GetGlobalNamespace*(interp: pInterp): pNamespace{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_GetGlobalNamespace".}
|
||||
proc Tcl_PushCallFrame*(interp: pInterp, callFramePtr: var Tcl_CallFrame,
|
||||
namespacePtr: pNamespace, isProcCallFrame: int): int{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_PushCallFrame".}
|
||||
proc Tcl_PopCallFrame*(interp: pInterp){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_PopCallFrame".}
|
||||
proc Tcl_VarEval*(interp: pInterp): int{.cdecl, varargs, dynlib: dllName,
|
||||
importc: "Tcl_VarEval".}
|
||||
# For TkConsole.c *
|
||||
proc Tcl_RecordAndEval*(interp: pInterp, cmd: cstring, flags: int): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_RecordAndEval".}
|
||||
proc Tcl_GlobalEval*(interp: pInterp, command: cstring): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_GlobalEval".}
|
||||
proc Tcl_DStringFree*(dsPtr: pDString){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_DStringFree".}
|
||||
proc Tcl_DStringAppend*(dsPtr: pDString, str: cstring, length: int): cstring{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_DStringAppend".}
|
||||
proc Tcl_DStringAppendElement*(dsPtr: pDString, str: cstring): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_DStringAppendElement".}
|
||||
proc Tcl_DStringInit*(dsPtr: pDString){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_DStringInit".}
|
||||
proc Tcl_AppendResult*(interp: pInterp){.cdecl, varargs, dynlib: dllName,
|
||||
importc: "Tcl_AppendResult".}
|
||||
# actually a "C" var array
|
||||
proc Tcl_SetStdChannel*(channel: pChannel, typ: int){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_SetStdChannel".}
|
||||
proc Tcl_SetChannelOption*(interp: pInterp, chan: pChannel, optionName: cstring,
|
||||
newValue: cstring): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_SetChannelOption".}
|
||||
proc Tcl_GetChannelOption*(interp: pInterp, chan: pChannel, optionName: cstring,
|
||||
dsPtr: pDString): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_GetChannelOption".}
|
||||
proc Tcl_CreateChannel*(typePtr: pChannelType, chanName: cstring,
|
||||
instanceData: Tcl_ClientData, mask: int): pChannel{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_CreateChannel".}
|
||||
proc Tcl_RegisterChannel*(interp: pInterp, channel: pChannel){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_RegisterChannel".}
|
||||
proc Tcl_UnregisterChannel*(interp: pInterp, channel: pChannel): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_UnregisterChannel".}
|
||||
proc Tcl_CreateChannelHandler*(chan: pChannel, mask: int, prc: TChannelProc,
|
||||
clientData: Tcl_ClientData){.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_CreateChannelHandler".}
|
||||
proc Tcl_GetChannel*(interp: pInterp, chanName: cstring, modePtr: pInteger): pChannel{.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_GetChannel".}
|
||||
proc Tcl_GetStdChannel*(typ: int): pChannel{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_GetStdChannel".}
|
||||
proc Tcl_Gets*(chan: pChannel, dsPtr: pDString): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Gets".}
|
||||
proc Tcl_Write*(chan: pChannel, s: cstring, slen: int): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_Write".}
|
||||
proc Tcl_Flush*(chan: pChannel): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_Flush".}
|
||||
# TclWinLoadLibrary = function(name: PChar): HMODULE; cdecl; external dllName;
|
||||
proc Tcl_CreateExitHandler*(prc: TClientDataProc, clientData: Tcl_ClientData){.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_CreateExitHandler".}
|
||||
proc Tcl_DeleteExitHandler*(prc: TClientDataProc, clientData: Tcl_ClientData){.
|
||||
cdecl, dynlib: dllName, importc: "Tcl_DeleteExitHandler".}
|
||||
proc Tcl_GetStringFromObj*(pObj: pObj, pLen: pInteger): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_GetStringFromObj".}
|
||||
proc Tcl_CreateObjCommand*(interp: pInterp, name: cstring, cmdProc: TObjCmdProc,
|
||||
clientData: Tcl_ClientData,
|
||||
deleteProc: TCmdDeleteProc): pCommand{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_CreateObjCommand".}
|
||||
proc Tcl_NewStringObj*(bytes: cstring, length: int): pObj{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_NewStringObj".}
|
||||
# procedure TclFreeObj(pObj: pTcl_Obj); cdecl; external dllName;
|
||||
proc Tcl_EvalObj*(interp: pInterp, pObj: pObj): int{.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_EvalObj".}
|
||||
proc Tcl_GlobalEvalObj*(interp: pInterp, pObj: pObj): int{.cdecl,
|
||||
dynlib: dllName, importc: "Tcl_GlobalEvalObj".}
|
||||
proc TclRegComp*(exp: cstring): pointer{.cdecl, dynlib: dllName,
|
||||
importc: "TclRegComp".}
|
||||
proc TclRegExec*(prog: pointer, str: cstring, start: cstring): int{.cdecl,
|
||||
dynlib: dllName, importc: "TclRegExec".}
|
||||
proc TclRegError*(msg: cstring){.cdecl, dynlib: dllName, importc: "TclRegError".}
|
||||
proc TclGetRegError*(): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "TclGetRegError".}
|
||||
proc Tcl_RegExpRange*(prog: pointer, index: int, head: var cstring,
|
||||
tail: var cstring){.cdecl, dynlib: dllName,
|
||||
importc: "Tcl_RegExpRange".}
|
||||
proc Tcl_GetCommandTable*(interp: pInterp): pHashTable =
|
||||
if interp != nil:
|
||||
result = cast[pHashTable](cast[int](interp) + sizeof(Tcl_Interp) +
|
||||
sizeof(pointer))
|
||||
|
||||
proc Tcl_CreateHashEntry*(tablePtr: pHashTable, key: cstring, newPtr: pInteger): pHashEntry =
|
||||
result = cast[pHashTable](tablePtr).createProc(tablePtr, key, newPtr)
|
||||
|
||||
proc Tcl_FindHashEntry*(tablePtr: pHashTable, key: cstring): pHashEntry =
|
||||
result = cast[pHashTable](tablePtr).findProc(tablePtr, key)
|
||||
|
||||
proc Tcl_SetHashValue*(h: pHashEntry, clientData: Tcl_ClientData) =
|
||||
h.clientData = clientData
|
||||
|
||||
proc Tcl_GetHashValue*(h: pHashEntry): Tcl_ClientData =
|
||||
result = h.clientData
|
||||
|
||||
proc Tcl_IncrRefCount*(pObj: pObj) =
|
||||
inc(pObj.refCount)
|
||||
|
||||
proc Tcl_DecrRefCount*(pObj: pObj) =
|
||||
dec(pObj.refCount)
|
||||
if pObj.refCount <= 0:
|
||||
dealloc(pObj)
|
||||
|
||||
proc Tcl_IsShared*(pObj: pObj): bool =
|
||||
return pObj.refCount > 1
|
||||
|
||||
proc Tcl_GetHashKey*(hashTbl: pHashTable, hashEntry: pHashEntry): cstring =
|
||||
if hashTbl == nil or hashEntry == nil:
|
||||
result = nil
|
||||
else:
|
||||
result = hashEntry.key
|
||||
@@ -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.
|
||||
|
||||
146
lib/pure/logging.nim
Executable file
146
lib/pure/logging.nim
Executable file
@@ -0,0 +1,146 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements a simple logger. It is based on the following design:
|
||||
## * Runtime log formating is a bug: Sooner or later ever log file is parsed.
|
||||
## * Keep it simple: If this library does not fullfill your needs, write your
|
||||
## own. Trying to support every logging feature just leads to bloat.
|
||||
##
|
||||
## Format is::
|
||||
##
|
||||
## DEBUG|INFO|... (2009-11-02 00:00:00)? (Component: )? Message
|
||||
##
|
||||
##
|
||||
|
||||
type
|
||||
TLevel* = enum ## logging level
|
||||
lvlAll, ## all levels active
|
||||
lvlDebug, ## debug level (and any above) active
|
||||
lvlInfo, ## info level (and any above) active
|
||||
lvlWarn, ## warn level (and any above) active
|
||||
lvlError, ## error level (and any above) active
|
||||
lvlFatal ## fatal level (and any above) active
|
||||
|
||||
const
|
||||
LevelNames*: array [TLevel, string] = [
|
||||
"DEBUG", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"
|
||||
]
|
||||
|
||||
type
|
||||
TLogger* = object of TObject ## abstract logger; the base type of all loggers
|
||||
levelThreshold*: TLevel ## only messages of level >= levelThreshold
|
||||
## should be processed
|
||||
TConsoleLogger* = object of TLogger ## logger that writes the messages to the
|
||||
## console
|
||||
|
||||
TFileLogger* = object of TLogger ## logger that writes the messages to a file
|
||||
f: TFile
|
||||
|
||||
TRollingFileLogger* = object of
|
||||
TFileLogger ## logger that writes the message to a file
|
||||
maxlines: int # maximum number of lines
|
||||
lines: seq[string]
|
||||
|
||||
method log*(L: ref TLogger, level: TLevel,
|
||||
frmt: string, args: openArray[string]) =
|
||||
## override this method in custom loggers. Default implementation does
|
||||
## nothing.
|
||||
nil
|
||||
|
||||
method log*(L: ref TConsoleLogger, level: TLevel,
|
||||
frmt: string, args: openArray[string]) =
|
||||
Writeln(stdout, LevelNames[level], " ", frmt % args)
|
||||
|
||||
method log*(L: ref TFileLogger, level: TLevel,
|
||||
frmt: string, args: openArray[string]) =
|
||||
Writeln(L.f, LevelNames[level], " ", frmt % args)
|
||||
|
||||
proc defaultFilename*(): string =
|
||||
## returns the default filename for a logger
|
||||
var (path, name, ext) = splitFile(getApplicationFilename())
|
||||
result = changeFileExt(path / name & "_" & getDateStr(), "log")
|
||||
|
||||
proc substituteLog*(frmt: string): string =
|
||||
## converts $date to the current date
|
||||
## converts $time to the current time
|
||||
## converts $app to getApplicationFilename()
|
||||
## converts
|
||||
result = ""
|
||||
var i = 0
|
||||
while i < frmt.len:
|
||||
if frmt[i] != '$':
|
||||
result.add(frmt[i])
|
||||
inc(i)
|
||||
else:
|
||||
inc(i)
|
||||
var v = ""
|
||||
var app = getApplicationFilename()
|
||||
while frmt[i] in IdentChars:
|
||||
v.add(toLower(frmt[i]))
|
||||
inc(i)
|
||||
case v
|
||||
of "date": result.add(getDateStr())
|
||||
of "time": result.add(getClockStr())
|
||||
of "app": result.add(app)
|
||||
of "appdir": result.add(app.splitFile.dir)
|
||||
of "appname": result.add(app.splitFile.name)
|
||||
|
||||
|
||||
proc newFileLogger(filename = defaultFilename(),
|
||||
mode: TFileMode = fmAppend,
|
||||
levelThreshold = lvlNone): ref TFileLogger =
|
||||
new(result)
|
||||
result.levelThreshold = levelThreshold
|
||||
if not open(result.f, filename, mode):
|
||||
raiseException(EIO, "cannot open for writing: " & filename)
|
||||
|
||||
proc newRollingFileLogger(filename = defaultFilename(),
|
||||
mode: TFileMode = fmAppend,
|
||||
levelThreshold = lvlNone,
|
||||
maxLines = 1000): ref TFileLogger =
|
||||
new(result)
|
||||
result.levelThreshold = levelThreshold
|
||||
result.maxLines = maxLines
|
||||
if not open(result.f, filename, mode):
|
||||
raiseException(EIO, "cannot open for writing: " & filename)
|
||||
|
||||
var
|
||||
level* = lvlNone
|
||||
handlers*: seq[ref TLogger] = @[]
|
||||
|
||||
proc logLoop(level: TLevel, msg: string) =
|
||||
for logger in items(handlers):
|
||||
if level >= logger.levelThreshold:
|
||||
log(logger, level, msg)
|
||||
|
||||
template log*(level: TLevel, msg: string) =
|
||||
## logs a message of the given level
|
||||
if level >= logging.Level:
|
||||
(bind logLoop)(level, frmt, args)
|
||||
|
||||
template debug*(msg: string) =
|
||||
## logs a debug message
|
||||
log(lvlDebug, msg)
|
||||
|
||||
template info*(msg: string) =
|
||||
## logs an info message
|
||||
log(lvlInfo, msg)
|
||||
|
||||
template warn*(msg: string) =
|
||||
## logs a warning message
|
||||
log(lvlWarn, msg)
|
||||
|
||||
template error*(msg: string) =
|
||||
## logs an error message
|
||||
log(lvlError, msg)
|
||||
|
||||
template fatal*(msg: string) =
|
||||
## logs a fatal error message and calls ``quit(msg)``
|
||||
log(lvlFatal, msg)
|
||||
|
||||
@@ -635,22 +635,23 @@ proc copyFile*(dest, source: string) =
|
||||
if CopyFileA(source, dest, 0'i32) == 0'i32: OSError()
|
||||
else:
|
||||
# generic version of copyFile which works for any platform:
|
||||
const
|
||||
bufSize = 8192 # 8K buffer
|
||||
var
|
||||
d, s: TFile
|
||||
const bufSize = 8000 # better for memory manager
|
||||
var d, s: TFile
|
||||
if not open(s, source): OSError()
|
||||
if not open(d, dest, fmWrite):
|
||||
close(s)
|
||||
OSError()
|
||||
var
|
||||
buf: Pointer = alloc(bufsize)
|
||||
bytesread, byteswritten: int
|
||||
var buf = alloc(bufsize)
|
||||
while True:
|
||||
bytesread = readBuffer(s, buf, bufsize)
|
||||
byteswritten = writeBuffer(d, buf, bytesread)
|
||||
var bytesread = readBuffer(s, buf, bufsize)
|
||||
if bytesread > 0:
|
||||
var byteswritten = writeBuffer(d, buf, bytesread)
|
||||
if bytesread != bytesWritten:
|
||||
dealloc(buf)
|
||||
close(s)
|
||||
close(d)
|
||||
OSError()
|
||||
if bytesread != bufSize: break
|
||||
if bytesread != bytesWritten: OSError()
|
||||
dealloc(buf)
|
||||
close(s)
|
||||
close(d)
|
||||
|
||||
375
lib/pure/ropes.nim
Executable file
375
lib/pure/ropes.nim
Executable file
@@ -0,0 +1,375 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module contains support for a `rope`:idx: data type.
|
||||
## Ropes can represent very long strings efficiently; especially concatenation
|
||||
## is done in O(1) instead of O(n). They are essentially concatenation
|
||||
## trees that are only flattened when converting to a native Nimrod
|
||||
## string. The empty string is represented by ``nil``. Ropes are immutable and
|
||||
## subtrees can be shared without copying.
|
||||
## Leaves can be cached for better memory efficiency at the cost of a bit of
|
||||
## runtime efficiency.
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
{.push debugger:off .} # the user does not want to trace a part
|
||||
# of the standard library!
|
||||
|
||||
# copied from excpt.nim, because I don't want to make this template public
|
||||
template newException(exceptn, message: expr): expr =
|
||||
block: # open a new scope
|
||||
var
|
||||
e: ref exceptn
|
||||
new(e)
|
||||
e.msg = message
|
||||
e
|
||||
|
||||
const
|
||||
countCacheMisses = false
|
||||
|
||||
var
|
||||
cacheEnabled = false
|
||||
|
||||
type
|
||||
PRope* = ref TRope ## empty rope is represented by nil
|
||||
TRope {.acyclic, final, pure.} = object
|
||||
left, right: PRope
|
||||
length: int
|
||||
data: string # != nil if a leaf
|
||||
|
||||
proc isConc(r: PRope): bool {.inline.} = return isNil(r.data)
|
||||
|
||||
# Note that the left and right pointers are not needed for leafs.
|
||||
# Leaves have relatively high memory overhead (~30 bytes on a 32
|
||||
# bit machine) and we produce many of them. This is why we cache and
|
||||
# share leafs accross different rope trees.
|
||||
# To cache them they are inserted in another tree, a splay tree for best
|
||||
# performance. But for the caching tree we use the leaf's left and right
|
||||
# pointers.
|
||||
|
||||
proc len*(a: PRope): int =
|
||||
## the rope's length
|
||||
if a == nil: result = 0
|
||||
else: result = a.length
|
||||
|
||||
proc newRope(): PRope = new(result)
|
||||
proc newRope(data: string): PRope =
|
||||
new(result)
|
||||
result.length = len(data)
|
||||
result.data = data
|
||||
|
||||
var
|
||||
cache: PRope # the root of the cache tree
|
||||
N: PRope # dummy rope needed for splay algorithm
|
||||
|
||||
when countCacheMisses:
|
||||
var misses, hits: int
|
||||
|
||||
proc splay(s: string, tree: PRope, cmpres: var int): PRope =
|
||||
var c: int
|
||||
var t = tree
|
||||
N.left = nil
|
||||
N.right = nil # reset to nil
|
||||
var le = N
|
||||
var r = N
|
||||
while true:
|
||||
c = cmp(s, t.data)
|
||||
if c < 0:
|
||||
if (t.left != nil) and (s < t.left.data):
|
||||
var y = t.left
|
||||
t.left = y.right
|
||||
y.right = t
|
||||
t = y
|
||||
if t.left == nil: break
|
||||
r.left = t
|
||||
r = t
|
||||
t = t.left
|
||||
elif c > 0:
|
||||
if (t.right != nil) and (s > t.right.data):
|
||||
var y = t.right
|
||||
t.right = y.left
|
||||
y.left = t
|
||||
t = y
|
||||
if t.right == nil: break
|
||||
le.right = t
|
||||
le = t
|
||||
t = t.right
|
||||
else:
|
||||
break
|
||||
cmpres = c
|
||||
le.right = t.left
|
||||
r.left = t.right
|
||||
t.left = N.right
|
||||
t.right = N.left
|
||||
result = t
|
||||
|
||||
proc insertInCache(s: string, tree: PRope): PRope =
|
||||
var t = tree
|
||||
if t == nil:
|
||||
result = newRope(s)
|
||||
when countCacheMisses: inc(misses)
|
||||
return
|
||||
var cmp: int
|
||||
t = splay(s, t, cmp)
|
||||
if cmp == 0:
|
||||
# We get here if it's already in the Tree
|
||||
# Don't add it again
|
||||
result = t
|
||||
when countCacheMisses: inc(hits)
|
||||
else:
|
||||
when countCacheMisses: inc(misses)
|
||||
result = newRope(s)
|
||||
if cmp < 0:
|
||||
result.left = t.left
|
||||
result.right = t
|
||||
t.left = nil
|
||||
else:
|
||||
# i > t.item:
|
||||
result.right = t.right
|
||||
result.left = t
|
||||
t.right = nil
|
||||
|
||||
proc rope*(s: string): PRope =
|
||||
## Converts a string to a rope.
|
||||
if s.len == 0:
|
||||
result = nil
|
||||
elif cacheEnabled:
|
||||
result = insertInCache(s, cache)
|
||||
cache = result
|
||||
else:
|
||||
result = newRope(s)
|
||||
|
||||
proc rope*(i: BiggestInt): PRope =
|
||||
## Converts an int to a rope.
|
||||
result = rope($i)
|
||||
|
||||
proc rope*(f: BiggestFloat): PRope =
|
||||
## Converts a float to a rope.
|
||||
result = rope($f)
|
||||
|
||||
proc disableCache*() =
|
||||
## the cache is discarded and disabled. The GC will reuse its used memory.
|
||||
cache = nil
|
||||
cacheEnabled = false
|
||||
|
||||
proc enableCache*() =
|
||||
## Enables the caching of leaves. This reduces the memory footprint at
|
||||
## the cost of runtime efficiency.
|
||||
cacheEnabled = true
|
||||
|
||||
proc `&`*(a, b: PRope): PRope =
|
||||
## the concatenation operator for ropes.
|
||||
if a == nil:
|
||||
result = b
|
||||
elif b == nil:
|
||||
result = a
|
||||
else:
|
||||
result = newRope()
|
||||
result.length = a.length + b.length
|
||||
when false:
|
||||
# XXX rebalancing would be nice, but is too expensive.
|
||||
result.left = a.left
|
||||
var x = newRope()
|
||||
x.left = a.right
|
||||
x.right = b
|
||||
result.right = x
|
||||
else:
|
||||
result.left = a
|
||||
result.right = b
|
||||
|
||||
proc `&`*(a: PRope, b: string): PRope =
|
||||
## the concatenation operator for ropes.
|
||||
result = a & rope(b)
|
||||
|
||||
proc `&`*(a: string, b: PRope): PRope =
|
||||
## the concatenation operator for ropes.
|
||||
result = rope(a) & b
|
||||
|
||||
proc `&`*(a: openarray[PRope]): PRope =
|
||||
## the concatenation operator for an openarray of ropes.
|
||||
for i in countup(0, high(a)): result = result & a[i]
|
||||
|
||||
proc add*(a: var PRope, b: PRope) =
|
||||
## adds `b` to the rope `a`.
|
||||
a = a & b
|
||||
|
||||
proc add*(a: var PRope, b: string) =
|
||||
## adds `b` to the rope `a`.
|
||||
a = a & b
|
||||
|
||||
proc `[]`*(r: PRope, i: int): char =
|
||||
## returns the character at position `i` in the rope `r`. This is quite
|
||||
## expensive! Worst-case: O(n). If ``i >= r.len``, ``\0`` is returned.
|
||||
var x = r
|
||||
var j = i
|
||||
if x == nil: return
|
||||
while true:
|
||||
if not isConc(x):
|
||||
if x.data.len <% j: return x.data[j]
|
||||
return '\0'
|
||||
else:
|
||||
if x.left.len >% j:
|
||||
x = x.left
|
||||
else:
|
||||
x = x.right
|
||||
dec(j, x.len)
|
||||
|
||||
iterator leaves*(r: PRope): string =
|
||||
## iterates over any leaf string in the rope `r`.
|
||||
if r != nil:
|
||||
var stack = @[r]
|
||||
while stack.len > 0:
|
||||
var it = stack.pop
|
||||
while isConc(it):
|
||||
stack.add(it.right)
|
||||
it = it.left
|
||||
assert(it != nil)
|
||||
assert(it.data != nil)
|
||||
yield it.data
|
||||
|
||||
iterator items*(r: PRope): char =
|
||||
## iterates over any character in the rope `r`.
|
||||
for s in leaves(r):
|
||||
for c in items(s): yield c
|
||||
|
||||
proc write*(f: TFile, r: PRope) =
|
||||
## writes a rope to a file.
|
||||
for s in leaves(r): write(f, s)
|
||||
|
||||
proc `$`*(r: PRope): string =
|
||||
## converts a rope back to a string.
|
||||
result = newString(r.len)
|
||||
setLen(result, 0)
|
||||
for s in leaves(r): add(result, s)
|
||||
|
||||
when false:
|
||||
# Format string caching seems reasonable: All leaves can be shared and format
|
||||
# string parsing has to be done only once. A compiled format string is stored
|
||||
# as a rope. A negative length is used for the index into the args array.
|
||||
proc compiledArg(idx: int): PRope =
|
||||
new(result)
|
||||
result.length = -idx
|
||||
|
||||
proc compileFrmt(frmt: string): PRope =
|
||||
var i = 0
|
||||
var length = len(frmt)
|
||||
result = nil
|
||||
var num = 0
|
||||
while i < length:
|
||||
if frmt[i] == '$':
|
||||
inc(i)
|
||||
case frmt[i]
|
||||
of '$':
|
||||
add(result, "$")
|
||||
inc(i)
|
||||
of '#':
|
||||
inc(i)
|
||||
add(result, compiledArg(num+1))
|
||||
inc(num)
|
||||
of '0'..'9':
|
||||
var j = 0
|
||||
while true:
|
||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||
inc(i)
|
||||
if frmt[i] notin {'0'..'9'}: break
|
||||
num = j
|
||||
add(s, compiledArg(j))
|
||||
of '{':
|
||||
inc(i)
|
||||
var j = 0
|
||||
while frmt[i] in {'0'..'9'}:
|
||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||
inc(i)
|
||||
if frmt[i] == '}': inc(i)
|
||||
else: raise newException(EInvalidValue, "invalid format string")
|
||||
num = j
|
||||
add(s, compiledArg(j))
|
||||
else: raise newException(EInvalidValue, "invalid format string")
|
||||
var start = i
|
||||
while i < length:
|
||||
if frmt[i] != '$': inc(i)
|
||||
else: break
|
||||
if i - 1 >= start:
|
||||
add(result, copy(frmt, start, i-1))
|
||||
|
||||
proc `%`*(frmt: string, args: openarray[PRope]): PRope =
|
||||
## `%` substitution operator for ropes. Does not support the ``$identifier``
|
||||
## nor ``${identifier}`` notations.
|
||||
var i = 0
|
||||
var length = len(frmt)
|
||||
result = nil
|
||||
var num = 0
|
||||
while i < length:
|
||||
if frmt[i] == '$':
|
||||
inc(i)
|
||||
case frmt[i]
|
||||
of '$':
|
||||
add(result, "$")
|
||||
inc(i)
|
||||
of '#':
|
||||
inc(i)
|
||||
add(result, args[num])
|
||||
inc(num)
|
||||
of '0'..'9':
|
||||
var j = 0
|
||||
while true:
|
||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||
inc(i)
|
||||
if frmt[i] notin {'0'..'9'}: break
|
||||
num = j
|
||||
add(result, args[j-1])
|
||||
of '{':
|
||||
inc(i)
|
||||
var j = 0
|
||||
while frmt[i] in {'0'..'9'}:
|
||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||
inc(i)
|
||||
if frmt[i] == '}': inc(i)
|
||||
else: raise newException(EInvalidValue, "invalid format string")
|
||||
num = j
|
||||
add(result, args[j-1])
|
||||
else: raise newException(EInvalidValue, "invalid format string")
|
||||
var start = i
|
||||
while i < length:
|
||||
if frmt[i] != '$': inc(i)
|
||||
else: break
|
||||
if i - 1 >= start:
|
||||
add(result, copy(frmt, start, i - 1))
|
||||
|
||||
proc addf*(c: var PRope, frmt: string, args: openarray[PRope]) =
|
||||
## shortcut for ``add(c, frmt % args)``.
|
||||
add(c, frmt % args)
|
||||
|
||||
proc equalsFile*(r: PRope, f: TFile): bool =
|
||||
## returns true if the contents of the file `f` equal `r`.
|
||||
var bufSize = 1024 # reasonable start value
|
||||
var buf = alloc(BufSize)
|
||||
for s in leaves(r):
|
||||
if s.len > bufSize:
|
||||
bufSize = max(bufSize * 2, s.len)
|
||||
buf = realloc(buf, bufSize)
|
||||
var readBytes = readBuffer(f, buf, s.len)
|
||||
result = readBytes == s.len and equalMem(buf, cstring(s), s.len)
|
||||
if not result: break
|
||||
if result:
|
||||
result = readBuffer(f, buf, 1) == 0 # really at the end of file?
|
||||
dealloc(buf)
|
||||
|
||||
proc equalsFile*(r: PRope, f: string): bool =
|
||||
## returns true if the contents of the file `f` equal `r`. If `f` does not
|
||||
## exist, false is returned.
|
||||
var bin: TFile
|
||||
result = open(bin, f)
|
||||
if result:
|
||||
result = equalsFile(r, bin)
|
||||
close(bin)
|
||||
|
||||
new(N) # init dummy node for splay algorithm
|
||||
|
||||
{.pop.}
|
||||
206
lib/pure/sockets.nim
Normal file
206
lib/pure/sockets.nim
Normal file
@@ -0,0 +1,206 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements a simple portable type-safe sockets layer. **Note**:
|
||||
## This module is incomplete and probably buggy. It does not work on Windows
|
||||
## yet. Help if you are interested.
|
||||
|
||||
# TODO:
|
||||
# getservbyname(name, proto)
|
||||
# getservbyport(port, proto)
|
||||
# gethostbyname(name)
|
||||
# gethostbyaddr(addr)
|
||||
# shutdown(sock, how)
|
||||
# connect(sock, address, port)
|
||||
# select({ socket, ... }, timeout)
|
||||
|
||||
# sendto
|
||||
# recvfrom
|
||||
|
||||
# bind(socket, address, port)
|
||||
|
||||
# getsockopt(socket, level, optname)
|
||||
# setsockopt(socket, level, optname, value)
|
||||
|
||||
import os
|
||||
|
||||
when defined(Windows):
|
||||
import winlean
|
||||
else:
|
||||
import posix
|
||||
|
||||
type
|
||||
TSocket* = distinct cint ## socket type
|
||||
TPort* = distinct int16 ## port type
|
||||
|
||||
TDomain* = enum ## domain, which specifies the protocol family of the
|
||||
## created socket. Other domains than those that are listed
|
||||
## here are unsupported.
|
||||
AF_UNIX, ## for local socket (using a file).
|
||||
AF_INET, ## for network protocol IPv4 or
|
||||
AF_INET6 ## for network protocol IPv6.
|
||||
|
||||
TType* = enum ## second argument to `socket` proc
|
||||
SOCK_STREAM, ## reliable stream-oriented service or Stream Sockets
|
||||
SOCK_DGRAM, ## datagram service or Datagram Sockets
|
||||
SOCK_SEQPACKET, ## reliable sequenced packet service, or
|
||||
SOCK_RAW ## raw protocols atop the network layer.
|
||||
|
||||
TProtocol* = enum ## third argument to `socket` proc
|
||||
IPPROTO_TCP, ## Transmission control protocol.
|
||||
IPPROTO_UDP, ## User datagram protocol.
|
||||
IPPROTO_IP, ## Internet protocol.
|
||||
IPPROTO_IPV6, ## Internet Protocol Version 6.
|
||||
IPPROTO_RAW, ## Raw IP Packets Protocol.
|
||||
IPPROTO_ICMP ## Control message protocol.
|
||||
|
||||
const
|
||||
InvalidSocket* = TSocket(-1'i32) ## invalid socket number
|
||||
|
||||
proc `==`*(a, b: TSocket): bool {.borrow.}
|
||||
proc `==`*(a, b: TPort): bool {.borrow.}
|
||||
|
||||
proc ToInt(domain: TDomain): cint =
|
||||
case domain
|
||||
of AF_UNIX: result = posix.AF_UNIX
|
||||
of AF_INET: result = posix.AF_INET
|
||||
of AF_INET6: result = posix.AF_INET6
|
||||
|
||||
proc ToInt(typ: TType): cint =
|
||||
case typ
|
||||
of SOCK_STREAM: result = posix.SOCK_STREAM
|
||||
of SOCK_DGRAM: result = posix.SOCK_DGRAM
|
||||
of SOCK_SEQPACKET: result = posix.SOCK_SEQPACKET
|
||||
of SOCK_RAW: result = posix.SOCK_RAW
|
||||
|
||||
proc ToInt(p: TProtocol): cint =
|
||||
case p
|
||||
of IPPROTO_TCP: result = posix.IPPROTO_TCP
|
||||
of IPPROTO_UDP: result = posix.IPPROTO_UDP
|
||||
of IPPROTO_IP: result = posix.IPPROTO_IP
|
||||
of IPPROTO_IPV6: result = posix.IPPROTO_IPV6
|
||||
of IPPROTO_RAW: result = posix.IPPROTO_RAW
|
||||
of IPPROTO_ICMP: result = posix.IPPROTO_ICMP
|
||||
|
||||
proc socket*(domain: TDomain = AF_INET6, typ: TType = SOCK_STREAM,
|
||||
protocol: TProtocol = IPPROTO_TCP): TSocket =
|
||||
## creates a new socket; returns `InvalidSocket` if an error occurs.
|
||||
result = TSocket(posix.socket(ToInt(domain), ToInt(typ), ToInt(protocol)))
|
||||
|
||||
proc listen*(socket: TSocket, attempts = 5) =
|
||||
## listens to socket.
|
||||
if posix.listen(cint(socket), cint(attempts)) < 0'i32: OSError()
|
||||
|
||||
proc bindAddr*(socket: TSocket, port = TPort(0)) =
|
||||
var name: Tsockaddr_in
|
||||
name.sin_family = posix.AF_INET
|
||||
name.sin_port = htons(int16(port))
|
||||
name.sin_addr.s_addr = htonl(INADDR_ANY)
|
||||
if bindSocket(cint(socket), cast[ptr TSockAddr](addr(name)),
|
||||
sizeof(name)) < 0'i32:
|
||||
OSError()
|
||||
|
||||
proc getSockName*(socket: TSocket): TPort =
|
||||
var name: Tsockaddr_in
|
||||
name.sin_family = posix.AF_INET
|
||||
#name.sin_port = htons(cint16(port))
|
||||
#name.sin_addr.s_addr = htonl(INADDR_ANY)
|
||||
var namelen: cint = sizeof(name)
|
||||
if getsockname(cint(socket), cast[ptr TSockAddr](addr(name)),
|
||||
addr(namelen)) == -1'i32:
|
||||
OSError()
|
||||
result = TPort(ntohs(name.sin_port))
|
||||
|
||||
proc accept*(server: TSocket): TSocket =
|
||||
## waits for a client and returns its socket
|
||||
var client: Tsockaddr_in
|
||||
var clientLen: TsockLen = sizeof(client)
|
||||
result = TSocket(accept(cint(server), cast[ptr TSockAddr](addr(client)),
|
||||
addr(clientLen)))
|
||||
|
||||
proc close*(socket: TSocket) =
|
||||
## closes a socket.
|
||||
when defined(windows):
|
||||
discard winlean.closeSocket(cint(socket))
|
||||
else:
|
||||
discard posix.close(cint(socket))
|
||||
|
||||
proc recvLine*(socket: TSocket, line: var string): bool =
|
||||
## returns false if no further data is available.
|
||||
setLen(line, 0)
|
||||
while true:
|
||||
var c: char
|
||||
var n = recv(cint(socket), addr(c), 1, 0'i32)
|
||||
if n <= 0: return
|
||||
if c == '\r':
|
||||
n = recv(cint(socket), addr(c), 1, MSG_PEEK)
|
||||
if n > 0 and c == '\L':
|
||||
discard recv(cint(socket), addr(c), 1, 0'i32)
|
||||
elif n <= 0: return false
|
||||
return true
|
||||
elif c == '\L': return true
|
||||
add(line, c)
|
||||
|
||||
proc recv*(socket: TSocket, data: pointer, size: int): int =
|
||||
## receive data from a socket
|
||||
result = posix.recv(cint(socket), data, size, 0'i32)
|
||||
|
||||
proc recv*(socket: TSocket): string =
|
||||
## receive all the data from the socket
|
||||
const bufSize = 200
|
||||
var buf = newString(bufSize)
|
||||
result = ""
|
||||
while true:
|
||||
var bytesRead = recv(socket, cstring(buf), bufSize-1)
|
||||
buf[bytesRead] = '\0' # might not be necessary
|
||||
setLen(buf, bytesRead)
|
||||
add(result, buf)
|
||||
if bytesRead != bufSize-1: break
|
||||
|
||||
proc skip*(socket: TSocket) =
|
||||
## skips all the data that is pending for the socket
|
||||
const bufSize = 200
|
||||
var buf = alloc(bufSize)
|
||||
while recv(socket, buf, bufSize) == bufSize: nil
|
||||
dealloc(buf)
|
||||
|
||||
proc send*(socket: TSocket, data: pointer, size: int): int =
|
||||
result = posix.send(cint(socket), data, size, 0'i32)
|
||||
|
||||
proc send*(socket: TSocket, data: string) =
|
||||
if send(socket, cstring(data), data.len) != data.len: OSError()
|
||||
|
||||
proc ntohl*(x: int32): int32 =
|
||||
## Convert 32-bit integers from network to host byte order.
|
||||
## On machines where the host byte order is the same as network byte order,
|
||||
## this is a no-op; otherwise, it performs a 4-byte swap operation.
|
||||
when cpuEndian == bigEndian: result = x
|
||||
else: result = (x shr 24'i32) or
|
||||
(x shr 8'i32 and 0xff00'i32) or
|
||||
(x shl 8'i32 and 0xff0000'i32) or
|
||||
(x shl 24'i32)
|
||||
|
||||
proc ntohs*(x: int16): int16 =
|
||||
## Convert 16-bit integers from network to host byte order. On machines
|
||||
## where the host byte order is the same as network byte order, this is
|
||||
## a no-op; otherwise, it performs a 2-byte swap operation.
|
||||
when cpuEndian == bigEndian: result = x
|
||||
else: result = (x shr 8'i16) or (x shl 8'i16)
|
||||
|
||||
proc htonl*(x: int32): int32 =
|
||||
## Convert 32-bit integers from host to network byte order. On machines
|
||||
## where the host byte order is the same as network byte order, this is
|
||||
## a no-op; otherwise, it performs a 4-byte swap operation.
|
||||
result = sockets.ntohl(x)
|
||||
|
||||
proc htons*(x: int16): int16 =
|
||||
## Convert 16-bit positive integers from host to network byte order.
|
||||
## On machines where the host byte order is the same as network byte
|
||||
## order, this is a no-op; otherwise, it performs a 2-byte swap operation.
|
||||
result = sockets.ntohs(x)
|
||||
@@ -7,10 +7,10 @@
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## The ``strtabs`` module implements an efficient hash table that is a mapping
|
||||
## from strings to strings. Supports a case-sensitive, case-insensitive and
|
||||
## style-insensitive mode. An efficient string substitution operator ``%``
|
||||
## for the string table is also provided.
|
||||
## The ``strtabs`` module implements an efficient hash table that is a mapping
|
||||
## from strings to strings. Supports a case-sensitive, case-insensitive and
|
||||
## style-insensitive mode. An efficient string substitution operator ``%``
|
||||
## for the string table is also provided.
|
||||
|
||||
import
|
||||
os, hashes, strutils
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
|
||||
# Exception handling code. This is difficult because it has
|
||||
# to work if there is no more memory. Thus we have to use
|
||||
# a static string. Do not use ``sprintf``, etc. as they are
|
||||
# to work if there is no more memory. Do not use ``sprintf``, etc. as they are
|
||||
# unsafe!
|
||||
|
||||
when not defined(windows) or not defined(guiapp):
|
||||
|
||||
@@ -155,6 +155,7 @@ type
|
||||
dwReserved1: int32
|
||||
cFileName*: array[0..(MAX_PATH) - 1, char]
|
||||
cAlternateFileName*: array[0..13, char]
|
||||
|
||||
proc FindFirstFileA*(lpFileName: cstring,
|
||||
lpFindFileData: var TWIN32_FIND_DATA): THANDLE {.
|
||||
stdcall, dynlib: "kernel32", importc: "FindFirstFileA".}
|
||||
|
||||
@@ -51,7 +51,7 @@ const
|
||||
TCL_VERSION_MAJOR* = 0
|
||||
TCL_VERSION_MINOR* = 0
|
||||
TCL_NO_EVAL* = 0x00010000
|
||||
TCL_EVAL_GLOBAL* = 0x00020000 #* Flag values passed to variable-related procedures. *
|
||||
TCL_EVAL_GLOBAL* = 0x00020000 # Flag values passed to variable-related procedures. *
|
||||
TCL_GLOBAL_ONLY* = 1
|
||||
TCL_NAMESPACE_ONLY* = 2
|
||||
TCL_APPEND_VALUE* = 4
|
||||
@@ -62,15 +62,15 @@ const
|
||||
TCL_TRACE_DESTROYED* = 0x00000080
|
||||
TCL_INTERP_DESTROYED* = 0x00000100
|
||||
TCL_LEAVE_ERR_MSG* = 0x00000200
|
||||
TCL_PARSE_PART1* = 0x00000400 #* Types for linked variables: *
|
||||
TCL_PARSE_PART1* = 0x00000400 # Types for linked variables: *
|
||||
TCL_LINK_INT* = 1
|
||||
TCL_LINK_DOUBLE* = 2
|
||||
TCL_LINK_BOOLEAN* = 3
|
||||
TCL_LINK_STRING* = 4
|
||||
TCL_LINK_READ_ONLY* = 0x00000080
|
||||
TCL_SMALL_HASH_TABLE* = 4 #* Hash Table *
|
||||
TCL_SMALL_HASH_TABLE* = 4 # Hash Table *
|
||||
TCL_STRING_KEYS* = 0
|
||||
TCL_ONE_WORD_KEYS* = 1 #* Const/enums Tcl_QueuePosition *
|
||||
TCL_ONE_WORD_KEYS* = 1 # Const/enums Tcl_QueuePosition *
|
||||
# typedef enum {
|
||||
TCL_QUEUE_TAIL* = 0
|
||||
TCL_QUEUE_HEAD* = 1
|
||||
@@ -80,7 +80,7 @@ const
|
||||
TCL_WINDOW_EVENTS* = 1 shl 2
|
||||
TCL_FILE_EVENTS* = 1 shl 3
|
||||
TCL_TIMER_EVENTS* = 1 shl 4
|
||||
TCL_IDLE_EVENTS* = 1 shl 5 #* WAS 0x10 ???? *
|
||||
TCL_IDLE_EVENTS* = 1 shl 5 # WAS 0x10 ???? *
|
||||
TCL_ALL_EVENTS* = not TCL_DONT_WAIT
|
||||
|
||||
TCL_VOLATILE* = 1
|
||||
@@ -92,7 +92,7 @@ const
|
||||
TCL_ENFORCE_MODE* = 1 shl 4
|
||||
TCL_READABLE* = 1 shl 1
|
||||
TCL_WRITABLE* = 1 shl 2
|
||||
TCL_EXCEPTION* = 1 shl 3 #* POSIX *
|
||||
TCL_EXCEPTION* = 1 shl 3 # POSIX *
|
||||
EPERM* = 1 # Operation not permitted; only the owner of the file (or other
|
||||
# resource) or processes with special privileges can perform the
|
||||
# operation.
|
||||
@@ -101,277 +101,277 @@ const
|
||||
# for ordinary files that are referenced in contexts where they are
|
||||
# expected to already exist.
|
||||
#
|
||||
ESRCH* = 3 #* No process matches the specified process ID. *
|
||||
EINTR* = 4 #* Interrupted function call; an asynchronous signal occurred and
|
||||
# * prevented completion of the call. When this happens, you should
|
||||
# * try the call again.
|
||||
# *
|
||||
EIO* = 5 #* Input/output error; usually used for physical read or write errors. *
|
||||
ENXIO* = 6 #* No such device or address. The system tried to use the device
|
||||
# * represented by a file you specified, and it couldn't find the
|
||||
# * device. This can mean that the device file was installed
|
||||
# * incorrectly, or that the physical device is missing or not
|
||||
# * correctly attached to the computer.
|
||||
# *
|
||||
E2BIG* = 7 #* Argument list too long; used when the arguments passed to a new
|
||||
# * program being executed with one of the `exec' functions (*note
|
||||
# * Executing a File::.) occupy too much memory space. This condition
|
||||
# * never arises in the GNU system.
|
||||
# *
|
||||
ENOEXEC* = 8 #* Invalid executable file format. This condition is detected by the
|
||||
# * `exec' functions; see *Note Executing a File::.
|
||||
# *
|
||||
EBADF* = 9 #* Bad file descriptor; for example, I/O on a descriptor that has been
|
||||
# * closed or reading from a descriptor open only for writing (or vice
|
||||
# * versa).
|
||||
# *
|
||||
ECHILD* = 10 #* There are no child processes. This error happens on operations
|
||||
# * that are supposed to manipulate child processes, when there aren't
|
||||
# * any processes to manipulate.
|
||||
# *
|
||||
EDEADLK* = 11 #* Deadlock avoided; allocating a system resource would have resulted
|
||||
# * in a deadlock situation. The system does not guarantee that it
|
||||
# * will notice all such situations. This error means you got lucky
|
||||
# * and the system noticed; it might just hang. *Note File Locks::,
|
||||
# * for an example.
|
||||
# *
|
||||
ENOMEM* = 12 #* No memory available. The system cannot allocate more virtual
|
||||
# * memory because its capacity is full.
|
||||
# *
|
||||
EACCES* = 13 #* Permission denied; the file permissions do not allow the attempted
|
||||
# * operation.
|
||||
# *
|
||||
EFAULT* = 14 #* Bad address; an invalid pointer was detected. In the GNU system,
|
||||
# * this error never happens; you get a signal instead.
|
||||
# *
|
||||
ENOTBLK* = 15 #* A file that isn't a block special file was given in a situation
|
||||
# * that requires one. For example, trying to mount an ordinary file
|
||||
# * as a file system in Unix gives this error.
|
||||
# *
|
||||
EBUSY* = 16 #* Resource busy; a system resource that can't be shared is already
|
||||
# * in use. For example, if you try to delete a file that is the root
|
||||
# * of a currently mounted filesystem, you get this error.
|
||||
# *
|
||||
EEXIST* = 17 #* File exists; an existing file was specified in a context where it
|
||||
# * only makes sense to specify a new file.
|
||||
# *
|
||||
EXDEV* = 18 #* An attempt to make an improper link across file systems was
|
||||
# * detected. This happens not only when you use `link' (*note Hard
|
||||
# * Links::.) but also when you rename a file with `rename' (*note
|
||||
# * Renaming Files::.).
|
||||
# *
|
||||
ENODEV* = 19 #* The wrong type of device was given to a function that expects a
|
||||
# * particular sort of device.
|
||||
# *
|
||||
ENOTDIR* = 20 #* A file that isn't a directory was specified when a directory is
|
||||
# * required.
|
||||
# *
|
||||
EISDIR* = 21 #* File is a directory; you cannot open a directory for writing, or
|
||||
# * create or remove hard links to it.
|
||||
# *
|
||||
EINVAL* = 22 #* Invalid argument. This is used to indicate various kinds of
|
||||
# * problems with passing the wrong argument to a library function.
|
||||
# *
|
||||
EMFILE* = 24 #* The current process has too many files open and can't open any
|
||||
# * more. Duplicate descriptors do count toward this limit.
|
||||
# *
|
||||
# * In BSD and GNU, the number of open files is controlled by a
|
||||
# * resource limit that can usually be increased. If you get this
|
||||
# * error, you might want to increase the `RLIMIT_NOFILE' limit or
|
||||
# * make it unlimited; *note Limits on Resources::..
|
||||
# *
|
||||
ENFILE* = 23 #* There are too many distinct file openings in the entire system.
|
||||
# * Note that any number of linked channels count as just one file
|
||||
# * opening; see *Note Linked Channels::. This error never occurs in
|
||||
# * the GNU system.
|
||||
# *
|
||||
ENOTTY* = 25 #* Inappropriate I/O control operation, such as trying to set terminal
|
||||
# * modes on an ordinary file.
|
||||
# *
|
||||
ETXTBSY* = 26 #* An attempt to execute a file that is currently open for writing, or
|
||||
# * write to a file that is currently being executed. Often using a
|
||||
# * debugger to run a program is considered having it open for writing
|
||||
# * and will cause this error. (The name stands for "text file
|
||||
# * busy".) This is not an error in the GNU system; the text is
|
||||
# * copied as necessary.
|
||||
# *
|
||||
EFBIG* = 27 #* File too big; the size of a file would be larger than allowed by
|
||||
# * the system.
|
||||
# *
|
||||
ENOSPC* = 28 #* No space left on device; write operation on a file failed because
|
||||
# * the disk is full.
|
||||
# *
|
||||
ESPIPE* = 29 #* Invalid seek operation (such as on a pipe). *
|
||||
EROFS* = 30 #* An attempt was made to modify something on a read-only file system. *
|
||||
EMLINK* = 31 #* Too many links; the link count of a single file would become too
|
||||
# * large. `rename' can cause this error if the file being renamed
|
||||
# * already has as many links as it can take (*note Renaming Files::.).
|
||||
# *
|
||||
EPIPE* = 32 #* Broken pipe; there is no process reading from the other end of a
|
||||
# * pipe. Every library function that returns this error code also
|
||||
# * generates a `SIGPIPE' signal; this signal terminates the program
|
||||
# * if not handled or blocked. Thus, your program will never actually
|
||||
# * see `EPIPE' unless it has handled or blocked `SIGPIPE'.
|
||||
# *
|
||||
EDOM* = 33 #* Domain error; used by mathematical functions when an argument
|
||||
# * value does not fall into the domain over which the function is
|
||||
# * defined.
|
||||
# *
|
||||
ERANGE* = 34 #* Range error; used by mathematical functions when the result value
|
||||
# * is not representable because of overflow or underflow.
|
||||
# *
|
||||
EAGAIN* = 35 #* Resource temporarily unavailable; the call might work if you try
|
||||
# * again later. The macro `EWOULDBLOCK' is another name for `EAGAIN';
|
||||
# * they are always the same in the GNU C library.
|
||||
# *
|
||||
EWOULDBLOCK* = EAGAIN #* In the GNU C library, this is another name for `EAGAIN' (above).
|
||||
# * The values are always the same, on every operating system.
|
||||
# * C libraries in many older Unix systems have `EWOULDBLOCK' as a
|
||||
# * separate error code.
|
||||
# *
|
||||
EINPROGRESS* = 36 #* An operation that cannot complete immediately was initiated on an
|
||||
# * object that has non-blocking mode selected. Some functions that
|
||||
# * must always block (such as `connect'; *note Connecting::.) never
|
||||
# * return `EAGAIN'. Instead, they return `EINPROGRESS' to indicate
|
||||
# * that the operation has begun and will take some time. Attempts to
|
||||
# * manipulate the object before the call completes return `EALREADY'.
|
||||
# * You can use the `select' function to find out when the pending
|
||||
# * operation has completed; *note Waiting for I/O::..
|
||||
# *
|
||||
EALREADY* = 37 #* An operation is already in progress on an object that has
|
||||
# * non-blocking mode selected.
|
||||
# *
|
||||
ENOTSOCK* = 38 #* A file that isn't a socket was specified when a socket is required. *
|
||||
EDESTADDRREQ* = 39 #* No default destination address was set for the socket. You get
|
||||
# * this error when you try to transmit data over a connectionless
|
||||
# * socket, without first specifying a destination for the data with
|
||||
# * `connect'.
|
||||
# *
|
||||
EMSGSIZE* = 40 #* The size of a message sent on a socket was larger than the
|
||||
# * supported maximum size.
|
||||
# *
|
||||
EPROTOTYPE* = 41 #* The socket type does not support the requested communications
|
||||
# * protocol.
|
||||
# *
|
||||
ENOPROTOOPT* = 42 #* You specified a socket option that doesn't make sense for the
|
||||
# * particular protocol being used by the socket. *Note Socket
|
||||
# * Options::.
|
||||
# *
|
||||
EPROTONOSUPPORT* = 43 #* The socket domain does not support the requested communications
|
||||
# * protocol (perhaps because the requested protocol is completely
|
||||
# * invalid.) *Note Creating a Socket::.
|
||||
# *
|
||||
ESOCKTNOSUPPORT* = 44 #* The socket type is not supported. *
|
||||
EOPNOTSUPP* = 45 #* The operation you requested is not supported. Some socket
|
||||
# * functions don't make sense for all types of sockets, and others
|
||||
# * may not be implemented for all communications protocols. In the
|
||||
# * GNU system, this error can happen for many calls when the object
|
||||
# * does not support the particular operation; it is a generic
|
||||
# * indication that the server knows nothing to do for that call.
|
||||
# *
|
||||
EPFNOSUPPORT* = 46 #* The socket communications protocol family you requested is not
|
||||
# * supported.
|
||||
# *
|
||||
EAFNOSUPPORT* = 47 #* The address family specified for a socket is not supported; it is
|
||||
# * inconsistent with the protocol being used on the socket. *Note
|
||||
# * Sockets::.
|
||||
# *
|
||||
EADDRINUSE* = 48 #* The requested socket address is already in use. *Note Socket
|
||||
# * Addresses::.
|
||||
# *
|
||||
EADDRNOTAVAIL* = 49 #* The requested socket address is not available; for example, you
|
||||
# * tried to give a socket a name that doesn't match the local host
|
||||
# * name. *Note Socket Addresses::.
|
||||
# *
|
||||
ENETDOWN* = 50 #* A socket operation failed because the network was down. *
|
||||
ENETUNREACH* = 51 #* A socket operation failed because the subnet containing the remote
|
||||
# * host was unreachable.
|
||||
# *
|
||||
ENETRESET* = 52 #* A network connection was reset because the remote host crashed. *
|
||||
ECONNABORTED* = 53 #* A network connection was aborted locally. *
|
||||
ECONNRESET* = 54 #* A network connection was closed for reasons outside the control of
|
||||
# * the local host, such as by the remote machine rebooting or an
|
||||
# * unrecoverable protocol violation.
|
||||
# *
|
||||
ENOBUFS* = 55 #* The kernel's buffers for I/O operations are all in use. In GNU,
|
||||
# * this error is always synonymous with `ENOMEM'; you may get one or
|
||||
# * the other from network operations.
|
||||
# *
|
||||
EISCONN* = 56 #* You tried to connect a socket that is already connected. *Note
|
||||
# * Connecting::.
|
||||
# *
|
||||
ENOTCONN* = 57 #* The socket is not connected to anything. You get this error when
|
||||
# * you try to transmit data over a socket, without first specifying a
|
||||
# * destination for the data. For a connectionless socket (for
|
||||
# * datagram protocols, such as UDP), you get `EDESTADDRREQ' instead.
|
||||
# *
|
||||
ESHUTDOWN* = 58 #* The socket has already been shut down. *
|
||||
ETOOMANYREFS* = 59 #* ??? *
|
||||
ETIMEDOUT* = 60 #* A socket operation with a specified timeout received no response
|
||||
# * during the timeout period.
|
||||
# *
|
||||
ECONNREFUSED* = 61 #* A remote host refused to allow the network connection (typically
|
||||
# * because it is not running the requested service).
|
||||
# *
|
||||
ELOOP* = 62 #* Too many levels of symbolic links were encountered in looking up a
|
||||
# * file name. This often indicates a cycle of symbolic links.
|
||||
# *
|
||||
ENAMETOOLONG* = 63 #* Filename too long (longer than `PATH_MAX'; *note Limits for
|
||||
# * Files::.) or host name too long (in `gethostname' or
|
||||
# * `sethostname'; *note Host Identification::.).
|
||||
# *
|
||||
EHOSTDOWN* = 64 #* The remote host for a requested network connection is down. *
|
||||
EHOSTUNREACH* = 65 #* The remote host for a requested network connection is not
|
||||
# * reachable.
|
||||
# *
|
||||
ENOTEMPTY* = 66 #* Directory not empty, where an empty directory was expected.
|
||||
# * Typically, this error occurs when you are trying to delete a
|
||||
# * directory.
|
||||
# *
|
||||
EPROCLIM* = 67 #* This means that the per-user limit on new process would be
|
||||
# * exceeded by an attempted `fork'. *Note Limits on Resources::, for
|
||||
# * details on the `RLIMIT_NPROC' limit.
|
||||
# *
|
||||
EUSERS* = 68 #* The file quota system is confused because there are too many users. *
|
||||
EDQUOT* = 69 #* The user's disk quota was exceeded. *
|
||||
ESTALE* = 70 #* Stale NFS file handle. This indicates an internal confusion in
|
||||
# * the NFS system which is due to file system rearrangements on the
|
||||
# * server host. Repairing this condition usually requires unmounting
|
||||
# * and remounting the NFS file system on the local host.
|
||||
# *
|
||||
EREMOTE* = 71 #* An attempt was made to NFS-mount a remote file system with a file
|
||||
# * name that already specifies an NFS-mounted file. (This is an
|
||||
# * error on some operating systems, but we expect it to work properly
|
||||
# * on the GNU system, making this error code impossible.)
|
||||
# *
|
||||
EBADRPC* = 72 #* ??? *
|
||||
ERPCMISMATCH* = 73 #* ??? *
|
||||
EPROGUNAVAIL* = 74 #* ??? *
|
||||
EPROGMISMATCH* = 75 #* ??? *
|
||||
EPROCUNAVAIL* = 76 #* ??? *
|
||||
ENOLCK* = 77 #* No locks available. This is used by the file locking facilities;
|
||||
# * see *Note File Locks::. This error is never generated by the GNU
|
||||
# * system, but it can result from an operation to an NFS server
|
||||
# * running another operating system.
|
||||
# *
|
||||
ENOSYS* = 78 #* Function not implemented. Some functions have commands or options
|
||||
# * defined that might not be supported in all implementations, and
|
||||
# * this is the kind of error you get if you request them and they are
|
||||
# * not supported.
|
||||
# *
|
||||
EFTYPE* = 79 #* Inappropriate file type or format. The file was the wrong type
|
||||
# * for the operation, or a data file had the wrong format.
|
||||
# * On some systems `chmod' returns this error if you try to set the
|
||||
# * sticky bit on a non-directory file; *note Setting Permissions::..
|
||||
# *
|
||||
ESRCH* = 3 # No process matches the specified process ID. *
|
||||
EINTR* = 4 # Interrupted function call; an asynchronous signal occurred and
|
||||
# prevented completion of the call. When this happens, you should
|
||||
# try the call again.
|
||||
#
|
||||
EIO* = 5 # Input/output error; usually used for physical read or write errors. *
|
||||
ENXIO* = 6 # No such device or address. The system tried to use the device
|
||||
# represented by a file you specified, and it couldn't find the
|
||||
# device. This can mean that the device file was installed
|
||||
# incorrectly, or that the physical device is missing or not
|
||||
# correctly attached to the computer.
|
||||
#
|
||||
E2BIG* = 7 # Argument list too long; used when the arguments passed to a new
|
||||
# program being executed with one of the `exec' functions (*note
|
||||
# Executing a File::.) occupy too much memory space. This condition
|
||||
# never arises in the GNU system.
|
||||
#
|
||||
ENOEXEC* = 8 # Invalid executable file format. This condition is detected by the
|
||||
# `exec' functions; see *Note Executing a File::.
|
||||
#
|
||||
EBADF* = 9 # Bad file descriptor; for example, I/O on a descriptor that has been
|
||||
# closed or reading from a descriptor open only for writing (or vice
|
||||
# versa).
|
||||
#
|
||||
ECHILD* = 10 # There are no child processes. This error happens on operations
|
||||
# that are supposed to manipulate child processes, when there aren't
|
||||
# any processes to manipulate.
|
||||
#
|
||||
EDEADLK* = 11 # Deadlock avoided; allocating a system resource would have resulted
|
||||
# in a deadlock situation. The system does not guarantee that it
|
||||
# will notice all such situations. This error means you got lucky
|
||||
# and the system noticed; it might just hang. *Note File Locks::,
|
||||
# for an example.
|
||||
#
|
||||
ENOMEM* = 12 # No memory available. The system cannot allocate more virtual
|
||||
# memory because its capacity is full.
|
||||
#
|
||||
EACCES* = 13 # Permission denied; the file permissions do not allow the attempted
|
||||
# operation.
|
||||
#
|
||||
EFAULT* = 14 # Bad address; an invalid pointer was detected. In the GNU system,
|
||||
# this error never happens; you get a signal instead.
|
||||
#
|
||||
ENOTBLK* = 15 # A file that isn't a block special file was given in a situation
|
||||
# that requires one. For example, trying to mount an ordinary file
|
||||
# as a file system in Unix gives this error.
|
||||
#
|
||||
EBUSY* = 16 # Resource busy; a system resource that can't be shared is already
|
||||
# in use. For example, if you try to delete a file that is the root
|
||||
# of a currently mounted filesystem, you get this error.
|
||||
#
|
||||
EEXIST* = 17 # File exists; an existing file was specified in a context where it
|
||||
# only makes sense to specify a new file.
|
||||
#
|
||||
EXDEV* = 18 # An attempt to make an improper link across file systems was
|
||||
# detected. This happens not only when you use `link' (*note Hard
|
||||
# Links::.) but also when you rename a file with `rename' (*note
|
||||
# Renaming Files::.).
|
||||
#
|
||||
ENODEV* = 19 # The wrong type of device was given to a function that expects a
|
||||
# particular sort of device.
|
||||
#
|
||||
ENOTDIR* = 20 # A file that isn't a directory was specified when a directory is
|
||||
# required.
|
||||
#
|
||||
EISDIR* = 21 # File is a directory; you cannot open a directory for writing, or
|
||||
# create or remove hard links to it.
|
||||
#
|
||||
EINVAL* = 22 # Invalid argument. This is used to indicate various kinds of
|
||||
# problems with passing the wrong argument to a library function.
|
||||
#
|
||||
EMFILE* = 24 # The current process has too many files open and can't open any
|
||||
# more. Duplicate descriptors do count toward this limit.
|
||||
#
|
||||
# In BSD and GNU, the number of open files is controlled by a
|
||||
# resource limit that can usually be increased. If you get this
|
||||
# error, you might want to increase the `RLIMIT_NOFILE' limit or
|
||||
# make it unlimited; *note Limits on Resources::..
|
||||
#
|
||||
ENFILE* = 23 # There are too many distinct file openings in the entire system.
|
||||
# Note that any number of linked channels count as just one file
|
||||
# opening; see *Note Linked Channels::. This error never occurs in
|
||||
# the GNU system.
|
||||
#
|
||||
ENOTTY* = 25 # Inappropriate I/O control operation, such as trying to set terminal
|
||||
# modes on an ordinary file.
|
||||
#
|
||||
ETXTBSY* = 26 # An attempt to execute a file that is currently open for writing, or
|
||||
# write to a file that is currently being executed. Often using a
|
||||
# debugger to run a program is considered having it open for writing
|
||||
# and will cause this error. (The name stands for "text file
|
||||
# busy".) This is not an error in the GNU system; the text is
|
||||
# copied as necessary.
|
||||
#
|
||||
EFBIG* = 27 # File too big; the size of a file would be larger than allowed by
|
||||
# the system.
|
||||
#
|
||||
ENOSPC* = 28 # No space left on device; write operation on a file failed because
|
||||
# the disk is full.
|
||||
#
|
||||
ESPIPE* = 29 # Invalid seek operation (such as on a pipe). *
|
||||
EROFS* = 30 # An attempt was made to modify something on a read-only file system. *
|
||||
EMLINK* = 31 # Too many links; the link count of a single file would become too
|
||||
# large. `rename' can cause this error if the file being renamed
|
||||
# already has as many links as it can take (*note Renaming Files::.).
|
||||
#
|
||||
EPIPE* = 32 # Broken pipe; there is no process reading from the other end of a
|
||||
# pipe. Every library function that returns this error code also
|
||||
# generates a `SIGPIPE' signal; this signal terminates the program
|
||||
# if not handled or blocked. Thus, your program will never actually
|
||||
# see `EPIPE' unless it has handled or blocked `SIGPIPE'.
|
||||
#
|
||||
EDOM* = 33 # Domain error; used by mathematical functions when an argument
|
||||
# value does not fall into the domain over which the function is
|
||||
# defined.
|
||||
#
|
||||
ERANGE* = 34 # Range error; used by mathematical functions when the result value
|
||||
# is not representable because of overflow or underflow.
|
||||
#
|
||||
EAGAIN* = 35 # Resource temporarily unavailable; the call might work if you try
|
||||
# again later. The macro `EWOULDBLOCK' is another name for `EAGAIN';
|
||||
# they are always the same in the GNU C library.
|
||||
#
|
||||
EWOULDBLOCK* = EAGAIN # In the GNU C library, this is another name for `EAGAIN' (above).
|
||||
# The values are always the same, on every operating system.
|
||||
# C libraries in many older Unix systems have `EWOULDBLOCK' as a
|
||||
# separate error code.
|
||||
#
|
||||
EINPROGRESS* = 36 # An operation that cannot complete immediately was initiated on an
|
||||
# object that has non-blocking mode selected. Some functions that
|
||||
# must always block (such as `connect'; *note Connecting::.) never
|
||||
# return `EAGAIN'. Instead, they return `EINPROGRESS' to indicate
|
||||
# that the operation has begun and will take some time. Attempts to
|
||||
# manipulate the object before the call completes return `EALREADY'.
|
||||
# You can use the `select' function to find out when the pending
|
||||
# operation has completed; *note Waiting for I/O::..
|
||||
#
|
||||
EALREADY* = 37 # An operation is already in progress on an object that has
|
||||
# non-blocking mode selected.
|
||||
#
|
||||
ENOTSOCK* = 38 # A file that isn't a socket was specified when a socket is required. *
|
||||
EDESTADDRREQ* = 39 # No default destination address was set for the socket. You get
|
||||
# this error when you try to transmit data over a connectionless
|
||||
# socket, without first specifying a destination for the data with
|
||||
# `connect'.
|
||||
#
|
||||
EMSGSIZE* = 40 # The size of a message sent on a socket was larger than the
|
||||
# supported maximum size.
|
||||
#
|
||||
EPROTOTYPE* = 41 # The socket type does not support the requested communications
|
||||
# protocol.
|
||||
#
|
||||
ENOPROTOOPT* = 42 # You specified a socket option that doesn't make sense for the
|
||||
# particular protocol being used by the socket. *Note Socket
|
||||
# Options::.
|
||||
#
|
||||
EPROTONOSUPPORT* = 43 # The socket domain does not support the requested communications
|
||||
# protocol (perhaps because the requested protocol is completely
|
||||
# invalid.) *Note Creating a Socket::.
|
||||
#
|
||||
ESOCKTNOSUPPORT* = 44 # The socket type is not supported. *
|
||||
EOPNOTSUPP* = 45 # The operation you requested is not supported. Some socket
|
||||
# functions don't make sense for all types of sockets, and others
|
||||
# may not be implemented for all communications protocols. In the
|
||||
# GNU system, this error can happen for many calls when the object
|
||||
# does not support the particular operation; it is a generic
|
||||
# indication that the server knows nothing to do for that call.
|
||||
#
|
||||
EPFNOSUPPORT* = 46 # The socket communications protocol family you requested is not
|
||||
# supported.
|
||||
#
|
||||
EAFNOSUPPORT* = 47 # The address family specified for a socket is not supported; it is
|
||||
# inconsistent with the protocol being used on the socket. *Note
|
||||
# Sockets::.
|
||||
#
|
||||
EADDRINUSE* = 48 # The requested socket address is already in use. *Note Socket
|
||||
# Addresses::.
|
||||
#
|
||||
EADDRNOTAVAIL* = 49 # The requested socket address is not available; for example, you
|
||||
# tried to give a socket a name that doesn't match the local host
|
||||
# name. *Note Socket Addresses::.
|
||||
#
|
||||
ENETDOWN* = 50 # A socket operation failed because the network was down. *
|
||||
ENETUNREACH* = 51 # A socket operation failed because the subnet containing the remote
|
||||
# host was unreachable.
|
||||
#
|
||||
ENETRESET* = 52 # A network connection was reset because the remote host crashed. *
|
||||
ECONNABORTED* = 53 # A network connection was aborted locally. *
|
||||
ECONNRESET* = 54 # A network connection was closed for reasons outside the control of
|
||||
# the local host, such as by the remote machine rebooting or an
|
||||
# unrecoverable protocol violation.
|
||||
#
|
||||
ENOBUFS* = 55 # The kernel's buffers for I/O operations are all in use. In GNU,
|
||||
# this error is always synonymous with `ENOMEM'; you may get one or
|
||||
# the other from network operations.
|
||||
#
|
||||
EISCONN* = 56 # You tried to connect a socket that is already connected. *Note
|
||||
# Connecting::.
|
||||
#
|
||||
ENOTCONN* = 57 # The socket is not connected to anything. You get this error when
|
||||
# you try to transmit data over a socket, without first specifying a
|
||||
# destination for the data. For a connectionless socket (for
|
||||
# datagram protocols, such as UDP), you get `EDESTADDRREQ' instead.
|
||||
#
|
||||
ESHUTDOWN* = 58 # The socket has already been shut down. *
|
||||
ETOOMANYREFS* = 59 # ??? *
|
||||
ETIMEDOUT* = 60 # A socket operation with a specified timeout received no response
|
||||
# during the timeout period.
|
||||
#
|
||||
ECONNREFUSED* = 61 # A remote host refused to allow the network connection (typically
|
||||
# because it is not running the requested service).
|
||||
#
|
||||
ELOOP* = 62 # Too many levels of symbolic links were encountered in looking up a
|
||||
# file name. This often indicates a cycle of symbolic links.
|
||||
#
|
||||
ENAMETOOLONG* = 63 # Filename too long (longer than `PATH_MAX'; *note Limits for
|
||||
# Files::.) or host name too long (in `gethostname' or
|
||||
# `sethostname'; *note Host Identification::.).
|
||||
#
|
||||
EHOSTDOWN* = 64 # The remote host for a requested network connection is down. *
|
||||
EHOSTUNREACH* = 65 # The remote host for a requested network connection is not
|
||||
# reachable.
|
||||
#
|
||||
ENOTEMPTY* = 66 # Directory not empty, where an empty directory was expected.
|
||||
# Typically, this error occurs when you are trying to delete a
|
||||
# directory.
|
||||
#
|
||||
EPROCLIM* = 67 # This means that the per-user limit on new process would be
|
||||
# exceeded by an attempted `fork'. *Note Limits on Resources::, for
|
||||
# details on the `RLIMIT_NPROC' limit.
|
||||
#
|
||||
EUSERS* = 68 # The file quota system is confused because there are too many users. *
|
||||
EDQUOT* = 69 # The user's disk quota was exceeded. *
|
||||
ESTALE* = 70 # Stale NFS file handle. This indicates an internal confusion in
|
||||
# the NFS system which is due to file system rearrangements on the
|
||||
# server host. Repairing this condition usually requires unmounting
|
||||
# and remounting the NFS file system on the local host.
|
||||
#
|
||||
EREMOTE* = 71 # An attempt was made to NFS-mount a remote file system with a file
|
||||
# name that already specifies an NFS-mounted file. (This is an
|
||||
# error on some operating systems, but we expect it to work properly
|
||||
# on the GNU system, making this error code impossible.)
|
||||
#
|
||||
EBADRPC* = 72 # ??? *
|
||||
ERPCMISMATCH* = 73 # ??? *
|
||||
EPROGUNAVAIL* = 74 # ??? *
|
||||
EPROGMISMATCH* = 75 # ??? *
|
||||
EPROCUNAVAIL* = 76 # ??? *
|
||||
ENOLCK* = 77 # No locks available. This is used by the file locking facilities;
|
||||
# see *Note File Locks::. This error is never generated by the GNU
|
||||
# system, but it can result from an operation to an NFS server
|
||||
# running another operating system.
|
||||
#
|
||||
ENOSYS* = 78 # Function not implemented. Some functions have commands or options
|
||||
# defined that might not be supported in all implementations, and
|
||||
# this is the kind of error you get if you request them and they are
|
||||
# not supported.
|
||||
#
|
||||
EFTYPE* = 79 # Inappropriate file type or format. The file was the wrong type
|
||||
# for the operation, or a data file had the wrong format.
|
||||
# On some systems `chmod' returns this error if you try to set the
|
||||
# sticky bit on a non-directory file; *note Setting Permissions::..
|
||||
#
|
||||
|
||||
type
|
||||
Tcl_Argv* = cstringArray
|
||||
Tcl_ClientData* = pointer
|
||||
Tcl_FreeProc* = proc (theBlock: pointer){.cdecl.}
|
||||
PTcl_Interp* = ptr Tcl_Interp
|
||||
Tcl_Interp*{.final.} = object #* Event Definitions *
|
||||
result*: cstring #* Do not access this directly. Use
|
||||
Tcl_Interp*{.final.} = object # Event Definitions *
|
||||
result*: cstring # Do not access this directly. Use
|
||||
# * Tcl_GetStringResult since result
|
||||
# * may be pointing to an object
|
||||
# *
|
||||
@@ -385,12 +385,12 @@ type
|
||||
Tcl_Event*{.final.} = object
|
||||
prc*: TTcl_EventProc
|
||||
nextPtr*: PTcl_Event
|
||||
ClientData*: TObject #* ClientData is just pointer.*
|
||||
ClientData*: TObject # ClientData is just pointer.*
|
||||
|
||||
PTcl_Time* = ptr Tcl_Time
|
||||
Tcl_Time*{.final.} = object
|
||||
sec*: int32 # * Seconds. *
|
||||
usec*: int32 # * Microseconds. *
|
||||
sec*: int32 # Seconds. *
|
||||
usec*: int32 # Microseconds. *
|
||||
|
||||
Tcl_TimerToken* = pointer
|
||||
PInteger* = ptr int
|
||||
@@ -749,7 +749,7 @@ proc Tcl_PushCallFrame*(interp: pTcl_Interp, callFramePtr: var Tcl_CallFrame,
|
||||
proc Tcl_PopCallFrame*(interp: pTcl_Interp){.cdecl, dynlib: dllName, importc.}
|
||||
proc Tcl_VarEval*(interp: pTcl_Interp): int{.cdecl, varargs,
|
||||
dynlib: dllName, importc.}
|
||||
#* For TkConsole.c *
|
||||
# For TkConsole.c *
|
||||
proc Tcl_RecordAndEval*(interp: pTcl_Interp, cmd: cstring, flags: int): int{.
|
||||
cdecl, dynlib: dllName, importc.}
|
||||
proc Tcl_GlobalEval*(interp: pTcl_Interp, command: cstring): int{.cdecl,
|
||||
|
||||
1418
llvm/llvm.h
Executable file
1418
llvm/llvm.h
Executable file
File diff suppressed because it is too large
Load Diff
1452
llvm/llvm.nim
Normal file
1452
llvm/llvm.nim
Normal file
File diff suppressed because it is too large
Load Diff
1034
llvm/llvm.pas
Executable file
1034
llvm/llvm.pas
Executable file
File diff suppressed because it is too large
Load Diff
1569
llvm/llvm_orig.nim
Normal file
1569
llvm/llvm_orig.nim
Normal file
File diff suppressed because it is too large
Load Diff
@@ -17,5 +17,5 @@ priority).
|
||||
See the file ``install.txt`` for installation instructions. See the file
|
||||
``doc/intern.txt`` for the internal documentation for developers.
|
||||
|
||||
Copyright (c) 2004-2009 Andreas Rumpf.
|
||||
Copyright (c) 2004-2010 Andreas Rumpf.
|
||||
All rights reserved.
|
||||
|
||||
17
rod/ast.nim
17
rod/ast.nim
@@ -855,6 +855,17 @@ proc sonsLen(n: PNode): int =
|
||||
if isNil(n.sons): result = 0
|
||||
else: result = len(n.sons)
|
||||
|
||||
proc len*(n: PNode): int {.inline.} =
|
||||
if isNil(n.sons): result = 0
|
||||
else: result = len(n.sons)
|
||||
|
||||
proc add*(father, son: PNode) =
|
||||
if isNil(father.sons): father.sons = @[]
|
||||
add(father.sons, son)
|
||||
|
||||
proc `[]`*(n: PNode, i: int): PNode {.inline.} =
|
||||
result = n.sons[i]
|
||||
|
||||
proc newSons(father: PNode, length: int) =
|
||||
if isNil(father.sons): father.sons = @[]
|
||||
setlen(father.sons, len(father.sons) + length)
|
||||
@@ -985,8 +996,7 @@ proc IntSetInit(s: var TIntSet) =
|
||||
s.head = nil
|
||||
|
||||
proc IntSetGet(t: TIntSet, key: int): PTrunk =
|
||||
var h: int
|
||||
h = key and t.max
|
||||
var h = key and t.max
|
||||
while t.data[h] != nil:
|
||||
if t.data[h].key == key:
|
||||
return t.data[h]
|
||||
@@ -994,8 +1004,7 @@ proc IntSetGet(t: TIntSet, key: int): PTrunk =
|
||||
result = nil
|
||||
|
||||
proc IntSetRawInsert(t: TIntSet, data: var TTrunkSeq, desc: PTrunk) =
|
||||
var h: int
|
||||
h = desc.key and t.max
|
||||
var h = desc.key and t.max
|
||||
while data[h] != nil:
|
||||
assert(data[h] != desc)
|
||||
h = nextTry(h, t.max)
|
||||
|
||||
@@ -39,9 +39,6 @@ proc getStrLit(m: BModule, s: string): PRope =
|
||||
[result, makeCString(s), ToRope(len(s))])
|
||||
|
||||
proc genLiteral(p: BProc, v: PNode, ty: PType): PRope =
|
||||
var
|
||||
f: biggestFloat
|
||||
id: int
|
||||
if ty == nil: internalError(v.info, "genLiteral: ty is nil")
|
||||
case v.kind
|
||||
of nkCharLit..nkInt64Lit:
|
||||
@@ -69,7 +66,7 @@ proc genLiteral(p: BProc, v: PNode, ty: PType): PRope =
|
||||
result = toRope("0")
|
||||
of nkStrLit..nkTripleStrLit:
|
||||
if skipTypes(ty, abstractVarRange).kind == tyString:
|
||||
id = NodeTableTestOrSet(p.module.dataCache, v, gid)
|
||||
var id = NodeTableTestOrSet(p.module.dataCache, v, gid)
|
||||
if id == gid:
|
||||
# string literal not found in the cache:
|
||||
useMagic(p.module, "NimStringDesc")
|
||||
@@ -79,7 +76,7 @@ proc genLiteral(p: BProc, v: PNode, ty: PType): PRope =
|
||||
else:
|
||||
result = makeCString(v.strVal)
|
||||
of nkFloatLit..nkFloat64Lit:
|
||||
f = v.floatVal
|
||||
var f = v.floatVal
|
||||
if f != f:
|
||||
result = toRope("NAN")
|
||||
elif f == 0.0:
|
||||
|
||||
@@ -344,8 +344,7 @@ proc getRecordDesc(m: BModule, typ: PType, name: PRope,
|
||||
if typ.kind == tyObject:
|
||||
useMagic(m, "TNimType")
|
||||
if typ.sons[0] == nil:
|
||||
if (typ.sym != nil) and (sfPure in typ.sym.flags) or
|
||||
(tfFinal in typ.flags):
|
||||
if typ.sym != nil and sfPure in typ.sym.flags or tfFinal in typ.flags:
|
||||
result = ropef("struct $1 {$n", [name])
|
||||
else:
|
||||
result = ropef("struct $1 {$nTNimType* m_type;$n", [name])
|
||||
|
||||
@@ -520,7 +520,7 @@ proc genProcAux(m: BModule, prc: PSym) =
|
||||
[toRope(prc.loc.a)])
|
||||
app(generatedProc, returnStmt)
|
||||
app(generatedProc, '}' & tnl)
|
||||
app(m.s[cfsProcs], generatedProc) #if prc.kind = skMethod then addMethodToCompile(gNimDat, prc);
|
||||
app(m.s[cfsProcs], generatedProc)
|
||||
|
||||
proc genProcPrototype(m: BModule, sym: PSym) =
|
||||
useHeader(m, sym)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
@@ -27,7 +27,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdlinePass, info: TLineInfo)
|
||||
|
||||
const
|
||||
HelpMessage = "Nimrod Compiler Version $1 (" & compileDate & ") [$2: $3]" &
|
||||
"\n" & "Copyright (c) 2004-2009 by Andreas Rumpf" & "\n"
|
||||
"\n" & "Copyright (c) 2004-2010 by Andreas Rumpf" & "\n"
|
||||
|
||||
const
|
||||
Usage = """
|
||||
|
||||
@@ -15,30 +15,30 @@ import
|
||||
|
||||
proc modifyPragmas(n: PNode, name: string) =
|
||||
if n == nil: return
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
var it = n.sons[i]
|
||||
for i in 0..len(n)-1:
|
||||
var it = n[i]
|
||||
if it.kind == nkIdent and whichKeyword(it.ident) == wImportc:
|
||||
var x = newNode(nkExprColonExpr)
|
||||
addSon(x, it)
|
||||
addSon(x, newStrNode(nkStrLit, name))
|
||||
add(x, it)
|
||||
add(x, newStrNode(nkStrLit, name))
|
||||
n.sons[i] = x
|
||||
|
||||
proc getName(n: PNode): string =
|
||||
case n.kind
|
||||
of nkPostfix: result = getName(n.sons[1])
|
||||
of nkPragmaExpr: result = getName(n.sons[0])
|
||||
of nkPostfix: result = getName(n[1])
|
||||
of nkPragmaExpr: result = getName(n[0])
|
||||
of nkSym: result = n.sym.name.s
|
||||
of nkIdent: result = n.ident.s
|
||||
of nkAccQuoted: result = getName(n.sons[0])
|
||||
of nkAccQuoted: result = getName(n[0])
|
||||
else: internalError(n.info, "getName()")
|
||||
|
||||
proc processRoutine(n: PNode) =
|
||||
var name = getName(n.sons[namePos])
|
||||
modifyPragmas(n.sons[pragmasPos], name)
|
||||
var name = getName(n[namePos])
|
||||
modifyPragmas(n[pragmasPos], name)
|
||||
|
||||
proc processIdent(ident, prefix: string, n: PNode): string =
|
||||
var pattern = sequence(capture(?(termIgnoreCase"T" / termIgnoreCase"P")),
|
||||
termIgnoreCase(prefix), capture(*any))
|
||||
termIgnoreCase(prefix), ?term('_'), capture(*any()))
|
||||
if ident =~ pattern:
|
||||
result = matches[0] & matches[1]
|
||||
else:
|
||||
@@ -49,27 +49,25 @@ proc processTree(n: PNode, prefix: string) =
|
||||
case n.kind
|
||||
of nkEmpty..pred(nkIdent), succ(nkIdent)..nkNilLit: nil
|
||||
of nkIdent:
|
||||
if prefix.len > 0:
|
||||
n.ident = getIdent(processIdent(n.ident.s, prefix, n))
|
||||
if prefix.len > 0: n.ident = getIdent(processIdent(n.ident.s, prefix, n))
|
||||
of nkProcDef, nkConverterDef:
|
||||
processRoutine(n)
|
||||
for i in 0..sonsLen(n)-1: processTree(n.sons[i], prefix)
|
||||
for i in 0..sonsLen(n)-1: processTree(n[i], prefix)
|
||||
else:
|
||||
for i in 0..sonsLen(n)-1: processTree(n.sons[i], prefix)
|
||||
for i in 0..sonsLen(n)-1: processTree(n[i], prefix)
|
||||
|
||||
proc main(infile, outfile, prefix: string) =
|
||||
proc main*(infile, outfile, prefix: string) =
|
||||
var module = ParseFile(infile)
|
||||
processTree(module, prefix)
|
||||
renderModule(module, outfile)
|
||||
|
||||
if paramcount() >= 1:
|
||||
var infile = addFileExt(paramStr(1), "nim")
|
||||
var outfile = changeFileExt(infile, "new.nim")
|
||||
if paramCount() >= 2:
|
||||
outfile = addFileExt(paramStr(2), "new.nim")
|
||||
var prefix = ""
|
||||
if paramCount() >= 3:
|
||||
prefix = paramStr(3)
|
||||
main(infile, outfile, prefix)
|
||||
else:
|
||||
echo "usage: expand_importc filename[.nim] outfilename[.nim] [prefix]"
|
||||
when isMainModule:
|
||||
if paramcount() >= 1:
|
||||
var infile = addFileExt(paramStr(1), "nim")
|
||||
var outfile = changeFileExt(infile, "new.nim")
|
||||
if paramCount() >= 2:
|
||||
outfile = addFileExt(paramStr(2), "new.nim")
|
||||
var prefix = if paramCount() >= 3: paramStr(3) else: ""
|
||||
main(infile, outfile, prefix)
|
||||
else:
|
||||
echo "usage: expand_importc filename[.nim] outfilename[.nim] [prefix]"
|
||||
|
||||
103
rod/llvmdata.nim
103
rod/llvmdata.nim
@@ -1,103 +0,0 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# this module implements data structures for emitting LLVM.
|
||||
|
||||
import
|
||||
ast, astalgo, idents, lists, passes
|
||||
|
||||
type
|
||||
VTypeKind* = enum
|
||||
VoidTyID, #/< 0: type with no size
|
||||
FloatTyID, #/< 1: 32 bit floating point type
|
||||
DoubleTyID, #/< 2: 64 bit floating point type
|
||||
X86_FP80TyID, #/< 3: 80 bit floating point type (X87)
|
||||
FP128TyID, #/< 4: 128 bit floating point type (112-bit mantissa)
|
||||
PPC_FP128TyID, #/< 5: 128 bit floating point type (two 64-bits)
|
||||
LabelTyID, #/< 6: Labels
|
||||
MetadataTyID, #/< 7: Metadata
|
||||
# Derived types... see DerivedTypes.h file...
|
||||
# Make sure FirstDerivedTyID stays up to date!!!
|
||||
IntegerTyID, #/< 8: Arbitrary bit width integers
|
||||
FunctionTyID, #/< 9: Functions
|
||||
StructTyID, #/< 10: Structures
|
||||
ArrayTyID, #/< 11: Arrays
|
||||
PointerTyID, #/< 12: Pointers
|
||||
OpaqueTyID, #/< 13: Opaque: type with unknown structure
|
||||
VectorTyID #/< 14: SIMD 'packed' format, or other vector type
|
||||
VType* = ref VTypeDesc
|
||||
VTypeSeq* = seq[VType]
|
||||
VTypeDesc* = object of TIdObj
|
||||
k*: VTypeKind
|
||||
s*: VTypeSeq
|
||||
arrayLen*: int
|
||||
name*: string
|
||||
|
||||
VInstrKind* = enum
|
||||
iNone, iAdd, iSub, iMul, iDiv, iMod
|
||||
VLocalVar*{.final.} = object
|
||||
VInstr*{.final.} = object #/ This represents a single basic block in LLVM. A basic block is simply a
|
||||
#/ container of instructions that execute sequentially. Basic blocks are Values
|
||||
#/ because they are referenced by instructions such as branches and switch
|
||||
#/ tables. The type of a BasicBlock is "Type::LabelTy" because the basic block
|
||||
#/ represents a label to which a branch can jump.
|
||||
#/
|
||||
k*: VInstrKind
|
||||
|
||||
VBlock* = ref VBlockDesc
|
||||
VBlockDesc*{.final.} = object # LLVM basic block
|
||||
# list of instructions
|
||||
VLinkage* = enum
|
||||
ExternalLinkage, # Externally visible function
|
||||
LinkOnceLinkage, # Keep one copy of function when linking (inline)
|
||||
WeakLinkage, # Keep one copy of function when linking (weak)
|
||||
AppendingLinkage, # Special purpose, only applies to global arrays
|
||||
InternalLinkage, # Rename collisions when linking (static functions)
|
||||
DLLImportLinkage, # Function to be imported from DLL
|
||||
DLLExportLinkage, # Function to be accessible from DLL
|
||||
ExternalWeakLinkage, # ExternalWeak linkage description
|
||||
GhostLinkage # Stand-in functions for streaming fns from bitcode
|
||||
VVisibility* = enum
|
||||
DefaultVisibility, # The GV is visible
|
||||
HiddenVisibility, # The GV is hidden
|
||||
ProtectedVisibility # The GV is protected
|
||||
TLLVMCallConv* = enum
|
||||
CCallConv = 0, FastCallConv = 8, ColdCallConv = 9, X86StdcallCallConv = 64,
|
||||
X86FastcallCallConv = 65
|
||||
VProc* = ref VProcDesc
|
||||
VProcDesc*{.final.} = object
|
||||
b*: VBlock
|
||||
name*: string
|
||||
sym*: PSym # proc that is generated
|
||||
linkage*: VLinkage
|
||||
vis*: VVisibility
|
||||
callConv*: VCallConv
|
||||
next*: VProc
|
||||
|
||||
VModule* = ref VModuleDesc
|
||||
VModuleDesc* = object of TPassContext # represents a C source file
|
||||
sym*: PSym
|
||||
filename*: string
|
||||
typeCache*: TIdTable # cache the generated types
|
||||
forwTypeCache*: TIdTable # cache for forward declarations of types
|
||||
declaredThings*: TIntSet # things we have declared in this file
|
||||
declaredProtos*: TIntSet # prototypes we have declared in this file
|
||||
headerFiles*: TLinkedList # needed headers to include
|
||||
typeInfoMarker*: TIntSet # needed for generating type information
|
||||
initProc*: VProc # code for init procedure
|
||||
typeStack*: TTypeSeq # used for type generation
|
||||
dataCache*: TNodeTable
|
||||
forwardedProcs*: TSymSeq # keep forwarded procs here
|
||||
typeNodes*, nimTypes*: int # used for type info generation
|
||||
typeNodesName*, nimTypesName*: PRope # used for type info generation
|
||||
labels*: natural # for generating unique module-scope names
|
||||
next*: VModule # to stack modules
|
||||
|
||||
|
||||
# implementation
|
||||
658
rod/llvmdyn.nim
658
rod/llvmdyn.nim
@@ -1,658 +0,0 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# this module implements the interface to LLVM.
|
||||
|
||||
const
|
||||
llvmdll* = "llvm.dll" # Opaque types.
|
||||
#
|
||||
# The top-level container for all other LLVM Intermediate Representation (IR)
|
||||
# objects. See the llvm::Module class.
|
||||
#
|
||||
|
||||
type
|
||||
cuint* = int32
|
||||
PLLVMBasicBlockRef* = ref TLLVMBasicBlockRef
|
||||
PLLVMMemoryBufferRef* = ref TLLVMMemoryBufferRef
|
||||
PLLVMTypeRef* = ref TLLVMTypeRef
|
||||
PLLVMValueRef* = ref TLLVMValueRef
|
||||
TLLVMOpaqueModule*{.final.} = object
|
||||
TLLVMModuleRef* = ref TLLVMOpaqueModule #
|
||||
# Each value in the LLVM IR has a type, an instance of [lltype]. See the
|
||||
# llvm: : Type class.
|
||||
#
|
||||
TLLVMOpaqueType*{.final.} = object
|
||||
TLLVMTypeRef* = ref TLLVMOpaqueType #
|
||||
# When building recursive types using [refine_type], [lltype] values may become
|
||||
# invalid; use [lltypehandle] to resolve this problem. See the
|
||||
# llvm: : AbstractTypeHolder] class.
|
||||
#
|
||||
TLLVMOpaqueTypeHandle*{.final.} = object
|
||||
TLLVMTypeHandleRef* = ref TLLVMOpaqueTypeHandle
|
||||
TLLVMOpaqueValue*{.final.} = object
|
||||
TLLVMValueRef* = ref TLLVMOpaqueValue
|
||||
TLLVMOpaqueBasicBlock*{.final.} = object
|
||||
TLLVMBasicBlockRef* = ref TLLVMOpaqueBasicBlock
|
||||
TLLVMOpaqueBuilder*{.final.} = object
|
||||
TLLVMBuilderRef* = ref TLLVMOpaqueBuilder # Used to provide a module to JIT or interpreter.
|
||||
# See the llvm: : ModuleProvider class.
|
||||
#
|
||||
TLLVMOpaqueModuleProvider*{.final.} = object
|
||||
TLLVMModuleProviderRef* = ref TLLVMOpaqueModuleProvider # Used to provide a module to JIT or interpreter.
|
||||
# See the llvm: : MemoryBuffer class.
|
||||
#
|
||||
TLLVMOpaqueMemoryBuffer*{.final.} = object
|
||||
TLLVMMemoryBufferRef* = ref TLLVMOpaqueMemoryBuffer
|
||||
TLLVMTypeKind* = enum
|
||||
LLVMVoidTypeKind, # type with no size
|
||||
LLVMFloatTypeKind, # 32 bit floating point type
|
||||
LLVMDoubleTypeKind, # 64 bit floating point type
|
||||
LLVMX86_FP80TypeKind, # 80 bit floating point type (X87)
|
||||
LLVMFP128TypeKind, # 128 bit floating point type (112-bit mantissa)
|
||||
LLVMPPC_FP128TypeKind, # 128 bit floating point type (two 64-bits)
|
||||
LLVMLabelTypeKind, # Labels
|
||||
LLVMIntegerTypeKind, # Arbitrary bit width integers
|
||||
LLVMFunctionTypeKind, # Functions
|
||||
LLVMStructTypeKind, # Structures
|
||||
LLVMArrayTypeKind, # Arrays
|
||||
LLVMPointerTypeKind, # Pointers
|
||||
LLVMOpaqueTypeKind, # Opaque: type with unknown structure
|
||||
LLVMVectorTypeKind # SIMD 'packed' format, or other vector type
|
||||
TLLVMLinkage* = enum
|
||||
LLVMExternalLinkage, # Externally visible function
|
||||
LLVMLinkOnceLinkage, # Keep one copy of function when linking (inline)
|
||||
LLVMWeakLinkage, # Keep one copy of function when linking (weak)
|
||||
LLVMAppendingLinkage, # Special purpose, only applies to global arrays
|
||||
LLVMInternalLinkage, # Rename collisions when linking (static functions)
|
||||
LLVMDLLImportLinkage, # Function to be imported from DLL
|
||||
LLVMDLLExportLinkage, # Function to be accessible from DLL
|
||||
LLVMExternalWeakLinkage, # ExternalWeak linkage description
|
||||
LLVMGhostLinkage # Stand-in functions for streaming fns from bitcode
|
||||
TLLVMVisibility* = enum
|
||||
LLVMDefaultVisibility, # The GV is visible
|
||||
LLVMHiddenVisibility, # The GV is hidden
|
||||
LLVMProtectedVisibility # The GV is protected
|
||||
TLLVMCallConv* = enum
|
||||
LLVMCCallConv = 0, LLVMFastCallConv = 8, LLVMColdCallConv = 9,
|
||||
LLVMX86StdcallCallConv = 64, LLVMX86FastcallCallConv = 65
|
||||
TLLVMIntPredicate* = enum
|
||||
LLVMIntEQ = 32, # equal
|
||||
LLVMIntNE, # not equal
|
||||
LLVMIntUGT, # unsigned greater than
|
||||
LLVMIntUGE, # unsigned greater or equal
|
||||
LLVMIntULT, # unsigned less than
|
||||
LLVMIntULE, # unsigned less or equal
|
||||
LLVMIntSGT, # signed greater than
|
||||
LLVMIntSGE, # signed greater or equal
|
||||
LLVMIntSLT, # signed less than
|
||||
LLVMIntSLE # signed less or equal
|
||||
TLLVMRealPredicate* = enum #===-- Error handling ----------------------------------------------------===
|
||||
LLVMRealPredicateFalse, # Always false (always folded)
|
||||
LLVMRealOEQ, # True if ordered and equal
|
||||
LLVMRealOGT, # True if ordered and greater than
|
||||
LLVMRealOGE, # True if ordered and greater than or equal
|
||||
LLVMRealOLT, # True if ordered and less than
|
||||
LLVMRealOLE, # True if ordered and less than or equal
|
||||
LLVMRealONE, # True if ordered and operands are unequal
|
||||
LLVMRealORD, # True if ordered (no nans)
|
||||
LLVMRealUNO, # True if unordered: isnan(X) | isnan(Y)
|
||||
LLVMRealUEQ, # True if unordered or equal
|
||||
LLVMRealUGT, # True if unordered or greater than
|
||||
LLVMRealUGE, # True if unordered, greater than, or equal
|
||||
LLVMRealULT, # True if unordered or less than
|
||||
LLVMRealULE, # True if unordered, less than, or equal
|
||||
LLVMRealUNE, # True if unordered or not equal
|
||||
LLVMRealPredicateTrue # Always true (always folded)
|
||||
|
||||
proc LLVMDisposeMessage*(msg: cstring){.cdecl, dynlib: llvmdll, importc.}
|
||||
#===-- Modules -----------------------------------------------------------===
|
||||
# Create and destroy modules.
|
||||
proc LLVMModuleCreateWithName*(ModuleID: cstring): TLLVMModuleRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMDisposeModule*(M: TLLVMModuleRef){.cdecl, dynlib: llvmdll, importc.}
|
||||
# Data layout
|
||||
proc LLVMGetDataLayout*(M: TLLVMModuleRef): cstring{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMSetDataLayout*(M: TLLVMModuleRef, Triple: cstring){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Target triple
|
||||
proc LLVMGetTarget*(M: TLLVMModuleRef): cstring{.cdecl, dynlib: llvmdll, importc.}
|
||||
# Const before type ignored
|
||||
proc LLVMSetTarget*(M: TLLVMModuleRef, Triple: cstring){.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
# Same as Module: : addTypeName.
|
||||
proc LLVMAddTypeName*(M: TLLVMModuleRef, Name: cstring, Ty: TLLVMTypeRef): int32{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMDeleteTypeName*(M: TLLVMModuleRef, Name: cstring){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
#===-- Types -------------------------------------------------------------===
|
||||
# LLVM types conform to the following hierarchy:
|
||||
# *
|
||||
# * types:
|
||||
# * integer type
|
||||
# * real type
|
||||
# * function type
|
||||
# * sequence types:
|
||||
# * array type
|
||||
# * pointer type
|
||||
# * vector type
|
||||
# * void type
|
||||
# * label type
|
||||
# * opaque type
|
||||
#
|
||||
proc LLVMGetTypeKind*(Ty: TLLVMTypeRef): TLLVMTypeKind{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMRefineAbstractType*(AbstractType: TLLVMTypeRef,
|
||||
ConcreteType: TLLVMTypeRef){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on integer types
|
||||
proc LLVMInt1Type*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMInt8Type*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMInt16Type*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMInt32Type*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMInt64Type*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMIntType*(NumBits: cuint): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMGetIntTypeWidth*(IntegerTy: TLLVMTypeRef): cuint{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on real types
|
||||
proc LLVMFloatType*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMDoubleType*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMX86FP80Type*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMFP128Type*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMPPCFP128Type*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
# Operations on function types
|
||||
proc LLVMFunctionType*(ReturnType: TLLVMTypeRef, ParamTypes: PLLVMTypeRef,
|
||||
ParamCount: cuint, IsVarArg: int32): TLLVMTypeRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMIsFunctionVarArg*(FunctionTy: TLLVMTypeRef): int32{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetReturnType*(FunctionTy: TLLVMTypeRef): TLLVMTypeRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMCountParamTypes*(FunctionTy: TLLVMTypeRef): cuint{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetParamTypes*(FunctionTy: TLLVMTypeRef, Dest: PLLVMTypeRef){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on struct types
|
||||
proc LLVMStructType*(ElementTypes: PLLVMTypeRef, ElementCount: cuint,
|
||||
isPacked: int32): TLLVMTypeRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMCountStructElementTypes*(StructTy: TLLVMTypeRef): cuint{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetStructElementTypes*(StructTy: TLLVMTypeRef, Dest: pLLVMTypeRef){.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMIsPackedStruct*(StructTy: TLLVMTypeRef): int32{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
# Operations on array, pointer, and vector types (sequence types)
|
||||
proc LLVMArrayType*(ElementType: TLLVMTypeRef, ElementCount: cuint): TLLVMTypeRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMPointerType*(ElementType: TLLVMTypeRef, AddressSpace: cuint): TLLVMTypeRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMVectorType*(ElementType: TLLVMTypeRef, ElementCount: cuint): TLLVMTypeRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMGetElementType*(Ty: TLLVMTypeRef): TLLVMTypeRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetArrayLength*(ArrayTy: TLLVMTypeRef): cuint{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMGetPointerAddressSpace*(PointerTy: TLLVMTypeRef): cuint{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetVectorSize*(VectorTy: TLLVMTypeRef): cuint{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
# Operations on other types
|
||||
proc LLVMVoidType*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMLabelType*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMOpaqueType*(): TLLVMTypeRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
# Operations on type handles
|
||||
proc LLVMCreateTypeHandle*(PotentiallyAbstractTy: TLLVMTypeRef): TLLVMTypeHandleRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMRefineType*(AbstractTy: TLLVMTypeRef, ConcreteTy: TLLVMTypeRef){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMResolveTypeHandle*(TypeHandle: TLLVMTypeHandleRef): TLLVMTypeRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMDisposeTypeHandle*(TypeHandle: TLLVMTypeHandleRef){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
#===-- Values ------------------------------------------------------------===
|
||||
# The bulk of LLVM's object model consists of values, which comprise a very
|
||||
# * rich type hierarchy.
|
||||
# *
|
||||
# * values:
|
||||
# * constants:
|
||||
# * scalar constants
|
||||
# * composite contants
|
||||
# * globals:
|
||||
# * global variable
|
||||
# * function
|
||||
# * alias
|
||||
# * basic blocks
|
||||
#
|
||||
# Operations on all values
|
||||
proc LLVMTypeOf*(Val: TLLVMValueRef): TLLVMTypeRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMGetValueName*(Val: TLLVMValueRef): cstring{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMSetValueName*(Val: TLLVMValueRef, Name: cstring){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMDumpValue*(Val: TLLVMValueRef){.cdecl, dynlib: llvmdll, importc.}
|
||||
# Operations on constants of any type
|
||||
proc LLVMConstNull*(Ty: TLLVMTypeRef): TLLVMValueRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
# all zeroes
|
||||
proc LLVMConstAllOnes*(Ty: TLLVMTypeRef): TLLVMValueRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
# only for int/vector
|
||||
proc LLVMGetUndef*(Ty: TLLVMTypeRef): TLLVMValueRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMIsConstant*(Val: TLLVMValueRef): int32{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMIsNull*(Val: TLLVMValueRef): int32{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMIsUndef*(Val: TLLVMValueRef): int32{.cdecl, dynlib: llvmdll, importc.}
|
||||
# Operations on scalar constants
|
||||
proc LLVMConstInt*(IntTy: TLLVMTypeRef, N: qword, SignExtend: int32): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstReal*(RealTy: TLLVMTypeRef, N: float64): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on composite constants
|
||||
proc LLVMConstString*(Str: cstring, len: cuint, DontNullTerminate: int32): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstArray*(ArrayTy: TLLVMTypeRef, ConstantVals: pLLVMValueRef,
|
||||
len: cuint): TLLVMValueRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstStruct*(ConstantVals: pLLVMValueRef, Count: cuint, ispacked: int32): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstVector*(ScalarConstantVals: pLLVMValueRef, Size: cuint): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Constant expressions
|
||||
proc LLVMSizeOf*(Ty: TLLVMTypeRef): TLLVMValueRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMConstNeg*(ConstantVal: TLLVMValueRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMConstNot*(ConstantVal: TLLVMValueRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMConstAdd*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstSub*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstMul*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstUDiv*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstSDiv*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstFDiv*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstURem*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstSRem*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstFRem*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstAnd*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstOr*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstXor*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstICmp*(Predicate: TLLVMIntPredicate, LHSConstant: TLLVMValueRef,
|
||||
RHSConstant: TLLVMValueRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMConstFCmp*(Predicate: TLLVMRealPredicate, LHSConstant: TLLVMValueRef,
|
||||
RHSConstant: TLLVMValueRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMConstShl*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstLShr*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstAShr*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstGEP*(ConstantVal: TLLVMValueRef, ConstantIndices: PLLVMValueRef,
|
||||
NumIndices: cuint): TLLVMValueRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMConstTrunc*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstSExt*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstZExt*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstFPTrunc*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstFPExt*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstUIToFP*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstSIToFP*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstFPToUI*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstFPToSI*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstPtrToInt*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstIntToPtr*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstBitCast*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstSelect*(ConstantCondition: TLLVMValueRef,
|
||||
ConstantIfTrue: TLLVMValueRef,
|
||||
ConstantIfFalse: TLLVMValueRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMConstExtractElement*(VectorConstant: TLLVMValueRef,
|
||||
IndexConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstInsertElement*(VectorConstant: TLLVMValueRef,
|
||||
ElementValueConstant: TLLVMValueRef,
|
||||
IndexConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMConstShuffleVector*(VectorAConstant: TLLVMValueRef,
|
||||
VectorBConstant: TLLVMValueRef,
|
||||
MaskConstant: TLLVMValueRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on global variables, functions, and aliases (globals)
|
||||
proc LLVMIsDeclaration*(Global: TLLVMValueRef): int32{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMGetLinkage*(Global: TLLVMValueRef): TLLVMLinkage{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMSetLinkage*(Global: TLLVMValueRef, Linkage: TLLVMLinkage){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetSection*(Global: TLLVMValueRef): cstring{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMSetSection*(Global: TLLVMValueRef, Section: cstring){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetVisibility*(Global: TLLVMValueRef): TLLVMVisibility{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMSetVisibility*(Global: TLLVMValueRef, Viz: TLLVMVisibility){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetAlignment*(Global: TLLVMValueRef): cuint{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMSetAlignment*(Global: TLLVMValueRef, Bytes: cuint){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on global variables
|
||||
# Const before type ignored
|
||||
proc LLVMAddGlobal*(M: TLLVMModuleRef, Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Const before type ignored
|
||||
proc LLVMGetNamedGlobal*(M: TLLVMModuleRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMDeleteGlobal*(GlobalVar: TLLVMValueRef){.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMHasInitializer*(GlobalVar: TLLVMValueRef): int32{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetInitializer*(GlobalVar: TLLVMValueRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMSetInitializer*(GlobalVar: TLLVMValueRef, ConstantVal: TLLVMValueRef){.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMIsThreadLocal*(GlobalVar: TLLVMValueRef): int32{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMSetThreadLocal*(GlobalVar: TLLVMValueRef, IsThreadLocal: int32){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMIsGlobalConstant*(GlobalVar: TLLVMValueRef): int32{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMSetGlobalConstant*(GlobalVar: TLLVMValueRef, IsConstant: int32){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on functions
|
||||
# Const before type ignored
|
||||
proc LLVMAddFunction*(M: TLLVMModuleRef, Name: cstring, FunctionTy: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Const before type ignored
|
||||
proc LLVMGetNamedFunction*(M: TLLVMModuleRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMDeleteFunction*(Fn: TLLVMValueRef){.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMCountParams*(Fn: TLLVMValueRef): cuint{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMGetParams*(Fn: TLLVMValueRef, Params: PLLVMValueRef){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetParam*(Fn: TLLVMValueRef, Index: cuint): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetIntrinsicID*(Fn: TLLVMValueRef): cuint{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMGetFunctionCallConv*(Fn: TLLVMValueRef): cuint{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMSetFunctionCallConv*(Fn: TLLVMValueRef, CC: cuint){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Const before type ignored
|
||||
proc LLVMGetCollector*(Fn: TLLVMValueRef): cstring{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
# Const before type ignored
|
||||
proc LLVMSetCollector*(Fn: TLLVMValueRef, Coll: cstring){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on basic blocks
|
||||
proc LLVMBasicBlockAsValue*(Bb: TLLVMBasicBlockRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMValueIsBasicBlock*(Val: TLLVMValueRef): int32{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMValueAsBasicBlock*(Val: TLLVMValueRef): TLLVMBasicBlockRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMCountBasicBlocks*(Fn: TLLVMValueRef): cuint{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMGetBasicBlocks*(Fn: TLLVMValueRef, BasicBlocks: PLLVMBasicBlockRef){.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMGetEntryBasicBlock*(Fn: TLLVMValueRef): TLLVMBasicBlockRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Const before type ignored
|
||||
proc LLVMAppendBasicBlock*(Fn: TLLVMValueRef, Name: cstring): TLLVMBasicBlockRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Const before type ignored
|
||||
proc LLVMInsertBasicBlock*(InsertBeforeBB: TLLVMBasicBlockRef, Name: cstring): TLLVMBasicBlockRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMDeleteBasicBlock*(BB: TLLVMBasicBlockRef){.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
# Operations on call sites
|
||||
proc LLVMSetInstructionCallConv*(Instr: TLLVMValueRef, CC: cuint){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMGetInstructionCallConv*(Instr: TLLVMValueRef): cuint{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Operations on phi nodes
|
||||
proc LLVMAddIncoming*(PhiNode: TLLVMValueRef, IncomingValues: PLLVMValueRef,
|
||||
IncomingBlocks: PLLVMBasicBlockRef, Count: cuint){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMCountIncoming*(PhiNode: TLLVMValueRef): cuint{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMGetIncomingValue*(PhiNode: TLLVMValueRef, Index: cuint): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMGetIncomingBlock*(PhiNode: TLLVMValueRef, Index: cuint): TLLVMBasicBlockRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
#===-- Instruction builders ----------------------------------------------===
|
||||
# An instruction builder represents a point within a basic block, and is the
|
||||
# * exclusive means of building instructions using the C interface.
|
||||
#
|
||||
proc LLVMCreateBuilder*(): TLLVMBuilderRef{.cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMPositionBuilderBefore*(Builder: TLLVMBuilderRef, Instr: TLLVMValueRef){.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMPositionBuilderAtEnd*(Builder: TLLVMBuilderRef,
|
||||
theBlock: TLLVMBasicBlockRef){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMDisposeBuilder*(Builder: TLLVMBuilderRef){.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
# Terminators
|
||||
proc LLVMBuildRetVoid*(para1: TLLVMBuilderRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildRet*(para1: TLLVMBuilderRef, V: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildBr*(para1: TLLVMBuilderRef, Dest: TLLVMBasicBlockRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildCondBr*(para1: TLLVMBuilderRef, IfCond: TLLVMValueRef,
|
||||
ThenBranch: TLLVMBasicBlockRef,
|
||||
ElseBranch: TLLVMBasicBlockRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildSwitch*(para1: TLLVMBuilderRef, V: TLLVMValueRef,
|
||||
ElseBranch: TLLVMBasicBlockRef, NumCases: cuint): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Const before type ignored
|
||||
proc LLVMBuildInvoke*(para1: TLLVMBuilderRef, Fn: TLLVMValueRef,
|
||||
Args: PLLVMValueRef, NumArgs: cuint,
|
||||
ThenBranch: TLLVMBasicBlockRef, Catch: TLLVMBasicBlockRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMBuildUnwind*(para1: TLLVMBuilderRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildUnreachable*(para1: TLLVMBuilderRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Add a case to the switch instruction
|
||||
proc LLVMAddCase*(Switch: TLLVMValueRef, OnVal: TLLVMValueRef,
|
||||
Dest: TLLVMBasicBlockRef){.cdecl, dynlib: llvmdll, importc.}
|
||||
# Arithmetic
|
||||
proc LLVMBuildAdd*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildSub*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildMul*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildUDiv*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildSDiv*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildFDiv*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildURem*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildSRem*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildFRem*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildShl*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildLShr*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildAShr*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildAnd*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildOr*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildXor*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildNeg*(para1: TLLVMBuilderRef, V: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildNot*(para1: TLLVMBuilderRef, V: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Memory
|
||||
proc LLVMBuildMalloc*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildArrayMalloc*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef,
|
||||
Val: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildAlloca*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildArrayAlloca*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef,
|
||||
Val: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildFree*(para1: TLLVMBuilderRef, PointerVal: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildLoad*(para1: TLLVMBuilderRef, PointerVal: TLLVMValueRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMBuildStore*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
thePtr: TLLVMValueRef): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildGEP*(B: TLLVMBuilderRef, Pointer: TLLVMValueRef,
|
||||
Indices: PLLVMValueRef, NumIndices: cuint, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Casts
|
||||
proc LLVMBuildTrunc*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildZExt*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildSExt*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildFPToUI*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildFPToSI*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildUIToFP*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildSIToFP*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildFPTrunc*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildFPExt*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildPtrToInt*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildIntToPtr*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildBitCast*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Comparisons
|
||||
proc LLVMBuildICmp*(para1: TLLVMBuilderRef, Op: TLLVMIntPredicate,
|
||||
LHS: TLLVMValueRef, RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildFCmp*(para1: TLLVMBuilderRef, Op: TLLVMRealPredicate,
|
||||
LHS: TLLVMValueRef, RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Miscellaneous instructions
|
||||
proc LLVMBuildPhi*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildCall*(para1: TLLVMBuilderRef, Fn: TLLVMValueRef,
|
||||
Args: PLLVMValueRef, NumArgs: cuint, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildSelect*(para1: TLLVMBuilderRef, IfCond: TLLVMValueRef,
|
||||
ThenBranch: TLLVMValueRef, ElseBranch: TLLVMValueRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl, dynlib: llvmdll,
|
||||
importc.}
|
||||
proc LLVMBuildVAArg*(para1: TLLVMBuilderRef, List: TLLVMValueRef,
|
||||
Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildExtractElement*(para1: TLLVMBuilderRef, VecVal: TLLVMValueRef,
|
||||
Index: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildInsertElement*(para1: TLLVMBuilderRef, VecVal: TLLVMValueRef,
|
||||
EltVal: TLLVMValueRef, Index: TLLVMValueRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMBuildShuffleVector*(para1: TLLVMBuilderRef, V1: TLLVMValueRef,
|
||||
V2: TLLVMValueRef, Mask: TLLVMValueRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
#===-- Module providers --------------------------------------------------===
|
||||
# Encapsulates the module M in a module provider, taking ownership of the
|
||||
# module.
|
||||
# See the constructor llvm: : ExistingModuleProvider: : ExistingModuleProvider.
|
||||
#
|
||||
proc LLVMCreateModuleProviderForExistingModule*(M: TLLVMModuleRef): TLLVMModuleProviderRef{.
|
||||
cdecl, dynlib: llvmdll, importc.}
|
||||
# Destroys the module provider MP as well as the contained module.
|
||||
# See the destructor llvm: : ModuleProvider: : ~ModuleProvider.
|
||||
#
|
||||
proc LLVMDisposeModuleProvider*(MP: TLLVMModuleProviderRef){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
#===-- Memory buffers ----------------------------------------------------===
|
||||
proc LLVMCreateMemoryBufferWithContentsOfFile*(Path: cstring,
|
||||
OutMemBuf: pLLVMMemoryBufferRef, OutMessage: var cstring): int32{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMCreateMemoryBufferWithSTDIN*(OutMemBuf: pLLVMMemoryBufferRef,
|
||||
OutMessage: var cstring): int32{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMDisposeMemoryBuffer*(MemBuf: TLLVMMemoryBufferRef){.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
proc LLVMWriteBitcodeToFile*(M: TLLVMModuleRef, path: cstring): int{.cdecl,
|
||||
dynlib: llvmdll, importc.}
|
||||
# Writes a module to the specified path. Returns 0 on success.
|
||||
# implementation
|
||||
890
rod/llvmgen.nim
Executable file
890
rod/llvmgen.nim
Executable file
@@ -0,0 +1,890 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## LLVM code generator.
|
||||
|
||||
import
|
||||
ast, astalgo, strutils, nhashes, trees, platform, magicsys, extccomp, options,
|
||||
nversion, nimsets, msgs, crc, bitsets, idents, lists, types, ccgutils, os,
|
||||
times, ropes, math, passes, rodread, wordrecg, rnimsyn, treetab, cgmeth,
|
||||
llvm
|
||||
|
||||
proc llvmGenPass*(): TPass
|
||||
|
||||
|
||||
type
|
||||
TLabel = PRope # for the C generator a label is just a rope
|
||||
TCFileSection = enum # the sections a generated C file consists of
|
||||
cfsHeaders, # section for C include file headers
|
||||
cfsForwardTypes, # section for C forward typedefs
|
||||
cfsTypes, # section for C typedefs
|
||||
cfsSeqTypes, # section for sequence types only
|
||||
# this is needed for strange type generation
|
||||
# reasons
|
||||
cfsFieldInfo, # section for field information
|
||||
cfsTypeInfo, # section for type information
|
||||
cfsProcHeaders, # section for C procs prototypes
|
||||
cfsData, # section for C constant data
|
||||
cfsVars, # section for C variable declarations
|
||||
cfsProcs, # section for C procs that are not inline
|
||||
cfsTypeInit1, # section 1 for declarations of type information
|
||||
cfsTypeInit2, # section 2 for init of type information
|
||||
cfsTypeInit3, # section 3 for init of type information
|
||||
cfsDebugInit, # section for init of debug information
|
||||
cfsDynLibInit, # section for init of dynamic library binding
|
||||
cfsDynLibDeinit # section for deinitialization of dynamic libraries
|
||||
TCTypeKind = enum # describes the type kind of a C type
|
||||
ctVoid, ctChar, ctBool, ctUInt, ctUInt8, ctUInt16, ctUInt32, ctUInt64,
|
||||
ctInt, ctInt8, ctInt16, ctInt32, ctInt64, ctFloat, ctFloat32, ctFloat64,
|
||||
ctFloat128, ctArray, ctStruct, ctPtr, ctNimStr, ctNimSeq, ctProc, ctCString
|
||||
TCFileSections = array[TCFileSection, PRope] # represents a generated C file
|
||||
TCProcSection = enum # the sections a generated C proc consists of
|
||||
cpsLocals, # section of local variables for C proc
|
||||
cpsInit, # section for init of variables for C proc
|
||||
cpsStmts # section of local statements for C proc
|
||||
TCProcSections = array[TCProcSection, PRope] # represents a generated C proc
|
||||
BModule = ref TCGen
|
||||
BProc = ref TCProc
|
||||
TBlock{.final.} = object
|
||||
id*: int # the ID of the label; positive means that it
|
||||
# has been used (i.e. the label should be emitted)
|
||||
nestedTryStmts*: int # how many try statements is it nested into
|
||||
|
||||
TCProc{.final.} = object # represents C proc that is currently generated
|
||||
s*: TCProcSections # the procs sections; short name for readability
|
||||
prc*: PSym # the Nimrod proc that this C proc belongs to
|
||||
BeforeRetNeeded*: bool # true iff 'BeforeRet' label for proc is needed
|
||||
nestedTryStmts*: Natural # in how many nested try statements we are
|
||||
# (the vars must be volatile then)
|
||||
labels*: Natural # for generating unique labels in the C proc
|
||||
blocks*: seq[TBlock] # nested blocks
|
||||
options*: TOptions # options that should be used for code
|
||||
# generation; this is the same as prc.options
|
||||
# unless prc == nil
|
||||
frameLen*: int # current length of frame descriptor
|
||||
sendClosure*: PType # closure record type that we pass
|
||||
receiveClosure*: PType # closure record type that we get
|
||||
module*: BModule # used to prevent excessive parameter passing
|
||||
|
||||
TTypeSeq = seq[PType]
|
||||
TCGen = object of TPassContext # represents a C source file
|
||||
module*: PSym
|
||||
filename*: string
|
||||
s*: TCFileSections # sections of the C file
|
||||
cfilename*: string # filename of the module (including path,
|
||||
# without extension)
|
||||
typeCache*: TIdTable # cache the generated types
|
||||
forwTypeCache*: TIdTable # cache for forward declarations of types
|
||||
declaredThings*: TIntSet # things we have declared in this .c file
|
||||
declaredProtos*: TIntSet # prototypes we have declared in this .c file
|
||||
headerFiles*: TLinkedList # needed headers to include
|
||||
typeInfoMarker*: TIntSet # needed for generating type information
|
||||
initProc*: BProc # code for init procedure
|
||||
typeStack*: TTypeSeq # used for type generation
|
||||
dataCache*: TNodeTable
|
||||
forwardedProcs*: TSymSeq # keep forwarded procs here
|
||||
typeNodes*, nimTypes*: int # used for type info generation
|
||||
typeNodesName*, nimTypesName*: PRope # used for type info generation
|
||||
labels*: natural # for generating unique module-scope names
|
||||
|
||||
|
||||
var
|
||||
mainModProcs, mainModInit: PRope # parts of the main module
|
||||
gMapping: PRope # the generated mapping file (if requested)
|
||||
gProcProfile: Natural # proc profile counter
|
||||
gGeneratedSyms: TIntSet # set of ID's of generated symbols
|
||||
gPendingModules: seq[BModule] = @[] # list of modules that are not
|
||||
# finished with code generation
|
||||
gForwardedProcsCounter: int = 0
|
||||
gNimDat: BModule # generated global data
|
||||
|
||||
proc ropeff(cformat, llvmformat: string, args: openarray[PRope]): PRope =
|
||||
if gCmd == cmdCompileToLLVM: result = ropef(llvmformat, args)
|
||||
else: result = ropef(cformat, args)
|
||||
|
||||
proc appff(dest: var PRope, cformat, llvmformat: string,
|
||||
args: openarray[PRope]) =
|
||||
if gCmd == cmdCompileToLLVM: appf(dest, llvmformat, args)
|
||||
else: appf(dest, cformat, args)
|
||||
|
||||
proc addForwardedProc(m: BModule, prc: PSym) =
|
||||
m.forwardedProcs.add(prc)
|
||||
inc(gForwardedProcsCounter)
|
||||
|
||||
proc addPendingModule(m: BModule) =
|
||||
for i in countup(0, high(gPendingModules)):
|
||||
if gPendingModules[i] == m:
|
||||
InternalError("module already pending: " & m.module.name.s)
|
||||
gPendingModules.add(m)
|
||||
|
||||
proc findPendingModule(m: BModule, s: PSym): BModule =
|
||||
var ms = getModule(s)
|
||||
if ms.id == m.module.id:
|
||||
return m
|
||||
for i in countup(0, high(gPendingModules)):
|
||||
result = gPendingModules[i]
|
||||
if result.module.id == ms.id: return
|
||||
InternalError(s.info, "no pending module found for: " & s.name.s)
|
||||
|
||||
proc initLoc(result: var TLoc, k: TLocKind, typ: PType, s: TStorageLoc) =
|
||||
result.k = k
|
||||
result.s = s
|
||||
result.t = GetUniqueType(typ)
|
||||
result.r = nil
|
||||
result.a = - 1
|
||||
result.flags = {}
|
||||
|
||||
proc fillLoc(a: var TLoc, k: TLocKind, typ: PType, r: PRope, s: TStorageLoc) =
|
||||
# fills the loc if it is not already initialized
|
||||
if a.k == locNone:
|
||||
a.k = k
|
||||
a.t = getUniqueType(typ)
|
||||
a.a = - 1
|
||||
a.s = s
|
||||
if a.r == nil: a.r = r
|
||||
|
||||
proc newProc(prc: PSym, module: BModule): BProc =
|
||||
new(result)
|
||||
result.prc = prc
|
||||
result.module = module
|
||||
if prc != nil: result.options = prc.options
|
||||
else: result.options = gOptions
|
||||
result.blocks = @[]
|
||||
|
||||
proc isSimpleConst(typ: PType): bool =
|
||||
result = not (skipTypes(typ, abstractVar).kind in
|
||||
{tyTuple, tyObject, tyArray, tyArrayConstr, tySet, tySequence})
|
||||
|
||||
proc useHeader(m: BModule, sym: PSym) =
|
||||
if lfHeader in sym.loc.Flags:
|
||||
assert(sym.annex != nil)
|
||||
discard lists.IncludeStr(m.headerFiles, getStr(sym.annex.path))
|
||||
|
||||
proc UseMagic(m: BModule, name: string)
|
||||
|
||||
include "ccgtypes.nim"
|
||||
|
||||
# ------------------------------ Manager of temporaries ------------------
|
||||
|
||||
proc getTemp(p: BProc, t: PType, result: var TLoc) =
|
||||
inc(p.labels)
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
result.r = con("%LOC", toRope(p.labels))
|
||||
else:
|
||||
result.r = con("LOC", toRope(p.labels))
|
||||
appf(p.s[cpsLocals], "$1 $2;$n", [getTypeDesc(p.module, t), result.r])
|
||||
result.k = locTemp
|
||||
result.a = - 1
|
||||
result.t = getUniqueType(t)
|
||||
result.s = OnStack
|
||||
result.flags = {}
|
||||
|
||||
proc cstringLit(p: BProc, r: var PRope, s: string): PRope =
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
inc(p.module.labels)
|
||||
inc(p.labels)
|
||||
result = ropef("%LOC$1", [toRope(p.labels)])
|
||||
appf(p.module.s[cfsData], "@C$1 = private constant [$2 x i8] $3$n",
|
||||
[toRope(p.module.labels), toRope(len(s)), makeLLVMString(s)])
|
||||
appf(r, "$1 = getelementptr [$2 x i8]* @C$3, %NI 0, %NI 0$n",
|
||||
[result, toRope(len(s)), toRope(p.module.labels)])
|
||||
else:
|
||||
result = makeCString(s)
|
||||
|
||||
proc cstringLit(m: BModule, r: var PRope, s: string): PRope =
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
inc(m.labels, 2)
|
||||
result = ropef("%MOC$1", [toRope(m.labels - 1)])
|
||||
appf(m.s[cfsData], "@MOC$1 = private constant [$2 x i8] $3$n",
|
||||
[toRope(m.labels), toRope(len(s)), makeLLVMString(s)])
|
||||
appf(r, "$1 = getelementptr [$2 x i8]* @MOC$3, %NI 0, %NI 0$n",
|
||||
[result, toRope(len(s)), toRope(m.labels)])
|
||||
else:
|
||||
result = makeCString(s)
|
||||
|
||||
proc allocParam(p: BProc, s: PSym) =
|
||||
assert(s.kind == skParam)
|
||||
if not (lfParamCopy in s.loc.flags):
|
||||
inc(p.labels)
|
||||
var tmp = con("%LOC", toRope(p.labels))
|
||||
incl(s.loc.flags, lfParamCopy)
|
||||
incl(s.loc.flags, lfIndirect)
|
||||
appf(p.s[cpsInit], "$1 = alloca $3$n" & "store $3 $2, $3* $1$n",
|
||||
[tmp, s.loc.r, getTypeDesc(p.module, s.loc.t)])
|
||||
s.loc.r = tmp
|
||||
|
||||
proc localDebugInfo(p: BProc, s: PSym) =
|
||||
var name, a: PRope
|
||||
if {optStackTrace, optEndb} * p.options != {optStackTrace, optEndb}: return
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
# "address" is the 0th field
|
||||
# "typ" is the 1rst field
|
||||
# "name" is the 2nd field
|
||||
name = cstringLit(p, p.s[cpsInit], normalize(s.name.s))
|
||||
if (s.kind == skParam) and not ccgIntroducedPtr(s): allocParam(p, s)
|
||||
inc(p.labels, 3)
|
||||
appf(p.s[cpsInit], "%LOC$6 = getelementptr %TF* %F, %NI 0, $1, %NI 0$n" &
|
||||
"%LOC$7 = getelementptr %TF* %F, %NI 0, $1, %NI 1$n" &
|
||||
"%LOC$8 = getelementptr %TF* %F, %NI 0, $1, %NI 2$n" &
|
||||
"store i8* $2, i8** %LOC$6$n" & "store $3* $4, $3** %LOC$7$n" &
|
||||
"store i8* $5, i8** %LOC$8$n", [toRope(p.frameLen), s.loc.r,
|
||||
getTypeDesc(p.module, "TNimType"),
|
||||
genTypeInfo(p.module, s.loc.t), name,
|
||||
toRope(p.labels), toRope(p.labels - 1),
|
||||
toRope(p.labels - 2)])
|
||||
else:
|
||||
a = con("&", s.loc.r)
|
||||
if (s.kind == skParam) and ccgIntroducedPtr(s): a = s.loc.r
|
||||
appf(p.s[cpsInit],
|
||||
"F.s[$1].address = (void*)$3; F.s[$1].typ = $4; F.s[$1].name = $2;$n", [
|
||||
toRope(p.frameLen), makeCString(normalize(s.name.s)), a,
|
||||
genTypeInfo(p.module, s.loc.t)])
|
||||
inc(p.frameLen)
|
||||
|
||||
proc assignLocalVar(p: BProc, s: PSym) =
|
||||
#assert(s.loc.k == locNone) // not yet assigned
|
||||
# this need not be fullfilled for inline procs; they are regenerated
|
||||
# for each module that uses them!
|
||||
if s.loc.k == locNone:
|
||||
fillLoc(s.loc, locLocalVar, s.typ, mangleName(s), OnStack)
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
appf(p.s[cpsLocals], "$1 = alloca $2$n",
|
||||
[s.loc.r, getTypeDesc(p.module, s.loc.t)])
|
||||
incl(s.loc.flags, lfIndirect)
|
||||
else:
|
||||
app(p.s[cpsLocals], getTypeDesc(p.module, s.loc.t))
|
||||
if sfRegister in s.flags: app(p.s[cpsLocals], " register")
|
||||
if (sfVolatile in s.flags) or (p.nestedTryStmts > 0):
|
||||
app(p.s[cpsLocals], " volatile")
|
||||
appf(p.s[cpsLocals], " $1;$n", [s.loc.r])
|
||||
localDebugInfo(p, s)
|
||||
|
||||
proc assignGlobalVar(p: BProc, s: PSym) =
|
||||
if s.loc.k == locNone:
|
||||
fillLoc(s.loc, locGlobalVar, s.typ, mangleName(s), OnHeap)
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
appf(p.module.s[cfsVars], "$1 = linkonce global $2 zeroinitializer$n",
|
||||
[s.loc.r, getTypeDesc(p.module, s.loc.t)])
|
||||
incl(s.loc.flags, lfIndirect)
|
||||
else:
|
||||
useHeader(p.module, s)
|
||||
if lfNoDecl in s.loc.flags: return
|
||||
if sfImportc in s.flags: app(p.module.s[cfsVars], "extern ")
|
||||
app(p.module.s[cfsVars], getTypeDesc(p.module, s.loc.t))
|
||||
if sfRegister in s.flags: app(p.module.s[cfsVars], " register")
|
||||
if sfVolatile in s.flags: app(p.module.s[cfsVars], " volatile")
|
||||
if sfThreadVar in s.flags: app(p.module.s[cfsVars], " NIM_THREADVAR")
|
||||
appf(p.module.s[cfsVars], " $1;$n", [s.loc.r])
|
||||
if {optStackTrace, optEndb} * p.module.module.options ==
|
||||
{optStackTrace, optEndb}:
|
||||
useMagic(p.module, "dbgRegisterGlobal")
|
||||
appff(p.module.s[cfsDebugInit], "dbgRegisterGlobal($1, &$2, $3);$n",
|
||||
"call void @dbgRegisterGlobal(i8* $1, i8* $2, $4* $3)$n", [cstringLit(
|
||||
p, p.module.s[cfsDebugInit], normalize(s.owner.name.s & '.' & s.name.s)),
|
||||
s.loc.r, genTypeInfo(p.module, s.typ), getTypeDesc(p.module, "TNimType")])
|
||||
|
||||
proc iff(cond: bool, the, els: PRope): PRope =
|
||||
if cond: result = the
|
||||
else: result = els
|
||||
|
||||
proc assignParam(p: BProc, s: PSym) =
|
||||
assert(s.loc.r != nil)
|
||||
if (sfAddrTaken in s.flags) and (gCmd == cmdCompileToLLVM): allocParam(p, s)
|
||||
localDebugInfo(p, s)
|
||||
|
||||
proc fillProcLoc(sym: PSym) =
|
||||
if sym.loc.k == locNone:
|
||||
fillLoc(sym.loc, locProc, sym.typ, mangleName(sym), OnStack)
|
||||
|
||||
proc getLabel(p: BProc): TLabel =
|
||||
inc(p.labels)
|
||||
result = con("LA", toRope(p.labels))
|
||||
|
||||
proc fixLabel(p: BProc, labl: TLabel) =
|
||||
appf(p.s[cpsStmts], "$1: ;$n", [labl])
|
||||
|
||||
proc genVarPrototype(m: BModule, sym: PSym)
|
||||
proc genConstPrototype(m: BModule, sym: PSym)
|
||||
proc genProc(m: BModule, prc: PSym)
|
||||
proc genStmts(p: BProc, t: PNode)
|
||||
proc genProcPrototype(m: BModule, sym: PSym)
|
||||
|
||||
include "ccgexprs.nim", "ccgstmts.nim"
|
||||
|
||||
# ----------------------------- dynamic library handling -----------------
|
||||
# We don't finalize dynamic libs as this does the OS for us.
|
||||
|
||||
proc libCandidates(s: string, dest: var TStringSeq) =
|
||||
var le = strutils.find(s, '(')
|
||||
var ri = strutils.find(s, ')', le+1)
|
||||
if le >= 0 and ri > le:
|
||||
var prefix = copy(s, 0, le - 1)
|
||||
var suffix = copy(s, ri + 1)
|
||||
for middle in split(copy(s, le + 1, ri - 1), '|'):
|
||||
libCandidates(prefix & middle & suffix, dest)
|
||||
else:
|
||||
add(dest, s)
|
||||
|
||||
proc loadDynamicLib(m: BModule, lib: PLib) =
|
||||
assert(lib != nil)
|
||||
if not lib.generated:
|
||||
lib.generated = true
|
||||
var tmp = getGlobalTempName()
|
||||
assert(lib.name == nil)
|
||||
lib.name = tmp # BUGFIX: useMagic has awful side-effects
|
||||
appf(m.s[cfsVars], "static void* $1;$n", [tmp])
|
||||
if lib.path.kind in {nkStrLit..nkTripleStrLit}:
|
||||
var s: TStringSeq = @[]
|
||||
libCandidates(lib.path.strVal, s)
|
||||
var loadlib: PRope = nil
|
||||
for i in countup(0, high(s)):
|
||||
inc(m.labels)
|
||||
if i > 0: app(loadlib, "||")
|
||||
appf(loadlib, "($1 = nimLoadLibrary((NimStringDesc*) &$2))$n",
|
||||
[tmp, getStrLit(m, s[i])])
|
||||
appf(m.s[cfsDynLibInit],
|
||||
"if (!($1)) nimLoadLibraryError((NimStringDesc*) &$2);$n",
|
||||
[loadlib, getStrLit(m, lib.path.strVal)])
|
||||
else:
|
||||
var p = newProc(nil, m)
|
||||
var dest: TLoc
|
||||
initLocExpr(p, lib.path, dest)
|
||||
app(m.s[cfsVars], p.s[cpsLocals])
|
||||
app(m.s[cfsDynLibInit], p.s[cpsInit])
|
||||
app(m.s[cfsDynLibInit], p.s[cpsStmts])
|
||||
appf(m.s[cfsDynLibInit],
|
||||
"if (!($1 = nimLoadLibrary($2))) nimLoadLibraryError($2);$n",
|
||||
[tmp, rdLoc(dest)])
|
||||
|
||||
useMagic(m, "nimLoadLibrary")
|
||||
useMagic(m, "nimUnloadLibrary")
|
||||
useMagic(m, "NimStringDesc")
|
||||
useMagic(m, "nimLoadLibraryError")
|
||||
if lib.name == nil: InternalError("loadDynamicLib")
|
||||
|
||||
proc SymInDynamicLib(m: BModule, sym: PSym) =
|
||||
var lib = sym.annex
|
||||
var extname = sym.loc.r
|
||||
loadDynamicLib(m, lib)
|
||||
useMagic(m, "nimGetProcAddr")
|
||||
if gCmd == cmdCompileToLLVM: incl(sym.loc.flags, lfIndirect)
|
||||
var tmp = ropeff("Dl_$1", "@Dl_$1", [toRope(sym.id)])
|
||||
sym.loc.r = tmp # from now on we only need the internal name
|
||||
sym.typ.sym = nil # generate a new name
|
||||
inc(m.labels, 2)
|
||||
appff(m.s[cfsDynLibInit],
|
||||
"$1 = ($2) nimGetProcAddr($3, $4);$n", "%MOC$5 = load i8* $3$n" &
|
||||
"%MOC$6 = call $2 @nimGetProcAddr(i8* %MOC$5, i8* $4)$n" &
|
||||
"store $2 %MOC$6, $2* $1$n", [tmp, getTypeDesc(m, sym.typ),
|
||||
lib.name, cstringLit(m, m.s[cfsDynLibInit], ropeToStr(extname)),
|
||||
toRope(m.labels), toRope(m.labels - 1)])
|
||||
appff(m.s[cfsVars], "$2 $1;$n",
|
||||
"$1 = linkonce global $2 zeroinitializer$n",
|
||||
[sym.loc.r, getTypeDesc(m, sym.loc.t)])
|
||||
|
||||
proc UseMagic(m: BModule, name: string) =
|
||||
var sym = magicsys.getCompilerProc(name)
|
||||
if sym != nil:
|
||||
case sym.kind
|
||||
of skProc, skMethod, skConverter: genProc(m, sym)
|
||||
of skVar: genVarPrototype(m, sym)
|
||||
of skType: discard getTypeDesc(m, sym.typ)
|
||||
else: InternalError("useMagic: " & name)
|
||||
elif not (sfSystemModule in m.module.flags):
|
||||
rawMessage(errSystemNeeds, name) # don't be too picky here
|
||||
|
||||
proc generateHeaders(m: BModule) =
|
||||
app(m.s[cfsHeaders], "#include \"nimbase.h\"" & tnl & tnl)
|
||||
var it = PStrEntry(m.headerFiles.head)
|
||||
while it != nil:
|
||||
if not (it.data[0] in {'\"', '<'}):
|
||||
appf(m.s[cfsHeaders], "#include \"$1\"$n", [toRope(it.data)])
|
||||
else:
|
||||
appf(m.s[cfsHeaders], "#include $1$n", [toRope(it.data)])
|
||||
it = PStrEntry(it.Next)
|
||||
|
||||
proc getFrameDecl(p: BProc) =
|
||||
var slots: PRope
|
||||
if p.frameLen > 0:
|
||||
useMagic(p.module, "TVarSlot")
|
||||
slots = ropeff(" TVarSlot s[$1];$n", ", [$1 x %TVarSlot]",
|
||||
[toRope(p.frameLen)])
|
||||
else:
|
||||
slots = nil
|
||||
appff(p.s[cpsLocals], "volatile struct {TFrame* prev;" &
|
||||
"NCSTRING procname;NI line;NCSTRING filename;" &
|
||||
"NI len;$n$1} F;$n",
|
||||
"%TF = type {%TFrame*, i8*, %NI, %NI$1}$n" &
|
||||
"%F = alloca %TF$n", [slots])
|
||||
inc(p.labels)
|
||||
prepend(p.s[cpsInit], ropeff("F.len = $1;$n",
|
||||
"%LOC$2 = getelementptr %TF %F, %NI 4$n" &
|
||||
"store %NI $1, %NI* %LOC$2$n", [toRope(p.frameLen), toRope(p.labels)]))
|
||||
|
||||
proc retIsNotVoid(s: PSym): bool =
|
||||
result = (s.typ.sons[0] != nil) and not isInvalidReturnType(s.typ.sons[0])
|
||||
|
||||
proc initFrame(p: BProc, procname, filename: PRope): PRope =
|
||||
inc(p.labels, 5)
|
||||
result = ropeff("F.procname = $1;$n" & "F.prev = framePtr;$n" &
|
||||
"F.filename = $2;$n" & "F.line = 0;$n" & "framePtr = (TFrame*)&F;$n",
|
||||
"%LOC$3 = getelementptr %TF %F, %NI 1$n" &
|
||||
"%LOC$4 = getelementptr %TF %F, %NI 0$n" &
|
||||
"%LOC$5 = getelementptr %TF %F, %NI 3$n" &
|
||||
"%LOC$6 = getelementptr %TF %F, %NI 2$n" & "store i8* $1, i8** %LOC$3$n" &
|
||||
"store %TFrame* @framePtr, %TFrame** %LOC$4$n" &
|
||||
"store i8* $2, i8** %LOC$5$n" & "store %NI 0, %NI* %LOC$6$n" &
|
||||
"%LOC$7 = bitcast %TF* %F to %TFrame*$n" &
|
||||
"store %TFrame* %LOC$7, %TFrame** @framePtr$n", [procname, filename,
|
||||
toRope(p.labels), toRope(p.labels - 1), toRope(p.labels - 2),
|
||||
toRope(p.labels - 3), toRope(p.labels - 4)])
|
||||
|
||||
proc deinitFrame(p: BProc): PRope =
|
||||
inc(p.labels, 3)
|
||||
result = ropeff("framePtr = framePtr->prev;$n",
|
||||
"%LOC$1 = load %TFrame* @framePtr$n" &
|
||||
"%LOC$2 = getelementptr %TFrame* %LOC$1, %NI 0$n" &
|
||||
"%LOC$3 = load %TFrame** %LOC$2$n" &
|
||||
"store %TFrame* $LOC$3, %TFrame** @framePtr", [toRope(p.labels),
|
||||
toRope(p.labels - 1), toRope(p.labels - 2)])
|
||||
|
||||
proc genProcAux(m: BModule, prc: PSym) =
|
||||
var
|
||||
p: BProc
|
||||
generatedProc, header, returnStmt, procname, filename: PRope
|
||||
res, param: PSym
|
||||
p = newProc(prc, m)
|
||||
header = genProcHeader(m, prc)
|
||||
if (gCmd != cmdCompileToLLVM) and (lfExportLib in prc.loc.flags):
|
||||
header = con("N_LIB_EXPORT ", header)
|
||||
returnStmt = nil
|
||||
assert(prc.ast != nil)
|
||||
if not (sfPure in prc.flags) and (prc.typ.sons[0] != nil):
|
||||
res = prc.ast.sons[resultPos].sym # get result symbol
|
||||
if not isInvalidReturnType(prc.typ.sons[0]):
|
||||
# declare the result symbol:
|
||||
assignLocalVar(p, res)
|
||||
assert(res.loc.r != nil)
|
||||
returnStmt = ropeff("return $1;$n", "ret $1$n", [rdLoc(res.loc)])
|
||||
else:
|
||||
fillResult(res)
|
||||
assignParam(p, res)
|
||||
if skipTypes(res.typ, abstractInst).kind == tyArray:
|
||||
incl(res.loc.flags, lfIndirect)
|
||||
res.loc.s = OnUnknown
|
||||
initVariable(p, res)
|
||||
genObjectInit(p, res.typ, res.loc, true)
|
||||
for i in countup(1, sonsLen(prc.typ.n) - 1):
|
||||
param = prc.typ.n.sons[i].sym
|
||||
assignParam(p, param)
|
||||
genStmts(p, prc.ast.sons[codePos]) # modifies p.locals, p.init, etc.
|
||||
if sfPure in prc.flags:
|
||||
generatedProc = ropeff("$1 {$n$2$3$4}$n", "define $1 {$n$2$3$4}$n", [header,
|
||||
p.s[cpsLocals], p.s[cpsInit], p.s[cpsStmts]])
|
||||
else:
|
||||
generatedProc = ropeff("$1 {$n", "define $1 {$n", [header])
|
||||
if optStackTrace in prc.options:
|
||||
getFrameDecl(p)
|
||||
app(generatedProc, p.s[cpsLocals])
|
||||
procname = CStringLit(p, generatedProc,
|
||||
prc.owner.name.s & '.' & prc.name.s)
|
||||
filename = CStringLit(p, generatedProc, toFilename(prc.info))
|
||||
app(generatedProc, initFrame(p, procname, filename))
|
||||
else:
|
||||
app(generatedProc, p.s[cpsLocals])
|
||||
if (optProfiler in prc.options) and (gCmd != cmdCompileToLLVM):
|
||||
if gProcProfile >= 64 * 1024:
|
||||
InternalError(prc.info, "too many procedures for profiling")
|
||||
useMagic(m, "profileData")
|
||||
app(p.s[cpsLocals], "ticks NIM_profilingStart;" & tnl)
|
||||
if prc.loc.a < 0:
|
||||
appf(m.s[cfsDebugInit], "profileData[$1].procname = $2;$n", [
|
||||
toRope(gProcProfile),
|
||||
makeCString(prc.owner.name.s & '.' & prc.name.s)])
|
||||
prc.loc.a = gProcProfile
|
||||
inc(gProcProfile)
|
||||
prepend(p.s[cpsInit], toRope("NIM_profilingStart = getticks();" & tnl))
|
||||
app(generatedProc, p.s[cpsInit])
|
||||
app(generatedProc, p.s[cpsStmts])
|
||||
if p.beforeRetNeeded: app(generatedProc, "BeforeRet: ;" & tnl)
|
||||
if optStackTrace in prc.options: app(generatedProc, deinitFrame(p))
|
||||
if (optProfiler in prc.options) and (gCmd != cmdCompileToLLVM):
|
||||
appf(generatedProc, "profileData[$1].total += elapsed(getticks(), NIM_profilingStart);$n",
|
||||
[toRope(prc.loc.a)])
|
||||
app(generatedProc, returnStmt)
|
||||
app(generatedProc, '}' & tnl)
|
||||
app(m.s[cfsProcs], generatedProc) #if prc.kind = skMethod then addMethodToCompile(gNimDat, prc);
|
||||
|
||||
proc genProcPrototype(m: BModule, sym: PSym) =
|
||||
useHeader(m, sym)
|
||||
if (lfNoDecl in sym.loc.Flags): return
|
||||
if lfDynamicLib in sym.loc.Flags:
|
||||
if (sym.owner.id != m.module.id) and
|
||||
not intSetContainsOrIncl(m.declaredThings, sym.id):
|
||||
appff(m.s[cfsVars], "extern $1 Dl_$2;$n",
|
||||
"@Dl_$2 = linkonce global $1 zeroinitializer$n",
|
||||
[getTypeDesc(m, sym.loc.t), toRope(sym.id)])
|
||||
if gCmd == cmdCompileToLLVM: incl(sym.loc.flags, lfIndirect)
|
||||
else:
|
||||
if not IntSetContainsOrIncl(m.declaredProtos, sym.id):
|
||||
appf(m.s[cfsProcHeaders], "$1;$n", [genProcHeader(m, sym)])
|
||||
|
||||
proc genProcNoForward(m: BModule, prc: PSym) =
|
||||
fillProcLoc(prc)
|
||||
useHeader(m, prc)
|
||||
genProcPrototype(m, prc)
|
||||
if (lfNoDecl in prc.loc.Flags): return
|
||||
if prc.typ.callConv == ccInline:
|
||||
# We add inline procs to the calling module to enable C based inlining.
|
||||
# This also means that a check with ``gGeneratedSyms`` is wrong, we need
|
||||
# a check for ``m.declaredThings``.
|
||||
if not intSetContainsOrIncl(m.declaredThings, prc.id): genProcAux(m, prc)
|
||||
elif lfDynamicLib in prc.loc.flags:
|
||||
if not IntSetContainsOrIncl(gGeneratedSyms, prc.id):
|
||||
SymInDynamicLib(findPendingModule(m, prc), prc)
|
||||
elif not (sfImportc in prc.flags):
|
||||
if not IntSetContainsOrIncl(gGeneratedSyms, prc.id):
|
||||
genProcAux(findPendingModule(m, prc), prc)
|
||||
|
||||
proc genProc(m: BModule, prc: PSym) =
|
||||
if sfBorrow in prc.flags: return
|
||||
fillProcLoc(prc)
|
||||
if {sfForward, sfFromGeneric} * prc.flags != {}: addForwardedProc(m, prc)
|
||||
else: genProcNoForward(m, prc)
|
||||
|
||||
proc genVarPrototype(m: BModule, sym: PSym) =
|
||||
assert(sfGlobal in sym.flags)
|
||||
useHeader(m, sym)
|
||||
fillLoc(sym.loc, locGlobalVar, sym.typ, mangleName(sym), OnHeap)
|
||||
if (lfNoDecl in sym.loc.Flags) or
|
||||
intSetContainsOrIncl(m.declaredThings, sym.id):
|
||||
return
|
||||
if sym.owner.id != m.module.id:
|
||||
# else we already have the symbol generated!
|
||||
assert(sym.loc.r != nil)
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
incl(sym.loc.flags, lfIndirect)
|
||||
appf(m.s[cfsVars], "$1 = linkonce global $2 zeroinitializer$n",
|
||||
[sym.loc.r, getTypeDesc(m, sym.loc.t)])
|
||||
else:
|
||||
app(m.s[cfsVars], "extern ")
|
||||
app(m.s[cfsVars], getTypeDesc(m, sym.loc.t))
|
||||
if sfRegister in sym.flags: app(m.s[cfsVars], " register")
|
||||
if sfVolatile in sym.flags: app(m.s[cfsVars], " volatile")
|
||||
if sfThreadVar in sym.flags: app(m.s[cfsVars], " NIM_THREADVAR")
|
||||
appf(m.s[cfsVars], " $1;$n", [sym.loc.r])
|
||||
|
||||
proc genConstPrototype(m: BModule, sym: PSym) =
|
||||
useHeader(m, sym)
|
||||
if sym.loc.k == locNone:
|
||||
fillLoc(sym.loc, locData, sym.typ, mangleName(sym), OnUnknown)
|
||||
if (lfNoDecl in sym.loc.Flags) or
|
||||
intSetContainsOrIncl(m.declaredThings, sym.id):
|
||||
return
|
||||
if sym.owner.id != m.module.id:
|
||||
# else we already have the symbol generated!
|
||||
assert(sym.loc.r != nil)
|
||||
appff(m.s[cfsData], "extern NIM_CONST $1 $2;$n",
|
||||
"$1 = linkonce constant $2 zeroinitializer",
|
||||
[getTypeDesc(m, sym.loc.t), sym.loc.r])
|
||||
|
||||
proc getFileHeader(cfilenoext: string): PRope =
|
||||
if optCompileOnly in gGlobalOptions:
|
||||
result = ropeff("/* Generated by Nimrod Compiler v$1 */$n" &
|
||||
"/* (c) 2009 Andreas Rumpf */$n", "; Generated by Nimrod Compiler v$1$n" &
|
||||
"; (c) 2009 Andreas Rumpf$n", [toRope(versionAsString)])
|
||||
else:
|
||||
result = ropeff("/* Generated by Nimrod Compiler v$1 */$n" &
|
||||
"/* (c) 2009 Andreas Rumpf */$n" & "/* Compiled for: $2, $3, $4 */$n" &
|
||||
"/* Command for C compiler:$n $5 */$n", "; Generated by Nimrod Compiler v$1$n" &
|
||||
"; (c) 2009 Andreas Rumpf$n" & "; Compiled for: $2, $3, $4$n" &
|
||||
"; Command for LLVM compiler:$n $5$n", [toRope(versionAsString),
|
||||
toRope(platform.OS[targetOS].name),
|
||||
toRope(platform.CPU[targetCPU].name),
|
||||
toRope(extccomp.CC[extccomp.ccompiler].name),
|
||||
toRope(getCompileCFileCmd(cfilenoext))])
|
||||
case platform.CPU[targetCPU].intSize
|
||||
of 16:
|
||||
appff(result,
|
||||
"$ntypedef short int NI;$n" & "typedef unsigned short int NU;$n",
|
||||
"$n%NI = type i16$n", [])
|
||||
of 32:
|
||||
appff(result,
|
||||
"$ntypedef long int NI;$n" & "typedef unsigned long int NU;$n",
|
||||
"$n%NI = type i32$n", [])
|
||||
of 64:
|
||||
appff(result, "$ntypedef long long int NI;$n" &
|
||||
"typedef unsigned long long int NU;$n", "$n%NI = type i64$n", [])
|
||||
else:
|
||||
nil
|
||||
|
||||
proc genMainProc(m: BModule) =
|
||||
const
|
||||
CommonMainBody = " setStackBottom(dummy);$n" & " nim__datInit();$n" &
|
||||
" systemInit();$n" & "$1" & "$2"
|
||||
CommonMainBodyLLVM = " %MOC$3 = bitcast [8 x %NI]* %dummy to i8*$n" &
|
||||
" call void @setStackBottom(i8* %MOC$3)$n" &
|
||||
" call void @nim__datInit()$n" & " call void systemInit()$n" & "$1" &
|
||||
"$2"
|
||||
PosixNimMain = "int cmdCount;$n" & "char** cmdLine;$n" & "char** gEnv;$n" &
|
||||
"N_CDECL(void, NimMain)(void) {$n" & " int dummy[8];$n" &
|
||||
CommonMainBody & "}$n"
|
||||
PosixCMain = "int main(int argc, char** args, char** env) {$n" &
|
||||
" cmdLine = args;$n" & " cmdCount = argc;$n" & " gEnv = env;$n" &
|
||||
" NimMain();$n" & " return 0;$n" & "}$n"
|
||||
PosixNimMainLLVM = "@cmdCount = linkonce i32$n" &
|
||||
"@cmdLine = linkonce i8**$n" & "@gEnv = linkonce i8**$n" &
|
||||
"define void @NimMain(void) {$n" & " %dummy = alloca [8 x %NI]$n" &
|
||||
CommonMainBodyLLVM & "}$n"
|
||||
PosixCMainLLVM = "define i32 @main(i32 %argc, i8** %args, i8** %env) {$n" &
|
||||
" store i8** %args, i8*** @cmdLine$n" &
|
||||
" store i32 %argc, i32* @cmdCount$n" &
|
||||
" store i8** %env, i8*** @gEnv$n" & " call void @NimMain()$n" &
|
||||
" ret i32 0$n" & "}$n"
|
||||
WinNimMain = "N_CDECL(void, NimMain)(void) {$n" & " int dummy[8];$n" &
|
||||
CommonMainBody & "}$n"
|
||||
WinCMain = "N_STDCALL(int, WinMain)(HINSTANCE hCurInstance, $n" &
|
||||
" HINSTANCE hPrevInstance, $n" &
|
||||
" LPSTR lpCmdLine, int nCmdShow) {$n" &
|
||||
" NimMain();$n" & " return 0;$n" & "}$n"
|
||||
WinNimMainLLVM = "define void @NimMain(void) {$n" &
|
||||
" %dummy = alloca [8 x %NI]$n" & CommonMainBodyLLVM & "}$n"
|
||||
WinCMainLLVM = "define stdcall i32 @WinMain(i32 %hCurInstance, $n" &
|
||||
" i32 %hPrevInstance, $n" &
|
||||
" i8* %lpCmdLine, i32 %nCmdShow) {$n" &
|
||||
" call void @NimMain()$n" & " ret i32 0$n" & "}$n"
|
||||
WinNimDllMain = "N_LIB_EXPORT N_CDECL(void, NimMain)(void) {$n" &
|
||||
" int dummy[8];$n" & CommonMainBody & "}$n"
|
||||
WinCDllMain = "BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, $n" &
|
||||
" LPVOID lpvReserved) {$n" & " NimMain();$n" &
|
||||
" return 1;$n" & "}$n"
|
||||
WinNimDllMainLLVM = WinNimMainLLVM
|
||||
WinCDllMainLLVM = "define stdcall i32 @DllMain(i32 %hinstDLL, i32 %fwdreason, $n" &
|
||||
" i8* %lpvReserved) {$n" &
|
||||
" call void @NimMain()$n" & " ret i32 1$n" & "}$n"
|
||||
var nimMain, otherMain: TFormatStr
|
||||
useMagic(m, "setStackBottom")
|
||||
if (platform.targetOS == osWindows) and
|
||||
(gGlobalOptions * {optGenGuiApp, optGenDynLib} != {}):
|
||||
if optGenGuiApp in gGlobalOptions:
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
nimMain = WinNimMainLLVM
|
||||
otherMain = WinCMainLLVM
|
||||
else:
|
||||
nimMain = WinNimMain
|
||||
otherMain = WinCMain
|
||||
else:
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
nimMain = WinNimDllMainLLVM
|
||||
otherMain = WinCDllMainLLVM
|
||||
else:
|
||||
nimMain = WinNimDllMain
|
||||
otherMain = WinCDllMain
|
||||
discard lists.IncludeStr(m.headerFiles, "<windows.h>")
|
||||
else:
|
||||
if gCmd == cmdCompileToLLVM:
|
||||
nimMain = PosixNimMainLLVM
|
||||
otherMain = PosixCMainLLVM
|
||||
else:
|
||||
nimMain = PosixNimMain
|
||||
otherMain = PosixCMain
|
||||
if gBreakpoints != nil: useMagic(m, "dbgRegisterBreakpoint")
|
||||
inc(m.labels)
|
||||
appf(m.s[cfsProcs], nimMain, [gBreakpoints, mainModInit, toRope(m.labels)])
|
||||
if not (optNoMain in gGlobalOptions): appf(m.s[cfsProcs], otherMain, [])
|
||||
|
||||
proc getInitName(m: PSym): PRope =
|
||||
result = ropeff("$1Init", "@$1Init", [toRope(m.name.s)])
|
||||
|
||||
proc registerModuleToMain(m: PSym) =
|
||||
var initname = getInitName(m)
|
||||
appff(mainModProcs, "N_NOINLINE(void, $1)(void);$n",
|
||||
"declare void $1() noinline$n", [initname])
|
||||
if not (sfSystemModule in m.flags):
|
||||
appff(mainModInit, "$1();$n", "call void ()* $1$n", [initname])
|
||||
|
||||
proc genInitCode(m: BModule) =
|
||||
var initname, prc, procname, filename: PRope
|
||||
if optProfiler in m.initProc.options:
|
||||
# This does not really belong here, but there is no good place for this
|
||||
# code. I don't want to put this to the proc generation as the
|
||||
# ``IncludeStr`` call is quite slow.
|
||||
discard lists.IncludeStr(m.headerFiles, "<cycle.h>")
|
||||
initname = getInitName(m.module)
|
||||
prc = ropeff("N_NOINLINE(void, $1)(void) {$n",
|
||||
"define void $1() noinline {$n", [initname])
|
||||
if m.typeNodes > 0:
|
||||
useMagic(m, "TNimNode")
|
||||
appff(m.s[cfsTypeInit1], "static TNimNode $1[$2];$n",
|
||||
"$1 = private alloca [$2 x @TNimNode]$n",
|
||||
[m.typeNodesName, toRope(m.typeNodes)])
|
||||
if m.nimTypes > 0:
|
||||
useMagic(m, "TNimType")
|
||||
appff(m.s[cfsTypeInit1], "static TNimType $1[$2];$n",
|
||||
"$1 = private alloca [$2 x @TNimType]$n",
|
||||
[m.nimTypesName, toRope(m.nimTypes)])
|
||||
if optStackTrace in m.initProc.options:
|
||||
getFrameDecl(m.initProc)
|
||||
app(prc, m.initProc.s[cpsLocals])
|
||||
app(prc, m.s[cfsTypeInit1])
|
||||
procname = CStringLit(m.initProc, prc, "module " & m.module.name.s)
|
||||
filename = CStringLit(m.initProc, prc, toFilename(m.module.info))
|
||||
app(prc, initFrame(m.initProc, procname, filename))
|
||||
else:
|
||||
app(prc, m.initProc.s[cpsLocals])
|
||||
app(prc, m.s[cfsTypeInit1])
|
||||
app(prc, m.s[cfsTypeInit2])
|
||||
app(prc, m.s[cfsTypeInit3])
|
||||
app(prc, m.s[cfsDebugInit])
|
||||
app(prc, m.s[cfsDynLibInit])
|
||||
app(prc, m.initProc.s[cpsInit])
|
||||
app(prc, m.initProc.s[cpsStmts])
|
||||
if optStackTrace in m.initProc.options: app(prc, deinitFrame(m.initProc))
|
||||
app(prc, '}' & tnl & tnl)
|
||||
app(m.s[cfsProcs], prc)
|
||||
|
||||
proc genModule(m: BModule, cfilenoext: string): PRope =
|
||||
result = getFileHeader(cfilenoext)
|
||||
generateHeaders(m)
|
||||
for i in countup(low(TCFileSection), cfsProcs): app(result, m.s[i])
|
||||
|
||||
proc rawNewModule(module: PSym, filename: string): BModule =
|
||||
new(result)
|
||||
InitLinkedList(result.headerFiles)
|
||||
intSetInit(result.declaredThings)
|
||||
intSetInit(result.declaredProtos)
|
||||
result.cfilename = filename
|
||||
result.filename = filename
|
||||
initIdTable(result.typeCache)
|
||||
initIdTable(result.forwTypeCache)
|
||||
result.module = module
|
||||
intSetInit(result.typeInfoMarker)
|
||||
result.initProc = newProc(nil, result)
|
||||
result.initProc.options = gOptions
|
||||
initNodeTable(result.dataCache)
|
||||
result.typeStack = @[]
|
||||
result.forwardedProcs = @[]
|
||||
result.typeNodesName = getTempName()
|
||||
result.nimTypesName = getTempName()
|
||||
|
||||
proc newModule(module: PSym, filename: string): BModule =
|
||||
result = rawNewModule(module, filename)
|
||||
if (optDeadCodeElim in gGlobalOptions):
|
||||
if (sfDeadCodeElim in module.flags):
|
||||
InternalError("added pending module twice: " & filename)
|
||||
addPendingModule(result)
|
||||
|
||||
proc registerTypeInfoModule() =
|
||||
const moduleName = "nim__dat"
|
||||
var s = NewSym(skModule, getIdent(moduleName), nil)
|
||||
gNimDat = rawNewModule(s, joinPath(options.projectPath, moduleName) & ".nim")
|
||||
addPendingModule(gNimDat)
|
||||
appff(mainModProcs, "N_NOINLINE(void, $1)(void);$n",
|
||||
"declare void $1() noinline$n", [getInitName(s)])
|
||||
|
||||
proc myOpen(module: PSym, filename: string): PPassContext =
|
||||
if gNimDat == nil: registerTypeInfoModule()
|
||||
result = newModule(module, filename)
|
||||
|
||||
proc myOpenCached(module: PSym, filename: string, rd: PRodReader): PPassContext =
|
||||
var cfile, cfilenoext, objFile: string
|
||||
if gNimDat == nil:
|
||||
registerTypeInfoModule()
|
||||
#MessageOut('cgen.myOpenCached has been called ' + filename);
|
||||
cfile = changeFileExt(completeCFilePath(filename), cExt)
|
||||
cfilenoext = changeFileExt(cfile, "")
|
||||
addFileToLink(cfilenoext)
|
||||
registerModuleToMain(module)
|
||||
# XXX: this cannot be right here, initalization has to be appended during
|
||||
# the ``myClose`` call
|
||||
result = nil
|
||||
|
||||
proc shouldRecompile(code: PRope, cfile, cfilenoext: string): bool =
|
||||
result = true
|
||||
if not (optForceFullMake in gGlobalOptions):
|
||||
var objFile = toObjFile(cfilenoext)
|
||||
if writeRopeIfNotEqual(code, cfile): return
|
||||
if ExistsFile(objFile) and os.FileNewer(objFile, cfile): result = false
|
||||
else:
|
||||
writeRope(code, cfile)
|
||||
|
||||
proc myProcess(b: PPassContext, n: PNode): PNode =
|
||||
result = n
|
||||
if b == nil: return
|
||||
var m = BModule(b)
|
||||
m.initProc.options = gOptions
|
||||
genStmts(m.initProc, n)
|
||||
|
||||
proc finishModule(m: BModule) =
|
||||
var i = 0
|
||||
while i <= high(m.forwardedProcs):
|
||||
# Note: ``genProc`` may add to ``m.forwardedProcs``, so we cannot use
|
||||
# a ``for`` loop here
|
||||
var prc = m.forwardedProcs[i]
|
||||
if sfForward in prc.flags: InternalError(prc.info, "still forwarded")
|
||||
genProcNoForward(m, prc)
|
||||
inc(i)
|
||||
assert(gForwardedProcsCounter >= i)
|
||||
dec(gForwardedProcsCounter, i)
|
||||
setlen(m.forwardedProcs, 0)
|
||||
|
||||
proc writeModule(m: BModule) =
|
||||
var
|
||||
cfile, cfilenoext: string
|
||||
code: PRope
|
||||
# generate code for the init statements of the module:
|
||||
genInitCode(m)
|
||||
finishTypeDescriptions(m)
|
||||
cfile = completeCFilePath(m.cfilename)
|
||||
cfilenoext = changeFileExt(cfile, "")
|
||||
if sfMainModule in m.module.flags:
|
||||
# generate main file:
|
||||
app(m.s[cfsProcHeaders], mainModProcs)
|
||||
code = genModule(m, cfilenoext)
|
||||
if shouldRecompile(code, changeFileExt(cfile, cExt), cfilenoext):
|
||||
addFileToCompile(cfilenoext)
|
||||
addFileToLink(cfilenoext)
|
||||
|
||||
proc myClose(b: PPassContext, n: PNode): PNode =
|
||||
result = n
|
||||
if b == nil: return
|
||||
var m = BModule(b)
|
||||
if n != nil:
|
||||
m.initProc.options = gOptions
|
||||
genStmts(m.initProc, n)
|
||||
registerModuleToMain(m.module)
|
||||
if not (optDeadCodeElim in gGlobalOptions) and
|
||||
not (sfDeadCodeElim in m.module.flags):
|
||||
finishModule(m)
|
||||
if sfMainModule in m.module.flags:
|
||||
var disp = generateMethodDispatchers()
|
||||
for i in countup(0, sonsLen(disp) - 1): genProcAux(gNimDat, disp.sons[i].sym)
|
||||
genMainProc(m)
|
||||
# we need to process the transitive closure because recursive module
|
||||
# deps are allowed (and the system module is processed in the wrong
|
||||
# order anyway)
|
||||
while gForwardedProcsCounter > 0:
|
||||
for i in countup(0, high(gPendingModules)):
|
||||
finishModule(gPendingModules[i])
|
||||
for i in countup(0, high(gPendingModules)): writeModule(gPendingModules[i])
|
||||
setlen(gPendingModules, 0)
|
||||
if not (optDeadCodeElim in gGlobalOptions) and
|
||||
not (sfDeadCodeElim in m.module.flags):
|
||||
writeModule(m)
|
||||
if sfMainModule in m.module.flags: writeMapping(gMapping)
|
||||
|
||||
proc llvmgenPass(): TPass =
|
||||
initPass(result)
|
||||
result.open = myOpen
|
||||
result.openCached = myOpenCached
|
||||
result.process = myProcess
|
||||
result.close = myClose
|
||||
|
||||
InitIiTable(gToTypeInfoId)
|
||||
IntSetInit(gGeneratedSyms)
|
||||
547
rod/llvmstat.nim
547
rod/llvmstat.nim
@@ -1,547 +0,0 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2008 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# this module implements the interface to LLVM.
|
||||
|
||||
import # Opaque types.
|
||||
#
|
||||
# The top-level container for all other LLVM Intermediate Representation (IR)
|
||||
# objects. See the llvm::Module class.
|
||||
#
|
||||
ropes
|
||||
|
||||
type
|
||||
cuint* = int32
|
||||
TLLVMTypeKind* = enum
|
||||
LLVMVoidTypeKind, # type with no size
|
||||
LLVMFloatTypeKind, # 32 bit floating point type
|
||||
LLVMDoubleTypeKind, # 64 bit floating point type
|
||||
LLVMX86_FP80TypeKind, # 80 bit floating point type (X87)
|
||||
LLVMFP128TypeKind, # 128 bit floating point type (112-bit mantissa)
|
||||
LLVMPPC_FP128TypeKind, # 128 bit floating point type (two 64-bits)
|
||||
LLVMLabelTypeKind, # Labels
|
||||
LLVMIntegerTypeKind, # Arbitrary bit width integers
|
||||
LLVMFunctionTypeKind, # Functions
|
||||
LLVMStructTypeKind, # Structures
|
||||
LLVMArrayTypeKind, # Arrays
|
||||
LLVMPointerTypeKind, # Pointers
|
||||
LLVMOpaqueTypeKind, # Opaque: type with unknown structure
|
||||
LLVMVectorTypeKind # SIMD 'packed' format, or other vector type
|
||||
TLLVMLinkage* = enum
|
||||
LLVMExternalLinkage, # Externally visible function
|
||||
LLVMLinkOnceLinkage, # Keep one copy of function when linking (inline)
|
||||
LLVMWeakLinkage, # Keep one copy of function when linking (weak)
|
||||
LLVMAppendingLinkage, # Special purpose, only applies to global arrays
|
||||
LLVMInternalLinkage, # Rename collisions when linking (static functions)
|
||||
LLVMDLLImportLinkage, # Function to be imported from DLL
|
||||
LLVMDLLExportLinkage, # Function to be accessible from DLL
|
||||
LLVMExternalWeakLinkage, # ExternalWeak linkage description
|
||||
LLVMGhostLinkage # Stand-in functions for streaming fns from bitcode
|
||||
TLLVMVisibility* = enum
|
||||
LLVMDefaultVisibility, # The GV is visible
|
||||
LLVMHiddenVisibility, # The GV is hidden
|
||||
LLVMProtectedVisibility # The GV is protected
|
||||
TLLVMCallConv* = enum
|
||||
LLVMCCallConv = 0, LLVMFastCallConv = 8, LLVMColdCallConv = 9,
|
||||
LLVMX86StdcallCallConv = 64, LLVMX86FastcallCallConv = 65
|
||||
TLLVMIntPredicate* = enum
|
||||
LLVMIntEQ = 32, # equal
|
||||
LLVMIntNE, # not equal
|
||||
LLVMIntUGT, # unsigned greater than
|
||||
LLVMIntUGE, # unsigned greater or equal
|
||||
LLVMIntULT, # unsigned less than
|
||||
LLVMIntULE, # unsigned less or equal
|
||||
LLVMIntSGT, # signed greater than
|
||||
LLVMIntSGE, # signed greater or equal
|
||||
LLVMIntSLT, # signed less than
|
||||
LLVMIntSLE # signed less or equal
|
||||
TLLVMRealPredicate* = enum
|
||||
LLVMRealPredicateFalse, # Always false (always folded)
|
||||
LLVMRealOEQ, # True if ordered and equal
|
||||
LLVMRealOGT, # True if ordered and greater than
|
||||
LLVMRealOGE, # True if ordered and greater than or equal
|
||||
LLVMRealOLT, # True if ordered and less than
|
||||
LLVMRealOLE, # True if ordered and less than or equal
|
||||
LLVMRealONE, # True if ordered and operands are unequal
|
||||
LLVMRealORD, # True if ordered (no nans)
|
||||
LLVMRealUNO, # True if unordered: isnan(X) | isnan(Y)
|
||||
LLVMRealUEQ, # True if unordered or equal
|
||||
LLVMRealUGT, # True if unordered or greater than
|
||||
LLVMRealUGE, # True if unordered, greater than, or equal
|
||||
LLVMRealULT, # True if unordered or less than
|
||||
LLVMRealULE, # True if unordered, less than, or equal
|
||||
LLVMRealUNE, # True if unordered or not equal
|
||||
LLVMRealPredicateTrue # Always true (always folded)
|
||||
PLLVMBasicBlockRef* = ref TLLVMBasicBlockRef
|
||||
PLLVMMemoryBufferRef* = ref TLLVMMemoryBufferRef
|
||||
PLLVMTypeRef* = ref TLLVMTypeRef
|
||||
PLLVMValueRef* = ref TLLVMValueRef
|
||||
TLLVMOpaqueModule*{.final.} = object
|
||||
code*: PRope
|
||||
|
||||
TLLVMModuleRef* = ref TLLVMOpaqueModule #
|
||||
# Each value in the LLVM IR has a type, an instance of [lltype]. See the
|
||||
# llvm::Type class.
|
||||
#
|
||||
TLLVMOpaqueType*{.final.} = object
|
||||
kind*: TLLVMTypeKind
|
||||
|
||||
TLLVMTypeRef* = ref TLLVMOpaqueType #
|
||||
# When building recursive types using [refine_type], [lltype] values may become
|
||||
# invalid; use [lltypehandle] to resolve this problem. See the
|
||||
# llvm::AbstractTypeHolder] class.
|
||||
#
|
||||
TLLVMOpaqueTypeHandle*{.final.} = object
|
||||
TLLVMTypeHandleRef* = ref TLLVMOpaqueTypeHandle
|
||||
TLLVMOpaqueValue*{.final.} = object
|
||||
TLLVMValueRef* = ref TLLVMOpaqueValue
|
||||
TLLVMOpaqueBasicBlock*{.final.} = object
|
||||
TLLVMBasicBlockRef* = ref TLLVMOpaqueBasicBlock
|
||||
TLLVMOpaqueBuilder*{.final.} = object
|
||||
TLLVMBuilderRef* = ref TLLVMOpaqueBuilder # Used to provide a module to JIT or interpreter.
|
||||
# See the llvm::ModuleProvider class.
|
||||
#
|
||||
TLLVMOpaqueModuleProvider*{.final.} = object
|
||||
TLLVMModuleProviderRef* = ref TLLVMOpaqueModuleProvider # Used to provide a module to JIT or interpreter.
|
||||
# See the llvm: : MemoryBuffer class.
|
||||
#
|
||||
TLLVMOpaqueMemoryBuffer*{.final.} = object
|
||||
TLLVMMemoryBufferRef* = ref TLLVMOpaqueMemoryBuffer #===-- Error handling ----------------------------------------------------===
|
||||
|
||||
proc LLVMDisposeMessage*(msg: cstring){.cdecl.}
|
||||
#===-- Modules -----------------------------------------------------------===
|
||||
# Create and destroy modules.
|
||||
proc LLVMModuleCreateWithName*(ModuleID: cstring): TLLVMModuleRef{.cdecl.}
|
||||
proc LLVMDisposeModule*(M: TLLVMModuleRef){.cdecl.}
|
||||
# Data layout
|
||||
proc LLVMGetDataLayout*(M: TLLVMModuleRef): cstring{.cdecl.}
|
||||
proc LLVMSetDataLayout*(M: TLLVMModuleRef, Triple: cstring){.cdecl.}
|
||||
# Target triple
|
||||
proc LLVMGetTarget*(M: TLLVMModuleRef): cstring{.cdecl.}
|
||||
proc LLVMSetTarget*(M: TLLVMModuleRef, Triple: cstring){.cdecl.}
|
||||
# Same as Module: : addTypeName.
|
||||
proc LLVMAddTypeName*(M: TLLVMModuleRef, Name: cstring, Ty: TLLVMTypeRef): int32{.
|
||||
cdecl.}
|
||||
proc LLVMDeleteTypeName*(M: TLLVMModuleRef, Name: cstring){.cdecl.}
|
||||
#===-- Types -------------------------------------------------------------===
|
||||
# LLVM types conform to the following hierarchy:
|
||||
# *
|
||||
# * types:
|
||||
# * integer type
|
||||
# * real type
|
||||
# * function type
|
||||
# * sequence types:
|
||||
# * array type
|
||||
# * pointer type
|
||||
# * vector type
|
||||
# * void type
|
||||
# * label type
|
||||
# * opaque type
|
||||
#
|
||||
proc LLVMGetTypeKind*(Ty: TLLVMTypeRef): TLLVMTypeKind{.cdecl.}
|
||||
proc LLVMRefineAbstractType*(AbstractType: TLLVMTypeRef,
|
||||
ConcreteType: TLLVMTypeRef){.cdecl.}
|
||||
# Operations on integer types
|
||||
proc LLVMInt1Type*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMInt8Type*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMInt16Type*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMInt32Type*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMInt64Type*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMIntType*(NumBits: cuint): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMGetIntTypeWidth*(IntegerTy: TLLVMTypeRef): cuint{.cdecl.}
|
||||
# Operations on real types
|
||||
proc LLVMFloatType*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMDoubleType*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMX86FP80Type*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMFP128Type*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMPPCFP128Type*(): TLLVMTypeRef{.cdecl.}
|
||||
# Operations on function types
|
||||
proc LLVMFunctionType*(ReturnType: TLLVMTypeRef, ParamTypes: PLLVMTypeRef,
|
||||
ParamCount: cuint, IsVarArg: int32): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMIsFunctionVarArg*(FunctionTy: TLLVMTypeRef): int32{.cdecl.}
|
||||
proc LLVMGetReturnType*(FunctionTy: TLLVMTypeRef): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMCountParamTypes*(FunctionTy: TLLVMTypeRef): cuint{.cdecl.}
|
||||
proc LLVMGetParamTypes*(FunctionTy: TLLVMTypeRef, Dest: PLLVMTypeRef){.cdecl.}
|
||||
# Operations on struct types
|
||||
proc LLVMStructType*(ElementTypes: PLLVMTypeRef, ElementCount: cuint,
|
||||
isPacked: int32): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMCountStructElementTypes*(StructTy: TLLVMTypeRef): cuint{.cdecl.}
|
||||
proc LLVMGetStructElementTypes*(StructTy: TLLVMTypeRef, Dest: pLLVMTypeRef){.
|
||||
cdecl.}
|
||||
proc LLVMIsPackedStruct*(StructTy: TLLVMTypeRef): int32{.cdecl.}
|
||||
# Operations on array, pointer, and vector types (sequence types)
|
||||
proc LLVMArrayType*(ElementType: TLLVMTypeRef, ElementCount: cuint): TLLVMTypeRef{.
|
||||
cdecl.}
|
||||
proc LLVMPointerType*(ElementType: TLLVMTypeRef, AddressSpace: cuint): TLLVMTypeRef{.
|
||||
cdecl.}
|
||||
proc LLVMVectorType*(ElementType: TLLVMTypeRef, ElementCount: cuint): TLLVMTypeRef{.
|
||||
cdecl.}
|
||||
proc LLVMGetElementType*(Ty: TLLVMTypeRef): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMGetArrayLength*(ArrayTy: TLLVMTypeRef): cuint{.cdecl.}
|
||||
proc LLVMGetPointerAddressSpace*(PointerTy: TLLVMTypeRef): cuint{.cdecl.}
|
||||
proc LLVMGetVectorSize*(VectorTy: TLLVMTypeRef): cuint{.cdecl.}
|
||||
# Operations on other types
|
||||
proc LLVMVoidType*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMLabelType*(): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMOpaqueType*(): TLLVMTypeRef{.cdecl.}
|
||||
# Operations on type handles
|
||||
proc LLVMCreateTypeHandle*(PotentiallyAbstractTy: TLLVMTypeRef): TLLVMTypeHandleRef{.
|
||||
cdecl.}
|
||||
proc LLVMRefineType*(AbstractTy: TLLVMTypeRef, ConcreteTy: TLLVMTypeRef){.cdecl.}
|
||||
proc LLVMResolveTypeHandle*(TypeHandle: TLLVMTypeHandleRef): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMDisposeTypeHandle*(TypeHandle: TLLVMTypeHandleRef){.cdecl.}
|
||||
#===-- Values ------------------------------------------------------------===
|
||||
# The bulk of LLVM's object model consists of values, which comprise a very
|
||||
# * rich type hierarchy.
|
||||
# *
|
||||
# * values:
|
||||
# * constants:
|
||||
# * scalar constants
|
||||
# * composite contants
|
||||
# * globals:
|
||||
# * global variable
|
||||
# * function
|
||||
# * alias
|
||||
# * basic blocks
|
||||
#
|
||||
# Operations on all values
|
||||
proc LLVMTypeOf*(Val: TLLVMValueRef): TLLVMTypeRef{.cdecl.}
|
||||
proc LLVMGetValueName*(Val: TLLVMValueRef): cstring{.cdecl.}
|
||||
proc LLVMSetValueName*(Val: TLLVMValueRef, Name: cstring){.cdecl.}
|
||||
proc LLVMDumpValue*(Val: TLLVMValueRef){.cdecl.}
|
||||
# Operations on constants of any type
|
||||
proc LLVMConstNull*(Ty: TLLVMTypeRef): TLLVMValueRef{.cdecl.}
|
||||
# all zeroes
|
||||
proc LLVMConstAllOnes*(Ty: TLLVMTypeRef): TLLVMValueRef{.cdecl.}
|
||||
# only for int/vector
|
||||
proc LLVMGetUndef*(Ty: TLLVMTypeRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMIsConstant*(Val: TLLVMValueRef): int32{.cdecl.}
|
||||
proc LLVMIsNull*(Val: TLLVMValueRef): int32{.cdecl.}
|
||||
proc LLVMIsUndef*(Val: TLLVMValueRef): int32{.cdecl.}
|
||||
# Operations on scalar constants
|
||||
proc LLVMConstInt*(IntTy: TLLVMTypeRef, N: qword, SignExtend: int32): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstReal*(RealTy: TLLVMTypeRef, N: float64): TLLVMValueRef{.cdecl.}
|
||||
# Operations on composite constants
|
||||
proc LLVMConstString*(Str: cstring, len: cuint, DontNullTerminate: int32): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstArray*(ArrayTy: TLLVMTypeRef, ConstantVals: pLLVMValueRef,
|
||||
len: cuint): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstStruct*(ConstantVals: pLLVMValueRef, Count: cuint, ispacked: int32): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstVector*(ScalarConstantVals: pLLVMValueRef, Size: cuint): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
# Constant expressions
|
||||
proc LLVMSizeOf*(Ty: TLLVMTypeRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstNeg*(ConstantVal: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstNot*(ConstantVal: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstAdd*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstSub*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstMul*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstUDiv*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstSDiv*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstFDiv*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstURem*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstSRem*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstFRem*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstAnd*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstOr*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstXor*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstICmp*(Predicate: TLLVMIntPredicate, LHSConstant: TLLVMValueRef,
|
||||
RHSConstant: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstFCmp*(Predicate: TLLVMRealPredicate, LHSConstant: TLLVMValueRef,
|
||||
RHSConstant: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstShl*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstLShr*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstAShr*(LHSConstant: TLLVMValueRef, RHSConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstGEP*(ConstantVal: TLLVMValueRef, ConstantIndices: PLLVMValueRef,
|
||||
NumIndices: cuint): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstTrunc*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstSExt*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstZExt*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstFPTrunc*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstFPExt*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstUIToFP*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstSIToFP*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstFPToUI*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstFPToSI*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstPtrToInt*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstIntToPtr*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstBitCast*(ConstantVal: TLLVMValueRef, ToType: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstSelect*(ConstantCondition: TLLVMValueRef,
|
||||
ConstantIfTrue: TLLVMValueRef,
|
||||
ConstantIfFalse: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstExtractElement*(VectorConstant: TLLVMValueRef,
|
||||
IndexConstant: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMConstInsertElement*(VectorConstant: TLLVMValueRef,
|
||||
ElementValueConstant: TLLVMValueRef,
|
||||
IndexConstant: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMConstShuffleVector*(VectorAConstant: TLLVMValueRef,
|
||||
VectorBConstant: TLLVMValueRef,
|
||||
MaskConstant: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
# Operations on global variables, functions, and aliases (globals)
|
||||
proc LLVMIsDeclaration*(Global: TLLVMValueRef): int32{.cdecl.}
|
||||
proc LLVMGetLinkage*(Global: TLLVMValueRef): TLLVMLinkage{.cdecl.}
|
||||
proc LLVMSetLinkage*(Global: TLLVMValueRef, Linkage: TLLVMLinkage){.cdecl.}
|
||||
proc LLVMGetSection*(Global: TLLVMValueRef): cstring{.cdecl.}
|
||||
proc LLVMSetSection*(Global: TLLVMValueRef, Section: cstring){.cdecl.}
|
||||
proc LLVMGetVisibility*(Global: TLLVMValueRef): TLLVMVisibility{.cdecl.}
|
||||
proc LLVMSetVisibility*(Global: TLLVMValueRef, Viz: TLLVMVisibility){.cdecl.}
|
||||
proc LLVMGetAlignment*(Global: TLLVMValueRef): cuint{.cdecl.}
|
||||
proc LLVMSetAlignment*(Global: TLLVMValueRef, Bytes: cuint){.cdecl.}
|
||||
# Operations on global variables
|
||||
# Const before type ignored
|
||||
proc LLVMAddGlobal*(M: TLLVMModuleRef, Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
# Const before type ignored
|
||||
proc LLVMGetNamedGlobal*(M: TLLVMModuleRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMDeleteGlobal*(GlobalVar: TLLVMValueRef){.cdecl.}
|
||||
proc LLVMHasInitializer*(GlobalVar: TLLVMValueRef): int32{.cdecl.}
|
||||
proc LLVMGetInitializer*(GlobalVar: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMSetInitializer*(GlobalVar: TLLVMValueRef, ConstantVal: TLLVMValueRef){.
|
||||
cdecl.}
|
||||
proc LLVMIsThreadLocal*(GlobalVar: TLLVMValueRef): int32{.cdecl.}
|
||||
proc LLVMSetThreadLocal*(GlobalVar: TLLVMValueRef, IsThreadLocal: int32){.cdecl.}
|
||||
proc LLVMIsGlobalConstant*(GlobalVar: TLLVMValueRef): int32{.cdecl.}
|
||||
proc LLVMSetGlobalConstant*(GlobalVar: TLLVMValueRef, IsConstant: int32){.cdecl.}
|
||||
# Operations on functions
|
||||
# Const before type ignored
|
||||
proc LLVMAddFunction*(M: TLLVMModuleRef, Name: cstring, FunctionTy: TLLVMTypeRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
# Const before type ignored
|
||||
proc LLVMGetNamedFunction*(M: TLLVMModuleRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMDeleteFunction*(Fn: TLLVMValueRef){.cdecl.}
|
||||
proc LLVMCountParams*(Fn: TLLVMValueRef): cuint{.cdecl.}
|
||||
proc LLVMGetParams*(Fn: TLLVMValueRef, Params: PLLVMValueRef){.cdecl.}
|
||||
proc LLVMGetParam*(Fn: TLLVMValueRef, Index: cuint): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMGetIntrinsicID*(Fn: TLLVMValueRef): cuint{.cdecl.}
|
||||
proc LLVMGetFunctionCallConv*(Fn: TLLVMValueRef): cuint{.cdecl.}
|
||||
proc LLVMSetFunctionCallConv*(Fn: TLLVMValueRef, CC: cuint){.cdecl.}
|
||||
# Const before type ignored
|
||||
proc LLVMGetCollector*(Fn: TLLVMValueRef): cstring{.cdecl.}
|
||||
# Const before type ignored
|
||||
proc LLVMSetCollector*(Fn: TLLVMValueRef, Coll: cstring){.cdecl.}
|
||||
# Operations on basic blocks
|
||||
proc LLVMBasicBlockAsValue*(Bb: TLLVMBasicBlockRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMValueIsBasicBlock*(Val: TLLVMValueRef): int32{.cdecl.}
|
||||
proc LLVMValueAsBasicBlock*(Val: TLLVMValueRef): TLLVMBasicBlockRef{.cdecl.}
|
||||
proc LLVMCountBasicBlocks*(Fn: TLLVMValueRef): cuint{.cdecl.}
|
||||
proc LLVMGetBasicBlocks*(Fn: TLLVMValueRef, BasicBlocks: PLLVMBasicBlockRef){.
|
||||
cdecl.}
|
||||
proc LLVMGetEntryBasicBlock*(Fn: TLLVMValueRef): TLLVMBasicBlockRef{.cdecl.}
|
||||
# Const before type ignored
|
||||
proc LLVMAppendBasicBlock*(Fn: TLLVMValueRef, Name: cstring): TLLVMBasicBlockRef{.
|
||||
cdecl.}
|
||||
# Const before type ignored
|
||||
proc LLVMInsertBasicBlock*(InsertBeforeBB: TLLVMBasicBlockRef, Name: cstring): TLLVMBasicBlockRef{.
|
||||
cdecl.}
|
||||
proc LLVMDeleteBasicBlock*(BB: TLLVMBasicBlockRef){.cdecl.}
|
||||
# Operations on call sites
|
||||
proc LLVMSetInstructionCallConv*(Instr: TLLVMValueRef, CC: cuint){.cdecl.}
|
||||
proc LLVMGetInstructionCallConv*(Instr: TLLVMValueRef): cuint{.cdecl.}
|
||||
# Operations on phi nodes
|
||||
proc LLVMAddIncoming*(PhiNode: TLLVMValueRef, IncomingValues: PLLVMValueRef,
|
||||
IncomingBlocks: PLLVMBasicBlockRef, Count: cuint){.cdecl.}
|
||||
proc LLVMCountIncoming*(PhiNode: TLLVMValueRef): cuint{.cdecl.}
|
||||
proc LLVMGetIncomingValue*(PhiNode: TLLVMValueRef, Index: cuint): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMGetIncomingBlock*(PhiNode: TLLVMValueRef, Index: cuint): TLLVMBasicBlockRef{.
|
||||
cdecl.}
|
||||
#===-- Instruction builders ----------------------------------------------===
|
||||
# An instruction builder represents a point within a basic block, and is the
|
||||
# * exclusive means of building instructions using the C interface.
|
||||
#
|
||||
proc LLVMCreateBuilder*(): TLLVMBuilderRef{.cdecl.}
|
||||
proc LLVMPositionBuilderBefore*(Builder: TLLVMBuilderRef, Instr: TLLVMValueRef){.
|
||||
cdecl.}
|
||||
proc LLVMPositionBuilderAtEnd*(Builder: TLLVMBuilderRef,
|
||||
theBlock: TLLVMBasicBlockRef){.cdecl.}
|
||||
proc LLVMDisposeBuilder*(Builder: TLLVMBuilderRef){.cdecl.}
|
||||
# Terminators
|
||||
proc LLVMBuildRetVoid*(para1: TLLVMBuilderRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildRet*(para1: TLLVMBuilderRef, V: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildBr*(para1: TLLVMBuilderRef, Dest: TLLVMBasicBlockRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildCondBr*(para1: TLLVMBuilderRef, IfCond: TLLVMValueRef,
|
||||
ThenBranch: TLLVMBasicBlockRef,
|
||||
ElseBranch: TLLVMBasicBlockRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildSwitch*(para1: TLLVMBuilderRef, V: TLLVMValueRef,
|
||||
ElseBranch: TLLVMBasicBlockRef, NumCases: cuint): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
# Const before type ignored
|
||||
proc LLVMBuildInvoke*(para1: TLLVMBuilderRef, Fn: TLLVMValueRef,
|
||||
Args: PLLVMValueRef, NumArgs: cuint,
|
||||
ThenBranch: TLLVMBasicBlockRef, Catch: TLLVMBasicBlockRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildUnwind*(para1: TLLVMBuilderRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildUnreachable*(para1: TLLVMBuilderRef): TLLVMValueRef{.cdecl.}
|
||||
# Add a case to the switch instruction
|
||||
proc LLVMAddCase*(Switch: TLLVMValueRef, OnVal: TLLVMValueRef,
|
||||
Dest: TLLVMBasicBlockRef){.cdecl.}
|
||||
# Arithmetic
|
||||
proc LLVMBuildAdd*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildSub*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildMul*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildUDiv*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildSDiv*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildFDiv*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildURem*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildSRem*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildFRem*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildShl*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildLShr*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildAShr*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildAnd*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildOr*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildXor*(para1: TLLVMBuilderRef, LHS: TLLVMValueRef,
|
||||
RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildNeg*(para1: TLLVMBuilderRef, V: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildNot*(para1: TLLVMBuilderRef, V: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
# Memory
|
||||
proc LLVMBuildMalloc*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildArrayMalloc*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef,
|
||||
Val: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildAlloca*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildArrayAlloca*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef,
|
||||
Val: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildFree*(para1: TLLVMBuilderRef, PointerVal: TLLVMValueRef): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildLoad*(para1: TLLVMBuilderRef, PointerVal: TLLVMValueRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildStore*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
thePtr: TLLVMValueRef): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildGEP*(B: TLLVMBuilderRef, Pointer: TLLVMValueRef,
|
||||
Indices: PLLVMValueRef, NumIndices: cuint, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
# Casts
|
||||
proc LLVMBuildTrunc*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildZExt*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildSExt*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildFPToUI*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildFPToSI*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildUIToFP*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildSIToFP*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildFPTrunc*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildFPExt*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildPtrToInt*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildIntToPtr*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildBitCast*(para1: TLLVMBuilderRef, Val: TLLVMValueRef,
|
||||
DestTy: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
# Comparisons
|
||||
proc LLVMBuildICmp*(para1: TLLVMBuilderRef, Op: TLLVMIntPredicate,
|
||||
LHS: TLLVMValueRef, RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildFCmp*(para1: TLLVMBuilderRef, Op: TLLVMRealPredicate,
|
||||
LHS: TLLVMValueRef, RHS: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
# Miscellaneous instructions
|
||||
proc LLVMBuildPhi*(para1: TLLVMBuilderRef, Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildCall*(para1: TLLVMBuilderRef, Fn: TLLVMValueRef,
|
||||
Args: PLLVMValueRef, NumArgs: cuint, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildSelect*(para1: TLLVMBuilderRef, IfCond: TLLVMValueRef,
|
||||
ThenBranch: TLLVMValueRef, ElseBranch: TLLVMValueRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildVAArg*(para1: TLLVMBuilderRef, List: TLLVMValueRef,
|
||||
Ty: TLLVMTypeRef, Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildExtractElement*(para1: TLLVMBuilderRef, VecVal: TLLVMValueRef,
|
||||
Index: TLLVMValueRef, Name: cstring): TLLVMValueRef{.
|
||||
cdecl.}
|
||||
proc LLVMBuildInsertElement*(para1: TLLVMBuilderRef, VecVal: TLLVMValueRef,
|
||||
EltVal: TLLVMValueRef, Index: TLLVMValueRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
proc LLVMBuildShuffleVector*(para1: TLLVMBuilderRef, V1: TLLVMValueRef,
|
||||
V2: TLLVMValueRef, Mask: TLLVMValueRef,
|
||||
Name: cstring): TLLVMValueRef{.cdecl.}
|
||||
#===-- Module providers --------------------------------------------------===
|
||||
# Encapsulates the module M in a module provider, taking ownership of the
|
||||
# module.
|
||||
# See the constructor llvm: : ExistingModuleProvider: : ExistingModuleProvider.
|
||||
#
|
||||
proc LLVMCreateModuleProviderForExistingModule*(M: TLLVMModuleRef): TLLVMModuleProviderRef{.
|
||||
cdecl.}
|
||||
# Destroys the module provider MP as well as the contained module.
|
||||
# See the destructor llvm: : ModuleProvider: : ~ModuleProvider.
|
||||
#
|
||||
proc LLVMDisposeModuleProvider*(MP: TLLVMModuleProviderRef){.cdecl.}
|
||||
#===-- Memory buffers ----------------------------------------------------===
|
||||
proc LLVMCreateMemoryBufferWithContentsOfFile*(Path: cstring,
|
||||
OutMemBuf: pLLVMMemoryBufferRef, OutMessage: var cstring): int32{.cdecl.}
|
||||
proc LLVMCreateMemoryBufferWithSTDIN*(OutMemBuf: pLLVMMemoryBufferRef,
|
||||
OutMessage: var cstring): int32{.cdecl.}
|
||||
proc LLVMDisposeMemoryBuffer*(MemBuf: TLLVMMemoryBufferRef){.cdecl.}
|
||||
proc LLVMWriteBitcodeToFile*(M: TLLVMModuleRef, path: cstring): int{.cdecl.}
|
||||
# Writes a module to the specified path. Returns 0 on success.
|
||||
# implementation
|
||||
125
rod/llvmtype.nim
Normal file
125
rod/llvmtype.nim
Normal file
@@ -0,0 +1,125 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## Converts Nimrod types to LLVM types.
|
||||
|
||||
import llvm
|
||||
|
||||
proc intFromSize(size: int): TypeRef =
|
||||
case size
|
||||
of 8: result = llvm.Int64Type()
|
||||
of 4: result = llvm.Int32Type()
|
||||
of 2: result = llvm.Int16Type()
|
||||
of 1: result = llvm.Int8Type()
|
||||
else: InternalError("unknown type size")
|
||||
|
||||
type
|
||||
TPending = TTypeHandleMap
|
||||
|
||||
proc convertProcType(m: BModule, t: PType, pending: var TPending): TypeRef =
|
||||
|
||||
|
||||
proc simpleType(m: BModule, t: PType): TypeRef =
|
||||
case t.kind
|
||||
of tyBool, tyChar, tyInt8: result = llvm.Int8Type()
|
||||
of tyEnum:
|
||||
if firstOrd(t) < 0:
|
||||
result = llvm.Int32Type()
|
||||
else:
|
||||
case int(getSize(t))
|
||||
of 1: result = llvm.Int8Type()
|
||||
of 2: result = llvm.Int16Type()
|
||||
of 4: result = llvm.Int32Type()
|
||||
of 8: result = llvm.Int64Type()
|
||||
else: internalError(t.sym.info, "convertTypeAux")
|
||||
of tyInt: result = intFromSize(getSize(t))
|
||||
of tyInt16: result = llvm.Int16Type()
|
||||
of tyInt32: result = llvm.Int32Type()
|
||||
of tyInt64: result = llvm.Int64Type()
|
||||
of tyFloat, tyFloat64: result = llvm.DoubleType()
|
||||
of tyFloat32: result = llvm.FloatType()
|
||||
of tyCString, tyPointer, tyNil: result = llvm.PointerType(llvm.Int8Type())
|
||||
else: result = nil
|
||||
|
||||
proc convertTypeAux(m: BModule, t: PType, pending: var TPending): TypeRef =
|
||||
case t.kind
|
||||
of tyDistinct, tyRange:
|
||||
result = convertTypeAux(m, t.sons[0], pending)
|
||||
of tyArray:
|
||||
result = m.typeCache[t]
|
||||
if result == nil:
|
||||
var handle = pending[t]
|
||||
if handle == nil:
|
||||
handle = llvm.CreateTypeHandle(llvm.OpaqueType())
|
||||
pending[t] = handle
|
||||
result = llvm.ArrayType(ResolveTypeHandle(handle), int32(lengthOrd(t)))
|
||||
var elemConcrete = convertTypeAux(m, elemType(t), pending)
|
||||
# this may destroy the types!
|
||||
refineType(ResolveTypeHandle(handle), elemConcrete)
|
||||
|
||||
# elemConcrete is potentially invalidated, but handle
|
||||
# (a PATypeHolder) is kept up-to-date
|
||||
elemConcrete = ResolveTypeHandle(handle)
|
||||
|
||||
|
||||
else:
|
||||
# we are pending!
|
||||
result = ResolveTypeHandle(handle)
|
||||
# now we have the correct type:
|
||||
m.typeCache[t] = result
|
||||
of tyOpenArray:
|
||||
|
||||
of tySeq:
|
||||
|
||||
of tyObject:
|
||||
of tyTuple:
|
||||
|
||||
of tyProc:
|
||||
else: result = simpleType(m, t)
|
||||
|
||||
proc CreateTypeHandle*(PotentiallyAbstractTy: TypeRef): TypeHandleRef{.cdecl,
|
||||
dynlib: libname, importc: "LLVMCreateTypeHandle".}
|
||||
proc RefineType*(AbstractTy: TypeRef, ConcreteTy: TypeRef){.cdecl,
|
||||
dynlib: libname, importc: "LLVMRefineType".}
|
||||
proc ResolveTypeHandle*(TypeHandle: TypeHandleRef): TypeRef{.cdecl,
|
||||
dynlib: libname, importc: "LLVMResolveTypeHandle".}
|
||||
proc DisposeTypeHandle*(TypeHandle: TypeHandleRef){.cdecl, dynlib: libname,
|
||||
importc: "LLVMDisposeTypeHandle".}
|
||||
|
||||
|
||||
proc `!`*(m: BModule, t: PType): TypeRef =
|
||||
## converts a Nimrod type to an LLVM type. Since this is so common, we use
|
||||
## an infix operator for this.
|
||||
result = simpleType(m, t)
|
||||
if result == nil:
|
||||
var cl: TTypeMap
|
||||
init(cl)
|
||||
result = convertTypeAux(m, t, cl)
|
||||
|
||||
proc FunctionType*(ReturnType: TypeRef, ParamTypes: ptr TypeRef,
|
||||
ParamCount: int32, IsVarArg: int32): TypeRef {.
|
||||
cdecl, dynlib: libname, importc: "LLVMFunctionType".}
|
||||
|
||||
|
||||
proc VoidType*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMVoidType".}
|
||||
proc LabelType*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMLabelType".}
|
||||
proc OpaqueType*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMOpaqueType".}
|
||||
# Operations on type handles
|
||||
proc CreateTypeHandle*(PotentiallyAbstractTy: TypeRef): TypeHandleRef{.cdecl,
|
||||
dynlib: libname, importc: "LLVMCreateTypeHandle".}
|
||||
proc RefineType*(AbstractTy: TypeRef, ConcreteTy: TypeRef){.cdecl,
|
||||
dynlib: libname, importc: "LLVMRefineType".}
|
||||
proc ResolveTypeHandle*(TypeHandle: TypeHandleRef): TypeRef{.cdecl,
|
||||
dynlib: libname, importc: "LLVMResolveTypeHandle".}
|
||||
proc DisposeTypeHandle*(TypeHandle: TypeHandleRef){.cdecl, dynlib: libname,
|
||||
importc: "LLVMDisposeTypeHandle".}
|
||||
|
||||
|
||||
# m!typ, m!a[i]
|
||||
|
||||
72
rod/main.nim
72
rod/main.nim
@@ -13,9 +13,16 @@
|
||||
import
|
||||
llstream, strutils, ast, astalgo, scanner, syntaxes, rnimsyn, options, msgs,
|
||||
os, lists, condsyms, paslex, pasparse, rodread, rodwrite, ropes, trees,
|
||||
wordrecg, sem, semdata, idents, passes, docgen, extccomp, cgen, ecmasgen,
|
||||
wordrecg, sem, semdata, idents, passes, docgen, extccomp,
|
||||
cgen, ecmasgen,
|
||||
platform, interact, nimconf, importer, passaux, depends, transf, evals, types
|
||||
|
||||
const
|
||||
has_LLVM_Backend = false
|
||||
|
||||
when has_LLVM_Backend:
|
||||
import llvmgen
|
||||
|
||||
proc MainCommand*(cmd, filename: string)
|
||||
# implementation
|
||||
# ------------------ module handling -----------------------------------------
|
||||
@@ -114,6 +121,14 @@ proc CommandCompileToC(filename: string) =
|
||||
compileProject(filename)
|
||||
extccomp.CallCCompiler(changeFileExt(filename, ""))
|
||||
|
||||
when has_LLVM_Backend:
|
||||
proc CommandCompileToLLVM(filename: string) =
|
||||
semanticPasses()
|
||||
registerPass(llvmgen.llvmgenPass())
|
||||
registerPass(rodwrite.rodwritePass())
|
||||
#registerPass(cleanupPass())
|
||||
compileProject(filename)
|
||||
|
||||
proc CommandCompileToEcmaScript(filename: string) =
|
||||
incl(gGlobalOptions, optSafeCode)
|
||||
setTarget(osEcmaScript, cpuEcmaScript)
|
||||
@@ -139,10 +154,8 @@ proc CommandInteractive() =
|
||||
|
||||
proc exSymbols(n: PNode) =
|
||||
case n.kind
|
||||
of nkEmpty..nkNilLit:
|
||||
nil
|
||||
of nkProcDef..nkIteratorDef:
|
||||
exSymbol(n.sons[namePos])
|
||||
of nkEmpty..nkNilLit: nil
|
||||
of nkProcDef..nkIteratorDef: exSymbol(n.sons[namePos])
|
||||
of nkWhenStmt, nkStmtList:
|
||||
for i in countup(0, sonsLen(n) - 1): exSymbols(n.sons[i])
|
||||
of nkVarSection, nkConstSection:
|
||||
@@ -153,8 +166,7 @@ proc exSymbols(n: PNode) =
|
||||
if (n.sons[i].sons[2] != nil) and
|
||||
(n.sons[i].sons[2].kind == nkObjectTy):
|
||||
fixRecordDef(n.sons[i].sons[2])
|
||||
else:
|
||||
nil
|
||||
else: nil
|
||||
|
||||
proc CommandExportSymbols(filename: string) =
|
||||
# now unused!
|
||||
@@ -171,49 +183,40 @@ proc CommandPretty(filename: string) =
|
||||
renderModule(module, getOutFile(filename, "pretty." & NimExt))
|
||||
|
||||
proc CommandLexPas(filename: string) =
|
||||
var
|
||||
L: TPasLex
|
||||
tok: TPasTok
|
||||
f: string
|
||||
stream: PLLStream
|
||||
f = addFileExt(filename, "pas")
|
||||
stream = LLStreamOpen(f, fmRead)
|
||||
var f = addFileExt(filename, "pas")
|
||||
var stream = LLStreamOpen(f, fmRead)
|
||||
if stream != nil:
|
||||
var
|
||||
L: TPasLex
|
||||
tok: TPasTok
|
||||
OpenLexer(L, f, stream)
|
||||
getPasTok(L, tok)
|
||||
while tok.xkind != pxEof:
|
||||
printPasTok(tok)
|
||||
getPasTok(L, tok)
|
||||
else:
|
||||
rawMessage(errCannotOpenFile, f)
|
||||
closeLexer(L)
|
||||
closeLexer(L)
|
||||
else: rawMessage(errCannotOpenFile, f)
|
||||
|
||||
proc CommandPas(filename: string) =
|
||||
var
|
||||
p: TPasParser
|
||||
module: PNode
|
||||
f: string
|
||||
stream: PLLStream
|
||||
f = addFileExt(filename, "pas")
|
||||
stream = LLStreamOpen(f, fmRead)
|
||||
var f = addFileExt(filename, "pas")
|
||||
var stream = LLStreamOpen(f, fmRead)
|
||||
if stream != nil:
|
||||
var p: TPasParser
|
||||
OpenPasParser(p, f, stream)
|
||||
module = parseUnit(p)
|
||||
var module = parseUnit(p)
|
||||
closePasParser(p)
|
||||
renderModule(module, getOutFile(filename, NimExt))
|
||||
else:
|
||||
rawMessage(errCannotOpenFile, f)
|
||||
|
||||
proc CommandScan(filename: string) =
|
||||
var
|
||||
L: TLexer
|
||||
tok: PToken
|
||||
f: string
|
||||
stream: PLLStream
|
||||
new(tok)
|
||||
f = addFileExt(filename, nimExt)
|
||||
stream = LLStreamOpen(f, fmRead)
|
||||
var f = addFileExt(filename, nimExt)
|
||||
var stream = LLStreamOpen(f, fmRead)
|
||||
if stream != nil:
|
||||
var
|
||||
L: TLexer
|
||||
tok: PToken
|
||||
new(tok)
|
||||
openLexer(L, f, stream)
|
||||
while true:
|
||||
rawGetTok(L, tok^)
|
||||
@@ -252,7 +255,8 @@ proc MainCommand(cmd, filename: string) =
|
||||
of wCompileToLLVM:
|
||||
gCmd = cmdCompileToLLVM
|
||||
wantFile(filename)
|
||||
CommandCompileToC(filename)
|
||||
when has_LLVM_Backend:
|
||||
CommandCompileToLLVM(filename)
|
||||
of wPretty:
|
||||
gCmd = cmdPretty
|
||||
wantFile(filename) #CommandExportSymbols(filename);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Special configuration file for the Nimrod project
|
||||
|
||||
--hint[XDeclaredButNotUsed]=off
|
||||
path="llvm"
|
||||
|
||||
@if llvm_gcc or gcc:
|
||||
# GCC, LLVM and Visual C++ have a problem to optimize some modules.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2008 Andreas Rumpf
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
@@ -15,6 +15,6 @@ const
|
||||
defaultAsmMarkerSymbol* = '!'
|
||||
VersionMajor* = 0
|
||||
VersionMinor* = 8
|
||||
VersionPatch* = 6
|
||||
VersionPatch* = 7
|
||||
VersionAsString* = $VersionMajor & "." & $VersionMinor & "." & $VersionPatch
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ var
|
||||
libpath*: string = ""
|
||||
projectPath*: string = ""
|
||||
gKeepComments*: bool = true # whether the parser needs to keep comments
|
||||
gImplicitMods*: TStringSeq = @ [] # modules that are to be implicitly imported
|
||||
gImplicitMods*: TStringSeq = @[] # modules that are to be implicitly imported
|
||||
|
||||
proc existsConfigVar*(key: string): bool
|
||||
proc getConfigVar*(key: string): string
|
||||
@@ -128,19 +128,19 @@ proc shortenDir(dir: string): string =
|
||||
# returns the interesting part of a dir
|
||||
var prefix = getPrefixDir() & dirSep
|
||||
if startsWith(dir, prefix):
|
||||
return copy(dir, len(prefix) + 0)
|
||||
return copy(dir, len(prefix))
|
||||
prefix = getCurrentDir() & dirSep
|
||||
if startsWith(dir, prefix):
|
||||
return copy(dir, len(prefix) + 0)
|
||||
return copy(dir, len(prefix))
|
||||
prefix = projectPath & dirSep #writeln(output, prefix);
|
||||
#writeln(output, dir);
|
||||
if startsWith(dir, prefix):
|
||||
return copy(dir, len(prefix) + 0)
|
||||
return copy(dir, len(prefix))
|
||||
result = dir
|
||||
|
||||
proc removeTrailingDirSep(path: string): string =
|
||||
if (len(path) > 0) and (path[len(path) + 0 - 1] == dirSep):
|
||||
result = copy(path, 0, len(path) + 0 - 2)
|
||||
if (len(path) > 0) and (path[len(path) - 1] == dirSep):
|
||||
result = copy(path, 0, len(path) - 2)
|
||||
else:
|
||||
result = path
|
||||
|
||||
@@ -162,11 +162,10 @@ proc completeGeneratedFilePath(f: string, createSubDir: bool = true): string =
|
||||
result = joinPath(subdir, tail)
|
||||
|
||||
proc rawFindFile(f: string): string =
|
||||
var it: PStrEntry
|
||||
if ExistsFile(f):
|
||||
result = f
|
||||
else:
|
||||
it = PStrEntry(SearchPaths.head)
|
||||
var it = PStrEntry(SearchPaths.head)
|
||||
while it != nil:
|
||||
result = JoinPath(it.data, f)
|
||||
if ExistsFile(result): return
|
||||
|
||||
@@ -177,19 +177,24 @@ proc parseSymbol(p: var TParser): PNode =
|
||||
of tkBracketLe:
|
||||
var s = "["
|
||||
getTok(p)
|
||||
if (p.tok.tokType == tkOpr) and (p.tok.ident.s == "$"):
|
||||
s = s & "$.."
|
||||
getTok(p)
|
||||
eat(p, tkDotDot)
|
||||
if (p.tok.tokType == tkOpr) and (p.tok.ident.s == "$"):
|
||||
add(s, '$')
|
||||
while true:
|
||||
if p.tok.tokType == tkComma:
|
||||
add(s, ",")
|
||||
getTok(p)
|
||||
elif p.tok.tokType == tkDotDot:
|
||||
s = s & ".."
|
||||
getTok(p)
|
||||
if (p.tok.tokType == tkOpr) and (p.tok.ident.s == "$"):
|
||||
add(s, '$')
|
||||
elif (p.tok.tokType == tkOpr) and (p.tok.ident.s == "$"):
|
||||
add(s, "$..")
|
||||
getTok(p)
|
||||
eat(p, tkDotDot)
|
||||
if (p.tok.tokType == tkOpr) and (p.tok.ident.s == "$"):
|
||||
add(s, '$')
|
||||
getTok(p)
|
||||
elif p.tok.tokType == tkDotDot:
|
||||
add(s, "..")
|
||||
getTok(p)
|
||||
if (p.tok.tokType == tkOpr) and (p.tok.ident.s == "$"):
|
||||
add(s, '$')
|
||||
getTok(p)
|
||||
else: break
|
||||
eat(p, tkBracketRi)
|
||||
add(s, ']')
|
||||
if p.tok.tokType == tkEquals:
|
||||
|
||||
137
rod/ropes.nim
137
rod/ropes.nim
@@ -221,75 +221,59 @@ proc RopeSeqInsert(rs: var TRopeSeq, r: PRope, at: Natural) =
|
||||
rs[i] = rs[i - 1] # this is correct, I used pen and paper to validate it
|
||||
rs[at] = r
|
||||
|
||||
proc con(a, b: PRope): PRope =
|
||||
assert(RopeInvariant(a))
|
||||
assert(RopeInvariant(b))
|
||||
if a == nil:
|
||||
result = b
|
||||
elif b == nil:
|
||||
result = a
|
||||
proc recRopeToStr(result: var string, resultLen: var int, p: PRope) =
|
||||
if p == nil:
|
||||
return # do not add to result
|
||||
if (p.data == nil):
|
||||
recRopeToStr(result, resultLen, p.left)
|
||||
recRopeToStr(result, resultLen, p.right)
|
||||
else:
|
||||
CopyMem(addr(result[resultLen + 0]), addr(p.data[0]), p.length)
|
||||
Inc(resultLen, p.length)
|
||||
assert(resultLen <= len(result))
|
||||
|
||||
proc newRecRopeToStr(result: var string, resultLen: var int, r: PRope) =
|
||||
var stack = @[r]
|
||||
while len(stack) > 0:
|
||||
var it = pop(stack)
|
||||
while it.data == nil:
|
||||
add(stack, it.right)
|
||||
it = it.left
|
||||
assert(it.data != nil)
|
||||
CopyMem(addr(result[resultLen]), addr(it.data[0]), it.length)
|
||||
Inc(resultLen, it.length)
|
||||
assert(resultLen <= len(result))
|
||||
|
||||
proc ropeToStr(p: PRope): string =
|
||||
if p == nil:
|
||||
result = ""
|
||||
else:
|
||||
result = newString(p.length)
|
||||
var resultLen = 0
|
||||
newRecRopeToStr(result, resultLen, p)
|
||||
|
||||
proc con(a, b: PRope): PRope =
|
||||
if a == nil: result = b
|
||||
elif b == nil: result = a
|
||||
else:
|
||||
result = newRope()
|
||||
result.length = a.length + b.length
|
||||
result.left = a
|
||||
result.right = b
|
||||
assert(RopeInvariant(result))
|
||||
|
||||
proc con(a: PRope, b: string): PRope =
|
||||
assert(RopeInvariant(a))
|
||||
if b == "":
|
||||
result = a
|
||||
else:
|
||||
var r = toRope(b)
|
||||
if a == nil:
|
||||
result = r
|
||||
else:
|
||||
result = newRope()
|
||||
result.length = a.length + r.length
|
||||
result.left = a
|
||||
result.right = r
|
||||
assert(RopeInvariant(result))
|
||||
|
||||
proc con(a: string, b: PRope): PRope =
|
||||
assert(RopeInvariant(b))
|
||||
if a == "":
|
||||
result = b
|
||||
else:
|
||||
var r = toRope(a)
|
||||
if b == nil:
|
||||
result = r
|
||||
else:
|
||||
result = newRope()
|
||||
result.length = b.length + r.length
|
||||
result.left = r
|
||||
result.right = b
|
||||
assert(RopeInvariant(result))
|
||||
proc con(a: PRope, b: string): PRope = result = con(a, toRope(b))
|
||||
proc con(a: string, b: PRope): PRope = result = con(toRope(a), b)
|
||||
|
||||
proc con(a: openarray[PRope]): PRope =
|
||||
result = nil
|
||||
for i in countup(0, high(a)): result = con(result, a[i])
|
||||
assert(RopeInvariant(result))
|
||||
|
||||
proc toRope(i: BiggestInt): PRope =
|
||||
result = toRope($(i))
|
||||
|
||||
proc toRopeF(r: BiggestFloat): PRope =
|
||||
result = toRope($(r))
|
||||
|
||||
proc app(a: var PRope, b: PRope) =
|
||||
a = con(a, b)
|
||||
assert(RopeInvariant(a))
|
||||
|
||||
proc app(a: var PRope, b: string) =
|
||||
a = con(a, b)
|
||||
assert(RopeInvariant(a))
|
||||
|
||||
proc prepend(a: var PRope, b: PRope) =
|
||||
a = con(b, a)
|
||||
assert(RopeInvariant(a))
|
||||
proc toRope(i: BiggestInt): PRope = result = toRope($i)
|
||||
proc toRopeF(r: BiggestFloat): PRope = result = toRope($r)
|
||||
proc app(a: var PRope, b: PRope) = a = con(a, b)
|
||||
proc app(a: var PRope, b: string) = a = con(a, b)
|
||||
proc prepend(a: var PRope, b: PRope) = a = con(b, a)
|
||||
|
||||
proc WriteRopeRec(f: var tfile, c: PRope) =
|
||||
assert(RopeInvariant(c))
|
||||
if c == nil: return
|
||||
if (c.data != nil):
|
||||
write(f, c.data)
|
||||
@@ -298,7 +282,7 @@ proc WriteRopeRec(f: var tfile, c: PRope) =
|
||||
writeRopeRec(f, c.right)
|
||||
|
||||
proc newWriteRopeRec(f: var tfile, c: PRope) =
|
||||
var stack: TRopeSeq = @[c]
|
||||
var stack = @[c]
|
||||
while len(stack) > 0:
|
||||
var it = pop(stack)
|
||||
while it.data == nil:
|
||||
@@ -315,37 +299,6 @@ proc WriteRope(head: PRope, filename: string) =
|
||||
close(f)
|
||||
else:
|
||||
rawMessage(errCannotOpenFile, filename)
|
||||
|
||||
proc recRopeToStr(result: var string, resultLen: var int, p: PRope) =
|
||||
if p == nil:
|
||||
return # do not add to result
|
||||
if (p.data == nil):
|
||||
recRopeToStr(result, resultLen, p.left)
|
||||
recRopeToStr(result, resultLen, p.right)
|
||||
else:
|
||||
CopyMem(addr(result[resultLen + 0]), addr(p.data[0]), p.length)
|
||||
Inc(resultLen, p.length)
|
||||
assert(resultLen <= len(result))
|
||||
|
||||
proc newRecRopeToStr(result: var string, resultLen: var int, r: PRope) =
|
||||
var stack: TRopeSeq = @[r]
|
||||
while len(stack) > 0:
|
||||
var it = pop(stack)
|
||||
while it.data == nil:
|
||||
add(stack, it.right)
|
||||
it = it.left
|
||||
assert(it.data != nil)
|
||||
CopyMem(addr(result[resultLen + 0]), addr(it.data[0]), it.length)
|
||||
Inc(resultLen, it.length)
|
||||
assert(resultLen <= len(result))
|
||||
|
||||
proc ropeToStr(p: PRope): string =
|
||||
if p == nil:
|
||||
result = ""
|
||||
else:
|
||||
result = newString(p.length)
|
||||
var resultLen = 0
|
||||
newRecRopeToStr(result, resultLen, p)
|
||||
|
||||
proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||
var i, j, length, start, num: int
|
||||
@@ -353,7 +306,7 @@ proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||
length = len(frmt)
|
||||
result = nil
|
||||
num = 0
|
||||
while i <= length + 0 - 1:
|
||||
while i <= length - 1:
|
||||
if frmt[i] == '$':
|
||||
inc(i) # skip '$'
|
||||
case frmt[i]
|
||||
@@ -379,7 +332,7 @@ proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||
inc(i)
|
||||
else: InternalError("ropes: invalid format string $" & frmt[i])
|
||||
start = i
|
||||
while (i <= length + 0 - 1):
|
||||
while (i <= length - 1):
|
||||
if (frmt[i] != '$'): inc(i)
|
||||
else: break
|
||||
if i - 1 >= start:
|
||||
@@ -418,7 +371,7 @@ proc RopeEqualsFile(r: PRope, f: string): bool =
|
||||
proc crcFromRopeAux(r: PRope, startVal: TCrc32): TCrc32 =
|
||||
if r.data != nil:
|
||||
result = startVal
|
||||
for i in countup(0, len(r.data) + 0 - 1):
|
||||
for i in countup(0, len(r.data) - 1):
|
||||
result = updateCrc32(r.data[i], result)
|
||||
else:
|
||||
result = crcFromRopeAux(r.left, startVal)
|
||||
|
||||
@@ -44,6 +44,7 @@ proc semIdentVis(c: PContext, kind: TSymKind, n: PNode, allowed: TSymFlags): PSy
|
||||
proc semIdentWithPragma(c: PContext, kind: TSymKind, n: PNode,
|
||||
allowed: TSymFlags): PSym
|
||||
proc semStmtScope(c: PContext, n: PNode): PNode
|
||||
|
||||
type
|
||||
TExprFlag = enum
|
||||
efAllowType, efLValue, efWantIterator
|
||||
|
||||
476
rod/semexprs.nim
476
rod/semexprs.nim
@@ -1,21 +1,26 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
# this module does the semantic checking for expressions
|
||||
|
||||
proc semTemplateExpr(c: PContext, n: PNode, s: PSym, semCheck: bool = true): PNode =
|
||||
# this module does the semantic checking for expressions
|
||||
const
|
||||
ConstAbstractTypes = {tyNil, tyChar, tyInt..tyInt64, tyFloat..tyFloat128,
|
||||
tyArrayConstr, tyTuple, tySet}
|
||||
|
||||
proc semTemplateExpr(c: PContext, n: PNode, s: PSym,
|
||||
semCheck: bool = true): PNode =
|
||||
markUsed(n, s)
|
||||
pushInfoContext(n.info)
|
||||
result = evalTemplate(c, n, s)
|
||||
if semCheck: result = semAfterMacroCall(c, result, s)
|
||||
popInfoContext()
|
||||
|
||||
proc semDotExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode
|
||||
proc semFieldAccess(c: PContext, n: PNode, flags: TExprFlags = {}): PNode
|
||||
proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
var d: PNode
|
||||
result = semExpr(c, n, flags)
|
||||
@@ -27,9 +32,59 @@ proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
addSon(d, result)
|
||||
result = d
|
||||
|
||||
proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||
if s.kind == skType and efAllowType notin flags:
|
||||
liMessage(n.info, errATypeHasNoValue)
|
||||
case s.kind
|
||||
of skProc, skMethod, skIterator, skConverter:
|
||||
if not (sfProcVar in s.flags) and (s.typ.callConv == ccDefault) and
|
||||
(getModule(s).id != c.module.id):
|
||||
liMessage(n.info, warnXisPassedToProcVar, s.name.s)
|
||||
# XXX change this to
|
||||
# errXCannotBePassedToProcVar after version 0.8.2
|
||||
# TODO VERSION 0.8.4
|
||||
#if (s.magic <> mNone) then
|
||||
# liMessage(n.info,
|
||||
# errInvalidContextForBuiltinX, s.name.s);
|
||||
result = symChoice(c, n, s)
|
||||
of skConst:
|
||||
#
|
||||
# Consider::
|
||||
# const x = []
|
||||
# proc p(a: openarray[int])
|
||||
# proc q(a: openarray[char])
|
||||
# p(x)
|
||||
# q(x)
|
||||
#
|
||||
# It is clear that ``[]`` means two totally different things. Thus, we
|
||||
# copy `x`'s AST into each context, so that the type fixup phase can
|
||||
# deal with two different ``[]``.
|
||||
#
|
||||
markUsed(n, s)
|
||||
if s.typ.kind in ConstAbstractTypes:
|
||||
result = copyTree(s.ast)
|
||||
result.typ = s.typ
|
||||
else:
|
||||
result = newSymNode(s)
|
||||
result.info = n.info
|
||||
of skMacro: result = semMacroExpr(c, n, s)
|
||||
of skTemplate: result = semTemplateExpr(c, n, s)
|
||||
of skVar:
|
||||
markUsed(n, s)
|
||||
# if a proc accesses a global variable, it is not side effect free:
|
||||
if sfGlobal in s.flags: incl(c.p.owner.flags, sfSideEffect)
|
||||
result = newSymNode(s)
|
||||
result.info = n.info
|
||||
of skGenericParam:
|
||||
if s.ast == nil: InternalError(n.info, "no default for")
|
||||
result = semExpr(c, s.ast)
|
||||
else:
|
||||
markUsed(n, s)
|
||||
result = newSymNode(s)
|
||||
result.info = n.info
|
||||
|
||||
proc checkConversionBetweenObjects(info: TLineInfo, castDest, src: PType) =
|
||||
var diff: int
|
||||
diff = inheritanceDiff(castDest, src)
|
||||
var diff = inheritanceDiff(castDest, src)
|
||||
if diff == high(int):
|
||||
liMessage(info, errGenerated, `%`(MsgKindToString(errIllegalConvFromXtoY), [
|
||||
typeToString(src), typeToString(castDest)]))
|
||||
@@ -37,14 +92,13 @@ proc checkConversionBetweenObjects(info: TLineInfo, castDest, src: PType) =
|
||||
proc checkConvertible(info: TLineInfo, castDest, src: PType) =
|
||||
const
|
||||
IntegralTypes = {tyBool, tyEnum, tyChar, tyInt..tyFloat128}
|
||||
var d, s: PType
|
||||
if sameType(castDest, src):
|
||||
# don't annoy conversions that may be needed on another processor:
|
||||
if not (castDest.kind in {tyInt..tyFloat128, tyNil}):
|
||||
liMessage(info, hintConvFromXtoItselfNotNeeded, typeToString(castDest))
|
||||
return
|
||||
d = skipTypes(castDest, abstractVar)
|
||||
s = skipTypes(src, abstractVar)
|
||||
var d = skipTypes(castDest, abstractVar)
|
||||
var s = skipTypes(src, abstractVar)
|
||||
while (d != nil) and (d.Kind in {tyPtr, tyRef}) and (d.Kind == s.Kind):
|
||||
d = base(d)
|
||||
s = base(s)
|
||||
@@ -87,13 +141,12 @@ proc isCastable(dst, src: PType): bool =
|
||||
(skipTypes(src, abstractInst).kind in {tyInt..tyFloat128})
|
||||
|
||||
proc semConv(c: PContext, n: PNode, s: PSym): PNode =
|
||||
var op: PNode
|
||||
if sonsLen(n) != 2: liMessage(n.info, errConvNeedsOneArg)
|
||||
result = newNodeI(nkConv, n.info)
|
||||
result.typ = semTypeNode(c, n.sons[0], nil)
|
||||
addSon(result, copyTree(n.sons[0]))
|
||||
addSon(result, semExprWithType(c, n.sons[1]))
|
||||
op = result.sons[1]
|
||||
var op = result.sons[1]
|
||||
if op.kind != nkSymChoice:
|
||||
checkConvertible(result.info, result.typ, op.typ)
|
||||
else:
|
||||
@@ -117,12 +170,11 @@ proc semCast(c: PContext, n: PNode): PNode =
|
||||
proc semLowHigh(c: PContext, n: PNode, m: TMagic): PNode =
|
||||
const
|
||||
opToStr: array[mLow..mHigh, string] = ["low", "high"]
|
||||
var typ: PType
|
||||
if sonsLen(n) != 2:
|
||||
liMessage(n.info, errXExpectsTypeOrValue, opToStr[m])
|
||||
else:
|
||||
n.sons[1] = semExprWithType(c, n.sons[1], {efAllowType})
|
||||
typ = skipTypes(n.sons[1].typ, abstractVarRange)
|
||||
var typ = skipTypes(n.sons[1].typ, abstractVarRange)
|
||||
case typ.Kind
|
||||
of tySequence, tyString, tyOpenArray:
|
||||
n.typ = getSysType(tyInt)
|
||||
@@ -140,12 +192,11 @@ proc semSizeof(c: PContext, n: PNode): PNode =
|
||||
result = n
|
||||
|
||||
proc semIs(c: PContext, n: PNode): PNode =
|
||||
var a, b: PType
|
||||
if sonsLen(n) == 3:
|
||||
n.sons[1] = semExprWithType(c, n.sons[1], {efAllowType})
|
||||
n.sons[2] = semExprWithType(c, n.sons[2], {efAllowType})
|
||||
a = n.sons[1].typ
|
||||
b = n.sons[2].typ
|
||||
var a = n.sons[1].typ
|
||||
var b = n.sons[2].typ
|
||||
if (b.kind != tyObject) or (a.kind != tyObject):
|
||||
liMessage(n.info, errIsExpectsObjectTypes)
|
||||
while (b != nil) and (b.id != a.id): b = b.sons[0]
|
||||
@@ -156,14 +207,11 @@ proc semIs(c: PContext, n: PNode): PNode =
|
||||
result = n
|
||||
|
||||
proc semOpAux(c: PContext, n: PNode) =
|
||||
var
|
||||
a: PNode
|
||||
info: TLineInfo
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
a = n.sons[i]
|
||||
var a = n.sons[i]
|
||||
if a.kind == nkExprEqExpr:
|
||||
checkSonsLen(a, 2)
|
||||
info = a.sons[0].info
|
||||
var info = a.sons[0].info
|
||||
a.sons[0] = newIdentNode(considerAcc(a.sons[0]), info)
|
||||
a.sons[1] = semExprWithType(c, a.sons[1])
|
||||
a.typ = a.sons[1].typ
|
||||
@@ -171,9 +219,8 @@ proc semOpAux(c: PContext, n: PNode) =
|
||||
n.sons[i] = semExprWithType(c, a)
|
||||
|
||||
proc overloadedCallOpr(c: PContext, n: PNode): PNode =
|
||||
var par: PIdent
|
||||
# quick check if there is *any* () operator overloaded:
|
||||
par = getIdent("()")
|
||||
var par = getIdent("()")
|
||||
if SymtabGet(c.Tab, par) == nil:
|
||||
result = nil
|
||||
else:
|
||||
@@ -214,7 +261,6 @@ proc changeType(n: PNode, newType: PType) =
|
||||
n.typ = newType
|
||||
|
||||
proc semArrayConstr(c: PContext, n: PNode): PNode =
|
||||
var typ: PType
|
||||
result = newNodeI(nkBracket, n.info)
|
||||
result.typ = newTypeS(tyArrayConstr, c)
|
||||
addSon(result.typ, nil) # index type
|
||||
@@ -222,29 +268,22 @@ proc semArrayConstr(c: PContext, n: PNode): PNode =
|
||||
addSon(result.typ, newTypeS(tyEmpty, c)) # needs an empty basetype!
|
||||
else:
|
||||
addSon(result, semExprWithType(c, n.sons[0]))
|
||||
typ = skipTypes(result.sons[0].typ, {tyGenericInst, tyVar, tyOrdinal})
|
||||
var typ = skipTypes(result.sons[0].typ, {tyGenericInst, tyVar, tyOrdinal})
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
n.sons[i] = semExprWithType(c, n.sons[i])
|
||||
addSon(result, fitNode(c, typ, n.sons[i]))
|
||||
addSon(result.typ, typ)
|
||||
result.typ.sons[0] = makeRangeType(c, 0, sonsLen(result) - 1, n.info)
|
||||
|
||||
const
|
||||
ConstAbstractTypes = {tyNil, tyChar, tyInt..tyInt64, tyFloat..tyFloat128,
|
||||
tyArrayConstr, tyTuple, tySet}
|
||||
|
||||
proc fixAbstractType(c: PContext, n: PNode) =
|
||||
var
|
||||
s: PType
|
||||
it: PNode
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
it = n.sons[i]
|
||||
var it = n.sons[i]
|
||||
case it.kind
|
||||
of nkHiddenStdConv, nkHiddenSubConv:
|
||||
if it.sons[1].kind == nkBracket:
|
||||
it.sons[1] = semArrayConstr(c, it.sons[1])
|
||||
if skipTypes(it.typ, abstractVar).kind == tyOpenArray:
|
||||
s = skipTypes(it.sons[1].typ, abstractVar)
|
||||
var s = skipTypes(it.sons[1].typ, abstractVar)
|
||||
if (s.kind == tyArrayConstr) and (s.sons[1].kind == tyEmpty):
|
||||
s = copyType(s, getCurrOwner(), false)
|
||||
skipTypes(s, abstractVar).sons[1] = elemType(
|
||||
@@ -252,7 +291,7 @@ proc fixAbstractType(c: PContext, n: PNode) =
|
||||
it.sons[1].typ = s
|
||||
elif skipTypes(it.sons[1].typ, abstractVar).kind in
|
||||
{tyNil, tyArrayConstr, tyTuple, tySet}:
|
||||
s = skipTypes(it.typ, abstractVar)
|
||||
var s = skipTypes(it.typ, abstractVar)
|
||||
changeType(it.sons[1], s)
|
||||
n.sons[i] = it.sons[1]
|
||||
of nkBracket:
|
||||
@@ -269,8 +308,7 @@ proc skipObjConv(n: PNode): PNode =
|
||||
result = n.sons[1]
|
||||
else:
|
||||
result = n
|
||||
of nkObjUpConv, nkObjDownConv:
|
||||
result = n.sons[0]
|
||||
of nkObjUpConv, nkObjDownConv: result = n.sons[0]
|
||||
else: result = n
|
||||
|
||||
type
|
||||
@@ -347,9 +385,8 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
||||
FakeVarParams = {mNew, mNewFinalize, mInc, ast.mDec, mIncl, mExcl,
|
||||
mSetLengthStr, mSetLengthSeq, mAppendStrCh, mAppendStrStr, mSwap,
|
||||
mAppendSeqElem, mNewSeq}
|
||||
var t: PType
|
||||
checkMinSonsLen(n, 1)
|
||||
t = n.sons[0].typ
|
||||
var t = n.sons[0].typ
|
||||
if (n.sons[0].kind == nkSym) and (n.sons[0].sym.magic in FakeVarParams):
|
||||
return
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
@@ -357,8 +394,8 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
||||
(skipTypes(t.sons[i], abstractInst).kind == tyVar):
|
||||
n.sons[i] = analyseIfAddressTaken(c, n.sons[i])
|
||||
|
||||
proc semDirectCallAnalyseEffects(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
var callee: PSym
|
||||
proc semDirectCallAnalyseEffects(c: PContext, n: PNode,
|
||||
flags: TExprFlags): PNode =
|
||||
if not (efWantIterator in flags):
|
||||
result = semDirectCall(c, n, {skProc, skMethod, skConverter})
|
||||
else:
|
||||
@@ -366,7 +403,7 @@ proc semDirectCallAnalyseEffects(c: PContext, n: PNode, flags: TExprFlags): PNod
|
||||
if result != nil:
|
||||
if result.sons[0].kind != nkSym:
|
||||
InternalError("semDirectCallAnalyseEffects")
|
||||
callee = result.sons[0].sym
|
||||
var callee = result.sons[0].sym
|
||||
if (callee.kind == skIterator) and (callee.id == c.p.owner.id):
|
||||
liMessage(n.info, errRecursiveDependencyX, callee.name.s)
|
||||
if not (sfNoSideEffect in callee.flags):
|
||||
@@ -375,17 +412,12 @@ proc semDirectCallAnalyseEffects(c: PContext, n: PNode, flags: TExprFlags): PNod
|
||||
incl(c.p.owner.flags, sfSideEffect)
|
||||
|
||||
proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
var
|
||||
m: TCandidate
|
||||
msg: string
|
||||
prc: PNode
|
||||
t: PType
|
||||
result = nil
|
||||
prc = n.sons[0]
|
||||
var prc = n.sons[0]
|
||||
checkMinSonsLen(n, 1)
|
||||
if n.sons[0].kind == nkDotExpr:
|
||||
checkSonsLen(n.sons[0], 2)
|
||||
n.sons[0] = semDotExpr(c, n.sons[0])
|
||||
n.sons[0] = semFieldAccess(c, n.sons[0])
|
||||
if n.sons[0].kind == nkDotCall:
|
||||
# it is a static call!
|
||||
result = n.sons[0]
|
||||
@@ -395,27 +427,30 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
else:
|
||||
n.sons[0] = semExpr(c, n.sons[0])
|
||||
semOpAux(c, n)
|
||||
var t: PType = nil
|
||||
if (n.sons[0].typ != nil): t = skipTypes(n.sons[0].typ, abstractInst)
|
||||
else: t = nil
|
||||
if (t != nil) and (t.kind == tyProc):
|
||||
var m: TCandidate
|
||||
initCandidate(m, t)
|
||||
matches(c, n, m)
|
||||
if m.state != csMatch:
|
||||
msg = msgKindToString(errTypeMismatch)
|
||||
var msg = msgKindToString(errTypeMismatch)
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
if i > 1: add(msg, ", ")
|
||||
add(msg, typeToString(n.sons[i].typ))
|
||||
add(msg, ')' & "\n" & msgKindToString(errButExpected) & "\n" &
|
||||
add(msg, ")\n" & msgKindToString(errButExpected) & "\n" &
|
||||
typeToString(n.sons[0].typ))
|
||||
liMessage(n.Info, errGenerated, msg)
|
||||
result = nil
|
||||
else:
|
||||
result = m.call # we assume that a procedure that calls something indirectly
|
||||
# has side-effects:
|
||||
result = m.call
|
||||
# we assume that a procedure that calls something indirectly
|
||||
# has side-effects:
|
||||
if not (tfNoSideEffect in t.flags): incl(c.p.owner.flags, sfSideEffect)
|
||||
else:
|
||||
result = overloadedCallOpr(c, n) # Now that nkSym does not imply an iteration over the proc/iterator space,
|
||||
# the old ``prc`` (which is likely an nkIdent) has to be restored:
|
||||
result = overloadedCallOpr(c, n)
|
||||
# Now that nkSym does not imply an iteration over the proc/iterator space,
|
||||
# the old ``prc`` (which is likely an nkIdent) has to be restored:
|
||||
if result == nil:
|
||||
n.sons[0] = prc
|
||||
result = semDirectCallAnalyseEffects(c, n, flags)
|
||||
@@ -436,21 +471,17 @@ proc semDirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
analyseIfAddressTakenInCall(c, result)
|
||||
|
||||
proc semEcho(c: PContext, n: PNode): PNode =
|
||||
var call, arg: PNode
|
||||
# this really is a macro
|
||||
checkMinSonsLen(n, 1)
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
arg = semExprWithType(c, n.sons[i])
|
||||
call = newNodeI(nkCall, arg.info)
|
||||
var arg = semExprWithType(c, n.sons[i])
|
||||
var call = newNodeI(nkCall, arg.info)
|
||||
addSon(call, newIdentNode(getIdent("$"), n.info))
|
||||
addSon(call, arg)
|
||||
n.sons[i] = semExpr(c, call)
|
||||
result = n
|
||||
|
||||
proc LookUpForDefined(c: PContext, n: PNode, onlyCurrentScope: bool): PSym =
|
||||
var
|
||||
m: PSym
|
||||
ident: PIdent
|
||||
case n.kind
|
||||
of nkIdent:
|
||||
if onlyCurrentScope:
|
||||
@@ -461,10 +492,10 @@ proc LookUpForDefined(c: PContext, n: PNode, onlyCurrentScope: bool): PSym =
|
||||
result = nil
|
||||
if onlyCurrentScope: return
|
||||
checkSonsLen(n, 2)
|
||||
m = LookupForDefined(c, n.sons[0], onlyCurrentScope)
|
||||
var m = LookupForDefined(c, n.sons[0], onlyCurrentScope)
|
||||
if (m != nil) and (m.kind == skModule):
|
||||
if (n.sons[1].kind == nkIdent):
|
||||
ident = n.sons[1].ident
|
||||
var ident = n.sons[1].ident
|
||||
if m == c.module:
|
||||
result = StrTableGet(c.tab.stack[ModuleTablePos], ident)
|
||||
else:
|
||||
@@ -480,7 +511,8 @@ proc LookUpForDefined(c: PContext, n: PNode, onlyCurrentScope: bool): PSym =
|
||||
|
||||
proc semDefined(c: PContext, n: PNode, onlyCurrentScope: bool): PNode =
|
||||
checkSonsLen(n, 2)
|
||||
result = newIntNode(nkIntLit, 0) # we replace this node by a 'true' or 'false' node
|
||||
# we replace this node by a 'true' or 'false' node:
|
||||
result = newIntNode(nkIntLit, 0)
|
||||
if LookUpForDefined(c, n.sons[1], onlyCurrentScope) != nil:
|
||||
result.intVal = 1
|
||||
elif not onlyCurrentScope and (n.sons[1].kind == nkIdent) and
|
||||
@@ -497,21 +529,14 @@ proc setMs(n: PNode, s: PSym): PNode =
|
||||
proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||
# this is a hotspot in the compiler!
|
||||
result = n
|
||||
case s.magic # magics that need special treatment
|
||||
of mDefined:
|
||||
result = semDefined(c, setMs(n, s), false)
|
||||
of mDefinedInScope:
|
||||
result = semDefined(c, setMs(n, s), true)
|
||||
of mLow:
|
||||
result = semLowHigh(c, setMs(n, s), mLow)
|
||||
of mHigh:
|
||||
result = semLowHigh(c, setMs(n, s), mHigh)
|
||||
of mSizeOf:
|
||||
result = semSizeof(c, setMs(n, s))
|
||||
of mIs:
|
||||
result = semIs(c, setMs(n, s))
|
||||
of mEcho:
|
||||
result = semEcho(c, setMs(n, s))
|
||||
case s.magic # magics that need special treatment
|
||||
of mDefined: result = semDefined(c, setMs(n, s), false)
|
||||
of mDefinedInScope: result = semDefined(c, setMs(n, s), true)
|
||||
of mLow: result = semLowHigh(c, setMs(n, s), mLow)
|
||||
of mHigh: result = semLowHigh(c, setMs(n, s), mHigh)
|
||||
of mSizeOf: result = semSizeof(c, setMs(n, s))
|
||||
of mIs: result = semIs(c, setMs(n, s))
|
||||
of mEcho: result = semEcho(c, setMs(n, s))
|
||||
else: result = semDirectOp(c, n, flags)
|
||||
|
||||
proc isTypeExpr(n: PNode): bool =
|
||||
@@ -543,7 +568,7 @@ proc lookupInRecordAndBuildCheck(c: PContext, n, r: PNode, field: PIdent,
|
||||
of nkOfBranch:
|
||||
result = lookupInRecordAndBuildCheck(c, n, lastSon(it), field, check)
|
||||
if result == nil:
|
||||
for j in countup(0, sonsLen(it) - 2): addSon(s, copyTree(it.sons[j]))
|
||||
for j in 0..sonsLen(it)-2: addSon(s, copyTree(it.sons[j]))
|
||||
else:
|
||||
if check == nil:
|
||||
check = newNodeI(nkCheckedFieldExpr, n.info)
|
||||
@@ -577,37 +602,32 @@ proc lookupInRecordAndBuildCheck(c: PContext, n, r: PNode, field: PIdent,
|
||||
else: illFormedAst(n)
|
||||
|
||||
proc makeDeref(n: PNode): PNode =
|
||||
var
|
||||
t: PType
|
||||
a: PNode
|
||||
t = skipTypes(n.typ, {tyGenericInst})
|
||||
var t = skipTypes(n.typ, {tyGenericInst})
|
||||
result = n
|
||||
if t.kind == tyVar:
|
||||
result = newNodeIT(nkHiddenDeref, n.info, t.sons[0])
|
||||
addSon(result, n)
|
||||
t = skipTypes(t.sons[0], {tyGenericInst})
|
||||
if t.kind in {tyPtr, tyRef}:
|
||||
a = result
|
||||
var a = result
|
||||
result = newNodeIT(nkDerefExpr, n.info, t.sons[0])
|
||||
addSon(result, a)
|
||||
|
||||
proc semFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
var
|
||||
f: PSym
|
||||
ty: PType
|
||||
i: PIdent
|
||||
check: PNode
|
||||
# this is difficult, because the '.' is used in many different contexts
|
||||
# in Nimrod. We first allow types in the semantic checking.
|
||||
proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
## returns nil if it's not a built-in field access
|
||||
var s = qualifiedLookup(c, n, true) # check for ambiguity
|
||||
if s != nil:
|
||||
return semSym(c, n, s, flags)
|
||||
|
||||
checkSonsLen(n, 2)
|
||||
n.sons[0] = semExprWithType(c, n.sons[0], {efAllowType} + flags)
|
||||
i = considerAcc(n.sons[1])
|
||||
ty = n.sons[0].Typ
|
||||
f = nil
|
||||
var i = considerAcc(n.sons[1])
|
||||
var ty = n.sons[0].Typ
|
||||
var f: PSym = nil
|
||||
result = nil
|
||||
if ty.kind == tyEnum:
|
||||
# look up if the identifier belongs to the enum:
|
||||
while (ty != nil):
|
||||
while ty != nil:
|
||||
f = getSymFromList(ty.n, i)
|
||||
if f != nil: break
|
||||
ty = ty.sons[0] # enum inheritance
|
||||
@@ -623,16 +643,16 @@ proc semFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
liMessage(n.sons[0].info, errATypeHasNoValue)
|
||||
return
|
||||
ty = skipTypes(ty, {tyGenericInst, tyVar, tyPtr, tyRef})
|
||||
var check: PNode = nil
|
||||
if ty.kind == tyObject:
|
||||
while true:
|
||||
check = nil
|
||||
f = lookupInRecordAndBuildCheck(c, n, ty.n, i, check) #f := lookupInRecord(ty.n, i);
|
||||
f = lookupInRecordAndBuildCheck(c, n, ty.n, i, check)
|
||||
if f != nil: break
|
||||
if ty.sons[0] == nil: break
|
||||
ty = skipTypes(ty.sons[0], {tyGenericInst})
|
||||
if f != nil:
|
||||
if ({sfStar, sfMinus} * f.flags != {}) or
|
||||
(getModule(f).id == c.module.id):
|
||||
if {sfStar, sfMinus} * f.flags != {} or getModule(f).id == c.module.id:
|
||||
# is the access to a public field or in the same module?
|
||||
n.sons[0] = makeDeref(n.sons[0])
|
||||
n.sons[1] = newSymNode(f) # we now have the correct field
|
||||
@@ -644,7 +664,6 @@ proc semFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
check.sons[0] = n
|
||||
check.typ = n.typ
|
||||
result = check
|
||||
return
|
||||
elif ty.kind == tyTuple:
|
||||
f = getSymFromList(ty.n, i)
|
||||
if f != nil:
|
||||
@@ -653,16 +672,24 @@ proc semFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
n.typ = f.typ
|
||||
result = n
|
||||
markUsed(n, f)
|
||||
return
|
||||
f = SymTabGet(c.tab, i) #if (f <> nil) and (f.kind = skStub) then loadStub(f);
|
||||
# ``loadStub`` is not correct here as we don't care for ``f`` really
|
||||
if (f != nil):
|
||||
# BUGFIX: do not check for (f.kind in [skProc, skMethod, skIterator]) here
|
||||
result = newNodeI(nkDotCall, n.info) # This special node kind is to merge with the call handler in `semExpr`.
|
||||
addSon(result, newIdentNode(i, n.info))
|
||||
addSon(result, copyTree(n.sons[0]))
|
||||
else:
|
||||
liMessage(n.Info, errUndeclaredFieldX, i.s)
|
||||
|
||||
proc semFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
# this is difficult, because the '.' is used in many different contexts
|
||||
# in Nimrod. We first allow types in the semantic checking.
|
||||
result = builtinFieldAccess(c, n, flags)
|
||||
if result == nil:
|
||||
var i = considerAcc(n.sons[1])
|
||||
var f = SymTabGet(c.tab, i)
|
||||
# if f != nil and f.kind == skStub: loadStub(f)
|
||||
# ``loadStub`` is not correct here as we don't care for ``f`` really
|
||||
if f != nil:
|
||||
# BUGFIX: do not check for (f.kind in [skProc, skMethod, skIterator]) here
|
||||
# This special node kind is to merge with the call handler in `semExpr`.
|
||||
result = newNodeI(nkDotCall, n.info)
|
||||
addSon(result, newIdentNode(i, n.info))
|
||||
addSon(result, copyTree(n[0]))
|
||||
else:
|
||||
liMessage(n.Info, errUndeclaredFieldX, i.s)
|
||||
|
||||
proc whichSliceOpr(n: PNode): string =
|
||||
if (n.sons[0] == nil):
|
||||
@@ -672,63 +699,92 @@ proc whichSliceOpr(n: PNode): string =
|
||||
result = "[$..]"
|
||||
else:
|
||||
result = "[$..$]"
|
||||
|
||||
proc addSliceOpr(result: var string, n: PNode) =
|
||||
if n[0] == nil:
|
||||
if n[1] == nil: result.add("..")
|
||||
else: result.add("..$")
|
||||
elif n[1] == nil: result.add("$..")
|
||||
else: result.add("$..$")
|
||||
|
||||
proc buildOverloadedSubscripts(n: PNode, inAsgn: bool): PNode =
|
||||
result = newNodeI(nkCall, n.info)
|
||||
add(result, nil) # fill with the correct node later
|
||||
add(result, n[0])
|
||||
var opr = "["
|
||||
for i in 1..n.len-1:
|
||||
if i > 1: add(opr, ",")
|
||||
if n[i].kind == nkRange:
|
||||
# we have a slice argument
|
||||
checkSonsLen(n[i], 2)
|
||||
addSliceOpr(opr, n[i])
|
||||
addSonIfNotNil(result, n[i][0])
|
||||
addSonIfNotNil(result, n[i][1])
|
||||
else:
|
||||
add(result, n[i])
|
||||
if inAsgn: add(opr, "]=")
|
||||
else: add(opr, "]")
|
||||
# now we know the operator
|
||||
result.sons[0] = newIdentNode(getIdent(opr), n.info)
|
||||
|
||||
proc semArrayAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
var
|
||||
arr, indexType: PType
|
||||
arg: PNode
|
||||
idx: biggestInt
|
||||
# check if array type:
|
||||
proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
## returns nil if not a built-in subscript operator;
|
||||
checkMinSonsLen(n, 2)
|
||||
n.sons[0] = semExprWithType(c, n.sons[0], flags - {efAllowType})
|
||||
arr = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar, tyPtr, tyRef})
|
||||
var arr = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar, tyPtr, tyRef})
|
||||
case arr.kind
|
||||
of tyArray, tyOpenArray, tyArrayConstr, tySequence, tyString, tyCString:
|
||||
checkSonsLen(n, 2)
|
||||
n.sons[0] = makeDeref(n.sons[0])
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
n.sons[i] = semExprWithType(c, n.sons[i], flags - {efAllowType})
|
||||
if arr.kind == tyArray: indexType = arr.sons[0]
|
||||
else: indexType = getSysType(tyInt)
|
||||
arg = IndexTypesMatch(c, indexType, n.sons[1].typ, n.sons[1])
|
||||
var indexType = if arr.kind == tyArray: arr.sons[0] else: getSysType(tyInt)
|
||||
var arg = IndexTypesMatch(c, indexType, n.sons[1].typ, n.sons[1])
|
||||
if arg != nil: n.sons[1] = arg
|
||||
else: liMessage(n.info, errIndexTypesDoNotMatch)
|
||||
result = n
|
||||
result.typ = elemType(arr)
|
||||
of tyTuple:
|
||||
n.sons[0] = makeDeref(n.sons[0]) # [] operator for tuples requires constant expression
|
||||
checkSonsLen(n, 2)
|
||||
n.sons[0] = makeDeref(n.sons[0])
|
||||
# [] operator for tuples requires constant expression:
|
||||
n.sons[1] = semConstExpr(c, n.sons[1])
|
||||
if skipTypes(n.sons[1].typ, {tyGenericInst, tyRange, tyOrdinal}).kind in
|
||||
{tyInt..tyInt64}:
|
||||
idx = getOrdValue(n.sons[1])
|
||||
var idx = getOrdValue(n.sons[1])
|
||||
if (idx >= 0) and (idx < sonsLen(arr)): n.typ = arr.sons[int(idx)]
|
||||
else: liMessage(n.info, errInvalidIndexValueForTuple)
|
||||
else:
|
||||
liMessage(n.info, errIndexTypesDoNotMatch)
|
||||
result = n
|
||||
else:
|
||||
else: nil
|
||||
|
||||
proc semArrayAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
result = semSubscript(c, n, flags)
|
||||
if result == nil:
|
||||
# overloaded [] operator:
|
||||
result = newNodeI(nkCall, n.info)
|
||||
if n.sons[1].kind == nkRange:
|
||||
checkSonsLen(n.sons[1], 2)
|
||||
addSon(result, newIdentNode(getIdent(whichSliceOpr(n.sons[1])), n.info))
|
||||
addSon(result, n.sons[0])
|
||||
addSonIfNotNil(result, n.sons[1].sons[0])
|
||||
addSonIfNotNil(result, n.sons[1].sons[1])
|
||||
else:
|
||||
addSon(result, newIdentNode(getIdent("[]"), n.info))
|
||||
addSon(result, n.sons[0])
|
||||
addSon(result, n.sons[1])
|
||||
result = semExpr(c, result)
|
||||
when false:
|
||||
result = newNodeI(nkCall, n.info)
|
||||
if n.sons[1].kind == nkRange:
|
||||
checkSonsLen(n.sons[1], 2)
|
||||
addSon(result, newIdentNode(getIdent(whichSliceOpr(n.sons[1])), n.info))
|
||||
addSon(result, n.sons[0])
|
||||
addSonIfNotNil(result, n.sons[1].sons[0])
|
||||
addSonIfNotNil(result, n.sons[1].sons[1])
|
||||
else:
|
||||
addSon(result, newIdentNode(getIdent("[]"), n.info))
|
||||
addSon(result, n.sons[0])
|
||||
addSon(result, n.sons[1])
|
||||
result = semExpr(c, result)
|
||||
else:
|
||||
result = semExpr(c, buildOverloadedSubscripts(n, inAsgn=false))
|
||||
|
||||
proc semIfExpr(c: PContext, n: PNode): PNode =
|
||||
var
|
||||
typ: PType
|
||||
it: PNode
|
||||
result = n
|
||||
checkSonsLen(n, 2)
|
||||
typ = nil
|
||||
var typ: PType = nil
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
it = n.sons[i]
|
||||
var it = n.sons[i]
|
||||
case it.kind
|
||||
of nkElifExpr:
|
||||
checkSonsLen(it, 2)
|
||||
@@ -740,22 +796,19 @@ proc semIfExpr(c: PContext, n: PNode): PNode =
|
||||
of nkElseExpr:
|
||||
checkSonsLen(it, 1)
|
||||
it.sons[0] = semExprWithType(c, it.sons[0])
|
||||
if (typ == nil): InternalError(it.info, "semIfExpr")
|
||||
if typ == nil: InternalError(it.info, "semIfExpr")
|
||||
it.sons[0] = fitNode(c, typ, it.sons[0])
|
||||
else: illFormedAst(n)
|
||||
result.typ = typ
|
||||
|
||||
proc semSetConstr(c: PContext, n: PNode): PNode =
|
||||
var
|
||||
typ: PType
|
||||
m: PNode
|
||||
result = newNodeI(nkCurly, n.info)
|
||||
result.typ = newTypeS(tySet, c)
|
||||
if sonsLen(n) == 0:
|
||||
addSon(result.typ, newTypeS(tyEmpty, c))
|
||||
else:
|
||||
# only semantic checking for all elements, later type checking:
|
||||
typ = nil
|
||||
var typ: PType = nil
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
if n.sons[i].kind == nkRange:
|
||||
checkSonsLen(n.sons[i], 2)
|
||||
@@ -776,6 +829,7 @@ proc semSetConstr(c: PContext, n: PNode): PNode =
|
||||
typ = makeRangeType(c, 0, MaxSetElements - 1, n.info)
|
||||
addSon(result.typ, typ)
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
var m: PNode
|
||||
if n.sons[i].kind == nkRange:
|
||||
m = newNodeI(nkRange, n.sons[i].info)
|
||||
addSon(m, fitNode(c, typ, n.sons[i].sons[0]))
|
||||
@@ -789,8 +843,7 @@ type
|
||||
paNone, paSingle, paTupleFields, paTuplePositions
|
||||
|
||||
proc checkPar(n: PNode): TParKind =
|
||||
var length: int
|
||||
length = sonsLen(n)
|
||||
var length = sonsLen(n)
|
||||
if length == 0:
|
||||
result = paTuplePositions # ()
|
||||
elif length == 1:
|
||||
@@ -810,25 +863,22 @@ proc checkPar(n: PNode): TParKind =
|
||||
return paNone
|
||||
|
||||
proc semTupleFieldsConstr(c: PContext, n: PNode): PNode =
|
||||
var
|
||||
typ: PType
|
||||
ids: TIntSet
|
||||
id: PIdent
|
||||
f: PSym
|
||||
var ids: TIntSet
|
||||
result = newNodeI(nkPar, n.info)
|
||||
typ = newTypeS(tyTuple, c)
|
||||
var typ = newTypeS(tyTuple, c)
|
||||
typ.n = newNodeI(nkRecList, n.info) # nkIdentDefs
|
||||
IntSetInit(ids)
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
if (n.sons[i].kind != nkExprColonExpr) or
|
||||
not (n.sons[i].sons[0].kind in {nkSym, nkIdent}):
|
||||
illFormedAst(n.sons[i])
|
||||
var id: PIdent
|
||||
if n.sons[i].sons[0].kind == nkIdent: id = n.sons[i].sons[0].ident
|
||||
else: id = n.sons[i].sons[0].sym.name
|
||||
if IntSetContainsOrIncl(ids, id.id):
|
||||
liMessage(n.sons[i].info, errFieldInitTwice, id.s)
|
||||
n.sons[i].sons[1] = semExprWithType(c, n.sons[i].sons[1])
|
||||
f = newSymS(skField, n.sons[i].sons[0], c)
|
||||
var f = newSymS(skField, n.sons[i].sons[0], c)
|
||||
f.typ = n.sons[i].sons[1].typ
|
||||
addSon(typ, f.typ)
|
||||
addSon(typ.n, newSymNode(f))
|
||||
@@ -837,19 +887,17 @@ proc semTupleFieldsConstr(c: PContext, n: PNode): PNode =
|
||||
result.typ = typ
|
||||
|
||||
proc semTuplePositionsConstr(c: PContext, n: PNode): PNode =
|
||||
var typ: PType
|
||||
result = n # we don't modify n, but compute the type:
|
||||
typ = newTypeS(tyTuple, c) # leave typ.n nil!
|
||||
var typ = newTypeS(tyTuple, c) # leave typ.n nil!
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
n.sons[i] = semExprWithType(c, n.sons[i])
|
||||
addSon(typ, n.sons[i].typ)
|
||||
result.typ = typ
|
||||
|
||||
proc semStmtListExpr(c: PContext, n: PNode): PNode =
|
||||
var length: int
|
||||
result = n
|
||||
checkMinSonsLen(n, 1)
|
||||
length = sonsLen(n)
|
||||
var length = sonsLen(n)
|
||||
for i in countup(0, length - 2):
|
||||
n.sons[i] = semStmt(c, n.sons[i])
|
||||
if length > 0:
|
||||
@@ -873,14 +921,12 @@ proc isCallExpr(n: PNode): bool =
|
||||
{nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit}
|
||||
|
||||
proc semMacroStmt(c: PContext, n: PNode, semCheck: bool = true): PNode =
|
||||
var
|
||||
s: PSym
|
||||
a: PNode
|
||||
checkMinSonsLen(n, 2)
|
||||
var a: PNode
|
||||
if isCallExpr(n.sons[0]): a = n.sons[0].sons[0]
|
||||
else: a = n.sons[0]
|
||||
s = qualifiedLookup(c, a, false)
|
||||
if (s != nil):
|
||||
var s = qualifiedLookup(c, a, false)
|
||||
if s != nil:
|
||||
case s.kind
|
||||
of skMacro:
|
||||
result = semMacroExpr(c, n, s, semCheck)
|
||||
@@ -900,76 +946,13 @@ proc semMacroStmt(c: PContext, n: PNode, semCheck: bool = true): PNode =
|
||||
else:
|
||||
liMessage(n.info, errInvalidExpressionX, renderTree(a, {renderNoComments}))
|
||||
|
||||
proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||
if (s.kind == skType) and not (efAllowType in flags):
|
||||
liMessage(n.info, errATypeHasNoValue)
|
||||
case s.kind
|
||||
of skProc, skMethod, skIterator, skConverter:
|
||||
if not (sfProcVar in s.flags) and (s.typ.callConv == ccDefault) and
|
||||
(getModule(s).id != c.module.id):
|
||||
liMessage(n.info, warnXisPassedToProcVar, s.name.s) # XXX change this to
|
||||
# errXCannotBePassedToProcVar after version 0.8.2
|
||||
# TODO VERSION 0.8.4
|
||||
#if (s.magic <> mNone) then
|
||||
# liMessage(n.info,
|
||||
# errInvalidContextForBuiltinX, s.name.s);
|
||||
result = symChoice(c, n, s)
|
||||
of skConst:
|
||||
#
|
||||
# Consider::
|
||||
# const x = []
|
||||
# proc p(a: openarray[int])
|
||||
# proc q(a: openarray[char])
|
||||
# p(x)
|
||||
# q(x)
|
||||
#
|
||||
# It is clear that ``[]`` means two totally different things. Thus, we
|
||||
# copy `x`'s AST into each context, so that the type fixup phase can
|
||||
# deal with two different ``[]``.
|
||||
#
|
||||
markUsed(n, s)
|
||||
if s.typ.kind in ConstAbstractTypes:
|
||||
result = copyTree(s.ast)
|
||||
result.info = n.info
|
||||
result.typ = s.typ
|
||||
else:
|
||||
result = newSymNode(s)
|
||||
result.info = n.info
|
||||
of skMacro:
|
||||
result = semMacroExpr(c, n, s)
|
||||
of skTemplate:
|
||||
result = semTemplateExpr(c, n, s)
|
||||
of skVar:
|
||||
markUsed(n, s) # if a proc accesses a global variable, it is not side effect free
|
||||
if sfGlobal in s.flags: incl(c.p.owner.flags, sfSideEffect)
|
||||
result = newSymNode(s)
|
||||
result.info = n.info
|
||||
of skGenericParam:
|
||||
if s.ast == nil: InternalError(n.info, "no default for")
|
||||
result = semExpr(c, s.ast)
|
||||
else:
|
||||
markUsed(n, s)
|
||||
result = newSymNode(s)
|
||||
result.info = n.info
|
||||
|
||||
proc semDotExpr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
var s: PSym
|
||||
s = qualifiedLookup(c, n, true) # check for ambiguity
|
||||
if s != nil: # this is a test comment; please don't touch it
|
||||
result = semSym(c, n, s, flags)
|
||||
else:
|
||||
result = semFieldAccess(c, n, flags)
|
||||
|
||||
proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
var
|
||||
s: PSym
|
||||
t: PType
|
||||
result = n
|
||||
if n == nil: return
|
||||
if nfSem in n.flags: return
|
||||
case n.kind # atoms:
|
||||
of nkIdent:
|
||||
s = lookUp(c, n)
|
||||
var s = lookUp(c, n)
|
||||
result = semSym(c, n, s, flags)
|
||||
of nkSym:
|
||||
#s := n.sym;
|
||||
@@ -1007,7 +990,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
of nkCharLit:
|
||||
if result.typ == nil: result.typ = getSysType(tyChar)
|
||||
of nkDotExpr:
|
||||
result = semDotExpr(c, n, flags)
|
||||
result = semFieldAccess(c, n, flags)
|
||||
if result.kind == nkDotCall:
|
||||
result.kind = nkCall
|
||||
result = semExpr(c, result, flags)
|
||||
@@ -1016,8 +999,8 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
of nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit:
|
||||
# check if it is an expression macro:
|
||||
checkMinSonsLen(n, 1)
|
||||
s = qualifiedLookup(c, n.sons[0], false)
|
||||
if (s != nil):
|
||||
var s = qualifiedLookup(c, n.sons[0], false)
|
||||
if s != nil:
|
||||
case s.kind
|
||||
of skMacro:
|
||||
result = semMacroExpr(c, n, s)
|
||||
@@ -1041,8 +1024,8 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
result = semMacroStmt(c, n)
|
||||
of nkBracketExpr:
|
||||
checkMinSonsLen(n, 1)
|
||||
s = qualifiedLookup(c, n.sons[0], false)
|
||||
if (s != nil) and (s.kind in {skProc, skMethod, skConverter, skIterator}):
|
||||
var s = qualifiedLookup(c, n.sons[0], false)
|
||||
if s != nil and s.kind in {skProc, skMethod, skConverter, skIterator}:
|
||||
# type parameters: partial generic specialization
|
||||
# XXX: too implement!
|
||||
internalError(n.info, "explicit generic instantation not implemented")
|
||||
@@ -1058,17 +1041,14 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
of paTuplePositions: result = semTuplePositionsConstr(c, n)
|
||||
of paTupleFields: result = semTupleFieldsConstr(c, n)
|
||||
of paSingle: result = semExpr(c, n.sons[0])
|
||||
of nkCurly:
|
||||
result = semSetConstr(c, n)
|
||||
of nkBracket:
|
||||
result = semArrayConstr(c, n)
|
||||
of nkLambda:
|
||||
result = semLambda(c, n)
|
||||
of nkCurly: result = semSetConstr(c, n)
|
||||
of nkBracket: result = semArrayConstr(c, n)
|
||||
of nkLambda: result = semLambda(c, n)
|
||||
of nkDerefExpr:
|
||||
checkSonsLen(n, 1)
|
||||
n.sons[0] = semExprWithType(c, n.sons[0])
|
||||
result = n
|
||||
t = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar})
|
||||
var t = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar})
|
||||
case t.kind
|
||||
of tyRef, tyPtr: n.typ = t.sons[0]
|
||||
else: liMessage(n.sons[0].info, errCircumNeedsPointer)
|
||||
@@ -1083,17 +1063,13 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
of nkHiddenAddr, nkHiddenDeref:
|
||||
checkSonsLen(n, 1)
|
||||
n.sons[0] = semExpr(c, n.sons[0], flags)
|
||||
of nkCast:
|
||||
result = semCast(c, n)
|
||||
of nkCast: result = semCast(c, n)
|
||||
of nkAccQuoted:
|
||||
checkSonsLen(n, 1)
|
||||
result = semExpr(c, n.sons[0])
|
||||
of nkIfExpr:
|
||||
result = semIfExpr(c, n)
|
||||
of nkStmtListExpr:
|
||||
result = semStmtListExpr(c, n)
|
||||
of nkBlockExpr:
|
||||
result = semBlockExpr(c, n)
|
||||
of nkIfExpr: result = semIfExpr(c, n)
|
||||
of nkStmtListExpr: result = semStmtListExpr(c, n)
|
||||
of nkBlockExpr: result = semBlockExpr(c, n)
|
||||
of nkHiddenStdConv, nkHiddenSubConv, nkConv, nkHiddenCallConv:
|
||||
checkSonsLen(n, 2)
|
||||
of nkStringToCString, nkCStringToString, nkPassAsOpenArray, nkObjDownConv,
|
||||
@@ -1105,9 +1081,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
checkMinSonsLen(n, 2)
|
||||
of nkSymChoice:
|
||||
liMessage(n.info, errExprXAmbiguous, renderTree(n, {renderNoComments}))
|
||||
result = nil
|
||||
else:
|
||||
#InternalError(n.info, nodeKindToStr[n.kind]);
|
||||
liMessage(n.info, errInvalidExpressionX, renderTree(n, {renderNoComments}))
|
||||
result = nil
|
||||
incl(result.flags, nfSem)
|
||||
|
||||
@@ -44,18 +44,13 @@ proc newStrNodeT(strVal: string, n: PNode): PNode =
|
||||
result.info = n.info
|
||||
|
||||
proc enumValToString(a: PNode): string =
|
||||
var
|
||||
n: PNode
|
||||
field: PSym
|
||||
x: biggestInt
|
||||
x = getInt(a)
|
||||
n = skipTypes(a.typ, abstractInst).n
|
||||
var x = getInt(a)
|
||||
var n = skipTypes(a.typ, abstractInst).n
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
if n.sons[i].kind != nkSym: InternalError(a.info, "enumValToString")
|
||||
field = n.sons[i].sym
|
||||
if field.position == x:
|
||||
return field.name.s
|
||||
InternalError(a.info, "no symbol for ordinal value: " & $(x))
|
||||
var field = n.sons[i].sym
|
||||
if field.position == x: return field.name.s
|
||||
InternalError(a.info, "no symbol for ordinal value: " & $x)
|
||||
|
||||
proc evalOp(m: TMagic, n, a, b, c: PNode): PNode =
|
||||
# b and c may be nil
|
||||
|
||||
145
rod/semstmts.nim
145
rod/semstmts.nim
@@ -8,16 +8,20 @@
|
||||
#
|
||||
# this module does the semantic checking of statements
|
||||
|
||||
proc semExprNoType(c: PContext, n: PNode): PNode =
|
||||
result = semExpr(c, n)
|
||||
if result.typ != nil and result.typ.kind != tyStmt:
|
||||
liMessage(n.info, errDiscardValue)
|
||||
|
||||
proc semWhen(c: PContext, n: PNode): PNode =
|
||||
var it, e: PNode
|
||||
result = nil
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
it = n.sons[i]
|
||||
var it = n.sons[i]
|
||||
if it == nil: illFormedAst(n)
|
||||
case it.kind
|
||||
of nkElifBranch:
|
||||
checkSonsLen(it, 2)
|
||||
e = semConstExpr(c, it.sons[0])
|
||||
var e = semConstExpr(c, it.sons[0])
|
||||
checkBool(e)
|
||||
if (e.kind != nkIntLit): InternalError(n.info, "semWhen")
|
||||
if (e.intVal != 0) and (result == nil):
|
||||
@@ -91,35 +95,27 @@ proc semBlock(c: PContext, n: PNode): PNode =
|
||||
Dec(c.p.nestedBlockCounter)
|
||||
|
||||
proc semAsm(con: PContext, n: PNode): PNode =
|
||||
var
|
||||
str, sub: string
|
||||
a, b, c: int
|
||||
e: PSym
|
||||
marker: char
|
||||
result = n
|
||||
checkSonsLen(n, 2)
|
||||
marker = pragmaAsm(con, n.sons[0])
|
||||
if marker == '\0':
|
||||
marker = '`' # default marker
|
||||
var marker = pragmaAsm(con, n.sons[0])
|
||||
if marker == '\0': marker = '`' # default marker
|
||||
case n.sons[1].kind
|
||||
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
||||
result = copyNode(n)
|
||||
str = n.sons[1].strVal
|
||||
if str == "":
|
||||
liMessage(n.info, errEmptyAsm)
|
||||
var str = n.sons[1].strVal
|
||||
if str == "": liMessage(n.info, errEmptyAsm)
|
||||
# now parse the string literal and substitute symbols:
|
||||
a = 0
|
||||
var a = 0
|
||||
while true:
|
||||
b = strutils.find(str, marker, a)
|
||||
if b < 0: sub = copy(str, a)
|
||||
else: sub = copy(str, a, b - 1)
|
||||
var b = strutils.find(str, marker, a)
|
||||
var sub = if b < 0: copy(str, a) else: copy(str, a, b - 1)
|
||||
if sub != "": addSon(result, newStrNode(nkStrLit, sub))
|
||||
if b < 0: break
|
||||
c = strutils.find(str, marker, b + 1)
|
||||
var c = strutils.find(str, marker, b + 1)
|
||||
if c < 0: sub = copy(str, b + 1)
|
||||
else: sub = copy(str, b + 1, c - 1)
|
||||
if sub != "":
|
||||
e = SymtabGet(con.tab, getIdent(sub))
|
||||
var e = SymtabGet(con.tab, getIdent(sub))
|
||||
if e != nil:
|
||||
if e.kind == skStub: loadStub(e)
|
||||
addSon(result, newSymNode(e))
|
||||
@@ -177,66 +173,61 @@ proc semCase(c: PContext, n: PNode): PNode =
|
||||
liMessage(n.info, errNotAllCasesCovered)
|
||||
closeScope(c.tab)
|
||||
|
||||
proc propertyWriteAccess(c: PContext, n, a: PNode): PNode =
|
||||
var id = considerAcc(a[1])
|
||||
result = newNodeI(nkCall, n.info)
|
||||
addSon(result, newIdentNode(getIdent(id.s & '='), n.info))
|
||||
# a[0] is already checked for semantics, that does ``builtinFieldAccess``
|
||||
# this is ugly. XXX Semantic checking should use the ``nfSem`` flag for
|
||||
# nodes!
|
||||
addSon(result, a[0])
|
||||
addSon(result, semExpr(c, n[1]))
|
||||
result = semDirectCallAnalyseEffects(c, result, {})
|
||||
if result != nil:
|
||||
fixAbstractType(c, result)
|
||||
analyseIfAddressTakenInCall(c, result)
|
||||
else:
|
||||
liMessage(n.Info, errUndeclaredFieldX, id.s)
|
||||
|
||||
proc semAsgn(c: PContext, n: PNode): PNode =
|
||||
var
|
||||
le: PType
|
||||
a: PNode
|
||||
id: PIdent
|
||||
checkSonsLen(n, 2)
|
||||
a = n.sons[0]
|
||||
var a = n.sons[0]
|
||||
case a.kind
|
||||
of nkDotExpr:
|
||||
# r.f = x
|
||||
# --> `f=` (r, x)
|
||||
checkSonsLen(a, 2)
|
||||
id = considerAcc(a.sons[1])
|
||||
result = newNodeI(nkCall, n.info)
|
||||
addSon(result, newIdentNode(getIdent(id.s & '='), n.info))
|
||||
addSon(result, semExpr(c, a.sons[0]))
|
||||
addSon(result, semExpr(c, n.sons[1]))
|
||||
result = semDirectCallAnalyseEffects(c, result, {})
|
||||
if result != nil:
|
||||
fixAbstractType(c, result)
|
||||
analyseIfAddressTakenInCall(c, result)
|
||||
return
|
||||
a = builtinFieldAccess(c, a, {efLValue})
|
||||
if a == nil:
|
||||
return propertyWriteAccess(c, n, n[0])
|
||||
when false:
|
||||
checkSonsLen(a, 2)
|
||||
var id = considerAcc(a.sons[1])
|
||||
result = newNodeI(nkCall, n.info)
|
||||
addSon(result, newIdentNode(getIdent(id.s & '='), n.info))
|
||||
addSon(result, semExpr(c, a.sons[0]))
|
||||
addSon(result, semExpr(c, n.sons[1]))
|
||||
result = semDirectCallAnalyseEffects(c, result, {})
|
||||
if result != nil:
|
||||
fixAbstractType(c, result)
|
||||
analyseIfAddressTakenInCall(c, result)
|
||||
return
|
||||
of nkBracketExpr:
|
||||
# a[i..j] = x
|
||||
# --> `[..]=`(a, i, j, x)
|
||||
result = newNodeI(nkCall, n.info)
|
||||
checkSonsLen(a, 2)
|
||||
if a.sons[1].kind == nkRange:
|
||||
checkSonsLen(a.sons[1], 2)
|
||||
addSon(result,
|
||||
newIdentNode(getIdent(whichSliceOpr(a.sons[1]) & '='), n.info))
|
||||
addSon(result, semExpr(c, a.sons[0]))
|
||||
addSonIfNotNil(result, semExpr(c, a.sons[1].sons[0]))
|
||||
addSonIfNotNil(result, semExpr(c, a.sons[1].sons[1]))
|
||||
addSon(result, semExpr(c, n.sons[1]))
|
||||
result = semDirectCallAnalyseEffects(c, result, {})
|
||||
if result != nil:
|
||||
fixAbstractType(c, result)
|
||||
analyseIfAddressTakenInCall(c, result)
|
||||
return
|
||||
else:
|
||||
addSon(result, newIdentNode(getIdent("[]="), n.info))
|
||||
addSon(result, semExpr(c, a.sons[0]))
|
||||
addSon(result, semExpr(c, a.sons[1]))
|
||||
addSon(result, semExpr(c, n.sons[1]))
|
||||
result = semDirectCallAnalyseEffects(c, result, {})
|
||||
if result != nil:
|
||||
fixAbstractType(c, result)
|
||||
analyseIfAddressTakenInCall(c, result)
|
||||
return
|
||||
a = semSubscript(c, a, {efLValue})
|
||||
if a == nil:
|
||||
result = buildOverloadedSubscripts(n.sons[0], inAsgn=true)
|
||||
add(result, n[1])
|
||||
return semExprNoType(c, result)
|
||||
else:
|
||||
nil
|
||||
n.sons[0] = semExprWithType(c, n.sons[0], {efLValue})
|
||||
a = semExprWithType(c, a, {efLValue})
|
||||
#n.sons[0] = semExprWithType(c, n.sons[0], {efLValue})
|
||||
n.sons[0] = a
|
||||
n.sons[1] = semExprWithType(c, n.sons[1])
|
||||
le = n.sons[0].typ
|
||||
if (skipTypes(le, {tyGenericInst}).kind != tyVar) and
|
||||
(IsAssignable(n.sons[0]) == arNone):
|
||||
var le = a.typ
|
||||
if skipTypes(le, {tyGenericInst}).kind != tyVar and IsAssignable(a) == arNone:
|
||||
# Direct assignment to a discriminant is allowed!
|
||||
liMessage(n.sons[0].info, errXCannotBeAssignedTo,
|
||||
renderTree(n.sons[0], {renderNoComments}))
|
||||
liMessage(a.info, errXCannotBeAssignedTo, renderTree(a, {renderNoComments}))
|
||||
else:
|
||||
n.sons[1] = fitNode(c, le, n.sons[1])
|
||||
fixAbstractType(c, n)
|
||||
@@ -255,8 +246,9 @@ proc SemReturn(c: PContext, n: PNode): PNode =
|
||||
restype = c.p.owner.typ.sons[0]
|
||||
if (restype != nil):
|
||||
a = newNodeI(nkAsgn, n.sons[0].info)
|
||||
n.sons[0] = fitNode(c, restype, n.sons[0]) # optimize away ``return result``, because it would be transformed
|
||||
# to ``result = result; return``:
|
||||
n.sons[0] = fitNode(c, restype, n.sons[0])
|
||||
# optimize away ``return result``, because it would be transformed
|
||||
# to ``result = result; return``:
|
||||
if (n.sons[0].kind == nkSym) and (sfResult in n.sons[0].sym.flags):
|
||||
n.sons[0] = nil
|
||||
else:
|
||||
@@ -499,12 +491,11 @@ proc SemTypeSection(c: PContext, n: PNode): PNode =
|
||||
var
|
||||
s: PSym
|
||||
t, body: PType
|
||||
a: PNode
|
||||
result = n
|
||||
# process the symbols on the left side for the whole type section, before
|
||||
# we even look at the type definitions on the right
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
a = n.sons[i]
|
||||
var a = n.sons[i]
|
||||
if a.kind == nkCommentStmt: continue
|
||||
if (a.kind != nkTypeDef): IllFormedAst(a)
|
||||
checkSonsLen(a, 3)
|
||||
@@ -522,7 +513,7 @@ proc SemTypeSection(c: PContext, n: PNode): PNode =
|
||||
addInterfaceDecl(c, s)
|
||||
a.sons[0] = newSymNode(s)
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
a = n.sons[i]
|
||||
var a = n.sons[i]
|
||||
if a.kind == nkCommentStmt: continue
|
||||
if (a.kind != nkTypeDef): IllFormedAst(a)
|
||||
checkSonsLen(a, 3)
|
||||
@@ -558,7 +549,7 @@ proc SemTypeSection(c: PContext, n: PNode): PNode =
|
||||
s.ast = a
|
||||
popOwner()
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
a = n.sons[i]
|
||||
var a = n.sons[i]
|
||||
if a.kind == nkCommentStmt: continue
|
||||
if (a.sons[0].kind != nkSym): IllFormedAst(a)
|
||||
s = a.sons[0].sym
|
||||
@@ -778,10 +769,8 @@ proc evalInclude(c: PContext, n: PNode): PNode =
|
||||
addSon(result, semStmt(c, gIncludeFile(f)))
|
||||
IntSetExcl(c.includedFiles, fileIndex)
|
||||
|
||||
proc semCommand(c: PContext, n: PNode): PNode =
|
||||
result = semExpr(c, n)
|
||||
if result.typ != nil and result.typ.kind != tyStmt:
|
||||
liMessage(n.info, errDiscardValue)
|
||||
proc semCommand(c: PContext, n: PNode): PNode =
|
||||
result = semExprNoType(c, n)
|
||||
|
||||
proc SemStmt(c: PContext, n: PNode): PNode =
|
||||
const # must be last statements in a block:
|
||||
|
||||
60
tests/tmatrix.nim
Normal file
60
tests/tmatrix.nim
Normal file
@@ -0,0 +1,60 @@
|
||||
# Test overloading of [] with multiple indices
|
||||
|
||||
type
|
||||
TMatrix* = object
|
||||
data: seq[float]
|
||||
fWidth, fHeight: int
|
||||
|
||||
template `|`(x, y: int): expr = y * m.fWidth + x
|
||||
|
||||
proc createMatrix*(width, height: int): TMatrix =
|
||||
result.fWidth = width
|
||||
result.fHeight = height
|
||||
newSeq(result.data, width*height)
|
||||
|
||||
proc width*(m: TMatrix): int {.inline.} = return m.fWidth
|
||||
proc height*(m: TMatrix): int {.inline.} = return m.fHeight
|
||||
|
||||
proc `[,]`*(m: TMatrix, x, y: int): float {.inline.} =
|
||||
result = m.data[x|y]
|
||||
|
||||
proc `[,]=`*(m: var TMatrix, x, y: int, val: float) {.inline.} =
|
||||
m.data[x|y] = val
|
||||
|
||||
proc `[$..$, $..$]`*(m: TMatrix, a, b, c, d: int): TMatrix =
|
||||
result = createMatrix(b-a+1, d-c+1)
|
||||
for x in a..b:
|
||||
for y in c..d:
|
||||
result[x-a, y-c] = m[x, y]
|
||||
|
||||
proc `[$..$, $..$]=`*(m: var TMatrix, a, b, c, d: int, val: float) =
|
||||
for x in a..b:
|
||||
for y in c..d:
|
||||
m[x, y] = val
|
||||
|
||||
proc `[$..$, $..$]=`*(m: var TMatrix, a, b, c, d: int, val: TMatrix) =
|
||||
assert val.width == b-a+1
|
||||
assert val.height == d-c+1
|
||||
for x in a..b:
|
||||
for y in c..d:
|
||||
m[x, y] = val[x-a, y-c]
|
||||
|
||||
proc `-|`*(m: TMatrix): TMatrix =
|
||||
## transposes a matrix
|
||||
result = createMatrix(m.height, m.width)
|
||||
for x in 0..m.width-1:
|
||||
for y in 0..m.height-1: result[y,x] = m[x,y]
|
||||
|
||||
#m.row(0, 2) # select row
|
||||
#m.col(0, 89) # select column
|
||||
|
||||
const
|
||||
w = 3
|
||||
h = 20
|
||||
|
||||
var m = createMatrix(w, h)
|
||||
for i in 0..w-1:
|
||||
m[i, i] = 1.0
|
||||
|
||||
for i in 0..w-1:
|
||||
stdout.write(m[i,i]) #OUT 1.01.01.0
|
||||
28
web/news.txt
28
web/news.txt
@@ -2,6 +2,34 @@
|
||||
News
|
||||
====
|
||||
|
||||
2010-XX-XX Version 0.8.8 released
|
||||
=================================
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
- The Posix version of ``os.copyFile`` has better error handling.
|
||||
|
||||
|
||||
Additions
|
||||
---------
|
||||
- Added ``ropes`` module.
|
||||
- Added ``sockets`` module.
|
||||
- Added ``httpserver`` module.
|
||||
- Many wrappers now do not contain redundant name prefixes (like ``GTK_``,
|
||||
``lua``). The new wrappers are available in ``lib/newwrap``. Change
|
||||
your configuration file to use these.
|
||||
- More extensive subscript operator overloading. See ``_ for further
|
||||
information.
|
||||
|
||||
|
||||
Changes affecting backwards compatibility
|
||||
-----------------------------------------
|
||||
|
||||
- Overloading of the subscript operator only works if the type does not provide
|
||||
a built-in one.
|
||||
|
||||
|
||||
|
||||
|
||||
2009-12-21 Version 0.8.6 released
|
||||
=================================
|
||||
|
||||
Reference in New Issue
Block a user