Skip to content

Commit

Permalink
Handle SIP_OUT with void functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 10, 2024
1 parent b39f760 commit 391b615
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ Make a graph using :py:class:`QgsGraphBuilder`

:param builder: the graph builder
:param additionalPoints: list of points that should be snapped to the graph
:param snappedPoints: list of snapped points
:param feedback: feedback object for reporting progress

.. note::

if snappedPoints[i] == QgsPointXY(0.0,0.0) then snapping failed.

:return: list of snapped points
%End

void addStrategy( QgsNetworkStrategy *prop /Transfer/ );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ Returns the coefficients (a, b, c for equation "ax + by + c = 0") of a line defi

:param pt1: first point.
:param pt2: second point.

:return: - a: Output parameter, a coefficient of the equation.
- b: Output parameter, b coefficient of the equation.
- c: Output parameter, c coefficient of the equation.
%End

static QgsLineString perpendicularSegment( const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2 ) /HoldGIL/;
Expand Down
4 changes: 4 additions & 0 deletions python/PyQt6/core/auto_generated/qgsmaplayer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ Saves named and sld style of the layer to the style table in the db.
Since 3.24, calling this method will ALWAYS overwrite any existing style with the same name.
Use :py:func:`QgsProviderRegistry.styleExists()` to test in advance if a style already exists and handle this appropriately
in your client code.

:return: a descriptive error message if any occurs
%End


Expand Down Expand Up @@ -1128,6 +1130,8 @@ Export the properties of this layer as named style in a QDomDocument
:param context: read write context
:param categories: the style categories to export
during the execution of writeSymbology

:return: this QString will be initialized on error
%End


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ Recalculate classes for a layer

:param vl: The layer being rendered (from which data values are calculated)
:param nclasses: the number of classes

:return: Optional parameter for error reporting
%End


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ Returns the possible enum values of an attribute. Returns an empty stringlist if
or if the given attribute is not an enum type.

:param index: the index of the attribute

:return: reference to the list to fill
%End

virtual bool addFeatures( QgsFeatureList &flist /In,Out/, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,12 @@ Parses a symbol layer as renderer or labeling.
This is private API only, and may change in future QGIS versions

:param jsonLayer: symbol layer to parse
:param rendererStyle: generated QGIS vector tile style
:param hasRenderer: will be set to ``True`` if symbol layer generated a renderer style
:param labelingStyle: generated QGIS vector tile labeling
:param context: conversion context

:return: - rendererStyle: generated QGIS vector tile style
- hasRenderer: ``True`` if symbol layer generated a renderer style
- labelingStyle: generated QGIS vector tile labeling
- hasLabeling: ``True`` if symbol layer generated a labeling style
%End

static bool parseSymbolLayerAsRenderer( const QVariantMap &jsonLayer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ Make a graph using :py:class:`QgsGraphBuilder`

:param builder: the graph builder
:param additionalPoints: list of points that should be snapped to the graph
:param snappedPoints: list of snapped points
:param feedback: feedback object for reporting progress

.. note::

if snappedPoints[i] == QgsPointXY(0.0,0.0) then snapping failed.

:return: list of snapped points
%End

void addStrategy( QgsNetworkStrategy *prop /Transfer/ );
Expand Down
4 changes: 4 additions & 0 deletions python/core/auto_generated/geometry/qgsgeometryutils.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ Returns the coefficients (a, b, c for equation "ax + by + c = 0") of a line defi

:param pt1: first point.
:param pt2: second point.

:return: - a: Output parameter, a coefficient of the equation.
- b: Output parameter, b coefficient of the equation.
- c: Output parameter, c coefficient of the equation.
%End

static QgsLineString perpendicularSegment( const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2 ) /HoldGIL/;
Expand Down
4 changes: 4 additions & 0 deletions python/core/auto_generated/qgsmaplayer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ Saves named and sld style of the layer to the style table in the db.
Since 3.24, calling this method will ALWAYS overwrite any existing style with the same name.
Use :py:func:`QgsProviderRegistry.styleExists()` to test in advance if a style already exists and handle this appropriately
in your client code.

:return: a descriptive error message if any occurs
%End


Expand Down Expand Up @@ -1128,6 +1130,8 @@ Export the properties of this layer as named style in a QDomDocument
:param context: read write context
:param categories: the style categories to export
during the execution of writeSymbology

:return: this QString will be initialized on error
%End


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ Recalculate classes for a layer

:param vl: The layer being rendered (from which data values are calculated)
:param nclasses: the number of classes

:return: Optional parameter for error reporting
%End


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ Returns the possible enum values of an attribute. Returns an empty stringlist if
or if the given attribute is not an enum type.

:param index: the index of the attribute

:return: reference to the list to fill
%End

virtual bool addFeatures( QgsFeatureList &flist /In,Out/, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,11 @@ Parses a symbol layer as renderer or labeling.

:param jsonLayer: symbol layer to parse
:param context: conversion context

:return: - rendererStyle: generated QGIS vector tile style
- hasRenderer: ``True`` if symbol layer generated a renderer style
- labelingStyle: generated QGIS vector tile labeling
- hasLabeling: ``True`` if symbol layer generated a labeling style
%End

static bool parseSymbolLayerAsRenderer( const QVariantMap &jsonLayer,
Expand Down
19 changes: 16 additions & 3 deletions scripts/sipify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2731,9 +2731,22 @@ def cpp_to_python_signature(cpp_function: str) -> str:
else:
pass # Return docstring should be single line with SIP_OUT params

if out_params and CONTEXT.return_type:
exit_with_error(
f"A method with output parameters must contain a return directive ({CONTEXT.current_method_name} method returns {CONTEXT.return_type})")
if out_params:
if CONTEXT.return_type:
exit_with_error(
f"A method with output parameters must contain a return directive ({CONTEXT.current_method_name} method returns {CONTEXT.return_type})")
else:
doc_string += "\n"

for out_param_idx, out_param in enumerate(out_params):
if out_param_idx == 0:
if len(out_params) > 1:
doc_string += f":return: - {out_param}\n"
else:
arg_name_match = re.match(r'^(.*?):\s*(.*?)$', out_param)
doc_string += f":return: {arg_name_match.group(2)}\n"
else:
doc_string += f"{doc_prepend} - {out_param}\n"

dbg_info(f'doc_string is {doc_string}')
write_output("DS", doc_string)
Expand Down

0 comments on commit 391b615

Please sign in to comment.