diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2022-05-15 19:12:39 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2022-05-15 19:12:39 +0100 |
commit | 6860e2bc03dc2a46de0989dc938bffe63eb0694b (patch) | |
tree | d93b7efb80800003ee374b204a28613ad266ef92 | |
parent | e4cdf9d98fe0cfc271192b9702cca1d9bcbe4549 (diff) | |
download | swig-6860e2bc03dc2a46de0989dc938bffe63eb0694b.tar.gz |
Document argc argv library
-rw-r--r-- | CHANGES.current | 6 | ||||
-rw-r--r-- | Doc/Manual/Contents.html | 1 | ||||
-rw-r--r-- | Doc/Manual/Library.html | 50 | ||||
-rw-r--r-- | Lib/lua/argcargv.i | 2 | ||||
-rw-r--r-- | Lib/ruby/argcargv.i | 7 |
5 files changed, 57 insertions, 9 deletions
diff --git a/CHANGES.current b/CHANGES.current index f14dc24ad..3818bdf0b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-05-15: erezgeva, eiselekd + [Lua, Perl, PHP, Tcl] #2275 #2276 Add argcargv.i library containing + (int ARGC, char **ARGV) multi-argument typemaps. + + Document this library in Typemaps.html. + 2022-05-04: wsfulton [C#] Add C# wchar_t * director typemaps diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 57ef77087..dfa9f6101 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -419,6 +419,7 @@ <li><a href="Library.html#Library_nn2">The %include directive and library search path</a> <li><a href="Library.html#Library_nn3">C arrays and pointers</a> <ul> +<li><a href="Library.html#Library_argcargv">argcargv.i</a> <li><a href="Library.html#Library_nn4">cpointer.i</a> <li><a href="Library.html#Library_carrays">carrays.i</a> <li><a href="Library.html#Library_nn6">cmalloc.i</a> diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 0efb8fb0f..3ecfc3a39 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -14,6 +14,7 @@ <li><a href="#Library_nn2">The %include directive and library search path</a> <li><a href="#Library_nn3">C arrays and pointers</a> <ul> +<li><a href="#Library_argcargv">argcargv.i</a> <li><a href="#Library_nn4">cpointer.i</a> <li><a href="#Library_carrays">carrays.i</a> <li><a href="#Library_nn6">cmalloc.i</a> @@ -115,7 +116,48 @@ pointers as class-like objects. Since these functions provide direct access to memory, their use is potentially unsafe and you should exercise caution. </p> -<H3><a name="Library_nn4">12.2.1 cpointer.i</a></H3> +<H3><a name="Library_argcargv">12.2.1 argcargv.i</a></H3> + + +<p> +The argcargv.i library is a simple library providing multi-argument typemaps for handling C +argc argv command line argument C string arrays. +The <tt>argc</tt> parameter contains the argument count and <tt>argv</tt> contains the argument vector array. +</p> + +<p> +This library provides the following multi-argument typemap: +</p> + +<p> +<b><tt>(int ARGC, char **ARGV)</tt></b> +</p> + +<p> +Apply this multi-argument typemap to your use case, for example: +</p> + +<div class="code"> +<pre> +%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) } + +int mainApp(size_t argc, const char **argv); +</pre> +</div> + +<p> +then from Ruby: +</p> + +<div class="targetlang"> +<pre> +$args = ["myarg1", "myarg2"] +mainApp(args); +</pre> +</div> + + +<H3><a name="Library_nn4">12.2.2 cpointer.i</a></H3> <p> @@ -331,7 +373,7 @@ In this example, the function <tt>int_to_uint()</tt> would be used to cast type <b>Note:</b> When working with simple pointers, typemaps can often be used to provide more seamless operation. </p> -<H3><a name="Library_carrays">12.2.2 carrays.i</a></H3> +<H3><a name="Library_carrays">12.2.3 carrays.i</a></H3> <p> @@ -510,7 +552,7 @@ used with types of <tt>char</tt> or <tt>char *</tt>. SWIG's default handling of these types is to handle them as character strings and the two macros do not do enough to change this. </p> -<H3><a name="Library_nn6">12.2.3 cmalloc.i</a></H3> +<H3><a name="Library_nn6">12.2.4 cmalloc.i</a></H3> <p> @@ -671,7 +713,7 @@ Now, in a script: </pre> </div> -<H3><a name="Library_nn7">12.2.4 cdata.i</a></H3> +<H3><a name="Library_nn7">12.2.5 cdata.i</a></H3> <p> diff --git a/Lib/lua/argcargv.i b/Lib/lua/argcargv.i index 376d346d8..94cc8ed42 100644 --- a/Lib/lua/argcargv.i +++ b/Lib/lua/argcargv.i @@ -9,7 +9,7 @@ then from lua: args = { "arg0", "arg1" } - mainApp(args); + mainApp(args) * ------------------------------------------------------------ */ diff --git a/Lib/ruby/argcargv.i b/Lib/ruby/argcargv.i index 330221a05..24df9c94a 100644 --- a/Lib/ruby/argcargv.i +++ b/Lib/ruby/argcargv.i @@ -7,15 +7,14 @@ %inline %{ - int mainApp(size_t argc, const char **argv) - { + int mainApp(size_t argc, const char **argv) { return argc; } then from ruby: - args = ["asdf", "asdf2"] - mainApp(args); + $args = ["asdf", "asdf2"] + mainApp(args) * ------------------------------------------------------------ */ |