tizen 2.3.1 release
[framework/graphics/freetype.git] / src / cff / cf2error.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  cf2error.h                                                             */
4 /*                                                                         */
5 /*    Adobe's code for error handling (specification).                     */
6 /*                                                                         */
7 /*  Copyright 2006-2013 Adobe Systems Incorporated.                        */
8 /*                                                                         */
9 /*  This software, and all works of authorship, whether in source or       */
10 /*  object code form as indicated by the copyright notice(s) included      */
11 /*  herein (collectively, the "Work") is made available, and may only be   */
12 /*  used, modified, and distributed under the FreeType Project License,    */
13 /*  LICENSE.TXT.  Additionally, subject to the terms and conditions of the */
14 /*  FreeType Project License, each contributor to the Work hereby grants   */
15 /*  to any individual or legal entity exercising permissions granted by    */
16 /*  the FreeType Project License and this section (hereafter, "You" or     */
17 /*  "Your") a perpetual, worldwide, non-exclusive, no-charge,              */
18 /*  royalty-free, irrevocable (except as stated in this section) patent    */
19 /*  license to make, have made, use, offer to sell, sell, import, and      */
20 /*  otherwise transfer the Work, where such license applies only to those  */
21 /*  patent claims licensable by such contributor that are necessarily      */
22 /*  infringed by their contribution(s) alone or by combination of their    */
23 /*  contribution(s) with the Work to which such contribution(s) was        */
24 /*  submitted.  If You institute patent litigation against any entity      */
25 /*  (including a cross-claim or counterclaim in a lawsuit) alleging that   */
26 /*  the Work or a contribution incorporated within the Work constitutes    */
27 /*  direct or contributory patent infringement, then any patent licenses   */
28 /*  granted to You under this License for that Work shall terminate as of  */
29 /*  the date such litigation is filed.                                     */
30 /*                                                                         */
31 /*  By using, modifying, or distributing the Work you indicate that you    */
32 /*  have read and understood the terms and conditions of the               */
33 /*  FreeType Project License as well as those provided in this section,    */
34 /*  and you accept them fully.                                             */
35 /*                                                                         */
36 /***************************************************************************/
37
38
39 #ifndef __CF2ERROR_H__
40 #define __CF2ERROR_H__
41
42
43 #include FT_MODULE_ERRORS_H
44
45 #undef __FTERRORS_H__
46
47 #undef  FT_ERR_PREFIX
48 #define FT_ERR_PREFIX  CF2_Err_
49 #define FT_ERR_BASE    FT_Mod_Err_CF2
50
51
52 #include FT_ERRORS_H
53 #include "cf2ft.h"
54
55
56 FT_BEGIN_HEADER
57
58
59   /*
60    * A poor-man error facility.
61    *
62    * This code being written in vanilla C, doesn't have the luxury of a
63    * language-supported exception mechanism such as the one available in
64    * Java.  Instead, we are stuck with using error codes that must be
65    * carefully managed and preserved.  However, it is convenient for us to
66    * model our error mechanism on a Java-like exception mechanism.
67    * When we assign an error code we are thus `throwing' an error.
68    *
69    * The perservation of an error code is done by coding convention.
70    * Upon a function call if the error code is anything other than
71    * `FT_Err_Ok', which is guaranteed to be zero, we
72    * will return without altering that error.  This will allow the
73    * error to propogate and be handled at the appropriate location in
74    * the code.
75    *
76    * This allows a style of code where the error code is initialized
77    * up front and a block of calls are made with the error code only
78    * being checked after the block.  If a new error occurs, the original
79    * error will be preserved and a functional no-op should result in any
80    * subsequent function that has an initial error code not equal to
81    * `FT_Err_Ok'.
82    *
83    * Errors are encoded by calling the `FT_THROW' macro.  For example,
84    *
85    * {
86    *   FT_Error  e;
87    *
88    *
89    *   ...
90    *   e = FT_THROW( Out_Of_Memory );
91    * }
92    *
93    */
94
95
96   /* Set error code to a particular value. */
97   FT_LOCAL( void )
98   cf2_setError( FT_Error*  error,
99                 FT_Error   value );
100
101
102   /*
103    * A macro that conditionally sets an error code.
104    *
105    * This macro will first check whether `error' is set;
106    * if not, it will set it to `e'.
107    *
108   */
109 #define CF2_SET_ERROR( error, e )              \
110           cf2_setError( error, FT_THROW( e ) )
111
112
113 FT_END_HEADER
114
115
116 #endif /* __CF2ERROR_H__ */
117
118
119 /* END */