Skip to content

Proposal: Consistent naming / patterns #17

@DSchroer

Description

@DSchroer

Currently the naming of methods and functions in lib.rs is inconsistent:

  • type_name
  • HandleGeomCurve_Value
  • DynamicType

Proposal:

Naming

  1. Always use the Opencascade convention for C++. (CammelCase with no _, including standalone functions). Not the rust convention.
type_name(...) -> TypeName(...)
  1. Since cxx has no better way yet, use _ to show associated types for functions that cant be bound using self. This covers constructors and other similar functions.
HandleGeomCurve_Value
  1. In lib.rs, since it is in rust, we always use rust naming conventions and make use of the cxx_name attribute to point to the correct c++ method.
#[cxx_name = "Shape"]
pub fn shape(self: Pin<&mut BRepAlgoAPI_Fuse>) -> &TopoDS_Shape;

Access

Free floating functions are hard to reason about. Since Opencascade is a class based library, we should follow the same by re-attaching methods to the respective parent. If a function is associated with a type it should be private and attached via an impl block to the associated type.

...
    type StlAPI_Writer;
    fn StlAPI_Writer_ctor() -> UniquePtr<StlAPI_Writer>;
  }
}
...

impl ffi::StlAPI_Writer {
    pub fn new() -> cxx::UniquePtr<ffi::StlAPI_Writer> {
        ffi::StlAPI_Writer_ctor()
    }
}

What do you think? I feel this will be a good step forward and help reason about how future additions to the -sys crate should be made.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions