Jump to content

  • Log In with Google      Sign In   
  • Create Account

STL Maps and SWIG/Lua


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 medevilenemy   Members   -  Reputation: 315

Like
0Likes
Like

Posted 21 March 2012 - 07:41 PM

Haven't been on in a while, so I'll start with "Hello All!". Ok, now that I have that out of the way, I'm having some trouble figuring out how to get SWIG to bing a stl map from int to an object pointer to lua. It compiles just fine, but I can't seem to get it to work. In the past, owl would be the one to talk to about SWIG stuff, but seeing as he is banned for some reason: Does anyone else have any experience with SWIG?

Specifically it is a map<int, Object*> where Object is a class of mine. It is wrapping an instance called Master_Object_Map. When I call Master_Object_Map:get(indexIwant) it just prints out the error "index not found" (I'm testing with known indices)
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.

Sponsor:

#2 Washu   Senior Moderators   -  Reputation: 5179

Like
0Likes
Like

Posted 21 March 2012 - 07:46 PM

Can you post a bit of code?

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#3 medevilenemy   Members   -  Reputation: 315

Like
0Likes
Like

Posted 21 March 2012 - 11:09 PM

well, the map itself is defined as: map<int, Object*> Master_Object_Map;

Whenever a new object is created, a pointer to it gets added to that map with its UID (starting at 0) as its key. The swig .i file contains the object class, as well as:

%template(MapIntObj) map<int, Object*>;

map<int, Object*> Master_Object_Map;

And this is the lua code I was playing with as a silly little simple test:

io.output("luatestoutputfunfunfunfunfun.txt")
io.output(objects.Master_Object_Map:get(0):Get_UID())
io.output(objects.Master_Object_Map:get(1):Get_UID())
io.output(objects.Master_Object_Map:get(2):Get_UID())
io.output(objects.Master_Object_Map:get(3):Get_UID())
io.output(objects.Master_Object_Map:get(4):Get_UID())
io.output(objects.Master_Object_Map:get(5):Get_UID())

The error I get from lua is as I stated above. Going by the generated swig wrapper code, it came from get(). (note, objects is the module name)
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.

#4 medevilenemy   Members   -  Reputation: 315

Like
0Likes
Like

Posted 24 March 2012 - 07:41 PM

No takers? Guess SWIG isn't terribly well known.
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.

#5 yckx   Prime Members   -  Reputation: 1209

Like
0Likes
Like

Posted 25 March 2012 - 12:35 AM

Eh, I don't have an answer for you. Sorry. But I can recommend you join the SWIG-users email list and ask there. I suspect there are people on that list who could solve your problem. The SWIG site has a mailing lists page with info on how to access the lists.

#6 medevilenemy   Members   -  Reputation: 315

Like
0Likes
Like

Posted 25 March 2012 - 01:37 AM

I figured it out (when in doubt, rely on the engineer's propensity to do good work at 3am)... This will sound silly, but I was looking for entries in the map in a script that is run before the relevant entries actually spawn and was therefore recieving what *appeared* like the map not having been bound properly. Progress goes marching on.
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS