Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert API to snake_case #60

Merged
merged 9 commits into from
Feb 12, 2020
Merged

Convert API to snake_case #60

merged 9 commits into from
Feb 12, 2020

Conversation

almarklein
Copy link
Member

Closes #57

  • flags: name is CamelCase, field names are UPPERCASE, values are int.
  • enums: name is CamelCase, field names are snake_case, values are 'like-this'.
  • structs: their fields are the function arguments, so we never refer them by name.
  • function args: name is snake_case.
  • function names: name is snake_case.

@almarklein
Copy link
Member Author

I'm going to prepare PR's in python-shader and visvis2 to adjust to the new API. Then I'll merge them in quick succession.


def getSizeAndPixelRatio(self):
def get_size_and_pixel_ratio(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think perhaps the entire Qt widget should have Qt style conventions? eh, it's just a little straining on the eyes :) wouldn't mind merging this as is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm, that's a good question. I think that since the methods that we add here are part of the wgpu API (they come from an abstract base class), they should be snake_case. It actually makes it clear with what API you're interacting with. But yeah, it does not look qt-ish :/

Comment on lines +75 to 86
render_pipeline = device.create_render_pipeline(
layout=pipeline_layout,
vertexStage={"module": vshader, "entryPoint": "main"},
fragmentStage={"module": fshader, "entryPoint": "main"},
primitiveTopology=wgpu.PrimitiveTopology.triangle_list,
rasterizationState={
"frontFace": wgpu.FrontFace.ccw,
"cullMode": wgpu.CullMode.none,
"depthBias": 0,
"depthBiasSlopeScale": 0.0,
"depthBiasClamp": 0.0,
vertex_stage={"module": vshader, "entry_point": "main"},
fragment_stage={"module": fshader, "entry_point": "main"},
primitive_topology=wgpu.PrimitiveTopology.triangle_list,
rasterization_state={
"front_face": wgpu.FrontFace.ccw,
"cull_mode": wgpu.CullMode.none,
"depth_bias": 0,
"depth_bias_slope_scale": 0.0,
"depth_bias_clamp": 0.0,
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this illustrates the changes best:

  • the function name is snake_case
  • the direct arguments are snake_case
  • the "sub-arguments" (keys of args that are dicts) are snake_case
  • enums and flags are unchanged.

@Korijn
Copy link
Collaborator

Korijn commented Feb 12, 2020

LGTM!

@almarklein almarklein merged commit b1f6566 into master Feb 12, 2020
@almarklein almarklein deleted the dev branch February 12, 2020 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adopt snake_case instead of camelCase
2 participants