mcneel / rhino3dm

Libraries based on OpenNURBS with a RhinoCommon style
MIT License
615 stars 139 forks source link

docgen doesn't create correct ts definition for rhino3dm js and py #376

Closed fraguada closed 3 years ago

fraguada commented 3 years ago

Example:

https://github.com/mcneel/rhino3dm/blob/master/src/bindings/bnd_surface.h#L33

BND_TUPLE FrameAt(double u, double v);

results in:

/**
* @description Computes the orient plane on a surface given a U and V parameter.
        This is the simple evaluation call with no error handling.
* @param {number} u A first parameter.
* @param {number} v A second parameter.
* @param {Plane} frame A frame plane that will be computed during this call.
* @returns {boolean} true if this operation succeeded; otherwise false.
*/
frameAt(u:number,v:number,frame:Plane): boolean;
pearswj commented 3 years ago

If you investigate this, can you take a look at #349? It should make working with docgen a little easier.

fraguada commented 3 years ago

Yes! That will be really useful.

fraguada commented 3 years ago

Editing this issue because the same is the case for python. Most of this is the result of adapting to the use of out in .net with BND_TUPLE. For example: RhinoCommon: https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Intersect_Intersection_LinePlane.htm

public static bool LinePlane(
    Line line,
    Plane plane,
    out double lineParameter
)

Binding code:

BND_TUPLE BND_Intersection::PlanePlane(const BND_Plane& planeA, const BND_Plane& planeB)
{
  ON_Line line;
  bool success = ON_Intersect(planeA.ToOnPlane(), planeB.ToOnPlane(), line);
  BND_TUPLE rc = CreateTuple(2);
  SetTuple(rc, 0, success);
  SetTuple(rc, 1, line);
  return rc;
}

rhino3dm.py: https://mcneel.github.io/rhino3dm/python/api/Intersection.html#rhino3dm.Intersection.LinePlane

image

rhino3dm.js: https://mcneel.github.io/rhino3dm/javascript/api/Intersection.html#.linePlane

image
sbaer commented 3 years ago

we need to handle functions with out parameters as returning tuples