Wednesday, March 31, 2010

swig'ed libtcod c# demo sucess...


There still are multiple modules not working right and a crash on exit in TCDODijkstra, but I got the demo in c# ported to the new API and working!

Between craziness at work and work planning a trip over the summer, my hacking time has been scare this week, but I feel like this is good progress.

Update: The TCODDijkstra crash appears to be a bug in libtcod itself, as I can reproduce it in the C++ demo. I've notified one of the maintainers.

Update^2: The crash was fixed in all of 15 minutes, nobody can say the libtcod maintainers aren't responsive.

Saturday, March 27, 2010

Sometimes you have to use a bigger hammer...

This evening I spent awhile trying to hammer the SWIG'ed c# wrapper into something usable and less ugly. I've fixed all the "known" issues with the wrapper not wrapping some modules or functionality. The reduction in ugliness is related to the C-style enum and data type names. Things such as:
  • TCOD_BKGND_NONE
  • TCOD_key_status_t
  • TCOD_NOISE_MAX_OCTAVES
While for C users there is nothing wrong with them, users of higher level languages expect identifiers with less capital letters and underscores. After spending an hour or two trying to do it "nicely", I finally settled with adding somewhere around 200 lines like:

%rename (NoiseMaxOctaves) TCOD_NOISE_MAX_OCTAVES;

While a few VIM macros made this less painful that first glace would suggest, it still took awhile. It isn't a very elegant solution it works.

Now that I can type the constants without wanting to cry, I'm working on converting the C# libtcod-net demo program to use the new API. It started with about 400 compiler errors and I still have 230 to go, so it will take a while. It also means converting magecrawl (and by extension all the users of libtcod-net) will take awhile.

Wednesday, March 24, 2010

libtcod and swig - The current plan...

tbellin stepped up and figured out the swig documentation when it came to callbacks. He's tested in C# and apparently it works. I'm thrilled that somebody figured it out. :)

From reading the documentation, the given language needs "director" support for callbacks to work, so some languages like lua are out of luck for now (until SWIG adds more support) unfortuntly.

As I mentioned in the comments sections yesterday, here are my plans:
  • Get heightmap finished
  • Fix one issue with callbacks user data.
  • Port the libtcod-net demo application to the new libtcod wrapper for testing.
  • Port magecrawl to the new libtcod wrapper for more testing.
  • Release two "official" platforms
    • C# - If things work out, for the period of at least a release support both the new and old library. Strongly encourage people to move to the new wrapper.
    • LUA - While it'll have to not have support for callbacks (stupid swig director support), it's still "good enough".
  • Ask people who are interested in other languages/platforms to work with me to bring those languages up to a good enough level.

Tuesday, March 23, 2010

Wrapping up libtcod, swig, and cmake nonsense soon hopefully....

While I've enjoyed the libtcod, swig, and cmake work, my interest is seriously starting to wind down. Here's a status update:

libtcod-java - See this mailing list post. Nobody has answered yet, and I have no clue how to get it working right now. This might have to be stowed.

libtcod-php - Waiting to hear back from person who wanted it to see if they wanted php4 or php5. cmake apparently only support php4 naively.

libtcod-ruby - Apparently there is some interest in this, but it isn't working for them. Will be trying to sort that out.

libtcod-cmake-osx - Working with somebody via e-mail (slowly) in order to try to get this working.

libtcod-csharp - Working with somebody via e-mail to sort out crashes and problems I'm not seeing.

Bit of libtcod swig isn't wrapping - Heightmap is down to four functions not being wrapped. BSP looks like a bit of a lost cause. The SWIG documentation on function pointers and callbacks is almost unreadable. The only way I can figure to wrap it is to remove the callback, and create functions that return lists of all the nodes in the BSP in the requested order.

Sunday, March 21, 2010

libtcod-ruby...

Well I have something done for ruby, but it isn't up the my normal standards (aka the demo isn't done). Here is what I have:

http://libtcod-net.googlecode.com/files/libtcod-ruby%20bits.zip

This is a built libtcod-ruby library, for Linux. I can't understand ruby well enough to get a hello world demo working, but require "libtcod-ruby" seems to work. If one of you ruby people want to get a demo working, I'll post it.

The reason that it's a Linux demo is because cmake seems to be utterly broken for finding ruby under Windows. After spending entirely too long messing with it, I gave up and built it under Linux. If someone want to try to get libtcod-ruby working under Windows, let me know and I'll point you to where I've given up.

Off to libtcod-php and libtcod-java, then fixing the known issues and then maybe I can go back to Magecrawl...

Wednesday, March 17, 2010

libtcod in LUA, any more requests?

I now have the same demo from yesterday in LUA for download. 



Download

Here are the list of output languages SWIG can target:

  • Allegro CL
  • C#
  • CFFI
  • CLISP
  • Chicken
  • Guile
  • Java
  • Lua
  • Modula-3
  • Mzscheme
  • OCAML
  • Octave
  • Perl
  • PHP
  • Python
  • R
  • Ruby
  • Tcl
  • UFFI 
If anyone is interested in libtcod wrapped in any of the above languages, speak up and I'll see what I can do.

Otherwise, I'm going to work on fixing up the known issues with these SWIG wrappers so I can hand some/all of it off to somebody else and go back to work on Magecrawl.

Tuesday, March 16, 2010

Prototype libtcod + swig wrappers (python & C#)...

So I finished up the 95% of wrapping libtcod via swig today. The major outstanding areas not done are heightmap and bsp. Heightmap just because it passes a lot of arrays around, and bsp since it uses callbacks. I'm still not sure how I'm going to handle both of these.

Since they were easy to push out (and it's midnight my time right now), I'm just doing python and c#. I hope to get java and/or lua done tomorrow.

Python Demo

C# Demo

Remember, these are demos. They could eat your leftovers in the fridge or cause your program to explode, so be careful. And if things do explode or don't work, let me know. These demos are at the "it compiles, ship it" quality level.