Skip to content

Commit 6860e2b

Browse files
committed
Document argc argv library
1 parent e4cdf9d commit 6860e2b

File tree

5 files changed

+57
-9
lines changed

5 files changed

+57
-9
lines changed

CHANGES.current

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
77
Version 4.1.0 (in progress)
88
===========================
99

10+
2022-05-15: erezgeva, eiselekd
11+
[Lua, Perl, PHP, Tcl] #2275 #2276 Add argcargv.i library containing
12+
(int ARGC, char **ARGV) multi-argument typemaps.
13+
14+
Document this library in Typemaps.html.
15+
1016
2022-05-04: wsfulton
1117
[C#] Add C# wchar_t * director typemaps
1218

Doc/Manual/Contents.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ <h3><a href="Library.html#Library">12 SWIG library</a></h3>
419419
<li><a href="Library.html#Library_nn2">The %include directive and library search path</a>
420420
<li><a href="Library.html#Library_nn3">C arrays and pointers</a>
421421
<ul>
422+
<li><a href="Library.html#Library_argcargv">argcargv.i</a>
422423
<li><a href="Library.html#Library_nn4">cpointer.i</a>
423424
<li><a href="Library.html#Library_carrays">carrays.i</a>
424425
<li><a href="Library.html#Library_nn6">cmalloc.i</a>

Doc/Manual/Library.html

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ <H1><a name="Library">12 SWIG library</a></H1>
1414
<li><a href="#Library_nn2">The %include directive and library search path</a>
1515
<li><a href="#Library_nn3">C arrays and pointers</a>
1616
<ul>
17+
<li><a href="#Library_argcargv">argcargv.i</a>
1718
<li><a href="#Library_nn4">cpointer.i</a>
1819
<li><a href="#Library_carrays">carrays.i</a>
1920
<li><a href="#Library_nn6">cmalloc.i</a>
@@ -115,7 +116,48 @@ <H2><a name="Library_nn3">12.2 C arrays and pointers</a></H2>
115116
memory, their use is potentially unsafe and you should exercise caution.
116117
</p>
117118

118-
<H3><a name="Library_nn4">12.2.1 cpointer.i</a></H3>
119+
<H3><a name="Library_argcargv">12.2.1 argcargv.i</a></H3>
120+
121+
122+
<p>
123+
The argcargv.i library is a simple library providing multi-argument typemaps for handling C
124+
argc argv command line argument C string arrays.
125+
The <tt>argc</tt> parameter contains the argument count and <tt>argv</tt> contains the argument vector array.
126+
</p>
127+
128+
<p>
129+
This library provides the following multi-argument typemap:
130+
</p>
131+
132+
<p>
133+
<b><tt>(int ARGC, char **ARGV)</tt></b>
134+
</p>
135+
136+
<p>
137+
Apply this multi-argument typemap to your use case, for example:
138+
</p>
139+
140+
<div class="code">
141+
<pre>
142+
%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) }
143+
144+
int mainApp(size_t argc, const char **argv);
145+
</pre>
146+
</div>
147+
148+
<p>
149+
then from Ruby:
150+
</p>
151+
152+
<div class="targetlang">
153+
<pre>
154+
$args = ["myarg1", "myarg2"]
155+
mainApp(args);
156+
</pre>
157+
</div>
158+
159+
160+
<H3><a name="Library_nn4">12.2.2 cpointer.i</a></H3>
119161

120162

121163
<p>
@@ -331,7 +373,7 @@ <H3><a name="Library_nn4">12.2.1 cpointer.i</a></H3>
331373
<b>Note:</b> When working with simple pointers, typemaps can often be used to provide more seamless operation.
332374
</p>
333375

334-
<H3><a name="Library_carrays">12.2.2 carrays.i</a></H3>
376+
<H3><a name="Library_carrays">12.2.3 carrays.i</a></H3>
335377

336378

337379
<p>
@@ -510,7 +552,7 @@ <H3><a name="Library_carrays">12.2.2 carrays.i</a></H3>
510552
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.
511553
</p>
512554

513-
<H3><a name="Library_nn6">12.2.3 cmalloc.i</a></H3>
555+
<H3><a name="Library_nn6">12.2.4 cmalloc.i</a></H3>
514556

515557

516558
<p>
@@ -671,7 +713,7 @@ <H3><a name="Library_nn6">12.2.3 cmalloc.i</a></H3>
671713
</pre>
672714
</div>
673715

674-
<H3><a name="Library_nn7">12.2.4 cdata.i</a></H3>
716+
<H3><a name="Library_nn7">12.2.5 cdata.i</a></H3>
675717

676718

677719
<p>

Lib/lua/argcargv.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
then from lua:
1010
1111
args = { "arg0", "arg1" }
12-
mainApp(args);
12+
mainApp(args)
1313
1414
* ------------------------------------------------------------ */
1515

Lib/ruby/argcargv.i

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
88
%inline %{
99
10-
int mainApp(size_t argc, const char **argv)
11-
{
10+
int mainApp(size_t argc, const char **argv) {
1211
return argc;
1312
}
1413
1514
then from ruby:
1615
17-
args = ["asdf", "asdf2"]
18-
mainApp(args);
16+
$args = ["asdf", "asdf2"]
17+
mainApp(args)
1918
2019
* ------------------------------------------------------------ */
2120

0 commit comments

Comments
 (0)