From c88941abc6f0fe91a41dc35dcaa1874d4de2c429 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 7 Apr 2017 16:18:53 +0200 Subject: Organize docs into HTML files. --- docs/coding-style.html | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 docs/coding-style.html (limited to 'docs/coding-style.html') diff --git a/docs/coding-style.html b/docs/coding-style.html new file mode 100644 index 00000000..d9a1602d --- /dev/null +++ b/docs/coding-style.html @@ -0,0 +1,127 @@ + + + +MuPDF Coding Style + + + + + + +
+

MuPDF Coding Style

+
+ + + +
+ +

Names

+ +

+Functions should be named according to one of the following schemes: + +

+ +

+Prefixes are mandatory for exported functions, macros, enums, globals and types. + +

+ +

+Prefixes are optional (but encouraged) for private functions and types. + +

+Avoid using 'get' as this is a meaningless and redundant filler word. + +

+These words are reserved for reference counting schemes: + +

+ +

+When searching for an object or value, the name used depends on whether +returning the value is passing ownership: + +

+ +

Types

+ +

+Various different integer types are used throughout MuPDF. + +

+In general: + +

+ +

+In addition, we use floats (and avoid doubles when possible), assumed to be IEEE compliant. + +

Reference counting

+ +

+Reference counting uses special words in functions to make it easy to remember +and follow the rules. + +

+Words that take ownership: new, find, load, open, keep. + +

+Words that release ownership: drop. + +

+If an object is returned by a function with one of the special words that take +ownership, you are responsible for freeing it by calling "drop" or "free", or +"close" before you return. You may pass ownership of an owned object by return +it only if you name the function using one of the special words. + +

+Any objects returned by functions that do not have any of these special words, +are borrowed and have a limited life time. Do not hold on to them past the +duration of the current function, or stow them away inside structs. If you need +to keep the object for longer than that, you have to either "keep" it or make +your own copy. + +

+ + + + + -- cgit v1.2.3