IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3165


Ignore:
Timestamp:
Feb 8, 2005, 3:04:01 PM (21 years ago)
Author:
desonia
Message:

added some helpful functionality to help SWIG.

Location:
trunk/psLib
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astronomy/astronomy.i

    r3114 r3165  
    33%include "psAstronomyErrors.h"
    44%include "psCoord.h"
     5
    56%include "psMetadata.h"
     7%extend psMetadataItem {
     8    const char *get_STR(void) {
     9       if (self->type != PS_META_STR) {
     10          return NULL;
     11       } else {
     12          return self->data.V;
     13       }
     14    }
     15}
     16
     17// add a method to add primitives to metadata
     18%inline %{
     19psBool psMetadataAddStr(psMetadata* md, psS32 where, const char* name, const char* comment, const char* value) {
     20    return psMetadataAdd(md,where,name,PS_TYPE_PTR, PS_META_STR,comment,value);
     21}
     22psBool psMetadataAddF32(psMetadata* md, psS32 where, const char* name, const char* comment, psF32 value) {
     23    return psMetadataAdd(md,where,name,PS_TYPE_F32, PS_META_PRIMITIVE,comment,value);
     24}
     25psBool psMetadataAddF64(psMetadata* md, psS32 where, const char* name, const char* comment, psF64 value) {
     26    return psMetadataAdd(md,where,name,PS_TYPE_F64, PS_META_PRIMITIVE,comment,value);
     27}
     28psBool psMetadataAddS32(psMetadata* md, psS32 where, const char* name, const char* comment, psS32 value) {
     29    return psMetadataAdd(md,where,name,PS_TYPE_S32, PS_META_PRIMITIVE,comment,value);
     30}
     31
     32psMetadataItem* psMetadataItemAllocStr(const char* name, const char* comment, const char* value) {
     33    return psMetadataItemAlloc(name, PS_TYPE_PTR, PS_META_STR, comment, value);
     34}
     35psMetadataItem* psMetadataItemAllocF32(const char* name, const char* comment, psF32 value) {
     36    return psMetadataItemAlloc(name, PS_TYPE_F32, PS_META_PRIMITIVE, comment, value);
     37}
     38psMetadataItem* psMetadataItemAllocF64(const char* name, const char* comment, psF64 value) {
     39    return psMetadataItemAlloc(name, PS_TYPE_F64, PS_META_PRIMITIVE, comment, value);
     40}
     41psMetadataItem* psMetadataItemAllocS32(const char* name, const char* comment, psS32 value) {
     42    return psMetadataItemAlloc(name, PS_TYPE_S32, PS_META_PRIMITIVE, comment, value);
     43}
     44%}
     45
     46%apply uint32_t *OUTPUT { uint32_t *nFail }; /* for psMetadataParseConfig */
    647%include "psMetadataIO.h"
     48%clear uint32_t *nFail;
     49
    750%include "psPhotometry.h"
    851%include "psTime.h"
  • trunk/psLib/src/collections/psArray.c

    r3115 r3165  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-02-03 00:54:10 $
     11 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-02-09 01:04:01 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    157157    return in;
    158158}
     159
     160/// Set an element in the array.
     161psBool psArraySet(psArray* in,                       ///< input array to set element in
     162                  psU32 position,                    ///< the element position to set
     163                  void* value)                       ///< the value to set it to
     164{
     165    if (in == NULL)
     166    {
     167        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     168                PS_ERRORTEXT_psArray_ARRAY_NULL);
     169        return false;
     170    }
     171
     172    if (position >= in->nalloc)
     173    {
     174        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     175                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     176                position, in->nalloc);
     177        return false;
     178    }
     179
     180    psFree(in->data[position]);
     181    in->data[position] = value;
     182
     183    return true;
     184}
     185
     186/// Get an element in the array.
     187void* psArrayGet(psArray* in, psU32 position )
     188{
     189    if (in == NULL) {
     190        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     191                PS_ERRORTEXT_psArray_ARRAY_NULL);
     192        return NULL;
     193    }
     194
     195    if (position >= in->nalloc) {
     196        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     197                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     198                position, in->nalloc);
     199        return NULL;
     200    }
     201
     202    return in->data[position];
     203}
     204
     205
     206
     207
  • trunk/psLib/src/collections/psArray.h

    r3115 r3165  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-02-03 00:54:10 $
     14 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-02-09 01:04:01 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    126126);
    127127
     128/** Set an element in the array.  If the current element is non-NULL, the old
     129 *  element is freed.
     130 *
     131 *  @return psBool  TRUE if the element was set successfully, otherwise FALSE
     132 */
     133psBool psArraySet(
     134    psArray* in,                       ///< input array to set element in
     135    psU32 position,                    ///< the element position to set
     136    void* value                        ///< the value to set it to
     137);
     138
     139/** Get an element from the array.
     140 *
     141 *  @return void*   the element at given position.
     142 */
     143void* psArrayGet(
     144    psArray* in,                       ///< input array to get element from
     145    psU32 position                     ///< the element position to get
     146);
     147
    128148/// @}
    129149
  • trunk/psLib/src/collections/psCollectionsErrors.dat

    r3107 r3165  
    1010psArray_REALLOC_NULL                   psArrayRealloc must be given a non-NULL psArray to resize.
    1111psArray_ARRAY_NULL                     Specified psArray can not be NULL.
     12psArray_POSITION_BEYOND_NALLOC         Specified position, %d, is greater than the allocated size of the array, %d.
    1213#
    1314psVector_REALLOC_NULL                  psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown.
  • trunk/psLib/src/collections/psCollectionsErrors.h

    r3107 r3165  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-02-02 20:21:48 $
     9 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-02-09 01:04:01 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#define PS_ERRORTEXT_psArray_REALLOC_NULL "psArrayRealloc must be given a non-NULL psArray to resize."
    3333#define PS_ERRORTEXT_psArray_ARRAY_NULL "Specified psArray can not be NULL."
     34#define PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC "Specified position, %d, is greater than the allocated size of the array, %d."
    3435#define PS_ERRORTEXT_psVector_REALLOC_NULL "psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown."
    3536#define PS_ERRORTEXT_psVector_NOT_A_VECTOR "The input psVector must have a vector dimension type."
  • trunk/psLib/src/sysUtils/sysUtils.i

    r3150 r3165  
    4040}
    4141
     42psS32 psMemCheckLeaksToStderr(psMemoryId id0, psMemBlock*** arr, psBool persistence) {
     43    return psMemCheckLeaks(id0, arr, stderr, persistence);
     44}
     45psS32 psMemCheckLeaksToStdout(psMemoryId id0, psMemBlock*** arr, psBool persistence) {
     46    return psMemCheckLeaks(id0, arr, stdout, persistence);
     47}
     48
    4249%}
  • trunk/psLib/src/types/psArray.c

    r3115 r3165  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-02-03 00:54:10 $
     11 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-02-09 01:04:01 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    157157    return in;
    158158}
     159
     160/// Set an element in the array.
     161psBool psArraySet(psArray* in,                       ///< input array to set element in
     162                  psU32 position,                    ///< the element position to set
     163                  void* value)                       ///< the value to set it to
     164{
     165    if (in == NULL)
     166    {
     167        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     168                PS_ERRORTEXT_psArray_ARRAY_NULL);
     169        return false;
     170    }
     171
     172    if (position >= in->nalloc)
     173    {
     174        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     175                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     176                position, in->nalloc);
     177        return false;
     178    }
     179
     180    psFree(in->data[position]);
     181    in->data[position] = value;
     182
     183    return true;
     184}
     185
     186/// Get an element in the array.
     187void* psArrayGet(psArray* in, psU32 position )
     188{
     189    if (in == NULL) {
     190        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     191                PS_ERRORTEXT_psArray_ARRAY_NULL);
     192        return NULL;
     193    }
     194
     195    if (position >= in->nalloc) {
     196        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     197                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     198                position, in->nalloc);
     199        return NULL;
     200    }
     201
     202    return in->data[position];
     203}
     204
     205
     206
     207
  • trunk/psLib/src/types/psArray.h

    r3115 r3165  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-02-03 00:54:10 $
     14 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-02-09 01:04:01 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    126126);
    127127
     128/** Set an element in the array.  If the current element is non-NULL, the old
     129 *  element is freed.
     130 *
     131 *  @return psBool  TRUE if the element was set successfully, otherwise FALSE
     132 */
     133psBool psArraySet(
     134    psArray* in,                       ///< input array to set element in
     135    psU32 position,                    ///< the element position to set
     136    void* value                        ///< the value to set it to
     137);
     138
     139/** Get an element from the array.
     140 *
     141 *  @return void*   the element at given position.
     142 */
     143void* psArrayGet(
     144    psArray* in,                       ///< input array to get element from
     145    psU32 position                     ///< the element position to get
     146);
     147
    128148/// @}
    129149
  • trunk/psLib/swig/pslib.i

    r3150 r3165  
    1616
    1717/* XXX: this is temporary -- not portable, but should work with any current OS supported */
    18 typedef char int8_t;
    19 typedef unsigned char uint8_t;
    20 typedef short int16_t;
     18typedef unsigned char  uint8_t;
    2119typedef unsigned short uint16_t;
    22 typedef int int32_t;
    23 typedef unsigned int uint32_t;
    24 typedef long long int64_t;
    25 typedef unsigned long long uint64_t;
    26 
     20typedef unsigned int   uint32_t;
     21typedef unsigned long  uint64_t;
     22typedef char           int8_t;
     23typedef short          int16_t;
     24typedef int            int32_t;
     25typedef long long      int64_t;
    2726
    2827/* grab the typedefs used throughout psLib, e.g. psU8, psU16,... */
    2928%include "cpointer.i"
     29%include "typemaps.i"
    3030
    3131/**
Note: See TracChangeset for help on using the changeset viewer.