Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: cambalinho on October 07, 2014, 09:31:31 pm

Title: why isn't showed in Intellegence list?
Post by: cambalinho on October 07, 2014, 09:31:31 pm
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?
Title: Re: why isn't showed in Intellegence list?
Post by: oBFusCATed on October 08, 2014, 02:02:56 am
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.
Title: Re: why isn't showed in Intellegence list?
Post by: cambalinho on October 08, 2014, 09:21:49 am
i have these property class:
Code
/*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:
Code
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:
Code
form a;
a.
why the Mousehover and TabStop aren't showed in Intelligence List?(when we write the dot, a list is showed)
Title: Re: why isn't showed in Intellegence list?
Post by: cacb on October 08, 2014, 03:07:44 pm
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;
            }
        };
Title: Re: why isn't showed in Intellegence list?
Post by: ollydbg on October 08, 2014, 03:28:37 pm
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 (http://www.quora.com/Why-is-C++-grammar-so-hard-to-parse) 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 (http://forums.codeblocks.org/index.php/topic,18785.msg128654.html#msg128654). 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.
Title: Re: why isn't showed in Intellegence list?
Post by: cambalinho on October 08, 2014, 05:03:48 pm
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:
Code
#define Get(x) [this]()->x
#define Set(...) [this](__VA_ARGS__)->void
Title: Re: why isn't showed in Intellegence list?
Post by: cambalinho on October 08, 2014, 05:05:00 pm
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 (http://www.quora.com/Why-is-C++-grammar-so-hard-to-parse) 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 (http://forums.codeblocks.org/index.php/topic,18785.msg128654.html#msg128654). 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...
Title: Re: why isn't showed in Intellegence list?
Post by: edison on October 09, 2014, 02:44:58 pm
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.codeblocks.org/index.php/topic,19611.0.html).
Title: Re: why isn't showed in Intellegence list?
Post by: cambalinho on October 09, 2014, 03:42:41 pm
edison: how can i found it and download it?
Title: Re: why isn't showed in Intellegence list?
Post by: stahta01 on October 09, 2014, 04:29:02 pm
edison: how can i found it and download it?

I would start here in the CB Wiki
http://wiki.codeblocks.org/index.php?title=Announcement_for_plugins/patches (http://wiki.codeblocks.org/index.php?title=Announcement_for_plugins/patches)

But, going to here would likely be faster
http://forums.codeblocks.org/index.php/topic,18785.0.html (http://forums.codeblocks.org/index.php/topic,18785.0.html)

Tim S.
Title: Re: why isn't showed in Intellegence list?
Post by: cambalinho on October 09, 2014, 04:38:32 pm
edison: how can i found it and download it?

I would start here in the CB Wiki
http://wiki.codeblocks.org/index.php?title=Announcement_for_plugins/patches (http://wiki.codeblocks.org/index.php?title=Announcement_for_plugins/patches)

But, going to here would likely be faster
http://forums.codeblocks.org/index.php/topic,18785.0.html (http://forums.codeblocks.org/index.php/topic,18785.0.html)

Tim S.
e see h files and more.. but how install it?
https://github.com/alpha0010/ClangLib
Title: Re: why isn't showed in Intellegence list?
Post by: Alpha on October 09, 2014, 07:09:16 pm
e see h files and more.. but how install it?
https://github.com/alpha0010/ClangLib
What OS you are using?
Title: Re: why isn't showed in Intellegence list?
Post by: cambalinho on October 09, 2014, 07:55:51 pm
e see h files and more.. but how install it?
https://github.com/alpha0010/ClangLib
What OS you are using?
windows 7
Title: Re: why isn't showed in Intellegence list?
Post by: Alpha on October 09, 2014, 08:11:54 pm
Okay.  Then the easiest method would be to get nightly 9765 (http://forums.codeblocks.org/index.php/topic,19261.0.html) and extract precompiled ClangLib (https://github.com/alpha0010/ClangLib/releases/tag/v0.1) 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.