The basic situation is that a class in libtcodwrapper, Background, is overriding `++` for some nefarious purposes. It's bad design, I think, but that's a discussion for some other time. Here's the overridden operator in C#
- Code: Select all
public class Background
{
internal int m_value;
/// <summary>
/// Increment background type to next background in BackgroundFlag enum
/// </summary>
/// <param name="lhs">Left Hand Side</param>
/// <returns>New Background</returns>
public static Background operator ++(Background lhs)
{
if (lhs.BackgroundFlag == BackgroundFlag.Alph)
throw new Exception("Can not increment past end of BackgroundFlag enum");
lhs.m_value += 1;
return lhs;
}
}
Cobra won't recognize the ++ operator, even overridden, and I had no luck trying to fake it with stuff like ".++" and ".plusplus". I decided to take a crack at extending Background with a new method ".increaseFlag" that looks like:
- Code: Select all
extend Background
def increaseFlag
.m_value += 1
But I get an error message suggesting that "m_value" cannot be found in "this" of type "Background". So I'm guessing maybe extension methods can't see the internal scoped members.
I also don't know that this is a bug or a bug worth fixing right now, since I don't know the long-term strategy for Cobra to incorporate the various backends. Most of my complaints have been C# specific and I'm feeling a bit guilty in that regard. Anyway, I'll be glad to provide more details or implement any workarounds that are suggested. Thanks!