📄 jstypes.h
字号:
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- *//* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Mozilla Communicator client code, released * March 31, 1998. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * IBM Corp. * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** *//*** File: jstypes.h** Description: Definitions of NSPR's basic types**** Prototypes and macros used to make up for deficiencies in ANSI environments** that we have found.**** Since we do not wrap <stdlib.h> and all the other standard headers, authors** of portable code will not know in general that they need these definitions.** Instead of requiring these authors to find the dependent uses in their code** and take the following steps only in those C files, we take steps once here** for all C files.**/#ifndef jstypes_h___#define jstypes_h___#include <stddef.h>/************************************************************************* MACROS: JS_EXTERN_API** JS_EXPORT_API** DESCRIPTION:** These are only for externally visible routines and globals. For** internal routines, just use "extern" for type checking and that** will not export internal cross-file or forward-declared symbols.** Define a macro for declaring procedures return types. We use this to** deal with windoze specific type hackery for DLL definitions. Use** JS_EXTERN_API when the prototype for the method is declared. Use** JS_EXPORT_API for the implementation of the method.**** Example:** in dowhim.h** JS_EXTERN_API( void ) DoWhatIMean( void );** in dowhim.c** JS_EXPORT_API( void ) DoWhatIMean( void ) { return; }***************************************************************************/#ifdef WIN32/* These also work for __MWERKS__ */#define JS_EXTERN_API(__type) extern __declspec(dllexport) __type#define JS_EXPORT_API(__type) __declspec(dllexport) __type#define JS_EXTERN_DATA(__type) extern __declspec(dllexport) __type#define JS_EXPORT_DATA(__type) __declspec(dllexport) __type#define JS_DLL_CALLBACK#define JS_STATIC_DLL_CALLBACK(__x) static __x#elif defined(XP_OS2) && defined(__declspec)#define JS_EXTERN_API(__type) extern __declspec(dllexport) __type#define JS_EXPORT_API(__type) __declspec(dllexport) __type#define JS_EXTERN_DATA(__type) extern __declspec(dllexport) __type#define JS_EXPORT_DATA(__type) __declspec(dllexport) __type#define JS_DLL_CALLBACK#define JS_STATIC_DLL_CALLBACK(__x) static __x#elif defined(WIN16)#ifdef _WINDLL#define JS_EXTERN_API(__type) extern __type _cdecl _export _loadds#define JS_EXPORT_API(__type) __type _cdecl _export _loadds#define JS_EXTERN_DATA(__type) extern __type _export#define JS_EXPORT_DATA(__type) __type _export#define JS_DLL_CALLBACK __cdecl __loadds#define JS_STATIC_DLL_CALLBACK(__x) static __x CALLBACK#else /* this must be .EXE */#define JS_EXTERN_API(__type) extern __type _cdecl _export#define JS_EXPORT_API(__type) __type _cdecl _export#define JS_EXTERN_DATA(__type) extern __type _export#define JS_EXPORT_DATA(__type) __type _export#define JS_DLL_CALLBACK __cdecl __loadds#define JS_STATIC_DLL_CALLBACK(__x) __x JS_DLL_CALLBACK#endif /* _WINDLL */#else /* Unix */#ifdef HAVE_VISIBILITY_ATTRIBUTE#define JS_EXTERNAL_VIS __attribute__((visibility ("default")))#else#define JS_EXTERNAL_VIS#endif#define JS_EXTERN_API(__type) extern JS_EXTERNAL_VIS __type#define JS_EXPORT_API(__type) JS_EXTERNAL_VIS __type#define JS_EXTERN_DATA(__type) extern JS_EXTERNAL_VIS __type#define JS_EXPORT_DATA(__type) JS_EXTERNAL_VIS __type#define JS_DLL_CALLBACK#define JS_STATIC_DLL_CALLBACK(__x) static __x#endif#ifdef _WIN32# if defined(__MWERKS__) || defined(__GNUC__)# define JS_IMPORT_API(__x) __x# else# define JS_IMPORT_API(__x) __declspec(dllimport) __x# endif#elif defined(XP_OS2) && defined(__declspec)# define JS_IMPORT_API(__x) __declspec(dllimport) __x#else# define JS_IMPORT_API(__x) JS_EXPORT_API (__x)#endif#if defined(_WIN32) && !defined(__MWERKS__)# define JS_IMPORT_DATA(__x) __declspec(dllimport) __x#elif defined(XP_OS2) && defined(__declspec)# define JS_IMPORT_DATA(__x) __declspec(dllimport) __x#else# define JS_IMPORT_DATA(__x) JS_EXPORT_DATA (__x)#endif/* * The linkage of JS API functions differs depending on whether the file is * used within the JS library or not. Any source file within the JS * interpreter should define EXPORT_JS_API whereas any client of the library * should not. */#ifdef EXPORT_JS_API#define JS_PUBLIC_API(t) JS_EXPORT_API(t)#define JS_PUBLIC_DATA(t) JS_EXPORT_DATA(t)#else#define JS_PUBLIC_API(t) JS_IMPORT_API(t)#define JS_PUBLIC_DATA(t) JS_IMPORT_DATA(t)#endif#define JS_FRIEND_API(t) JS_PUBLIC_API(t)#define JS_FRIEND_DATA(t) JS_PUBLIC_DATA(t)#ifdef _WIN32# define JS_INLINE __inline#elif defined(__GNUC__)# define JS_INLINE#else# define JS_INLINE#endif/************************************************************************* MACROS: JS_BEGIN_MACRO** JS_END_MACRO** DESCRIPTION:** Macro body brackets so that macros with compound statement definitions** behave syntactically more like functions when called.***********************************************************************/#define JS_BEGIN_MACRO do {#define JS_END_MACRO } while (0)/************************************************************************* MACROS: JS_BEGIN_EXTERN_C** JS_END_EXTERN_C** DESCRIPTION:** Macro shorthands for conditional C++ extern block delimiters.***********************************************************************/#ifdef __cplusplus#define JS_BEGIN_EXTERN_C extern "C" {#define JS_END_EXTERN_C }#else#define JS_BEGIN_EXTERN_C#define JS_END_EXTERN_C#endif/************************************************************************* MACROS: JS_BIT** JS_BITMASK** DESCRIPTION:** Bit masking macros. XXX n must be <= 31 to be portable***********************************************************************/#define JS_BIT(n) ((JSUint32)1 << (n))#define JS_BITMASK(n) (JS_BIT(n) - 1)/************************************************************************* MACROS: JS_PTR_TO_INT32** JS_PTR_TO_UINT32** JS_INT32_TO_PTR** JS_UINT32_TO_PTR** DESCRIPTION:** Integer to pointer and pointer to integer conversion macros.***********************************************************************/#define JS_PTR_TO_INT32(x) ((jsint)((char *)(x) - (char *)0))#define JS_PTR_TO_UINT32(x) ((jsuint)((char *)(x) - (char *)0))#define JS_INT32_TO_PTR(x) ((void *)((char *)0 + (jsint)(x)))#define JS_UINT32_TO_PTR(x) ((void *)((char *)0 + (jsuint)(x)))/************************************************************************* MACROS: JS_HOWMANY** JS_ROUNDUP** JS_MIN** JS_MAX
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -