Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Mozilla Framework Based on Templates (MFBT)

Nasi wolontariusze nie przetłumaczyli jeszcze tego artykułu na język Polski. Dołącz do nas i pomóż go przetłumaczyć!

The Mozilla Framework Based on Templates ("mfbt") is the central repository for macros, functions, and data structures used throughout Mozilla code, including in the JavaScript engine. Its code resides in the mfbt/ source directory, but headers within it should be included using paths like "mozilla/StandardInteger.h". It is fairly new, so its functionality is currently sparse. Feel free to file bugs to add new functionality to it, or to move existing functionality into it, as needed.

mfbt code goes to some length to document all its interfaces in comments, including examples when possible. It also attempts to define its functionality in well-named files, such that simply skimming the contents of mfbt/ will quickly suggest the relevant header to examine. Therefore this document primarily attempts to direct readers to the correct file to read those comments. Feel free to file a documentation bug if you think this approach could be improved, and feel free to make improvements to this document if you see them.

Functionality

Types and type manipulation

StandardInteger.h implements the <stdint.h> interface. (The <stdint.h> standard header is not available on all platforms and so cannot be used directly. This header also provides a useful "hook" for embeddings that must customize the types underlying the fixed-size integer types.)

Types.h includes StandardInteger.h and further provides size_t.

CheckedInt.h implements checked integers. They behave like integers, but safely check for integer overflow and divide-by-zero. Useful for input validation.

FloatingPoint.h provides various operations for examining and working upon double-precision floating point values, and for producing various special floating point values.

Core

Types.h further provides macros to define imported and exported C symbols.

Attributes.h implements various function and class attribute macros. The function macros control inlining, note whether a function returns, and enforce various C++-related restrictions on inheritance and use. The class macros permit controlling the inheritability of a class.

Likely.h provides MOZ_LIKELY and MOZ_UNLIKELY macros to annotate conditions with their expected truthiness.

Util.h implements various other bits of useful functionality. (This header will likely be further split up so that its functionality is less grab-bag.)

Debugging

Assertions.h provides assertion macros in implementing runtime assertions and compile-time assertions.

GuardObjects.h provides macros which can be used to annotate an RAII-style guard class, so that any attempt to create an unnamed temporary for it will assert. (An unnamed temporary lives for a shorter period of time than the scope where it's found, so it usually isn't what was desired.)

Data structures

LinkedList.h implements a type-safe doubly-linked list class. Most new code should use this rather than PRCList.

RangedPtr.h implements RangedPtr, a smart pointer template whose value may be manipulated only within a range specified at construction time, and which may be dereferenced only at valid locations in that range.  This pointer is a useful way to expose access to values within an array.

RefPtr.h implements various smart pointer templates to simplify reference counting of values of particular classes.

Scoped.h implements scope-based resource management, to simplify the task of cleaning up resources when leaving a scope.

ThreadLocal.h implements thread-local storage, aka "TLS", also called thread-specific storage. It should be used only for static-storage-duration variables, such as global variables or static class members.

Autorzy i etykiety dokumentu

Etykiety: 
 Autorzy tej strony: kanru, Sheppy, kscarfone, jwir3, Waldo, bjacob, Yoric, Ms2ger, jlebar
 Ostatnia aktualizacja: kanru,