summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/advopt.txt3
-rwxr-xr-xdoc/keywords.txt2
-rwxr-xr-xdoc/nimrodc.txt79
3 files changed, 82 insertions, 2 deletions
diff --git a/doc/advopt.txt b/doc/advopt.txt
index 5b22c6b48..90fe5850f 100755
--- a/doc/advopt.txt
+++ b/doc/advopt.txt
@@ -1,6 +1,7 @@
 Advanced commands:
   //compileToC, cc          compile project with C code generator
-  //compileToOC, oc         compile project to Objective C code
+  //compileToCpp, cpp       compile project to C++ code
+  //compileToOC, objc       compile project to Objective C code
   //rst2html                convert a reStructuredText file to HTML
   //rst2tex                 convert a reStructuredText file to TeX
   //run                     run the project (with Tiny C backend; buggy!)
diff --git a/doc/keywords.txt b/doc/keywords.txt
index a6d96834a..75014da42 100755
--- a/doc/keywords.txt
+++ b/doc/keywords.txt
@@ -4,7 +4,7 @@ case cast const continue converter
 discard distinct div
 elif else end enum except
 finally for from generic
-if implies import in include is isnot iterator
+if import in include is isnot iterator
 lambda let
 macro method mod
 nil not notin
diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt
index 71f5c0387..6961c41bd 100755
--- a/doc/nimrodc.txt
+++ b/doc/nimrodc.txt
@@ -192,6 +192,85 @@ Example:
   embedsC()

 

 

+ImportCpp pragma

+----------------

+The `importcpp`:idx: pragma can be used to import `C++`:idx: methods. The

+generated code then uses the C++ method calling syntax: ``obj->method(arg)``.

+In addition with the ``header`` and ``emit`` pragmas this allows *sloppy*

+interfacing with libraries written in C++:

+

+.. code-block:: Nimrod

+  # Horrible example of how to interface with a C++ engine ... ;-)

+

+  {.link: "/usr/lib/libIrrlicht.so".}

+

+  {.emit: """

+  using namespace irr;

+  using namespace core;

+  using namespace scene;

+  using namespace video;

+  using namespace io;

+  using namespace gui;

+  """.}

+

+  const

+    irr = "<irrlicht/irrlicht.h>"

+

+  type

+    TIrrlichtDevice {.final, header: irr, importc: "IrrlichtDevice".} = object

+    PIrrlichtDevice = ptr TIrrlichtDevice

+

+  proc createDevice(): PIrrlichtDevice {.

+    header: irr, importc: "createDevice".}

+  proc run(device: PIrrlichtDevice): bool {.

+    header: irr, importcpp: "run".}

+  

+

+ImportObjC pragma

+-----------------

+The `importobjc`:idx: pragma can be used to import `Objective C`:idx: methods. 

+The generated code then uses the Objective C method calling 

+syntax: ``[obj method param1: arg]``.

+In addition with the ``header`` and ``emit`` pragmas this allows *sloppy*

+interfacing with libraries written in Objective C:

+

+.. code-block:: Nimrod

+  # horrible example of how to interface with GNUStep ...

+

+  {.passL: "-lobjc".}

+  {.emit: """

+  #include <objc/Object.h>

+  @interface Greeter:Object

+  {

+  }

+

+  - (void)greet:(long)x y:(long)dummy;

+  @end

+

+  #include <stdio.h>

+  @implementation Greeter

+

+  - (void)greet:(long)x y:(long)dummy

+  {

+	  printf("Hello, World!\n");

+  }

+  @end

+

+  #include <stdlib.h>

+  """.}

+

+  type

+    TId {.importc: "id", header: "<objc/Object.h>", final.} = distinct int

+

+  proc newGreeter: TId {.importobjc: "Greeter new", nodecl.}

+  proc greet(self: TId, x, y: int) {.importobjc: "greet", nodecl.}

+  proc free(self: TId) {.importobjc: "free", nodecl.}

+

+  var g = newGreeter()

+  g.greet(12, 34)

+  g.free()

+

+

 LineDir option

 --------------

 The `lineDir`:idx: option can be turned on or off. If turned on the