Committed Kou's patch for the Ruby module (for the -prefix command line
option). Also updated the Ruby docs accordingly. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6029 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f6fc431e6c
commit
6b6f802ccb
2 changed files with 1599 additions and 2338 deletions
3915
Doc/Manual/Ruby.html
3915
Doc/Manual/Ruby.html
File diff suppressed because it is too large
Load diff
|
|
@ -121,19 +121,20 @@ usage = "\
|
||||||
Ruby Options (available with -ruby)\n\
|
Ruby Options (available with -ruby)\n\
|
||||||
-globalmodule - Wrap everything into the global module\n\
|
-globalmodule - Wrap everything into the global module\n\
|
||||||
-minherit - Attempt to support multiple inheritance\n\
|
-minherit - Attempt to support multiple inheritance\n\
|
||||||
|
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||||
-feature <name> - Set feature name to <name> (used by `require')\n";
|
-feature <name> - Set feature name to <name> (used by `require')\n";
|
||||||
|
|
||||||
|
|
||||||
#define RCLASS(hash, name) (RClass*)(Getattr(hash, name) ? Data(Getattr(hash, name)) : 0)
|
#define RCLASS(hash, name) (RClass*)(Getattr(hash, name) ? Data(Getattr(hash, name)) : 0)
|
||||||
#define SET_RCLASS(hash, name, klass) Setattr(hash, name, NewVoid(klass, 0))
|
#define SET_RCLASS(hash, name, klass) Setattr(hash, name, NewVoid(klass, 0))
|
||||||
|
|
||||||
|
|
||||||
class RUBY : public Language {
|
class RUBY : public Language {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
String *module;
|
String *module;
|
||||||
String *modvar;
|
String *modvar;
|
||||||
String *feature;
|
String *feature;
|
||||||
|
String *prefix;
|
||||||
int current;
|
int current;
|
||||||
Hash *classes; /* key=cname val=RClass */
|
Hash *classes; /* key=cname val=RClass */
|
||||||
RClass *klass; /* Currently processing class */
|
RClass *klass; /* Currently processing class */
|
||||||
|
|
@ -176,6 +177,7 @@ public:
|
||||||
module = 0;
|
module = 0;
|
||||||
modvar = 0;
|
modvar = 0;
|
||||||
feature = 0;
|
feature = 0;
|
||||||
|
prefix = 0;
|
||||||
current = NO_CPP;
|
current = NO_CPP;
|
||||||
classes = 0;
|
classes = 0;
|
||||||
klass = 0;
|
klass = 0;
|
||||||
|
|
@ -219,6 +221,16 @@ public:
|
||||||
} else if (strcmp(argv[i],"-minherit") == 0) {
|
} else if (strcmp(argv[i],"-minherit") == 0) {
|
||||||
multipleInheritance = true;
|
multipleInheritance = true;
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
|
} else if (strcmp(argv[i],"-prefix") == 0) {
|
||||||
|
if (argv[i+1]) {
|
||||||
|
char *name = argv[i+1];
|
||||||
|
prefix = NewString(name);
|
||||||
|
Swig_mark_arg(i);
|
||||||
|
Swig_mark_arg(i+1);
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
Swig_arg_error();
|
||||||
|
}
|
||||||
} else if (strcmp(argv[i],"-help") == 0) {
|
} else if (strcmp(argv[i],"-help") == 0) {
|
||||||
Printf(stderr,"%s\n", usage);
|
Printf(stderr,"%s\n", usage);
|
||||||
}
|
}
|
||||||
|
|
@ -480,6 +492,10 @@ public:
|
||||||
virtual int importDirective(Node *n) {
|
virtual int importDirective(Node *n) {
|
||||||
String *modname = Getattr(n,"module");
|
String *modname = Getattr(n,"module");
|
||||||
if (modname) {
|
if (modname) {
|
||||||
|
if (prefix) {
|
||||||
|
Insert(modname, 0, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
List *modules = Split(modname,':',INT_MAX);
|
List *modules = Split(modname,':',INT_MAX);
|
||||||
if (modules && Len(modules) > 0) {
|
if (modules && Len(modules) > 0) {
|
||||||
modname = NewString("");
|
modname = NewString("");
|
||||||
|
|
@ -515,6 +531,10 @@ public:
|
||||||
if (module == 0) {
|
if (module == 0) {
|
||||||
/* Start with the empty string */
|
/* Start with the empty string */
|
||||||
module = NewString("");
|
module = NewString("");
|
||||||
|
|
||||||
|
if (prefix) {
|
||||||
|
Insert(mod_name, 0, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
/* Account for nested modules */
|
/* Account for nested modules */
|
||||||
List *modules = Split(mod_name,':',INT_MAX);
|
List *modules = Split(mod_name,':',INT_MAX);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue