From f215e02bf85f68d3a6106c2a1f4f7f063f819064 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:17:27 +0200 Subject: Adding upstream version 7.0.14-dfsg. Signed-off-by: Daniel Baumann --- .../xpcom18a4/xpcom/typelib/xpt/public/.cvsignore | 1 + .../xpcom18a4/xpcom/typelib/xpt/public/Makefile.in | 51 ++ .../xpcom18a4/xpcom/typelib/xpt/public/xpt_arena.h | 145 ++++++ .../xpcom/typelib/xpt/public/xpt_struct.h | 562 +++++++++++++++++++++ .../xpcom18a4/xpcom/typelib/xpt/public/xpt_xdr.h | 240 +++++++++ 5 files changed, 999 insertions(+) create mode 100644 src/libs/xpcom18a4/xpcom/typelib/xpt/public/.cvsignore create mode 100644 src/libs/xpcom18a4/xpcom/typelib/xpt/public/Makefile.in create mode 100644 src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_arena.h create mode 100644 src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_struct.h create mode 100644 src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_xdr.h (limited to 'src/libs/xpcom18a4/xpcom/typelib/xpt/public') diff --git a/src/libs/xpcom18a4/xpcom/typelib/xpt/public/.cvsignore b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/.cvsignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/.cvsignore @@ -0,0 +1 @@ +Makefile diff --git a/src/libs/xpcom18a4/xpcom/typelib/xpt/public/Makefile.in b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/Makefile.in new file mode 100644 index 00000000..3e452486 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/Makefile.in @@ -0,0 +1,51 @@ +# +# ***** 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.org code. +# +# 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): +# +# 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 ***** + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = xpcom + +EXPORTS = xpt_arena.h xpt_struct.h xpt_xdr.h +EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) + +include $(topsrcdir)/config/rules.mk + diff --git a/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_arena.h b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_arena.h new file mode 100644 index 00000000..2b277467 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_arena.h @@ -0,0 +1,145 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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.org code. + * + * 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): + * + * 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 ***** */ + +/* + * Simple arena allocator for xpt (which avoids using NSPR). + */ + +#ifndef __xpt_arena_h__ +#define __xpt_arena_h__ + +#include "prtypes.h" +#include + +#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP +#define XPT_NewArena VBoxNsxpXPT_NewArena +#define XPT_ArenaMalloc VBoxNsxpXPT_ArenaMalloc +#define XPT_DestroyArena VBoxNsxpXPT_DestroyArena +#define XPT_ArenaFree VBoxNsxpXPT_ArenaFree +#define XPT_DestroyArena VBoxNsxpXPT_DestroyArena +#define XPT_DumpStats VBoxNsxpXPT_DumpStats +#define XPT_NotifyDoneLoading VBoxNsxpXPT_NotifyDoneLoading +#define XPT_ArenaStrDup VBoxNsxpXPT_ArenaStrDup +#define XPT_AssertFailed VBoxNsxpXPT_AssertFailed +#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */ + +/* + * The linkage of XPT API functions differs depending on whether the file is + * used within the XPT library or not. Any source file within the XPT + * library should define EXPORT_XPT_API whereas any client of the library + * should not. + */ +#ifdef EXPORT_XPT_API +#define XPT_PUBLIC_API(t) PR_IMPLEMENT(t) +#define XPT_PUBLIC_DATA(t) PR_IMPLEMENT_DATA(t) +#else +#ifdef _WIN32 +# define XPT_PUBLIC_API(t) __declspec(dllimport) t +# define XPT_PUBLIC_DATA(t) __declspec(dllimport) t +#else +# define XPT_PUBLIC_API(t) PR_IMPLEMENT(t) +# define XPT_PUBLIC_DATA(t) t +#endif +#endif +#define XPT_FRIEND_API(t) XPT_PUBLIC_API(t) +#define XPT_FRIEND_DATA(t) XPT_PUBLIC_DATA(t) + +PR_BEGIN_EXTERN_C + +/* + * Simple Arena support. Use with caution! + */ + +typedef struct XPTArena XPTArena; + +XPT_PUBLIC_API(XPTArena *) +XPT_NewArena(PRUint32 block_size, size_t alignment, const char* name); + +XPT_PUBLIC_API(void) +XPT_DestroyArena(XPTArena *arena); + +XPT_PUBLIC_API(void) +XPT_DumpStats(XPTArena *arena); + +XPT_PUBLIC_API(void *) +XPT_ArenaMalloc(XPTArena *arena, size_t size); + +XPT_PUBLIC_API(char *) +XPT_ArenaStrDup(XPTArena *arena, const char * s); + +XPT_PUBLIC_API(void) +XPT_NotifyDoneLoading(XPTArena *arena); + +XPT_PUBLIC_API(void) +XPT_ArenaFree(XPTArena *arena, void* block); + +/* --------------------------------------------------------- */ + +#define XPT_MALLOC(_arena, _bytes) \ + XPT_ArenaMalloc((_arena), (_bytes)) + +#ifdef DEBUG +#define XPT_FREE(_arena, _ptr) \ + XPT_ArenaFree((_arena), (_ptr)) +#else +#define XPT_FREE(_arena, _ptr) \ + ((void)0) +#endif + +#define XPT_STRDUP(_arena, _s) \ + XPT_ArenaStrDup((_arena), (_s)) + +#define XPT_CALLOC(_arena, _size) XPT_MALLOC((_arena), (_size)) +#define XPT_NEW(_arena, _struct) ((_struct *) XPT_MALLOC((_arena), sizeof(_struct))) +#define XPT_NEWZAP(_arena, _struct) XPT_NEW((_arena), _struct) +#define XPT_DELETE(_arena, _ptr) do{XPT_FREE((_arena), (_ptr)); ((_ptr)) = NULL;}while(0) +#define XPT_FREEIF(_arena, _ptr) do{if ((_ptr)) XPT_FREE((_arena), (_ptr));}while(0) + +/* --------------------------------------------------------- */ + +#ifdef DEBUG +XPT_PUBLIC_API(void) +XPT_AssertFailed(const char *s, const char *file, PRUint32 lineno); +#define XPT_ASSERT(_expr) \ + ((_expr)?((void)0):XPT_AssertFailed(# _expr, __FILE__, __LINE__)) +#else +#define XPT_ASSERT(_expr) ((void)0) +#endif + +PR_END_EXTERN_C + +#endif /* __xpt_arena_h__ */ diff --git a/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_struct.h b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_struct.h new file mode 100644 index 00000000..c7f36f2d --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_struct.h @@ -0,0 +1,562 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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.org code. + * + * 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): + * + * 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 ***** */ + +/* + * Structures matching the in-memory representation of typelib structures. + * http://www.mozilla.org/scriptable/typelib_file.html + */ + +#ifndef __xpt_struct_h__ +#define __xpt_struct_h__ + +#include "xpt_arena.h" + +#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP +#define XPT_NewHeader VBoxNsxpXPT_NewHeader +#define XPT_NewStringZ VBoxNsxpXPT_NewStringZ +#define XPT_NewAnnotation VBoxNsxpXPT_NewAnnotation +#define XPT_SizeOfHeaderBlock VBoxNsxpXPT_SizeOfHeaderBlock +#define XPT_NewInterfaceDescriptor VBoxNsxpXPT_NewInterfaceDescriptor +#define XPT_FillInterfaceDirectoryEntry VBoxNsxpXPT_FillInterfaceDirectoryEntry +#define XPT_FillMethodDescriptor VBoxNsxpXPT_FillMethodDescriptor +#define XPT_FreeHeader VBoxNsxpXPT_FreeHeader +#define XPT_ParseVersionString VBoxNsxpXPT_ParseVersionString +#define XPT_DestroyInterfaceDirectoryEntry VBoxNsxpXPT_DestroyInterfaceDirectoryEntry +#define XPT_FillParamDescriptor VBoxNsxpXPT_FillParamDescriptor +#define XPT_FreeInterfaceDescriptor VBoxNsxpXPT_FreeInterfaceDescriptor +#define XPT_InterfaceDescriptorAddConsts VBoxNsxpXPT_InterfaceDescriptorAddConsts +#define XPT_InterfaceDescriptorAddMethods VBoxNsxpXPT_InterfaceDescriptorAddMethods +#define XPT_InterfaceDescriptorAddTypes VBoxNsxpXPT_InterfaceDescriptorAddTypes +#define XPT_GetInterfaceIndexByName VBoxNsxpXPT_GetInterfaceIndexByName +#define XPT_NewString VBoxNsxpXPT_NewString +#define XPT_SizeOfHeader VBoxNsxpXPT_SizeOfHeader +#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */ + +PR_BEGIN_EXTERN_C + +/* + * Originally, I was going to have structures that exactly matched the on-disk + * representation, but that proved difficult: different compilers can pack + * their structs differently, and that makes overlaying them atop a + * read-from-disk byte buffer troublesome. So now I just have some structures + * that are used in memory, and we're going to write a nice XDR library to + * write them to disk and stuff. It is pure joy. -- shaver + */ + +/* Structures for the typelib components */ + +typedef struct XPTHeader XPTHeader; +typedef struct XPTInterfaceDirectoryEntry XPTInterfaceDirectoryEntry; +typedef struct XPTInterfaceDescriptor XPTInterfaceDescriptor; +typedef struct XPTConstDescriptor XPTConstDescriptor; +typedef struct XPTMethodDescriptor XPTMethodDescriptor; +typedef struct XPTParamDescriptor XPTParamDescriptor; +typedef struct XPTTypeDescriptor XPTTypeDescriptor; +typedef struct XPTTypeDescriptorPrefix XPTTypeDescriptorPrefix; +typedef struct XPTString XPTString; +typedef struct XPTAnnotation XPTAnnotation; +#ifndef nsID_h__ +/* + * We can't include nsID.h, because it's full of C++ goop and we're not doing + * C++ here, so we define our own minimal struct. We protect against multiple + * definitions of this struct, though, and use the same field naming. + */ +struct nsID { + PRUint32 m0; + PRUint16 m1; + PRUint16 m2; + PRUint8 m3[8]; +}; + +typedef struct nsID nsID; +#endif + +#define XPT_COPY_IID(to, from) \ + (to).m0 = (from).m0; \ + (to).m1 = (from).m1; \ + (to).m2 = (from).m2; \ + (to).m3[0] = (from).m3[0]; \ + (to).m3[1] = (from).m3[1]; \ + (to).m3[2] = (from).m3[2]; \ + (to).m3[3] = (from).m3[3]; \ + (to).m3[4] = (from).m3[4]; \ + (to).m3[5] = (from).m3[5]; \ + (to).m3[6] = (from).m3[6]; \ + (to).m3[7] = (from).m3[7]; + + +/* + * Every XPCOM typelib file begins with a header. + */ +struct XPTHeader { + PRUint8 magic[16]; + PRUint8 major_version; + PRUint8 minor_version; + PRUint16 num_interfaces; + PRUint32 file_length; + XPTInterfaceDirectoryEntry *interface_directory; + PRUint32 data_pool; + XPTAnnotation *annotations; +}; + +#define XPT_MAGIC "XPCOM\nTypeLib\r\n\032" +/* For error messages. */ +#define XPT_MAGIC_STRING "XPCOM\\nTypeLib\\r\\n\\032" +#define XPT_MAJOR_VERSION 0x01 +#define XPT_MINOR_VERSION 0x02 + +/* Any file with a major version number of XPT_MAJOR_INCOMPATIBLE_VERSION + * or higher is to be considered incompatible by this version of xpt and + * we will refuse to read it. We will return a header with magic, major and + * minor versions set from the file. num_interfaces and file_length will be + * set to zero to confirm our inability to read the file; i.e. even if some + * client of this library gets out of sync with us regarding the agreed upon + * value for XPT_MAJOR_INCOMPATIBLE_VERSION, anytime num_interfaces and + * file_length are both zero we *know* that this library refused to read the + * file due to version imcompatibility. + */ +#define XPT_MAJOR_INCOMPATIBLE_VERSION 0x02 + +/* + * The "[-t version number]" cmd line parameter to the XPIDL compiler and XPT + * linker specifies the major and minor version number of the output + * type library. + * + * The goal is for the compiler to check that the input IDL file only uses + * constructs that are supported in the version specified. The linker will + * check that all typelib files it reads are of the version specified or + * below. + * + * Both the compiler and the linker will report errors and abort if these + * checks fail. + * + * When you rev up major or minor versions of the type library in the future, + * think about the new stuff that you added to the type library and add checks + * to make sure that occurrences of that new "stuff" will get caught when [-t + * version number] is used with the compiler. Here's what you'll probably + * have to do each time you rev up major/minor versions: + * + * 1) Add the current version number string (before your change) to the + * XPT_TYPELIB_VERSIONS list. + * + * 2) Do your changes add new features to XPIDL? Ensure that those new + * features are rejected by the XPIDL compiler when any version number in + * the XPT_TYPELIB_VERSIONS list is specified on the command line. The + * one place that currently does this kind of error checking is the function + * verify_type_fits_version() in xpidl_util.c. It currently checks + * attribute types, parameter types, and return types. You'll probably have + * to add to it or generalize it further based on what kind of changes you + * are making. + * + * 3) You will probably NOT need to make any changes to the error checking + * in the linker. + */ + +#define XPT_VERSION_UNKNOWN 0 +#define XPT_VERSION_UNSUPPORTED 1 +#define XPT_VERSION_OLD 2 +#define XPT_VERSION_CURRENT 3 + +typedef struct { + const char* str; + PRUint8 major; + PRUint8 minor; + PRUint16 code; +} XPT_TYPELIB_VERSIONS_STRUCT; + +/* Currently accepted list of versions for typelibs */ +#define XPT_TYPELIB_VERSIONS { \ + {"1.0", 1, 0, XPT_VERSION_UNSUPPORTED}, \ + {"1.1", 1, 1, XPT_VERSION_OLD}, \ + {"1.2", 1, 2, XPT_VERSION_CURRENT} \ +} + +extern XPT_PUBLIC_API(PRUint16) +XPT_ParseVersionString(const char* str, PRUint8* major, PRUint8* minor); + +extern XPT_PUBLIC_API(XPTHeader *) +XPT_NewHeader(XPTArena *arena, PRUint16 num_interfaces, + PRUint8 major_version, PRUint8 minor_version); + +extern XPT_PUBLIC_API(void) +XPT_FreeHeader(XPTArena *arena, XPTHeader* aHeader); + +/* size of header and annotations */ +extern XPT_PUBLIC_API(PRUint32) +XPT_SizeOfHeader(XPTHeader *header); + +/* size of header and annotations and InterfaceDirectoryEntries */ +extern XPT_PUBLIC_API(PRUint32) +XPT_SizeOfHeaderBlock(XPTHeader *header); + +/* + * A contiguous array of fixed-size InterfaceDirectoryEntry records begins at + * the byte offset identified by the interface_directory field in the file + * header. The array is used to quickly locate an interface description + * using its IID. No interface should appear more than once in the array. + */ +struct XPTInterfaceDirectoryEntry { + nsID iid; + char *name; + char *name_space; + XPTInterfaceDescriptor *interface_descriptor; + +#if 0 /* not yet */ + /* not stored on disk */ + PRUint32 offset; /* the offset for an ID still to be read */ +#endif +}; + +extern XPT_PUBLIC_API(PRBool) +XPT_FillInterfaceDirectoryEntry(XPTArena *arena, + XPTInterfaceDirectoryEntry *ide, + nsID *iid, char *name, char *name_space, + XPTInterfaceDescriptor *descriptor); + +extern XPT_PUBLIC_API(void) +XPT_DestroyInterfaceDirectoryEntry(XPTArena *arena, + XPTInterfaceDirectoryEntry* ide); + +/* + * An InterfaceDescriptor is a variable-size record used to describe a + * single XPCOM interface, including all of its methods. + */ +struct XPTInterfaceDescriptor { + PRUint16 parent_interface; + PRUint16 num_methods; + XPTMethodDescriptor *method_descriptors; + PRUint16 num_constants; + XPTConstDescriptor *const_descriptors; + PRUint8 flags; + + /* additional_types are used for arrays where we may need multiple + * XPTTypeDescriptors for a single XPTMethodDescriptor. Since we still + * want to have a simple array of XPTMethodDescriptor (each with a single + * embedded XPTTypeDescriptor), a XPTTypeDescriptor can have a reference + * to an 'additional_type'. That reference is an index in this + * "additional_types" array. So a given XPTMethodDescriptor might have + * a whole chain of these XPTTypeDescriptors to represent, say, a multi + * dimensional array. + * + * Note that in the typelib file these additional types are stored 'inline' + * in the MethodDescriptor. But, in the typelib MethodDescriptors can be + * of varying sizes, where in XPT's in memory mapping of the data we want + * them to be of fixed size. This additional_types scheme is here to allow + * for that. + */ + + XPTTypeDescriptor *additional_types; + PRUint16 num_additional_types; +}; + +#define XPT_ID_SCRIPTABLE 0x80 +#define XPT_ID_FUNCTION 0x40 +#define XPT_ID_FLAGMASK 0xc0 +#define XPT_ID_TAGMASK (~XPT_ID_FLAGMASK) +#define XPT_ID_TAG(id) ((id).flags & XPT_ID_TAGMASK) + +#define XPT_ID_IS_SCRIPTABLE(flags) (flags & XPT_ID_SCRIPTABLE) +#define XPT_ID_IS_FUNCTION(flags) (flags & XPT_ID_FUNCTION) + +extern XPT_PUBLIC_API(PRBool) +XPT_GetInterfaceIndexByName(XPTInterfaceDirectoryEntry *ide_block, + PRUint16 num_interfaces, char *name, + PRUint16 *indexp); + +extern XPT_PUBLIC_API(XPTInterfaceDescriptor *) +XPT_NewInterfaceDescriptor(XPTArena *arena, + PRUint16 parent_interface, PRUint16 num_methods, + PRUint16 num_constants, PRUint8 flags); + +extern XPT_PUBLIC_API(void) +XPT_FreeInterfaceDescriptor(XPTArena *arena, XPTInterfaceDescriptor* id); + +extern XPT_PUBLIC_API(PRBool) +XPT_InterfaceDescriptorAddTypes(XPTArena *arena, XPTInterfaceDescriptor *id, + PRUint16 num); + +extern XPT_PUBLIC_API(PRBool) +XPT_InterfaceDescriptorAddMethods(XPTArena *arena, XPTInterfaceDescriptor *id, + PRUint16 num); + +extern XPT_PUBLIC_API(PRBool) +XPT_InterfaceDescriptorAddConsts(XPTArena *arena, XPTInterfaceDescriptor *id, + PRUint16 num); + +/* + * This is our special string struct with a length value associated with it, + * which means that it can contains embedded NULs. + */ +struct XPTString { + PRUint16 length; + char *bytes; +}; + +extern XPT_PUBLIC_API(XPTString *) +XPT_NewString(XPTArena *arena, PRUint16 length, char *bytes); + +extern XPT_PUBLIC_API(XPTString *) +XPT_NewStringZ(XPTArena *arena, char *bytes); + +/* + * A TypeDescriptor is a variable-size record used to identify the type of a + * method argument or return value. + * + * There are three types of TypeDescriptors: + * + * SimpleTypeDescriptor + * InterfaceTypeDescriptor + * InterfaceIsTypeDescriptor + * + * The tag field in the prefix indicates which of the variant TypeDescriptor + * records is being used, and hence the way any remaining fields should be + * parsed. Values from 0 to 17 refer to SimpleTypeDescriptors. The value 18 + * designates an InterfaceTypeDescriptor, while 19 represents an + * InterfaceIsTypeDescriptor. + */ + +/* why bother with a struct? - other code relies on this being a struct */ +struct XPTTypeDescriptorPrefix { + PRUint8 flags; +}; + +/* flag bits -- fur and jband were right, I was miserably wrong */ +#define XPT_TDP_POINTER 0x80 +#define XPT_TDP_UNIQUE_POINTER 0x40 +#define XPT_TDP_REFERENCE 0x20 +#define XPT_TDP_FLAGMASK 0xe0 +#define XPT_TDP_TAGMASK (~XPT_TDP_FLAGMASK) +#define XPT_TDP_TAG(tdp) ((tdp).flags & XPT_TDP_TAGMASK) + +#define XPT_TDP_IS_POINTER(flags) (flags & XPT_TDP_POINTER) +#define XPT_TDP_IS_UNIQUE_POINTER(flags) (flags & XPT_TDP_UNIQUE_POINTER) +#define XPT_TDP_IS_REFERENCE(flags) (flags & XPT_TDP_REFERENCE) + +/* + * The following enum maps mnemonic names to the different numeric values + * of XPTTypeDescriptor->tag. + */ +enum XPTTypeDescriptorTags { + TD_INT8 = 0, + TD_INT16 = 1, + TD_INT32 = 2, + TD_INT64 = 3, + TD_UINT8 = 4, + TD_UINT16 = 5, + TD_UINT32 = 6, + TD_UINT64 = 7, + TD_FLOAT = 8, + TD_DOUBLE = 9, + TD_BOOL = 10, + TD_CHAR = 11, + TD_WCHAR = 12, + TD_VOID = 13, + TD_PNSIID = 14, + TD_DOMSTRING = 15, + TD_PSTRING = 16, + TD_PWSTRING = 17, + TD_INTERFACE_TYPE = 18, + TD_INTERFACE_IS_TYPE = 19, + TD_ARRAY = 20, + TD_PSTRING_SIZE_IS = 21, + TD_PWSTRING_SIZE_IS = 22, + TD_UTF8STRING = 23, + TD_CSTRING = 24, + TD_ASTRING = 25 +}; + +struct XPTTypeDescriptor { + XPTTypeDescriptorPrefix prefix; + PRUint8 argnum; /* used for iid_is and size_is */ + PRUint8 argnum2; /* used for length_is */ + union { + PRUint16 iface; /* used for TD_INTERFACE_TYPE */ + PRUint16 additional_type; /* used for TD_ARRAY */ + } type; +}; + +#define XPT_COPY_TYPE(to, from) \ + (to).prefix.flags = (from).prefix.flags; \ + (to).argnum = (from).argnum; \ + (to).argnum2 = (from).argnum2; \ + (to).type.additional_type = (from).type.additional_type; + +/* + * A ConstDescriptor is a variable-size record that records the name and + * value of a scoped interface constant. + * + * The types of the method parameter are restricted to the following subset + * of TypeDescriptors: + * + * int8, uint8, int16, uint16, int32, uint32, + * int64, uint64, wchar_t, char, string + * + * The type (and thus the size) of the value record is determined by the + * contents of the associated TypeDescriptor record. For instance, if type + * corresponds to int16, then value is a two-byte record consisting of a + * 16-bit signed integer. For a ConstDescriptor type of string, the value + * record is of type String*, i.e. an offset within the data pool to a + * String record containing the constant string. + */ +union XPTConstValue { + PRInt8 i8; + PRUint8 ui8; + PRInt16 i16; + PRUint16 ui16; + PRInt32 i32; + PRUint32 ui32; + PRInt64 i64; + PRUint64 ui64; + float flt; + double dbl; + PRBool bul; + char ch; + PRUint16 wch; + nsID *iid; + XPTString *string; + char *str; + PRUint16 *wstr; +}; /* varies according to type */ + +struct XPTConstDescriptor { + char *name; + XPTTypeDescriptor type; + union XPTConstValue value; +}; + +/* + * A ParamDescriptor is a variable-size record used to describe either a + * single argument to a method or a method's result. + */ +struct XPTParamDescriptor { + PRUint8 flags; + XPTTypeDescriptor type; +}; + +/* flag bits -- jband and fur were right, and I was miserably wrong */ +#define XPT_PD_IN 0x80 +#define XPT_PD_OUT 0x40 +#define XPT_PD_RETVAL 0x20 +#define XPT_PD_SHARED 0x10 +#define XPT_PD_DIPPER 0x08 +#define XPT_PD_FLAGMASK 0xf8 + +#define XPT_PD_IS_IN(flags) (flags & XPT_PD_IN) +#define XPT_PD_IS_OUT(flags) (flags & XPT_PD_OUT) +#define XPT_PD_IS_RETVAL(flags) (flags & XPT_PD_RETVAL) +#define XPT_PD_IS_SHARED(flags) (flags & XPT_PD_SHARED) +#define XPT_PD_IS_DIPPER(flags) (flags & XPT_PD_DIPPER) + +/* this is bogus +#define XPT_PARAMDESCRIPTOR_SIZE (XPT_TYPEDESCRIPTOR_SIZE + 1) +*/ + +extern XPT_PUBLIC_API(PRBool) +XPT_FillParamDescriptor(XPTArena *arena, + XPTParamDescriptor *pd, PRUint8 flags, + XPTTypeDescriptor *type); + +/* + * A MethodDescriptor is a variable-size record used to describe a single + * interface method. + */ +struct XPTMethodDescriptor { + char *name; + XPTParamDescriptor *params; + XPTParamDescriptor *result; + PRUint8 flags; + PRUint8 num_args; +}; + +/* flag bits -- jband and fur were right, and I was miserably wrong */ +#define XPT_MD_GETTER 0x80 +#define XPT_MD_SETTER 0x40 +#define XPT_MD_NOTXPCOM 0x20 +#define XPT_MD_CTOR 0x10 +#define XPT_MD_HIDDEN 0x08 +#define XPT_MD_FLAGMASK 0xf8 + +#define XPT_MD_IS_GETTER(flags) (flags & XPT_MD_GETTER) +#define XPT_MD_IS_SETTER(flags) (flags & XPT_MD_SETTER) +#define XPT_MD_IS_NOTXPCOM(flags) (flags & XPT_MD_NOTXPCOM) +#define XPT_MD_IS_CTOR(flags) (flags & XPT_MD_CTOR) +#define XPT_MD_IS_HIDDEN(flags) (flags & XPT_MD_HIDDEN) + +extern XPT_PUBLIC_API(PRBool) +XPT_FillMethodDescriptor(XPTArena *arena, + XPTMethodDescriptor *meth, PRUint8 flags, char *name, + PRUint8 num_args); + +/* + * Annotation records are variable-size records used to store secondary + * information about the typelib, e.g. such as the name of the tool that + * generated the typelib file, the date it was generated, etc. The + * information is stored with very loose format requirements so as to + * allow virtually any private data to be stored in the typelib. + * + * There are two types of Annotations: + * + * EmptyAnnotation + * PrivateAnnotation + * + * The tag field of the prefix discriminates among the variant record + * types for Annotation's. If the tag is 0, this record is an + * EmptyAnnotation. EmptyAnnotation's are ignored - they're only used to + * indicate an array of Annotation's that's completely empty. If the tag + * is 1, the record is a PrivateAnnotation. + */ + +struct XPTAnnotation { + XPTAnnotation *next; + PRUint8 flags; + /* remaining fields are present in typelib iff XPT_ANN_IS_PRIVATE */ + XPTString *creator; + XPTString *private_data; +}; + +#define XPT_ANN_LAST 0x80 +#define XPT_ANN_IS_LAST(flags) (flags & XPT_ANN_LAST) +#define XPT_ANN_PRIVATE 0x40 +#define XPT_ANN_IS_PRIVATE(flags) (flags & XPT_ANN_PRIVATE) + +extern XPT_PUBLIC_API(XPTAnnotation *) +XPT_NewAnnotation(XPTArena *arena, PRUint8 flags, XPTString *creator, + XPTString *private_data); + +PR_END_EXTERN_C + +#endif /* __xpt_struct_h__ */ diff --git a/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_xdr.h b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_xdr.h new file mode 100644 index 00000000..89d1c3f6 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/typelib/xpt/public/xpt_xdr.h @@ -0,0 +1,240 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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.org code. + * + * 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): + * + * 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 ***** */ + +/* + * Basic APIs for streaming typelib structures to/from disk. + */ + +#ifndef __xpt_xdr_h__ +#define __xpt_xdr_h__ + +#include "xpt_struct.h" + +#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP +#define XPT_Do8 VBoxNsxpXPT_Do8 +#define XPT_Do16 VBoxNsxpXPT_Do16 +#define XPT_Do32 VBoxNsxpXPT_Do32 +#define XPT_Do64 VBoxNsxpXPT_Do64 +#define XPT_DoIID VBoxNsxpXPT_DoIID +#define XPT_DoCString VBoxNsxpXPT_DoCString +#define XPT_DoString VBoxNsxpXPT_DoString +#define XPT_DoStringInline VBoxNsxpXPT_DoStringInline +#define XPT_NewXDRState VBoxNsxpXPT_NewXDRState +#define XPT_SetDataOffset VBoxNsxpXPT_SetDataOffset +#define XPT_SeekTo VBoxNsxpXPT_SeekTo +#define XPT_MakeCursor VBoxNsxpXPT_MakeCursor +#define XPT_DestroyXDRState VBoxNsxpXPT_DestroyXDRState +#define XPT_GetXDRData VBoxNsxpXPT_GetXDRData +#define XPT_GetXDRDataLength VBoxNsxpXPT_GetXDRDataLength +#define XPT_DoHeader VBoxNsxpXPT_DoHeader +#define XPT_DoHeaderPrologue VBoxNsxpXPT_DoHeaderPrologue +#define XPT_UpdateFileLength VBoxNsxpXPT_UpdateFileLength +#define XPT_DataOffset VBoxNsxpXPT_DataOffset +#define XPT_GetOffsetForAddr VBoxNsxpXPT_GetOffsetForAddr +#define XPT_SetOffsetForAddr VBoxNsxpXPT_SetOffsetForAddr +#define XPT_SetAddrForOffset VBoxNsxpXPT_SetAddrForOffset +#define XPT_GetAddrForOffset VBoxNsxpXPT_GetAddrForOffset +#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */ + +PR_BEGIN_EXTERN_C + +typedef struct XPTState XPTState; +typedef struct XPTDatapool XPTDatapool; +typedef struct XPTCursor XPTCursor; + +/* Opaque type, for internal use */ +typedef struct XPTHashTable XPTHashTable; + +extern XPT_PUBLIC_API(PRBool) +XPT_DoString(XPTArena *arena, XPTCursor *cursor, XPTString **strp); + +extern XPT_PUBLIC_API(PRBool) +XPT_DoStringInline(XPTArena *arena, XPTCursor *cursor, XPTString **strp); + +extern XPT_PUBLIC_API(PRBool) +XPT_DoCString(XPTArena *arena, XPTCursor *cursor, char **strp); + +extern XPT_PUBLIC_API(PRBool) +XPT_DoIID(XPTCursor *cursor, nsID *iidp); + +extern XPT_PUBLIC_API(PRBool) +XPT_Do64(XPTCursor *cursor, PRInt64 *u64p); + +extern XPT_PUBLIC_API(PRBool) +XPT_Do32(XPTCursor *cursor, PRUint32 *u32p); + +extern XPT_PUBLIC_API(PRBool) +XPT_Do16(XPTCursor *cursor, PRUint16 *u16p); + +extern XPT_PUBLIC_API(PRBool) +XPT_Do8(XPTCursor *cursor, PRUint8 *u8p); + +extern XPT_PUBLIC_API(PRBool) +XPT_DoHeaderPrologue(XPTArena *arena, XPTCursor *cursor, XPTHeader **headerp, PRUint32 * ide_offset); +extern XPT_PUBLIC_API(PRBool) +XPT_DoHeader(XPTArena *arena, XPTCursor *cursor, XPTHeader **headerp); + +typedef enum { + XPT_ENCODE, + XPT_DECODE +} XPTMode; + +typedef enum { + XPT_HEADER = 0, + XPT_DATA = 1 +} XPTPool; + +struct XPTState { + XPTMode mode; + PRUint32 data_offset; + PRUint32 next_cursor[2]; + XPTDatapool *pool; + XPTArena *arena; +}; + +struct XPTDatapool { + XPTHashTable *offset_map; + char *data; + PRUint32 count; + PRUint32 allocated; +}; + +struct XPTCursor { + XPTState *state; + XPTPool pool; + PRUint32 offset; + PRUint8 bits; +}; + +extern XPT_PUBLIC_API(XPTState *) +XPT_NewXDRState(XPTMode mode, char *data, PRUint32 len); + +extern XPT_PUBLIC_API(PRBool) +XPT_MakeCursor(XPTState *state, XPTPool pool, PRUint32 len, XPTCursor *cursor); + +extern XPT_PUBLIC_API(PRBool) +XPT_SeekTo(XPTCursor *cursor, PRUint32 offset); + +extern XPT_PUBLIC_API(void) +XPT_DestroyXDRState(XPTState *state); + +/* Set file_length based on the data used in the state. (Only ENCODE.) */ +extern XPT_PUBLIC_API(PRBool) +XPT_UpdateFileLength(XPTState *state); + +/* returns the length of the specified data block */ +extern XPT_PUBLIC_API(void) +XPT_GetXDRDataLength(XPTState *state, XPTPool pool, PRUint32 *len); + +extern XPT_PUBLIC_API(void) +XPT_GetXDRData(XPTState *state, XPTPool pool, char **data, PRUint32 *len); + +/* set or get the data offset for the state, depending on mode */ +extern XPT_PUBLIC_API(void) +XPT_DataOffset(XPTState *state, PRUint32 *data_offsetp); + +extern XPT_PUBLIC_API(void) +XPT_SetDataOffset(XPTState *state, PRUint32 data_offset); + +extern XPT_PUBLIC_API(PRUint32) +XPT_GetOffsetForAddr(XPTCursor *cursor, void *addr); + +extern XPT_PUBLIC_API(PRBool) +XPT_SetOffsetForAddr(XPTCursor *cursor, void *addr, PRUint32 offset); + +extern XPT_PUBLIC_API(PRBool) +XPT_SetAddrForOffset(XPTCursor *cursor, PRUint32 offset, void *addr); + +extern XPT_PUBLIC_API(void *) +XPT_GetAddrForOffset(XPTCursor *cursor, PRUint32 offset); + +/* all data structures are big-endian */ + +#if defined IS_BIG_ENDIAN +# ifdef VBOX +# error "Misconfigured endian!" +# endif +# define XPT_SWAB32(x) x +# define XPT_SWAB16(x) x +#elif defined IS_LITTLE_ENDIAN +# define XPT_SWAB32(x) (((x) >> 24) | \ + (((x) >> 8) & 0xff00) | \ + (((x) << 8) & 0xff0000) | \ + ((x) << 24)) +# define XPT_SWAB16(x) (((x) >> 8) | ((x) << 8)) +#else +# error "unknown byte order" +#endif + +/* + * If we're decoding, we want to read the offset before we check + * for already-decoded values. + * + * Then we check for repetition: CheckForRepeat will see if we've already + * encoded/decoded this value, and if so will set offset/addr correctly + * and make already be true. If not, it will set up the cursor for + * encoding (reserve space) or decoding (seek to correct location) as + * appropriate. In the encode case, it will also set the addr->offset + * mapping. + */ + +#define XPT_PREAMBLE_(cursor, addrp, pool, size, new_curs, already) \ + XPTMode mode = cursor->state->mode; \ + if (!(mode == XPT_ENCODE || XPT_Do32(cursor, &new_curs.offset)) || \ + !CheckForRepeat(cursor, (void **)addrp, pool, \ + mode == XPT_ENCODE ? size : 0u, &new_curs, \ + &already) || \ + !(mode == XPT_DECODE || XPT_Do32(cursor, &new_curs.offset))) \ + return PR_FALSE; \ + if (already) \ + return PR_TRUE; \ + +#define XPT_PREAMBLE_NO_ALLOC(cursor, addrp, pool, size, new_curs, already) \ + { \ + XPT_PREAMBLE_(cursor, addrp, pool, size, new_curs, already) \ + } + +#define XPT_ERROR_HANDLE(arena, free_it) \ + error: \ + if (cursor->state->mode == XPT_DECODE) \ + XPT_FREEIF(arena, free_it); \ + return PR_FALSE; + + +PR_END_EXTERN_C + +#endif /* __xpt_xdr_h__ */ -- cgit v1.2.3