[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/HuidaeCho/mapserver/master/mapscript/python/pymodule.i [Back]  [Original]

/******************************************************************************
 * Project:  MapServer
 * Purpose:  Python-specific enhancements to MapScript
 * Author:   Sean Gillies, sgillies@frii.com
 *
 ******************************************************************************
 *
 * Python-specific mapscript code has been moved into this 
 * SWIG interface file to improve the readability of the main
 * interface file.  The main mapscript.i file includes this
 * file when SWIGPYTHON is defined (via 'swig -python ...').
 *
 *****************************************************************************/

/******************************************************************************
 * Simple Typemaps
 *****************************************************************************/

/* Translates Python None to C NULL for strings */
%typemap(in,parse="z") char * "";

/* To support imageObj::getBytes */
%typemap(out) gdBuffer {
    $result = PyBytes_FromStringAndSize((const char*)$1.data, $1.size);
    if( $1.owns_data )
       msFree($1.data);
}


/*
 *  Typemap for counted arrays of doubles routine, "msSearchDiskTree()") != 0) {
                    _raise_ms_exception();
                    msResetErrorList();
                    return NULL;
                }
            default:
                _raise_ms_exception();
                msResetErrorList();
                return NULL;
        }
                
    }
}
         
%pythoncode %{
MapServerError = _mapscript.MapServerError
MapServerChildError = _mapscript.MapServerChildError
%}

/* The bogus "if 1:" is to introduce a new scope to work around indentation
   handling with pythonappend in different versions.  (#3180) */
%feature("pythonappend") layerObj %{if 1:
            self.p_map=None
            try:
                # python 2.5
                if args and len(args)!=0: 
                    self.p_map=args[0]
            except NameError:
                # python 2.6
                if map: 
                    self.p_map=map
       %}

/* The bogus "if 1:" is to introduce a new scope to work around indentation
   handling with pythonappend in different versions. (#3180) */
%feature("pythonappend") classObj %{if 1:
            self.p_layer =None
            try:
                # python 2.5
                if args and len(args)!=0: 
                    self.p_layer=args[0]
            except NameError:
                # python 2.6
                if layer: 
                    self.p_layer=layer
       %}

%feature("shadow") insertClass %{
    def insertClass(*args):
        actualIndex=$action(*args)
        args[1].p_layer=args[0]
        return actualIndex%}

%feature("shadow") getClass %{
    def getClass(*args):
        clazz = $action(*args)
        if clazz:
            if args and len(args)!=0:
                clazz.p_layer=args[0]
            else:
                clazz.p_layer=None
        return clazz%}

%feature("shadow") insertLayer %{
    def insertLayer(*args):
        actualIndex=$action(*args)
        args[1].p_map=args[0]
        return actualIndex%}

%feature("shadow") getLayer %{
    def getLayer(*args):
        layer = $action(*args)
        if layer:
            if args and len(args)!=0:
                layer.p_map=args[0]
            else:
                layer.p_map=None
        return layer%}

%feature("shadow") getLayerByName %{
    def getLayerByName(*args):
        layer = $action(*args)
        if layer:
            if args and len(args)!=0:
                layer.p_map=args[0]
            else:
                layer.p_map=None
        return layer%}

Web Proxy Viewer  |  New URL  |  Original Page