File indexing completed on 2024-04-21 15:38:01

0001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
0002  *
0003  * ***** BEGIN LICENSE BLOCK *****
0004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
0005  *
0006  * The contents of this file are subject to the Mozilla Public License Version
0007  * 1.1 (the "License"); you may not use this file except in compliance with
0008  * the License. You may obtain a copy of the License at
0009  * http://www.mozilla.org/MPL/
0010  *
0011  * Software distributed under the License is distributed on an "AS IS" basis,
0012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
0013  * for the specific language governing rights and limitations under the
0014  * License.
0015  *
0016  * The Original Code is mozilla.org code.
0017  *
0018  * The Initial Developer of the Original Code is
0019  * Netscape Communications Corporation.
0020  * Portions created by the Initial Developer are Copyright (C) 1998
0021  * the Initial Developer. All Rights Reserved.
0022  *
0023  * Contributor(s):
0024  *
0025  * Alternatively, the contents of this file may be used under the terms of
0026  * either the GNU General Public License Version 2 or later (the "GPL"), or
0027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
0028  * in which case the provisions of the GPL or the LGPL are applicable instead
0029  * of those above. If you wish to allow use of your version of this file only
0030  * under the terms of either the GPL or the LGPL, and not to allow others to
0031  * use your version of this file under the terms of the MPL, indicate your
0032  * decision by deleting the provisions above and replace them with the notice
0033  * and other provisions required by the GPL or the LGPL. If you do not delete
0034  * the provisions above, a recipient may use your version of this file under
0035  * the terms of any one of the MPL, the GPL or the LGPL.
0036  *
0037  * ***** END LICENSE BLOCK *****
0038  *
0039  *
0040  * This Original Code has been modified by IBM Corporation.
0041  * Modifications made by IBM described herein are
0042  * Copyright (c) International Business Machines
0043  * Corporation, 2000
0044  *
0045  * Modifications to Mozilla code or documentation
0046  * identified per MPL Section 3.3
0047  *
0048  * Date         Modified by     Description of modification
0049  * 03/27/2000   IBM Corp.       Set JNICALL to Optlink for
0050  *                               use in OS2
0051  */
0052 
0053 /*******************************************************************************
0054  * Netscape version of jni_md.h -- depends on jri_md.h
0055  ******************************************************************************/
0056 
0057 #ifndef JNI_MD_H
0058 #define JNI_MD_H
0059 
0060 #include "prtypes.h" /* needed for _declspec */
0061 
0062 /*******************************************************************************
0063  * WHAT'S UP WITH THIS FILE?
0064  * 
0065  * This is where we define the mystical JNI_PUBLIC_API macro that works on all
0066  * platforms. If you're running with Visual C++, Symantec C, or Borland's 
0067  * development environment on the PC, you're all set. Or if you're on the Mac
0068  * with Metrowerks, Symantec or MPW with SC you're ok too. For UNIX it shouldn't
0069  * matter.
0070 
0071  * Changes by sailesh on 9/26 
0072 
0073  * There are two symbols used in the declaration of the JNI functions
0074  * and native code that uses the JNI:
0075  * JNICALL - specifies the calling convention 
0076  * JNIEXPORT - specifies export status of the function 
0077  * 
0078  * The syntax to specify calling conventions is different in Win16 and
0079  * Win32 - the brains at Micro$oft at work here. JavaSoft in their
0080  * infinite wisdom cares for no platform other than Win32, and so they
0081  * just define these two symbols as:
0082 
0083  #define JNIEXPORT __declspec(dllexport)
0084  #define JNICALL __stdcall
0085 
0086  * We deal with this, in the way JRI defines the JRI_PUBLIC_API, by
0087  * defining a macro called JNI_PUBLIC_API. Any of our developers who
0088  * wish to use code for Win16 and Win32, _must_ use JNI_PUBLIC_API to
0089  * be able to export functions properly.
0090 
0091  * Since we must also maintain compatibility with JavaSoft, we
0092  * continue to define the symbol JNIEXPORT. However, use of this
0093  * internally is deprecated, since it will cause a mess on Win16.
0094 
0095  * We _do not_ need a new symbol called JNICALL. Instead we
0096  * redefine JNICALL in the same way JRI_CALLBACK was defined.
0097 
0098  ******************************************************************************/
0099 
0100 /* DLL Entry modifiers... */
0101 /* Win32 */
0102 #if defined(XP_WIN) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32)
0103 #   include <windows.h>
0104 #   if defined(_MSC_VER) || defined(__GNUC__)
0105 #       if defined(WIN32) || defined(_WIN32)
0106 #           define JNI_PUBLIC_API(ResultType)   _declspec(dllexport) ResultType __stdcall
0107 #           define JNI_PUBLIC_VAR(VarType)      VarType
0108 #           define JNI_NATIVE_STUB(ResultType)  _declspec(dllexport) ResultType
0109 #           define JNICALL                          __stdcall
0110 #       else /* !_WIN32 */
0111 #           if defined(_WINDLL)
0112 #           define JNI_PUBLIC_API(ResultType)   ResultType __cdecl __export __loadds 
0113 #           define JNI_PUBLIC_VAR(VarType)      VarType
0114 #           define JNI_NATIVE_STUB(ResultType)  ResultType __cdecl __loadds
0115 #           define JNICALL                  __loadds
0116 #           else /* !WINDLL */
0117 #           define JNI_PUBLIC_API(ResultType)   ResultType __cdecl __export
0118 #           define JNI_PUBLIC_VAR(VarType)      VarType
0119 #           define JNI_NATIVE_STUB(ResultType)  ResultType __cdecl __export
0120 #           define JNICALL                  __export
0121 #                   endif /* !WINDLL */
0122 #       endif /* !_WIN32 */
0123 #   elif defined(__BORLANDC__)
0124 #       if defined(WIN32) || defined(_WIN32)
0125 #           define JNI_PUBLIC_API(ResultType)   __export ResultType
0126 #           define JNI_PUBLIC_VAR(VarType)      VarType
0127 #           define JNI_NATIVE_STUB(ResultType)   __export ResultType
0128 #           define JNICALL
0129 #       else /* !_WIN32 */
0130 #           define JNI_PUBLIC_API(ResultType)   ResultType _cdecl _export _loadds 
0131 #           define JNI_PUBLIC_VAR(VarType)      VarType
0132 #           define JNI_NATIVE_STUB(ResultType)  ResultType _cdecl _loadds
0133 #           define JNICALL          _loadds
0134 #       endif
0135 #   else
0136 #       error Unsupported PC development environment.   
0137 #   endif
0138 #   ifndef IS_LITTLE_ENDIAN
0139 #       define IS_LITTLE_ENDIAN
0140 #   endif
0141     /*  This is the stuff inherited from JavaSoft .. */
0142 #   define JNIEXPORT __declspec(dllexport)
0143 #   define JNIIMPORT __declspec(dllimport)
0144 
0145 /* OS/2 */
0146 #elif defined(XP_OS2)
0147 #   ifdef __declspec
0148 #       define JNI_PUBLIC_API(ResultType)   __declspec(dllexport) ResultType
0149 #       define JNI_PUBLIC_VAR(VarType)      VarType
0150 #       define JNI_NATIVE_STUB(ResultType)  __declspec(dllexport) ResultType
0151 #       define JNICALL
0152 #       define JNIEXPORT
0153 #       define JNIIMPORT
0154 #   else
0155 #       define JNI_PUBLIC_API(ResultType)   ResultType
0156 #       define JNI_PUBLIC_VAR(VarType)      VarType
0157 #       define JNICALL
0158 #       define JNIEXPORT
0159 #       define JNIIMPORT
0160 #   endif
0161 #   ifndef IS_LITTLE_ENDIAN
0162 #       define IS_LITTLE_ENDIAN
0163 #   endif
0164 
0165 /* Mac */
0166 #elif macintosh || Macintosh || THINK_C
0167 #   if defined(__MWERKS__)              /* Metrowerks */
0168 #       if !__option(enumsalwaysint)
0169 #           error You need to define 'Enums Always Int' for your project.
0170 #       endif
0171 #       if defined(TARGET_CPU_68K) && !TARGET_RT_MAC_CFM 
0172 #           if !__option(fourbyteints) 
0173 #               error You need to define 'Struct Alignment: 68k' for your project.
0174 #           endif
0175 #       endif /* !GENERATINGCFM */
0176 #       define JNI_PUBLIC_API(ResultType)   __declspec(export) ResultType 
0177 #       define JNI_PUBLIC_VAR(VarType)      JNI_PUBLIC_API(VarType)
0178 #       define JNI_NATIVE_STUB(ResultType)  JNI_PUBLIC_API(ResultType)
0179 #   elif defined(__SC__)                /* Symantec */
0180 #       error What are the Symantec defines? (warren@netscape.com)
0181 #   elif macintosh && applec            /* MPW */
0182 #       error Please upgrade to the latest MPW compiler (SC).
0183 #   else
0184 #       error Unsupported Mac development environment.
0185 #   endif
0186 #   define JNICALL
0187     /*  This is the stuff inherited from JavaSoft .. */
0188 #   define JNIEXPORT
0189 #   define JNIIMPORT
0190 
0191 /* Unix or else */
0192 #else
0193 #   define JNI_PUBLIC_API(ResultType)       ResultType
0194 #       define JNI_PUBLIC_VAR(VarType)                  VarType
0195 #       define JNI_NATIVE_STUB(ResultType)              ResultType
0196 #   define JNICALL
0197     /*  This is the stuff inherited from JavaSoft .. */
0198 #   define JNIEXPORT
0199 #   define JNIIMPORT
0200 #endif
0201 
0202 #ifndef FAR     /* for non-Win16 */
0203 #define FAR
0204 #endif
0205 
0206 /* Get the rest of the stuff from jri_md.h */
0207 #include "jri_md.h"
0208 
0209 #endif /* JNI_MD_H */