Author Topic: Fix global namespace bug  (Read 6536 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Fix global namespace bug
« on: May 01, 2010, 01:27:20 pm »
test demo:
Code
typedef struct _CERT_ECC_SIGNATURE {
    CRYPT_UINT_BLOB     r;
    CRYPT_UINT_BLOB     s;
} CERT_ECC_SIGNATURE, *PCERT_ECC_SIGNATURE;

namespace std
{
    class string
    {
    public:
        void test() {}
    };
};

std::string s;


[attachment deleted by admin]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5721
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Fix global namespace bug
« Reply #1 on: May 01, 2010, 05:10:45 pm »
@loaden
That's great you have fix this bug.
But can you explain more about the patch? How and what you have done.
So that Morten and other devs can understand the theory quickly and applied it soon in the near feature.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5721
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Fix global namespace bug
« Reply #2 on: May 02, 2010, 06:13:52 am »
Ok, I have add a related post Re: CC toolbar enhancement.

The explanation we change the code in token.cpp from

Code
        if (   (   (parent < 0)
                || (curToken->m_ParentIndex == parent) )
            && (curToken->m_TokenKind & kindMask) )
        {
            return result;
        }
to
Code
        if ((curToken->m_ParentIndex == parent) && (curToken->m_TokenKind & kindMask))
        {
            return result;
        }

Is that:

When adding a token, for example, we need to check if this token already exist.
So, it check already exists in the parent scope.

But I'm not sure why the first code need to "parent<0", because the global scope is defined as parent = -1.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.