Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
obj->ToggleSet in Python

 
Post new topic   Reply to topic Printable version
 View previous topic  Cygwin Post :: Post Broadcast  View next topic  
Author Message
Hawkaloogie
Newbie


Joined: Jan 11 2003
Posts: 13
Offline

PostPosted: Fri Dec 26, 2008 4:44 am    Post subject: obj->ToggleSet in Python Reply to topic Reply with quote

Would it be possible to make obj->ToggleSet work through the Python interface? I've got 50+ objects to toggle at once, and doing them individually makes it look slow (cool, kinda, but slow).

If I want ToggleSet, do I need to learn C?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Fri Dec 26, 2008 7:17 pm    Post subject: Reply to topic Reply with quote

From what I can tell, object->ToggleSet is only available in C, though you could just use object->Toggle for each individual object. It's not as efficient, but I don't see there being a hugely noticeable delay if you did so (but I haven't tried, so I can't say).
Back to top
View users profile Send private message Add User to Ignore List Send email
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Fri Dec 26, 2008 10:04 pm    Post subject: Reply to topic Reply with quote

he said there was, which is why he specifically wanted to use ToggleSet()
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Hawkaloogie
Newbie


Joined: Jan 11 2003
Posts: 13
Offline

PostPosted: Sat Dec 27, 2008 12:13 am    Post subject: Reply to topic Reply with quote

Yeah, that's why I asked if it would be possible to make ToggleSet work. I've been trying to figure out the magic that is the pymod interface with little luck (having just started with Python a couple days ago, and my C knowledge being completely academic).

It seems that if I could translate the Python lists into the required C data structures, that it would work.

Is whatever I just mumbled about even possible? Is there documentation available somewhere for this type of thing?

I'll start checking the Google.

EDIT: Swig seems interesting...
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Sat Dec 27, 2008 5:30 am    Post subject: Reply to topic Reply with quote

pymod is really confusing, even to me. Whenever I want to change something I have to spend an hour re-learning how it all works. Swig is also really confusing, though, so it's not clear that it would have been a net win if I had used that instead of basically reimplementing the parts that I needed.

You should be able to make toggleset work by adding support for lists of integers to pymod. You'd want to make a new type in pymod-process.py (see the other class type_...'s) and write conversion functions in pymod.c (cvt_c2p/p2c_...). Actually you only need p2c in this case. It shouldn't be too hard to make it work, the hard part is making it work without leaking memory on every call icon_smile.gif

It's probably easiest to use a fixed-size buffer and enforce a maximum size, because then you can allocate it on the stack and don't have to worry about freeing it. I think. Good luck.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Hawkaloogie
Newbie


Joined: Jan 11 2003
Posts: 13
Offline

PostPosted: Sat Dec 27, 2008 5:46 am    Post subject: Reply to topic Reply with quote

Thanks, I'll try that and report on my findings.

In the future, I might try something more ambitious with SWIG. The benefits with SWIG seem incredible: Automatic handling of array pointers (which means ToggleSet would work out-of-the-box), completely generated from .h files, interface translation for objects done inside the SWIG interface file (cleaner code), and the ability to translate to a whole host of languages. I've got a SWIG interface to objects.c compiling, but it seems that it needs to use shared objects instead of compiling everything into the binary. Since I have absolutely no idea how to change the Makefile to do that, I'm stuck for now.

That being said, are there any references anyone can suggest for GNU Make and/or the rest of the GNU build tools?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Sun Dec 28, 2008 3:37 am    Post subject: Reply to topic Reply with quote

If you can make a natural-feeling interface using swig, go for it. I've written some swig typemaps myself, and I know it's really powerful, but it's also hard to use and confusing to debug when it doesn't work. Specifically, it doesn't know anything about asss' interface and callback systems, so to make those come out naturally, you'll have to write a bunch of helper code, similar to what's in pymod.c now.

For make, you might be able to find an introduction to the concept of a makefile (i.e. a directed graph of files with actions) somewhere, but the best reference is probably the gnu make manual itself, even though it's a little dry. asss does use several gnu-specific features.

There's nothing about swig that requires shared objects. It just generates a .c file that you can compile and link however you want. You will need to integrate it into the makefile though, however you link it, so you should learn how to do that.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Tue Dec 30, 2008 8:37 pm    Post subject: Reply to topic Reply with quote

In working on exposing some of the Hyperspace stuff to python, I actually started on hand coding some translation functions for the util LinkedList a while back. It took me several days of poring back and forth between pymod, pymod_process, and the Py/C API docs to even figure out what needed to be done, so I back burnered it while focusing on more immediate concerns. I'm actually pretty excited about this thread because I thought I was the only person who was doing any serious work with pymod.

The other day I found Cython which looks to be much easier to use than SWIG but haven't taken it for a spin yet.
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 36 page(s) served in previous 5 minutes.

phpBB Created this page in 0.471408 seconds : 32 queries executed (94.5%): GZIP compression disabled