News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

why isn't showed in Intellegence list?

Started by cambalinho, October 07, 2014, 09:31:31 PM

Previous topic - Next topic

cambalinho

i did the property class. i create variables from it, in a new class. why that new class variables, the properties, aren't showed in Intellegence list?

oBFusCATed

If you don't post minimal example which shows that the problem can be reproduced with the latest night build then we can hardly do something about it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

cambalinho

i have these property class:
/*properties

- how use create 1 property with macro:

      PROPERTY(TypeName,PropertyName,getfunction, setfunction)

- never forget to do 1 Copy Constructor inside of class's, that uses the property,
         for avoid copy the 'this' value\adress and use a diferent memory adress
*/
template <typename T>
class property
{
private:
    T PropertyValue;
    std::function<T(void)> getf;
    std::function<void(T)> setf;
public:

    property(const T value)
    {
        getf=nullptr;
        setf=nullptr;
        PropertyValue=value;
    };

    property(const property &value)  :  PropertyValue(value.PropertyValue) , getf(value.getf)
    {
    }

    property(std::function<T(void)> GetFunction=nullptr,std::function<void(T)> SetFunction=nullptr)
    {
        setf=SetFunction;
        getf=GetFunction;
    }

    property& operator=(const T &value)
    {
        PropertyValue=value;
        if (setf!=nullptr)
            setf(value);
        return *this;
    }

    property& operator=(const property &value)
    {
        PropertyValue = value.PropertyValue;
        if (setf!=nullptr)
            setf(PropertyValue);
        return *this;
    }

    operator T()
    {
        if (getf!=nullptr)
            return getf();
        else
            return PropertyValue;
    }

    friend ostream& operator<<(ostream& os, property& dt)
    {
        if(dt.getf==nullptr && dt.setf==nullptr)
            os << dt.PropertyValue;
        else if (dt.getf!=nullptr)
            os << dt.getf();
        return os;
    }

    friend istream& operator>>(istream &input, property &dt)
    {
        input >> dt.PropertyValue;
        if (dt.setf!=nullptr)
            dt.setf(dt.PropertyValue);
        return input;
    }

    friend istream &getline(istream &in, property &dt)
    {
        getline(in, dt.PropertyValue);
        if (dt.setf!=nullptr)
            dt.setf(dt.PropertyValue);
        return in;
    }
};

/*template<typename T, typename Fnc1_t, typename Fnc2_t, typename classthis>
property<T> GetProperty(Fnc1_t Getter, Fnc2_t Setter, classthis clsthis)
{
    return property<T>(std::bind(Getter, clsthis), std::bind(Setter, clsthis, std::placeholders::_1));
}

#define PROPERTY(TypeName,PropertyName,getfunction, setfunction) \
property<TypeName> PropertyName{std::bind(&getfunction, *this),std::bind(&setfunction, *this, std::placeholders::_1)}*/
#define Get(x) [this]()->x
#define Set(...) [this](__VA_ARGS__)->void

now i'm add some members on a new class:
class form
{
public:
property <boolean> TabStop
        {
            Get(boolean)
            {
                return blnTabStop;
            },
            Set(boolean tabstop)
            {
                if (blnTabStop != tabstop)
                {
                    blnTabStop = tabstop;
                    long s;
                    if (tabstop == false)
                    {
                        s = GetWindowLongPtr(hwnd, GWL_STYLE);
                        s = s & ~(WS_TABSTOP);
                    }
                    else
                    {
                        s = GetWindowLongPtr(hwnd, GWL_STYLE);
                        s = s | (WS_TABSTOP);
                    }
                    SetWindowLongPtr(hwnd, GWL_STYLE, (LONG_PTR)s);
                }
            }
        };

        property <int> Mousehover
        {
            Get(int)
            {
               return intMouseHover;
            },
            Set(int mousehover)
            {
                intMouseHover = mousehover;
            }
        };
};

when i do:
form a;
a.

why the Mousehover and TabStop aren't showed in Intelligence List?(when we write the dot, a list is showed)

cacb

Quote from: cambalinho on October 08, 2014, 09:21:49 AM
why the Mousehover and TabStop aren't showed in Intelligence List?(when we write the dot, a list is showed)

Is your comma-notation and functions without retyrn type proper C++ syntax? I am guessing this would confuse C::B

you have
       property <int> Mousehover
       {
           Get(int)
           {
              return intMouseHover;
           },
           Set(int mousehover)
           {
               intMouseHover = mousehover;
           }
       };


I would guess you need something like (observe comma removed, return types added)
       property <int> Mousehover
       {
           int Get()
           {
              return intMouseHover;
           }
           void Set(int mousehover)
           {
               intMouseHover = mousehover;
           }
       };

ollydbg

Quote from: cambalinho on October 08, 2014, 09:21:49 AM
i have these property class:
**snip**
**snip**
why the Mousehover and TabStop aren't showed in Intelligence List?(when we write the dot, a list is showed)
Hi, cambalinho.
Our CodeCompletion's parser currently doesn't have the ability to parse the new C++ grammar like "[this]()->x". (I don't understand those grammar too :)), so you code are not parsed correctly. Two solutions:
1, help us to improve, if you have ability to read the CodeCompletion's source code, you will see that we have very limited C++ semantic check when parsing, in-fact, C++ language is very hard to parse, see: Why is C++ grammar so hard to parse? - Quora or many other related discussions.

2, you can use some external tools currently like Clang codecompletion, our developer Alpha have implement such plugin, see: Clang based CC, new CC interface. Note Clang is a full compiler suite, so it has the ability to parse very complex C++ source code and give your very precise code suggestion. I'm not use Clang quite often, maybe, its speed is not very good, you can follow that thread for more informations.
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.

cambalinho

Quote from: cacb on October 08, 2014, 03:07:44 PM
Quote from: cambalinho on October 08, 2014, 09:21:49 AM
why the Mousehover and TabStop aren't showed in Intelligence List?(when we write the dot, a list is showed)

Is your comma-notation and functions without retyrn type proper C++ syntax? I am guessing this would confuse C::B

you have
       property <int> Mousehover
       {
           Get(int)
           {
              return intMouseHover;
           },
           Set(int mousehover)
           {
               intMouseHover = mousehover;
           }
       };


I would guess you need something like (observe comma removed, return types added)
       property <int> Mousehover
       {
           int Get()
           {
              return intMouseHover;
           }
           void Set(int mousehover)
           {
               intMouseHover = mousehover;
           }
       };

if you can give me the right macro.. i accept ;)
heres the Get and Set macros:
#define Get(x) [this]()->x
#define Set(...) [this](__VA_ARGS__)->void

cambalinho

Quote from: ollydbg on October 08, 2014, 03:28:37 PM
Quote from: cambalinho on October 08, 2014, 09:21:49 AM
i have these property class:
**snip**
**snip**
why the Mousehover and TabStop aren't showed in Intelligence List?(when we write the dot, a list is showed)
Hi, cambalinho.
Our CodeCompletion's parser currently doesn't have the ability to parse the new C++ grammar like "[this]()->x". (I don't understand those grammar too :)), so you code are not parsed correctly. Two solutions:
1, help us to improve, if you have ability to read the CodeCompletion's source code, you will see that we have very limited C++ semantic check when parsing, in-fact, C++ language is very hard to parse, see: Why is C++ grammar so hard to parse? - Quora or many other related discussions.

2, you can use some external tools currently like Clang codecompletion, our developer Alpha have implement such plugin, see: Clang based CC, new CC interface. Note Clang is a full compiler suite, so it has the ability to parse very complex C++ source code and give your very precise code suggestion. I'm not use Clang quite often, maybe, its speed is not very good, you can follow that thread for more informations.
sorry i don't know how CodeCompletion works...

edison

The parsing speed of Clang CC plug-in is very very slow, but it works.
The build-in  CC of CB sometimes need to re-open the file and sometimes can not provide correct hint when enabled the std=c++11 switch with MinGW (http://forums.next.codeblocks.org/index.php/topic,19611.0.html).

cambalinho

edison: how can i found it and download it?

stahta01

#9
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]


Alpha



Alpha

Okay.  Then the easiest method would be to get nightly 9765 and extract precompiled ClangLib on top of it.

I have not updated that build recently, so compiling it yourself from source is always preferable and ensures you have the latest fixes, but that should be enough to provide you with a taste of how it currently functions.
Note: when using this plugin save often, it is still in its early stages, and can be slow and unstable.