User forums > Using Code::Blocks
why isn't showed in Intellegence list?
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.
cambalinho:
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
--- End code ---
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;
}
};
};
--- End code ---
when i do:
--- Code: ---form a;
a.
--- End code ---
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)
--- End quote ---
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)
--- End quote ---
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.
Navigation
[0] Message Index
[#] Next page
Go to full version