Ticket #244 (closed defect: fixed)

Opened 9 years ago

Last modified 3 years ago

[MapScript] Inconsistent return values (0/-1 vs MS_SUCCESS/FAILURE)

Reported by: dmorissette Owned by: dmorissette
Priority: high Milestone: 5.4 release
Component: MapScript Version: 4.1
Severity: normal Keywords:
Cc: tamas

Description (last modified by dmorissette) (diff)

This is a problem that's been around for quite a while: some functions in MapScript? return 0/-1, and others return MS_SUCCESS/MS_FAILURE.

We should eventually walk through the MapScript? API and list all functions that still return 0/-1. Then for every function we should make required changes to return MS_SUCCESS/FAILURE and also make sure that we look for and update every location where the function is called.

We have talked about this between me and Steve, and it would be a good idea to clean this us before the 3.7 release if possible.

Change History

Changed 9 years ago by dmorissette

Whoever has time first between me, Steve, Assefa or Julien (hopefully Julien ;) 
should assign this bug to himself and walk through the MapScript API and 
identify all functions that return 0/-1 and should be returning 
MS_SUCCESS/FAILURE.

Then report the list of functions in the bug report and we'll split the job of 
fixing things.

Changed 9 years ago by jlacroix

  • cc steve.lime@… added; lacroix@… removed
  • owner changed from sdlime to lacroix@…

Changed 9 years ago by jlacroix

I pass through mapscript.i and found many functions that doesn't return
MS_SUCCESS or MS_FAILURE. I report all this function here. 
The way I report them:

Class
  (mapscript function) => (mapserver function called) return value



Function list
-------------
mapObj
  addColor => msAddColor doesn't exist
  embedScalebar => msEmbedScalebar return 0 or -1
  embedLegend => msEmbedLegend return 0 or -1
  drawLabelCache => msDrawLabelCache return MS_SUCCESS or
                        msDrawLabelCacheGD return 0 or -1
                        msDrawLabelCacheSWF return 0 or -1
                        msDrawLabelCachePDF return 0 or -1
  setProjection => msLoadProjectionString return -1 or 
                     msProcessProjection return 0 or -1
  save => msSaveMap return 0 or -1
  setSymbolSet => msLoadSymbolSet return 0 or -1
  setFontSet => msLoadFontSet return 0 or -1
  moveLayerup => msMoveLayerUp return 0 or -1
  moveLayerdown => msMoveLayerDown return 0 or -1
  setLayersdrawingOrder => msSetLayersdrawingOrder return 1 or 0
layerObj
  draw => msDrawLayer return MS_SUCCESS or MS_FAILURE or
              msDrawRasterLayer return MS_FAILURE or
                  msDrawRasterLayerLow return 0 or -1
                  msDrawRasterLayerSWF return 0 or -1
                  msDrawRasterLayerPDF return 0 or -1
  drawQuery => msDrawLayer return MS_SUCCESS or MS_FAILURE or
                   msDrawRasterLayer return MS_FAILURE or
                       msDrawRasterLayerLow return 0 or -1
                       msDrawRasterLayerSWF return 0 or -1
                       msDrawRasterLayerPDF return 0 or -1
  setFilter => loadExpressionString return 0 or -1
  addFeature => return 0 or -1
classObj
  setExpression => loadExpressionString return 0 or -1
  setText => loadExpressionString return 0 or -1
pointObj
  draw => msDrawPoint return MS_SUCCESS or MS_FAILURE or 0
lineObj
  add => return 0 or -1
shapeObj
  add => msAddLine return 0 or -1
  copy => msCopyShape return 0 or -1
  contains => msIntersectPointPolygon return MS_FALSE or !MS_FALSE
  intersects => return -1 or
                    msIntersectPolylines return MS_FALSE or MS_TRUE
                    msIntersectPolygons return MS_FALSE or MS_TRUE
                    msIntersectPolylinePolygon return MS_[FALSE/TRUE]
rectObj
  contrain => msConstrainRect doesn't exist
  draw => return 0
shapefileObj
  get => return 0 or -1
  getPoint => return 0 or -1
  getTransformed => return 0 or -1
  add => msSHPWriteShape record number
  addPoint => msSHPWritePoint record number or -1
imageObj
  saveToString => need #if defined (SWIGPYTHON) || defined (SWIGTCL8)
DBFInfo
  getFieldType => msDBFGetFieldInfo return DBFFieldType

Changed 9 years ago by dmorissette

  • cc lacroix@… added
  • owner changed from lacroix@… to morissette@…
  • version changed from 4.0 to 4.1
Definitely too late for 4.0... setting version to 4.1

Changed 5 years ago by hobu

  • cc tamas added
  • description modified (diff)

Should we try and revisit this for 5.0? CC'ing Tamas...

Changed 4 years ago by hobu

  • milestone set to 5.2 release

This should be done as part of the MapServer C API effort (should that ever happen). Pushing it forward to 5.2...

Changed 4 years ago by dmorissette

  • milestone changed from 5.2 release to 5.4 release

Changed 3 years ago by dmorissette

  • status changed from new to assigned

This ticket was discussed at the TO Code Sprint and the consensus is to leave the existing functions unchanged, and come up with a RFC to provide guidelines for future functions (i.e. new methods should use MS_SUCCESS/MS_FAILURE instead of 0/-1)

Changed 3 years ago by dmorissette

  • description modified (diff)

Changed 3 years ago by dmorissette

  • status changed from assigned to closed
  • resolution set to fixed

Closing. RFC-53 has been approved and defines guidelines for future function defns.

Note: See TracTickets for help on using tickets.