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
Python Interfaces

 
Post new topic   Reply to topic Printable version
 View previous topic  Fakes & chat Post :: Post Hosting ASSS on a Dynamic IP  View next topic  
Author Message
Initrd.gz
Seasoned Helper


Joined: Sep 18 2008
Posts: 134
Location: Over there --->
Offline

PostPosted: Wed Mar 11, 2009 9:43 pm    Post subject: Python Interfaces Reply to topic Reply with quote

Hello all. I have another (probably newbie-ish) question.

I am making a python module, but I want a C interface to it. I am looking at D1st0rt's Optparser module, and that is helping out a lot. I was wondering if there was anything else I should know, because the ioptparser module doesn't really use ASSS as opposed to the optparser library/builtins that much. Also, I was wondering what this meant on the top of most includes:
Code: Show/Hide
/* dist: public */


Another question, but I don't think it is possible. Could you make a person "shoot" L5 bullets (burst rounds) the same way HS does it?

Thanks for your time.[/code]
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Thu Mar 12, 2009 2:30 am    Post subject: Reply to topic Reply with quote

lv5 doesnt exist, but lv4s, the purple ones, do...
_________________
SSC Distension Owner
SSCU Trench Wars Developer
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Thu Mar 12, 2009 6:53 am    Post subject: Reply to topic Reply with quote

The /* dist: public */ is used by an automated packaging script to pick out the files that need to be included with asss when it gets shipped out.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Initrd.gz
Seasoned Helper


Joined: Sep 18 2008
Posts: 134
Location: Over there --->
Offline

PostPosted: Thu Mar 12, 2009 6:55 pm    Post subject: Reply to topic Reply with quote

Thanks.

Another question: what is the difference between pyint: use and pyint: impl in the interface?
Back to top
View users profile Send private message Add User to Ignore List AIM Address
D1st0rt
Miss Directed Wannabe


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

PostPosted: Fri Mar 13, 2009 11:10 am    Post subject: Reply to topic Reply with quote

Use is for an interface you want to be able to use from python, impl is for an interface you want to be able to implement in python. You can also specify both with pyint: use, impl
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Initrd.gz
Seasoned Helper


Joined: Sep 18 2008
Posts: 134
Location: Over there --->
Offline

PostPosted: Sat Mar 14, 2009 4:00 pm    Post subject: Reply to topic Reply with quote

Oh, so If I use impl, I can write python code for the interface?

Thanks a lot. This is probably the last question. How do I use pytype?
Back to top
View users profile Send private message Add User to Ignore List AIM Address
D1st0rt
Miss Directed Wannabe


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

PostPosted: Mon Mar 16, 2009 2:01 pm    Post subject: Reply to topic Reply with quote

There are a couple of different ways you can use pytype. It follows the general pattern of pytype: <mode>, <what it is in c>, <what you are going to call it in pyint declarations>

If you just want to be able to hold onto an arbitrary pointer to the object, you use opaque. name2 is what you will use in future pyint declarations:
Code: Show/Hide
/* pytype: opaque, typename *, name2 */
This won't have any functions you can call, and you wont be able to access any of the members, it's just for when you need to pass it back to a c module.

If you define a struct that contains only members pymod knows how to process (int, Player *, Arena *, etc) you can use that struct in python as an object. For example, from hgcore.h:
Code: Show/Hide
/* pytype: struct, struct HGTeam, hgteam */

For enums, you need to set up a naming convention in the c code where all entries within a struct have a consistent prefix. For example, from hgcore.h:
Code: Show/Hide
/* pyconst: enum, "HGS_*" */
This will create these constants in the asss namespace under their full name.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Initrd.gz
Seasoned Helper


Joined: Sep 18 2008
Posts: 134
Location: Over there --->
Offline

PostPosted: Tue Mar 17, 2009 10:54 am    Post subject: Reply to topic Reply with quote

Thanks a lot. That should be the last question.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Initrd.gz
Seasoned Helper


Joined: Sep 18 2008
Posts: 134
Location: Over there --->
Offline

PostPosted: Thu Mar 19, 2009 2:16 pm    Post subject: Reply to topic Reply with quote

Ok, another small question:

Say I have a structure like this:
Code: Show/Hide

typedef struct Bot
{
    char name[40];
    int ship;
    struct
    {
        unsigned alive : 1;
        unsigned aiming : 1;
        unsigned firing : 1;
        unsigned reloading : 1;
        unsigned padding : 4;
    } flags;
} Bot;
/* pytype: struct, *Bot, bot */

Could I use anything in the flags structure within the Bot structure in python, or do I have to pytype that as well?
Back to top
View users profile Send private message Add User to Ignore List AIM Address
D1st0rt
Miss Directed Wannabe


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

PostPosted: Tue Mar 24, 2009 4:33 pm    Post subject: Reply to topic Reply with quote

I am not sure if you can use generated structures within structures, it might have to be one of the hardcoded types.
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: 647 page(s) served in previous 5 minutes.

phpBB Created this page in 0.557018 seconds : 35 queries executed (89.1%): GZIP compression disabled