VirtualBox

Changeset 17304 in vbox


Ignore:
Timestamp:
Mar 3, 2009 5:13:00 PM (16 years ago)
Author:
vboxsync
Message:

C API: Modified the xpcidl.xsl to create VirtualBox_CXPCOM.h
header file automatically which is the only header needed
to compile any C API apps. (VirtualBox_CXPCOM.h has no other
external dependencies what so ever during compile time,
naturally during runtime it depends on VBoxXPCOMC.so)
Modified the sample applications accordingly.

Location:
trunk/src/VBox/Main/cbinding
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/cbinding/Makefile.kmk

    r16841 r17304  
    4141XpComCHeaders_INST = $(INST_SDK)bindings/xpcom/include/
    4242XpComCHeaders_SOURCES = \
    43         cbinding.h \
    4443        $(XpComCHeaders_0_OUTDIR)/VirtualBox_CXPCOM.h
    4544
  • trunk/src/VBox/Main/cbinding/VBoxXPCOMC.cpp

    r16832 r17304  
    3030
    3131#include "VirtualBox_XPCOM.h"
     32#include "VirtualBox_CXPCOM.h"
    3233#include "VBox/com/com.h"
    33 #include "cbinding.h"
    3434
    3535using namespace std;
  • trunk/src/VBox/Main/cbinding/VBoxXPCOMCGlue.h

    r16837 r17304  
    11/* $Revision$ */
    2 /** @file cbinding.h
     2/** @file VBoxXPCOMCGlue.h
    33 * Glue for dynamically linking with VBoxXPCOMC.
    44 */
     
    3232#define ___VBoxXPCOMC_cglue_h
    3333
    34 #include "cbinding.h"
     34#include "VirtualBox_CXPCOM.h"
    3535
    3636#ifdef __cplusplus
  • trunk/src/VBox/Main/cbinding/makefile.tstLinuxC

    r16729 r17304  
    2121
    2222PATH_BIN      = /opt/VirtualBox
    23 XPCOM_INCLUDE = ../../include
    24 INCS_XPCOM    = -I$(XPCOM_INCLUDE) \
    25                 -I$(XPCOM_INCLUDE)/nsprpub
     23INCS_XPCOM = -I../../include
    2624
    2725CC            = gcc
     
    3937
    4038tstLinuxC.o: tstLinuxC.c
    41         $(CC) $(CFLAGS) -DRT_OS_LINUX -DMOZ_UNICODE $(INCS_XPCOM) -o $@ -c $<
     39        $(CC) $(CFLAGS) $(INCS_XPCOM) -o $@ -c $<
    4240
    4341tstdlOpen: tstdlOpen.o
     
    4543
    4644tstdlOpen.o: tstdlOpen.c
    47         $(CC) $(CFLAGS) -DRT_OS_LINUX -DMOZ_UNICODE -DUSE_DYNAMIC_GLUE $(INCS_XPCOM) -o $@ -c $<
     45        $(CC) $(CFLAGS) -DUSE_DYNAMIC_GLUE $(INCS_XPCOM) -o $@ -c $<
  • trunk/src/VBox/Main/cbinding/tstLinuxC.c

    r16838 r17304  
    2626#include <stdlib.h>
    2727#include <sys/stat.h>
    28 #include "cbinding.h"
     28#include "VirtualBox_CXPCOM.h"
    2929
    3030static char *nsIDToString(nsID *guid);
  • trunk/src/VBox/Main/cbinding/tstdlOpen.c

    r16838 r17304  
    2626#include <sys/stat.h>
    2727#include <dlfcn.h>
    28 #include "cbinding.h"
     28#include "VirtualBox_CXPCOM.h"
    2929
    3030static char *nsIDToString(nsID *guid);
  • trunk/src/VBox/Main/cbinding/xpcidl.xsl

    r16406 r17304  
    115115 */
    116116
     117#ifndef ___VirtualBox_CXPCOM_h
     118#define ___VirtualBox_CXPCOM_h
     119
     120#ifdef __cplusplus
     121# include "VirtualBox_XPCOM.h"
     122#else /* !__cplusplus */
     123
     124#include &lt;stddef.h&gt;
    117125#include "wchar.h"
    118 #include "prtypes.h"
     126
     127#if defined(WIN32)
     128
     129#define PR_EXPORT(__type) extern __declspec(dllexport) __type
     130#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
     131#define PR_IMPORT(__type) __declspec(dllimport) __type
     132#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
     133
     134#define PR_EXTERN(__type) extern __declspec(dllexport) __type
     135#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
     136#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
     137#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
     138
     139#define PR_CALLBACK
     140#define PR_CALLBACK_DECL
     141#define PR_STATIC_CALLBACK(__x) static __x
     142
     143#elif defined(XP_BEOS)
     144
     145#define PR_EXPORT(__type) extern __declspec(dllexport) __type
     146#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
     147#define PR_IMPORT(__type) extern __declspec(dllexport) __type
     148#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
     149
     150#define PR_EXTERN(__type) extern __declspec(dllexport) __type
     151#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
     152#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
     153#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
     154
     155#define PR_CALLBACK
     156#define PR_CALLBACK_DECL
     157#define PR_STATIC_CALLBACK(__x) static __x
     158
     159#elif defined(WIN16)
     160
     161#define PR_CALLBACK_DECL        __cdecl
     162
     163#if defined(_WINDLL)
     164#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
     165#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
     166#define PR_EXPORT_DATA(__type) extern __type _export
     167#define PR_IMPORT_DATA(__type) extern __type _export
     168
     169#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
     170#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
     171#define PR_EXTERN_DATA(__type) extern __type _export
     172#define PR_IMPLEMENT_DATA(__type) __type _export
     173
     174#define PR_CALLBACK             __cdecl __loadds
     175#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
     176
     177#else /* this must be .EXE */
     178#define PR_EXPORT(__type) extern __type _cdecl _export
     179#define PR_IMPORT(__type) extern __type _cdecl _export
     180#define PR_EXPORT_DATA(__type) extern __type _export
     181#define PR_IMPORT_DATA(__type) extern __type _export
     182
     183#define PR_EXTERN(__type) extern __type _cdecl _export
     184#define PR_IMPLEMENT(__type) __type _cdecl _export
     185#define PR_EXTERN_DATA(__type) extern __type _export
     186#define PR_IMPLEMENT_DATA(__type) __type _export
     187
     188#define PR_CALLBACK             __cdecl __loadds
     189#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
     190#endif /* _WINDLL */
     191
     192#elif defined(XP_MAC)
     193
     194#define PR_EXPORT(__type) extern __declspec(export) __type
     195#define PR_EXPORT_DATA(__type) extern __declspec(export) __type
     196#define PR_IMPORT(__type) extern __declspec(export) __type
     197#define PR_IMPORT_DATA(__type) extern __declspec(export) __type
     198
     199#define PR_EXTERN(__type) extern __declspec(export) __type
     200#define PR_IMPLEMENT(__type) __declspec(export) __type
     201#define PR_EXTERN_DATA(__type) extern __declspec(export) __type
     202#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
     203
     204#define PR_CALLBACK
     205#define PR_CALLBACK_DECL
     206#define PR_STATIC_CALLBACK(__x) static __x
     207
     208#elif defined(XP_OS2) &amp;&amp; defined(__declspec)
     209
     210#define PR_EXPORT(__type) extern __declspec(dllexport) __type
     211#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
     212#define PR_IMPORT(__type) __declspec(dllimport) __type
     213#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
     214
     215#define PR_EXTERN(__type) extern __declspec(dllexport) __type
     216#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
     217#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
     218#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
     219
     220#define PR_CALLBACK
     221#define PR_CALLBACK_DECL
     222#define PR_STATIC_CALLBACK(__x) static __x
     223
     224#elif defined(XP_OS2_VACPP)
     225
     226#define PR_EXPORT(__type) extern __type
     227#define PR_EXPORT_DATA(__type) extern __type
     228#define PR_IMPORT(__type) extern __type
     229#define PR_IMPORT_DATA(__type) extern __type
     230
     231#define PR_EXTERN(__type) extern __type
     232#define PR_IMPLEMENT(__type) __type
     233#define PR_EXTERN_DATA(__type) extern __type
     234#define PR_IMPLEMENT_DATA(__type) __type
     235#define PR_CALLBACK _Optlink
     236#define PR_CALLBACK_DECL
     237#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
     238
     239#else /* Unix */
     240
     241# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
     242#  define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
     243#  define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
     244#  define PR_IMPORT(__type) extern __type
     245#  define PR_IMPORT_DATA(__type) extern __type
     246#  define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
     247#  define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
     248#  define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
     249#  define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
     250#  define PR_CALLBACK
     251#  define PR_CALLBACK_DECL
     252#  define PR_STATIC_CALLBACK(__x) static __x
     253# else
     254#  define PR_EXPORT(__type) extern __type
     255#  define PR_EXPORT_DATA(__type) extern __type
     256#  define PR_IMPORT(__type) extern __type
     257#  define PR_IMPORT_DATA(__type) extern __type
     258#  define PR_EXTERN(__type) extern __type
     259#  define PR_IMPLEMENT(__type) __type
     260#  define PR_EXTERN_DATA(__type) extern __type
     261#  define PR_IMPLEMENT_DATA(__type) __type
     262#  define PR_CALLBACK
     263#  define PR_CALLBACK_DECL
     264#  define PR_STATIC_CALLBACK(__x) static __x
     265# endif
     266#endif
     267
     268#if defined(_NSPR_BUILD_)
     269#define NSPR_API(__type) PR_EXPORT(__type)
     270#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
     271#else
     272#define NSPR_API(__type) PR_IMPORT(__type)
     273#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
     274#endif
     275
     276typedef unsigned char PRUint8;
     277#if (defined(HPUX) &amp;&amp; defined(__cplusplus) \
     278        &amp;&amp; !defined(__GNUC__) &amp;&amp; __cplusplus &lt; 199707L) \
     279    || (defined(SCO) &amp;&amp; defined(__cplusplus) \
     280        &amp;&amp; !defined(__GNUC__) &amp;&amp; __cplusplus == 1L)
     281typedef char PRInt8;
     282#else
     283typedef signed char PRInt8;
     284#endif
     285
     286#define PR_INT8_MAX 127
     287#define PR_INT8_MIN (-128)
     288#define PR_UINT8_MAX 255U
     289
     290typedef unsigned short PRUint16;
     291typedef short PRInt16;
     292
     293#define PR_INT16_MAX 32767
     294#define PR_INT16_MIN (-32768)
     295#define PR_UINT16_MAX 65535U
     296
     297typedef unsigned int PRUint32;
     298typedef int PRInt32;
     299#define PR_INT32(x)  x
     300#define PR_UINT32(x) x ## U
     301
     302#define PR_INT32_MAX PR_INT32(2147483647)
     303#define PR_INT32_MIN (-PR_INT32_MAX - 1)
     304#define PR_UINT32_MAX PR_UINT32(4294967295)
     305
     306typedef long PRInt64;
     307typedef unsigned long PRUint64;
     308typedef int PRIntn;
     309typedef unsigned int PRUintn;
     310
     311typedef double          PRFloat64;
     312typedef size_t PRSize;
     313
     314typedef ptrdiff_t PRPtrdiff;
     315
     316typedef unsigned long PRUptrdiff;
     317
     318typedef PRIntn PRBool;
     319
     320#define PR_TRUE 1
     321#define PR_FALSE 0
     322
     323typedef PRUint8 PRPackedBool;
     324
     325/*
     326** Status code used by some routines that have a single point of failure or
     327** special status return.
     328*/
     329typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
     330
     331#ifndef __PRUNICHAR__
     332#define __PRUNICHAR__
     333#if defined(WIN32) || defined(XP_MAC)
     334typedef wchar_t PRUnichar;
     335#else
     336typedef PRUint16 PRUnichar;
     337#endif
     338#endif
     339
     340typedef long PRWord;
     341typedef unsigned long PRUword;
    119342
    120343#define nsnull 0
     
    311534</xsl:text>
    312535 <xsl:apply-templates/>
     536<xsl:text>
     537#endif /* !__cplusplus */
     538
     539#ifdef IN_VBOXXPCOMC
     540# define VBOXXPCOMC_DECL(type)  PR_EXPORT(type)
     541#else
     542# define VBOXXPCOMC_DECL(type)  PR_IMPORT(type)
     543#endif
     544
     545#ifdef __cplusplus
     546extern "C" {
     547#endif
     548
     549/* Initialize/Uninitialize XPCOM. */
     550VBOXXPCOMC_DECL(void) VBoxComInitialize(IVirtualBox **virtualBox, ISession **session);
     551VBOXXPCOMC_DECL(void) VBoxComUninitialize(void);
     552
     553/* Deallocation functions. */
     554VBOXXPCOMC_DECL(void) VBoxComUnallocMem(void *ptr);
     555VBOXXPCOMC_DECL(void) VBoxUtf16Free(PRUnichar *pwszString);
     556VBOXXPCOMC_DECL(void) VBoxUtf8Free(char *pszString);
     557
     558/* Converting to and from UTF-8 and UTF-16. */
     559VBOXXPCOMC_DECL(int) VBoxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString);
     560VBOXXPCOMC_DECL(int) VBoxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString);
     561
     562/* Getting and setting the environment variables. */
     563VBOXXPCOMC_DECL(const char *) VBoxGetEnv(const char *pszVar);
     564VBOXXPCOMC_DECL(int) VBoxSetEnv(const char *pszVar, const char *pszValue);
     565
     566
     567/**
     568 * Function table for dynamic linking.
     569 * Use VBoxGetFunctions() to obtain the pointer to it.
     570 */
     571typedef struct VBOXXPCOMC
     572{
     573    /** The size of the structure. */
     574    unsigned cb;
     575    /** The structure version. */
     576    unsigned uVersion;
     577    void  (*pfnComInitialize)(IVirtualBox **virtualBox, ISession **session);
     578    void  (*pfnComUninitialize)(void);
     579
     580    void  (*pfnComUnallocMem)(void *pv);
     581    void  (*pfnUtf16Free)(PRUnichar *pwszString);
     582    void  (*pfnUtf8Free)(char *pszString);
     583
     584    int   (*pfnUtf16ToUtf8)(const PRUnichar *pwszString, char **ppszString);
     585    int   (*pfnUtf8ToUtf16)(const char *pszString, PRUnichar **ppwszString);
     586
     587    const char * (*pfnGetEnv)(const char *pszVar);
     588    int   (*pfnSetEnv)(const char *pszVar, const char *pszValue);
     589    /** Tail version, same as uVersion. */
     590    unsigned uEndVersion;
     591} VBOXXPCOMC;
     592/** Pointer to a const VBoxXPCOMC function table. */
     593typedef VBOXXPCOMC const *PCVBOXXPCOM;
     594
     595/** The current interface version.
     596 * For use with VBoxGetXPCOMCFunctions and to be found in
     597 * VBOXXPCOMC::uVersion. */
     598#define VBOX_XPCOMC_VERSION     0x00010000U
     599
     600VBOXXPCOMC_DECL(PCVBOXXPCOM) VBoxGetXPCOMCFunctions(unsigned uVersion);
     601/** Typedef for VBoxGetXPCOMCFunctions. */
     602typedef PCVBOXXPCOM (*PFNVBOXGETXPCOMCFUNCTIONS)(unsigned uVersion);
     603
     604/** The symbol name of VBoxGetXPCOMCFunctions. */
     605#if defined(__APPLE__) || defined(__OS2__)
     606# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME   "_VBoxGetXPCOMCFunctions"
     607#else
     608# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME   "VBoxGetXPCOMCFunctions"
     609#endif
     610
     611
     612#ifdef __cplusplus
     613}
     614#endif
     615
     616#endif /* !___VirtualBox_CXPCOM_h */
     617</xsl:text>
    313618</xsl:template>
    314619
     
    7741079    <xsl:text>        </xsl:text>
    7751080    <xsl:value-of select="../@name" />
    776     <xsl:text> *this_, &#x0A;</xsl:text>
     1081    <xsl:text> *this_,&#x0A;</xsl:text>
    7771082    <xsl:for-each select="param [position() != last()]">
    7781083      <xsl:text>        </xsl:text>
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette