1 /**************************************************************************** 2 * 3 * pserror.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 PSERROR_H_ 40 #define PSERROR_H_ 41 42 43 #include <freetype/ftmoderr.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 <freetype/fterrors.h> 53 #include <freetype/internal/compiler-macros.h> 54 #include "psft.h" 55 56 57 FT_BEGIN_HEADER 58 59 60 /* 61 * A poor-man error facility. 62 * 63 * This code being written in vanilla C, doesn't have the luxury of a 64 * language-supported exception mechanism such as the one available in 65 * Java. Instead, we are stuck with using error codes that must be 66 * carefully managed and preserved. However, it is convenient for us to 67 * model our error mechanism on a Java-like exception mechanism. 68 * When we assign an error code we are thus `throwing' an error. 69 * 70 * The preservation of an error code is done by coding convention. 71 * Upon a function call if the error code is anything other than 72 * `FT_Err_Ok', which is guaranteed to be zero, we 73 * will return without altering that error. This will allow the 74 * error to propagate and be handled at the appropriate location in 75 * the code. 76 * 77 * This allows a style of code where the error code is initialized 78 * up front and a block of calls are made with the error code only 79 * being checked after the block. If a new error occurs, the original 80 * error will be preserved and a functional no-op should result in any 81 * subsequent function that has an initial error code not equal to 82 * `FT_Err_Ok'. 83 * 84 * Errors are encoded by calling the `FT_THROW' macro. For example, 85 * 86 * { 87 * FT_Error e; 88 * 89 * 90 * ... 91 * e = FT_THROW( Out_Of_Memory ); 92 * } 93 * 94 */ 95 96 97 /* Set error code to a particular value. */ 98 FT_LOCAL( void ) 99 cf2_setError( FT_Error* error, 100 FT_Error value ); 101 102 103 /* 104 * A macro that conditionally sets an error code. 105 * 106 * This macro will first check whether `error' is set; 107 * if not, it will set it to `e'. 108 * 109 */ 110 #define CF2_SET_ERROR( error, e ) \ 111 cf2_setError( error, FT_THROW( e ) ) 112 113 114 FT_END_HEADER 115 116 117 #endif /* PSERROR_H_ */ 118 119 120 /* END */ 121