Don't call Swig_scopename_prefix() unnecessarily
No real changes, just make the code do what the comment said it did and only use the namespace as prefix when "nspace" feature is on instead of always trying to use it as prefix and then resetting it. This required adding default ctor and assignment operator from raw pointer to scoped_dohptr, but they can be useful elsewhere too, while the actual code in getGlobalWrapperName() is simpler and more readable now. No real changes.
This commit is contained in:
parent
2f6f6df211
commit
1fb0de9e00
1 changed files with 15 additions and 5 deletions
|
|
@ -33,6 +33,7 @@ namespace
|
|||
class scoped_dohptr
|
||||
{
|
||||
public:
|
||||
scoped_dohptr() : obj_(NULL) {}
|
||||
explicit scoped_dohptr(DOH* obj) : obj_(obj) {}
|
||||
~scoped_dohptr() { Delete(obj_); }
|
||||
|
||||
|
|
@ -49,6 +50,16 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
// Assignment operator takes ownership of the pointer, just as the ctor does.
|
||||
scoped_dohptr& operator=(DOH* obj) {
|
||||
if (obj != obj_) {
|
||||
Delete(obj_);
|
||||
obj_ = obj;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
DOH* get() const { return obj_; }
|
||||
|
||||
DOH* release() const /* not really */ {
|
||||
|
|
@ -196,13 +207,12 @@ public:
|
|||
String *getGlobalWrapperName(Node *n, String *name) const
|
||||
{
|
||||
// Use namespace as the prefix if feature:nspace is in use.
|
||||
scoped_dohptr scopename_prefix(Swig_scopename_prefix(Getattr(n, "name")));
|
||||
if (scopename_prefix) {
|
||||
if (GetFlag(parentNode(n), "feature:nspace")) {
|
||||
scoped_dohptr scopename_prefix;
|
||||
if (GetFlag(parentNode(n), "feature:nspace")) {
|
||||
scopename_prefix = Swig_scopename_prefix(Getattr(n, "name"));
|
||||
if (scopename_prefix) {
|
||||
scoped_dohptr mangled_prefix(Swig_string_mangle(scopename_prefix));
|
||||
scopename_prefix = mangled_prefix;
|
||||
} else {
|
||||
scopename_prefix.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue