Added the -globalmodule command-line option for the Ruby module, which
allows the user to wrap all classes, methods and constants directly into the global module (i.e. the Kernel module) instead of a named, nested module. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4706 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
31dd4ae3b5
commit
0805ba938d
4 changed files with 27 additions and 9 deletions
|
|
@ -1,5 +1,10 @@
|
|||
Version 1.3.20 (In progress)
|
||||
============================
|
||||
04/25/2003: ljohnson (Lyle Johnson)
|
||||
[Ruby] Added the -globalmodule command-line option for the Ruby
|
||||
module, for wrapping stuff into the global module (Kernel) instead
|
||||
of a nested module. Updated documentation accordingly.
|
||||
|
||||
04/23/2003: mrose (Mark Rose)
|
||||
Fixed symname error in director calls to Python methods
|
||||
that extend C++ operators.
|
||||
|
|
|
|||
|
|
@ -211,8 +211,7 @@ Ruby <i>module</i> names must be capitalized, but the convention for Ruby
|
|||
<i>feature</i> names is to use lowercase names. So, for example, the <b>Etc</b>
|
||||
extension module is imported by requiring the <b>etc</b> feature:
|
||||
|
||||
<pre><blockquote>
|
||||
# The feature name begins with a lowercase letter...
|
||||
<pre><blockquote># The feature name begins with a lowercase letter...
|
||||
require 'etc'
|
||||
|
||||
# ... but the module name begins with an uppercase letter
|
||||
|
|
@ -224,8 +223,7 @@ To stay consistent with this practice, you should always specify a
|
|||
SWIG will automatically correct the resulting Ruby module name for your
|
||||
extension. So for example, a SWIG interface file that begins with:
|
||||
|
||||
<pre><blockquote>
|
||||
%module example
|
||||
<pre><blockquote>%module example
|
||||
</blockquote></pre>
|
||||
|
||||
will result in an extension module using the feature name "example" and
|
||||
|
|
@ -364,9 +362,20 @@ nested directly under the global module. You can specify a more deeply nested
|
|||
module by specifying the fully-qualified module name in quotes, e.g.
|
||||
<blockquote><pre>%module "Foo::Bar::Spam"</pre></blockquote>
|
||||
|
||||
When choosing a module name, do not use the same
|
||||
name as a built-in Ruby command or standard module name, the results may be
|
||||
unpredictable.
|
||||
Starting with SWIG 1.3.20, you can also choose to wrap everything into the global
|
||||
module by specifying the <tt>-globalmodule</tt> option on the SWIG command line, i.e.
|
||||
|
||||
<blockquote><pre>$ <b>swig -ruby -globalmodule example.i</b></pre></blockquote>
|
||||
|
||||
Note that this does not relieve you of the requirement of specifying the SWIG
|
||||
module name with the <tt>%module</tt> directive (or the <tt>-module</tt>
|
||||
command-line option) as described earlier.<p>
|
||||
|
||||
When choosing a module name, do not use the same name as a built-in Ruby command
|
||||
or standard module name, as the results may be unpredictable. Similarly, if you're
|
||||
using the <tt>-globalmodule</tt> option to wrap everything into the global module,
|
||||
take care that the names of your constants, classes and methods don't conflict
|
||||
with any of Ruby's built-in names.
|
||||
|
||||
<a name="n13"></a><H3>20.3.2 Functions</H3>
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ static const char *
|
|||
usage = "\
|
||||
Ruby Options (available with -ruby)\n\
|
||||
-ldflags - Print runtime libraries to link with\n\
|
||||
-globalmodule - Wrap everything into the global module\n\
|
||||
-feature name - Set feature name (used by `require')\n";
|
||||
|
||||
|
||||
|
|
@ -177,6 +178,9 @@ public:
|
|||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i],"-globalmodule") == 0) {
|
||||
useGlobalModule = true;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-help") == 0) {
|
||||
Printf(stderr,"%s\n", usage);
|
||||
} else if (strcmp (argv[i],"-ldflags") == 0) {
|
||||
|
|
@ -1330,7 +1334,7 @@ public:
|
|||
Printv(klass->init, klass->vname, " = rb_define_class_under(", modvar,
|
||||
", \"", klass->name, "\", $super);\n", NIL);
|
||||
} else {
|
||||
Printv(klass->init, klass->vname, " = rb_define_class_under(\"",
|
||||
Printv(klass->init, klass->vname, " = rb_define_class(\"",
|
||||
klass->name, "\", $super);\n", NIL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ Ruby
|
|||
* Add some special directives to automatically rename declarations to
|
||||
or from CamelCase.
|
||||
|
||||
* Consider adding a switch to define everything in the global (Kernel)
|
||||
[DONE] Consider adding a switch to define everything in the global (Kernel)
|
||||
module instead of nested in a user-defined module, but only if
|
||||
it comes up.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue