Skip to content

Commit

Permalink
Add more code style requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Susurrus committed May 31, 2017
1 parent 85a5655 commit 5b1dd49
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* When breaking on binary operators, put the operator at the beginning of the new line.
* Do not use aligned indentation. Indentation should always be block indentation.
* Always use spaces for indentation.
* Blank spaces should be avoided except around the import section at the top.

## Imports

Expand Down Expand Up @@ -53,17 +54,19 @@ FN!{stdcall DRAWSTATEPROC(
lData: LPARAM,
wData: WPARAM,
cx: c_int,
cy: c_int
cy: c_int,
) -> BOOL}
FN!{stdcall NAMEENUMPROCA(
LPSTR,
LPARAM
LPARAM,
) -> BOOL}
```

## Constants

* Convert macro constants to Rust constants.
* Numeric values should be formatted identically to how they are in the source file (don't convert
hex values to decimal, preserve capitalization of hex values, etc.)
* The type of the constant should depend on where the constant is used. MSDN may help for this.

```C
Expand All @@ -75,6 +78,9 @@ pub const CLSCTX_INPROC: CLSCTX = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER;

## GUIDs

* Numeric values should be formatted identically to how they are in the source file (don't convert
hex values to decimal, preserve capitalization of hex values, etc.)

```Rust
DEFINE_GUID!{GUID_DEVCLASS_SENSOR,
0x5175d334, 0xc371, 0x4806, 0xb3, 0xba, 0x71, 0xfd, 0x53, 0xc9, 0x25, 0x8d}
Expand Down Expand Up @@ -137,20 +143,22 @@ interface IDWriteFontFileStream(IDWriteFontFileStreamVtbl): IUnknown(IUnknownVtb
fragmentStart: *mut *const c_void,
fileOffset: UINT64,
fragmentSize: UINT64,
fragmentContext: *mut *mut c_void
fragmentContext: *mut *mut c_void,
) -> HRESULT,
fn ReleaseFileFragment(
fragmentContext: *mut c_void
fragmentContext: *mut c_void,
) -> (),
fn GetFileSize(
fileSize: *mut UINT64
fileSize: *mut UINT64,
) -> HRESULT,
fn GetLastWriteTime(
lastWriteTime: *mut UINT64
lastWriteTime: *mut UINT64,
) -> HRESULT
}}
```

For COM interfaces without a UUID, a UUID of all-zeroes should be used.

## Organization of code

* All definitions go into the source file that directly maps to the header the definition is from.
Expand Down

0 comments on commit 5b1dd49

Please sign in to comment.