Crossfire Server, Branch 1.12  R12190
cfpython_archetype.c
Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /* CFPython - A Python module for Crossfire RPG.                             */
00003 /* Version: 2.0beta8 (also known as "Alexander")                             */
00004 /* Contact: yann.chachkoff@myrealbox.com                                     */
00005 /*****************************************************************************/
00006 /* That code is placed under the GNU General Public Licence (GPL)            */
00007 /* (C)2001-2005 by Chachkoff Yann (Feel free to deliver your complaints)     */
00008 /*****************************************************************************/
00009 /*  CrossFire, A Multiplayer game for X-windows                              */
00010 /*                                                                           */
00011 /*  Copyright (C) 2000 Mark Wedel                                            */
00012 /*  Copyright (C) 1992 Frank Tore Johansen                                   */
00013 /*                                                                           */
00014 /*  This program is free software; you can redistribute it and/or modify     */
00015 /*  it under the terms of the GNU General Public License as published by     */
00016 /*  the Free Software Foundation; either version 2 of the License, or        */
00017 /*  (at your option) any later version.                                      */
00018 /*                                                                           */
00019 /*  This program is distributed in the hope that it will be useful,          */
00020 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of           */
00021 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            */
00022 /*  GNU General Public License for more details.                             */
00023 /*                                                                           */
00024 /*  You should have received a copy of the GNU General Public License        */
00025 /*  along with this program; if not, write to the Free Software              */
00026 /*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
00027 /*                                                                           */
00028 /*****************************************************************************/
00029 
00030 #include <cfpython.h>
00031 #include <cfpython_archetype_private.h>
00032 
00033 static PyObject *Crossfire_Archetype_GetName(Crossfire_Archetype *whoptr, void *closure) {
00034     return Py_BuildValue("s", cf_archetype_get_name(whoptr->arch));
00035 }
00036 
00037 static PyObject *Crossfire_Archetype_GetNext(Crossfire_Archetype *who, void *closure) {
00038     return Crossfire_Archetype_wrap(cf_archetype_get_next(who->arch));
00039 }
00040 
00041 static PyObject *Crossfire_Archetype_GetMore(Crossfire_Archetype *who, void *closure) {
00042     return Crossfire_Archetype_wrap(cf_archetype_get_more(who->arch));
00043 }
00044 
00045 static PyObject *Crossfire_Archetype_GetHead(Crossfire_Archetype *who, void *closure) {
00046     return Crossfire_Archetype_wrap(cf_archetype_get_head(who->arch));
00047 }
00048 
00049 static PyObject *Crossfire_Archetype_GetClone(Crossfire_Archetype *who, void *closure) {
00050     return Crossfire_Object_wrap(cf_archetype_get_clone(who->arch));
00051 }
00052 
00053 static PyObject *Crossfire_Archetype_GetNewObject(Crossfire_Archetype *who, PyObject *args) {
00054     return Crossfire_Object_wrap(cf_create_object_by_name(cf_archetype_get_name(who->arch)));
00055 }
00056 
00057 PyObject *Crossfire_Archetype_wrap(archetype *what) {
00058     Crossfire_Archetype *wrapper;
00059 
00060     /* return None if no object was to be wrapped */
00061     if (what == NULL) {
00062         Py_INCREF(Py_None);
00063         return Py_None;
00064     }
00065 
00066     wrapper = PyObject_NEW(Crossfire_Archetype, &Crossfire_ArchetypeType);
00067     if (wrapper != NULL)
00068         wrapper->arch = what;
00069     return (PyObject *)wrapper;
00070 }
00071 
00072 static int Crossfire_Archetype_InternalCompare(Crossfire_Archetype *left, Crossfire_Archetype *right) {
00073     return (left->arch < right->arch ? -1 : (left->arch == right->arch ? 0 : 1));
00074 }