summaryrefslogtreecommitdiffstats
path: root/src/libs/xpcom18a4/java/tools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xsrc/libs/xpcom18a4/java/tools/gen-nsError.pl161
-rw-r--r--src/libs/xpcom18a4/java/tools/genifaces/GenerateJavaInterfaces.cpp952
-rw-r--r--src/libs/xpcom18a4/java/tools/genjifaces.xsl600
3 files changed, 1713 insertions, 0 deletions
diff --git a/src/libs/xpcom18a4/java/tools/gen-nsError.pl b/src/libs/xpcom18a4/java/tools/gen-nsError.pl
new file mode 100755
index 00000000..da866b83
--- /dev/null
+++ b/src/libs/xpcom18a4/java/tools/gen-nsError.pl
@@ -0,0 +1,161 @@
+#! /usr/bin/env perl
+# ***** 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 Java XPCOM Bindings.
+#
+# The Initial Developer of the Original Code is
+# Michal Ceresna.
+# Portions created by the Initial Developer are Copyright (C) 2005
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Michal Ceresna (ceresna@dbai.tuwien.ac.at)
+# Javier Pedemonte (jhpedemonte@gmail.com)
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either 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 *****
+
+# Generates XPCOMError.java from xpcom/base/nsError.h
+#
+# usage: perl gen-nsErrors.pl < <topsrcdir>/xpcom/base/nsError.h > XPCOMError.java
+
+
+print "/* ***** BEGIN LICENSE BLOCK *****\n";
+print " * Version: MPL 1.1/GPL 2.0/LGPL 2.1\n";
+print " *\n";
+print " * The contents of this file are subject to the Mozilla Public License Version\n";
+print " * 1.1 (the \"License\"); you may not use this file except in compliance with\n";
+print " * the License. You may obtain a copy of the License at\n";
+print " * http://www.mozilla.org/MPL/\n";
+print " *\n";
+print " * Software distributed under the License is distributed on an \"AS IS\" basis,\n";
+print " * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\n";
+print " * for the specific language governing rights and limitations under the\n";
+print " * License.\n";
+print " *\n";
+print " * The Original Code is mozilla.org code.\n";
+print " *\n";
+print " * The Initial Developer of the Original Code is\n";
+print " * Netscape Communications Corporation.\n";
+print " * Portions created by the Initial Developer are Copyright (C) 1998\n";
+print " * the Initial Developer. All Rights Reserved.\n";
+print " *\n";
+print " * Contributor(s):\n";
+print " *\n";
+print " * Alternatively, the contents of this file may be used under the terms of\n";
+print " * either of the GNU General Public License Version 2 or later (the \"GPL\"),\n";
+print " * or the GNU Lesser General Public License Version 2.1 or later (the \"LGPL\"),\n";
+print " * in which case the provisions of the GPL or the LGPL are applicable instead\n";
+print " * of those above. If you wish to allow use of your version of this file only\n";
+print " * under the terms of either the GPL or the LGPL, and not to allow others to\n";
+print " * use your version of this file under the terms of the MPL, indicate your\n";
+print " * decision by deleting the provisions above and replace them with the notice\n";
+print " * and other provisions required by the GPL or the LGPL. If you do not delete\n";
+print " * the provisions above, a recipient may use your version of this file under\n";
+print " * the terms of any one of the MPL, the GPL or the LGPL.\n";
+print " *\n";
+print " * ***** END LICENSE BLOCK ***** */\n";
+
+print "\n";
+print "package org.mozilla.xpcom;\n";
+print "\n\n";
+
+print "/**\n";
+print " * Mozilla error codes.\n";
+print " *\n";
+print " * THIS FILE GENERATED FROM mozilla/xpcom/base/nsError.h.\n";
+print " * PLEASE SEE THAT FILE FOR FULL DOCUMENTATION.\n";
+print " */\n";
+print "public interface XPCOMError {\n";
+
+while (<STDIN>) {
+ $line = $_;
+
+ if ($prevline) {
+ $_ = $prevline.$_;
+ }
+ if (/(.*)\\$/) {
+ #splitted line
+ $prevline = $1;
+ next;
+ }
+ $prevline = "";
+
+ if (/^\s*#define\s+(NS_[A-Z_]+)\s+(0x)?([0-9a-fA-F]+)\s*$/) {
+ #define NS_ERROR_MODULE_XPCOM 1
+ #define NS_ERROR_MODULE_BASE_OFFSET 0x45
+ print " public static final long $1 = $2$3L;\n";
+ }
+ elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+\((NS_[A-Z_]+)\s+\+\s+(0x)?([0-9a-fA-F]+)\s*\)\s*/) {
+ #define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
+ #define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
+ print " public static final long $1 = $2 + $3$4L;\n";
+ }
+ elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+(NS_[A-Z_]+)\s\s*/) {
+ #define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
+ print " public static final long $1 = $2;\n";
+ }
+ elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+\(\(nsresult\)\s*(0x)?([0-9a-fA-F]+)L?\)\s*$/) {
+ #define NS_ERROR_BASE ((nsresult) 0xC1F30000)
+ #define NS_ERROR_ABORT ((nsresult) 0x80004004L)
+ print " public static final long $1 = $2$3L;\n";
+ }
+ elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+NS_ERROR_GENERATE_FAILURE\s*\(\s*(NS_[A-Z_]+)\s*,\s*([0-9]+)\s*\)\s*$/) {
+ #define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2)
+ $module = $2;
+ $code = $3;
+ print " public static final long $1 = ((NS_ERROR_SEVERITY_ERROR<<31) | (($module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | $code);\n";
+ }
+ elsif (/^\s*#define\s+(NS_[A-Z_]+)\s+NS_ERROR_GENERATE_SUCCESS\s*\(\s*(NS_[A-Z_]+)\s*,\s*([0-9]+)\s*\)\s*$/) {
+ #define NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 1)
+ $module = $2;
+ $code = $3;
+ print " public static final long $1 = ((NS_ERROR_SEVERITY_SUCCESS<<31) | (($module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | $code);\n";
+ }
+ elsif (/^\s*\/\*(.*)\*\/\s*$/ && !/^\s*\/\*@[\{\}]\*\/\s*$/ &&
+ !/^\s*\/\*\ -\*- Mode:/) {
+ #single line comment, but not
+ #/*@{*/, /*@}*/,
+ #/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ print " /*$1*/\n";
+ }
+ elsif (/^\s*$/) {
+ #empty line, but write only the first
+ #line from a sequence of empty lines
+ if (!$wasEmpty) {
+ print "\n";
+ }
+ $wasEmpty = 1;
+ next;
+ }
+ else {
+ next;
+ }
+
+ $wasEmpty = 0;
+}
+
+print "}\n";
+
diff --git a/src/libs/xpcom18a4/java/tools/genifaces/GenerateJavaInterfaces.cpp b/src/libs/xpcom18a4/java/tools/genifaces/GenerateJavaInterfaces.cpp
new file mode 100644
index 00000000..60648beb
--- /dev/null
+++ b/src/libs/xpcom18a4/java/tools/genifaces/GenerateJavaInterfaces.cpp
@@ -0,0 +1,952 @@
+/* ***** 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 Java XPCOM Bindings.
+ *
+ * The Initial Developer of the Original Code is
+ * IBM Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2005
+ * IBM Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Javier Pedemonte (jhpedemonte@gmail.com)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either 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 ***** */
+
+#include "nsXPCOM.h"
+#include "nsString.h"
+#include "nsILocalFile.h"
+#include "nsIInterfaceInfoManager.h"
+#include "xptinfo.h"
+#include "nsCOMPtr.h"
+#include "prmem.h"
+#include "xptcall.h"
+#ifdef VBOX
+#include "nsFileStreams.h"
+static nsresult
+NS_NewLocalFileInputStream(nsIInputStream **aResult,
+ nsIFile *aFile,
+ PRInt32 aIOFlags = -1,
+ PRInt32 aPerm = -1,
+ PRInt32 aBehaviorFlags = 0)
+{
+ nsFileInputStream* in = new nsFileInputStream();
+ nsresult rv;
+
+ rv = in->Init(aFile, aIOFlags, aPerm, aBehaviorFlags);
+ if (NS_SUCCEEDED(rv))
+ NS_ADDREF(*aResult = in);
+
+ return rv;
+}
+
+inline nsresult
+NS_NewLocalFileOutputStream(nsIOutputStream **aResult,
+ nsIFile *aFile,
+ PRInt32 aIOFlags = -1,
+ PRInt32 aPerm = -1,
+ PRInt32 aBehaviorFlags = 0)
+{
+ nsFileOutputStream* in = new nsFileOutputStream();
+ nsresult rv;
+
+ rv = in->Init(aFile, aIOFlags, aPerm, aBehaviorFlags);
+ if (NS_SUCCEEDED(rv))
+ NS_ADDREF(*aResult = in);
+
+ return rv;
+}
+
+
+#else
+#include "nsNetUtil.h"
+#endif
+#include "nsHashSets.h"
+#include "nsIWeakReference.h"
+#include <stdio.h>
+
+#ifdef WIN32
+#define snprintf _snprintf
+#endif
+
+#define WRITE_NOSCRIPT_METHODS
+
+
+class TypeInfo
+{
+public:
+ static nsresult GetParentInfo(nsIInterfaceInfo* aIInfo,
+ nsIInterfaceInfo** aParentInfo,
+ PRUint16* aParentMethodCount,
+ PRUint16* aParentConstCount)
+ {
+ nsCOMPtr<nsIInterfaceInfo> parent;
+ nsresult rv = aIInfo->GetParent(getter_AddRefs(parent));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ if (!parent) {
+ *aParentInfo = nsnull;
+ *aParentMethodCount = 0;
+ return NS_OK;
+ }
+
+ rv = parent->GetMethodCount(aParentMethodCount);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = parent->GetConstantCount(aParentConstCount);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ *aParentInfo = parent;
+ NS_ADDREF(*aParentInfo);
+ return rv;
+ }
+
+ static nsresult GetInterfaceName(nsIInterfaceInfo* aIInfo,
+ PRUint16 aMethodIndex,
+ const nsXPTParamInfo* aParamInfo,
+ char** aResult)
+ {
+ static const char isupp_str[] = "nsISupports";
+
+ nsIID* iid;
+ nsresult rv = aIInfo->GetIIDForParam(aMethodIndex, aParamInfo, &iid);
+ if (NS_FAILED(rv)) {
+ // GetIIDForParam will sometimes fail to find an interface, particularly
+ // if that interface is not defined in an IDL file. In those cases, just
+ // return |nsISupports|.
+ //
+ // For example, the |onStreamComplete| method for the interface
+ // |nsIUnicharStreamLoaderObserver| takes a param of
+ // |nsIUnicharInputStream|, which is defined in a simple header file, not
+ // an IDL file.
+ *aResult = (char*) nsMemory::Clone(isupp_str, sizeof(isupp_str));
+ rv = (*aResult == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
+
+ } else {
+
+ // In Javaconnect, we handle weak references internally; no need for the
+ // |nsIWeakReference| interface. So just return |nsISupports|.
+ if (iid->Equals(NS_GET_IID(nsIWeakReference))) {
+ *aResult = (char*) nsMemory::Clone(isupp_str, sizeof(isupp_str));
+ rv = (*aResult == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
+
+ } else {
+
+ // Some methods take parameters of non-scriptable interfaces. But we
+ // only output scriptable interfaces. So if one of the param types is
+ // a non-scriptable interface, output |nsISupports| instead of the
+ // interface name.
+ nsCOMPtr<nsIInterfaceInfo> info;
+ nsCOMPtr<nsIInterfaceInfoManager> iim =
+ getter_AddRefs(XPTI_GetInterfaceInfoManager());
+ NS_ASSERTION(iim, "could not get interface info manager");
+ rv = iim->GetInfoForIID(iid, getter_AddRefs(info));
+ NS_ENSURE_SUCCESS(rv, rv);
+ PRBool scriptable;
+ if (NS_SUCCEEDED(rv)) {
+ info->IsScriptable(&scriptable);
+ }
+ if (NS_FAILED(rv) || !scriptable) {
+ *aResult = (char*) nsMemory::Clone(isupp_str, sizeof(isupp_str));
+ rv = (*aResult == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
+ } else {
+
+ // If is scriptable, get name for given IID
+ rv = iim->GetNameForIID(iid, aResult);
+ }
+ }
+
+ nsMemory::Free(iid);
+ }
+
+ return rv;
+ }
+};
+
+
+static const char* kJavaKeywords[] = {
+ "abstract", "default", "if" , "private" , "this" ,
+ "boolean" , "do" , "implements", "protected" , "throw" ,
+ "break" , "double" , "import", "public" , "throws" ,
+ "byte" , "else" , "instanceof", "return" , "transient",
+ "case" , "extends", "int" , "short" , "try" ,
+ "catch" , "final" , "interface" , "static" , "void" ,
+ "char" , "finally", "long" , "strictfp" , "volatile" ,
+ "class" , "float" , "native" , "super" , "while" ,
+ "const" , "for" , "new" , "switch" ,
+ "continue", "goto" , "package" , "synchronized",
+ "assert" , /* added in Java 1.4 */
+ "enum" , /* added in Java 5.0 */
+ "clone" , /* clone is a member function of java.lang.Object */
+ "finalize" /* finalize is a member function of java.lang.Object */
+};
+
+#ifdef WRITE_NOSCRIPT_METHODS
+// SWT uses [noscript] methods of the following interfaces, so we need to
+// output the [noscript] methods for these interfaces.
+static const char* kNoscriptMethodIfaces[] = {
+ "nsIBaseWindow", "nsIEmbeddingSiteWindow"
+};
+#endif
+
+
+class Generate
+{
+ nsILocalFile* mOutputDir;
+ nsCStringHashSet mIfaceTable;
+ nsCStringHashSet mJavaKeywords;
+#ifdef WRITE_NOSCRIPT_METHODS
+ nsCStringHashSet mNoscriptMethodsTable;
+#endif
+
+public:
+ Generate(nsILocalFile* aOutputDir)
+ : mOutputDir(aOutputDir)
+ {
+ mIfaceTable.Init(100);
+
+ PRUint32 size = NS_ARRAY_LENGTH(kJavaKeywords);
+ mJavaKeywords.Init(size);
+ for (PRUint32 i = 0; i < size; i++) {
+ mJavaKeywords.Put(nsDependentCString(kJavaKeywords[i]));
+ }
+
+#ifdef WRITE_NOSCRIPT_METHODS
+ size = NS_ARRAY_LENGTH(kNoscriptMethodIfaces);
+ mNoscriptMethodsTable.Init(size);
+ for (PRUint32 j = 0; j < size; j++) {
+ mNoscriptMethodsTable.Put(nsDependentCString(kNoscriptMethodIfaces[j]));
+ }
+#endif
+ }
+
+ ~Generate()
+ {
+ }
+
+ nsresult GenerateInterfaces()
+ {
+ nsresult rv;
+
+ nsCOMPtr<nsIInterfaceInfoManager> iim =
+ getter_AddRefs(XPTI_GetInterfaceInfoManager());
+ NS_ASSERTION(iim, "could not get interface info manager");
+ nsCOMPtr<nsIEnumerator> etor;
+ rv = iim->EnumerateInterfaces(getter_AddRefs(etor));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // loop over interfaces
+ etor->First();
+ do {
+ // get current interface
+ nsCOMPtr<nsISupports> item;
+ rv = etor->CurrentItem(getter_AddRefs(item));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIInterfaceInfo> iface(do_QueryInterface(item));
+ if (!iface)
+ break;
+
+ // we only care about scriptable interfaces, so skip over those
+ // that aren't
+ PRBool scriptable;
+ iface->IsScriptable(&scriptable);
+ if (!scriptable) {
+ // XXX SWT uses non-scriptable interface 'nsIAppShell' (bug 270892), so
+ // include that one.
+ const char* iface_name;
+ iface->GetNameShared(&iface_name);
+ if (strcmp("nsIAppShell", iface_name) != 0)
+ continue;
+ }
+
+ rv = WriteOneInterface(iface);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ } while (NS_SUCCEEDED(etor->Next()));
+
+ return NS_OK;
+ }
+
+ nsresult WriteOneInterface(nsIInterfaceInfo* aIInfo)
+ {
+ nsresult rv;
+
+ // write each interface only once
+ const char* iface_name;
+ aIInfo->GetNameShared(&iface_name);
+ if (mIfaceTable.Contains(nsDependentCString(iface_name)))
+ return NS_OK;
+
+ // write any parent interface
+ nsCOMPtr<nsIInterfaceInfo> parentInfo;
+ PRUint16 parentMethodCount, parentConstCount;
+ rv = TypeInfo::GetParentInfo(aIInfo, getter_AddRefs(parentInfo),
+ &parentMethodCount, &parentConstCount);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (parentInfo)
+ WriteOneInterface(parentInfo);
+
+ mIfaceTable.Put(nsDependentCString(iface_name));
+
+ // create file for interface
+ nsCOMPtr<nsIOutputStream> out;
+ rv = OpenIfaceFileStream(iface_name, getter_AddRefs(out));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // write contents to file
+ rv = WriteHeader(out, iface_name);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = WriteInterfaceStart(out, aIInfo, parentInfo);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = WriteIID(out, aIInfo);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = WriteConstants(out, aIInfo, parentConstCount);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = WriteMethods(out, aIInfo, parentMethodCount);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = WriteInterfaceEnd(out);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = CloseIfaceFileStream(out);
+
+ return rv;
+ }
+
+ nsresult OpenIfaceFileStream(const char* aIfaceName,
+ nsIOutputStream** aResult)
+ {
+ nsresult rv;
+
+ // create interface file in output dir
+ nsCOMPtr<nsIFile> iface_file;
+ rv = mOutputDir->Clone(getter_AddRefs(iface_file));
+ NS_ENSURE_SUCCESS(rv, rv);
+ nsAutoString filename;
+ filename.AppendASCII(aIfaceName);
+ filename.AppendLiteral(".java");
+ rv = iface_file->Append(filename);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // create interface file
+ PRBool exists;
+ iface_file->Exists(&exists);
+ if (exists)
+ iface_file->Remove(PR_FALSE);
+ rv = iface_file->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // create output stream for writing to file
+ nsCOMPtr<nsIOutputStream> out;
+ rv = NS_NewLocalFileOutputStream(getter_AddRefs(out), iface_file);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ *aResult = out;
+ NS_ADDREF(*aResult);
+ return NS_OK;
+ }
+
+ nsresult CloseIfaceFileStream(nsIOutputStream* out)
+ {
+ return out->Close();
+ }
+
+ nsresult WriteHeader(nsIOutputStream* out, const char* aIfaceName)
+ {
+ static const char kHeader1[] =
+ "/**\n"
+ " * NOTE: THIS IS A GENERATED FILE. PLEASE CONSULT THE ORIGINAL IDL FILE\n"
+ " * FOR THE FULL DOCUMENTION AND LICENSE.\n"
+ " *\n"
+ " * @see <a href=\"http://lxr.mozilla.org/mozilla/search?string=";
+ static const char kHeader2[]= "\">\n **/\n\n";
+ static const char kPackage[] = "package org.mozilla.interfaces;\n\n";
+
+ PRUint32 count;
+ nsresult rv = out->Write(kHeader1, sizeof(kHeader1) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCAutoString searchTerm;
+ searchTerm.AppendLiteral("interface+");
+ searchTerm.AppendASCII(aIfaceName);
+ // LXR limits to 29 chars
+ rv = out->Write(searchTerm.get(), PR_MIN(29, searchTerm.Length()), &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = out->Write(kHeader2, sizeof(kHeader2) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(kPackage, sizeof(kPackage) - 1, &count);
+ return rv;
+ }
+
+ nsresult WriteInterfaceStart(nsIOutputStream* out, nsIInterfaceInfo* aIInfo,
+ nsIInterfaceInfo* aParentInfo)
+ {
+ static const char kIfaceDecl1[] = "public interface ";
+ static const char kParentDecl[] = " extends ";
+ static const char kIfaceDecl2[] = "\n{\n";
+
+ const char* iface_name;
+ aIInfo->GetNameShared(&iface_name);
+ PRUint32 count;
+ nsresult rv = out->Write(kIfaceDecl1, sizeof(kIfaceDecl1) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(iface_name, strlen(iface_name), &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ if (aParentInfo) {
+ const char* parent_name;
+ aParentInfo->GetNameShared(&parent_name);
+ rv = out->Write(kParentDecl, sizeof(kParentDecl) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(parent_name, strlen(parent_name), &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ rv = out->Write(kIfaceDecl2, sizeof(kIfaceDecl2) - 1, &count);
+ return rv;
+ }
+
+ nsresult WriteInterfaceEnd(nsIOutputStream* out)
+ {
+ PRUint32 count;
+ return out->Write("}\n", 2, &count);
+ }
+
+ nsresult WriteIID(nsIOutputStream* out, nsIInterfaceInfo* aIInfo)
+ {
+ static const char kIIDDecl1[] = " public static final String ";
+ static const char kIIDDecl2[] = " =\n \"";
+ static const char kIIDDecl3[] = "\";\n\n";
+
+ nsIID* iid = nsnull;
+ aIInfo->GetInterfaceIID(&iid);
+ if (!iid)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ // create iid field name
+ nsCAutoString iid_name;
+ const char* iface_name;
+ aIInfo->GetNameShared(&iface_name);
+ if (strncmp("ns", iface_name, 2) == 0) {
+ iid_name.AppendLiteral("NS_");
+ iid_name.Append(iface_name + 2);
+ } else {
+ iid_name.Append(iface_name);
+ }
+ iid_name.AppendLiteral("_IID");
+ ToUpperCase(iid_name);
+
+ // get iid string
+ char* iid_str = iid->ToString();
+ if (!iid_str)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ PRUint32 count;
+ nsresult rv = out->Write(kIIDDecl1, sizeof(kIIDDecl1) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(iid_name.get(), iid_name.Length(), &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(kIIDDecl2, sizeof(kIIDDecl2) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(iid_str, strlen(iid_str), &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(kIIDDecl3, sizeof(kIIDDecl3) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // cleanup
+ PR_Free(iid_str);
+ nsMemory::Free(iid);
+ return NS_OK;
+ }
+
+ nsresult WriteConstants(nsIOutputStream* out, nsIInterfaceInfo* aIInfo,
+ PRUint16 aParentConstCount)
+ {
+ static const char kConstDecl1[] = " public static final ";
+ static const char kConstDecl2[] = " = ";
+ static const char kConstDecl3[] = ";\n\n";
+
+ PRUint16 constCount;
+ nsresult rv = aIInfo->GetConstantCount(&constCount);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ for (PRUint16 i = aParentConstCount; i < constCount; i++) {
+ const nsXPTConstant* constInfo;
+ rv = aIInfo->GetConstant(i, &constInfo);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ PRUint32 count;
+ rv = out->Write(kConstDecl1, sizeof(kConstDecl1) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ const nsXPTType &type = constInfo->GetType();
+ rv = WriteType(out, &type, aIInfo, nsnull, nsnull);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(" ", 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ const char* name = constInfo->GetName();
+ rv = out->Write(name, strlen(name), &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(kConstDecl2, sizeof(kConstDecl2) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = WriteConstantValue(out, &type, constInfo->GetValue());
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(kConstDecl3, sizeof(kConstDecl3) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ return NS_OK;
+ }
+
+ nsresult WriteConstantValue(nsIOutputStream* out, const nsXPTType* aType,
+ const nsXPTCMiniVariant* aValue)
+ {
+ char buf[32];
+ switch (aType->TagPart()) {
+ case nsXPTType::T_I8:
+ snprintf(buf, sizeof(buf), "%d", aValue->val.i8);
+ break;
+
+ case nsXPTType::T_U8:
+ snprintf(buf, sizeof(buf), "%u", aValue->val.u8);
+ break;
+
+ case nsXPTType::T_I16:
+ snprintf(buf, sizeof(buf), "%d", aValue->val.i16);
+ break;
+
+ case nsXPTType::T_U16:
+ snprintf(buf, sizeof(buf), "%u", aValue->val.u16);
+ break;
+
+ case nsXPTType::T_I32:
+ snprintf(buf, sizeof(buf), "%d", aValue->val.i32);
+ break;
+
+ case nsXPTType::T_U32:
+ snprintf(buf, sizeof(buf), "%uL", aValue->val.u32);
+ break;
+
+ case nsXPTType::T_I64:
+ snprintf(buf, sizeof(buf), "%lldL", aValue->val.i64);
+ break;
+
+ case nsXPTType::T_U64:
+ snprintf(buf, sizeof(buf), "%lluL", aValue->val.u64);
+ break;
+
+ case nsXPTType::T_FLOAT:
+ snprintf(buf, sizeof(buf), "%f", aValue->val.f);
+ break;
+
+ case nsXPTType::T_DOUBLE:
+ snprintf(buf, sizeof(buf), "%f", aValue->val.d);
+ break;
+
+ case nsXPTType::T_BOOL:
+ if (aValue->val.b)
+ sprintf(buf, "true");
+ else
+ sprintf(buf, "false");
+ break;
+
+ case nsXPTType::T_CHAR:
+ snprintf(buf, sizeof(buf), "%c", aValue->val.c);
+ break;
+
+ case nsXPTType::T_WCHAR:
+ snprintf(buf, sizeof(buf), "%c", aValue->val.wc);
+ break;
+
+ default:
+ NS_WARNING("unexpected constant type");
+ return NS_ERROR_UNEXPECTED;
+ }
+
+ PRUint32 count;
+ return out->Write(buf, strlen(buf), &count);
+ }
+
+ nsresult WriteMethods(nsIOutputStream* out, nsIInterfaceInfo* aIInfo,
+ PRUint16 aParentMethodCount)
+ {
+ PRUint16 methodCount;
+ nsresult rv = aIInfo->GetMethodCount(&methodCount);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+#ifdef DEBUG_bird /* attributes first, then method. For making diffing easier. */
+ for (int pass = 0; pass < 2; pass++)
+#endif
+ for (PRUint16 i = aParentMethodCount; i < methodCount; i++) {
+ const nsXPTMethodInfo* methodInfo;
+ rv = aIInfo->GetMethodInfo(i, &methodInfo);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+#ifdef WRITE_NOSCRIPT_METHODS
+ // XXX
+ // SWT makes use of [noscript] methods in some classes, so output them
+ // for those classes.
+
+ // skip [notxpcom] methods
+ if (methodInfo->IsNotXPCOM())
+ continue;
+
+ // skip most hidden ([noscript]) methods
+ if (methodInfo->IsHidden()) {
+ const char* iface_name;
+ aIInfo->GetNameShared(&iface_name);
+ if (!mNoscriptMethodsTable.Contains(nsDependentCString(iface_name)))
+ continue;
+ }
+#else
+ // skip hidden ([noscript]) or [notxpcom] methods
+ if (methodInfo->IsHidden() || methodInfo->IsNotXPCOM())
+ continue;
+#endif
+#ifdef DEBUG_bird /* attributes first, then method. For making diffing easier. */
+ if ((methodInfo->IsSetter() || methodInfo->IsGetter()) == pass)
+ continue;
+#endif
+
+ rv = WriteOneMethod(out, aIInfo, methodInfo, i);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ return NS_OK;
+ }
+
+ nsresult WriteOneMethod(nsIOutputStream* out, nsIInterfaceInfo* aIInfo,
+ const nsXPTMethodInfo* aMethodInfo,
+ PRUint16 aMethodIndex)
+ {
+ static const char kMethodDecl1[] = " public ";
+ static const char kVoidReturn[] = "void";
+ static const char kParamSeparator[] = ", ";
+ static const char kMethodDecl2[] = ");\n\n";
+
+ PRUint32 count;
+ nsresult rv = out->Write(kMethodDecl1, sizeof(kMethodDecl1) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // write return type
+ PRUint8 paramCount = aMethodInfo->GetParamCount();
+ const nsXPTParamInfo* resultInfo = nsnull;
+ for (PRUint8 i = 0; i < paramCount; i++) {
+ const nsXPTParamInfo &paramInfo = aMethodInfo->GetParam(i);
+ if (paramInfo.IsRetval()) {
+ resultInfo = &paramInfo;
+ break;
+ }
+ }
+ if (resultInfo) {
+ rv = WriteParam(out, aIInfo, aMethodIndex, resultInfo, 0);
+ } else {
+ rv = out->Write(kVoidReturn, sizeof(kVoidReturn) - 1, &count);
+ }
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // write method name string
+ nsCAutoString method_name;
+ const char* name = aMethodInfo->GetName();
+ if (aMethodInfo->IsGetter() || aMethodInfo->IsSetter()) {
+ if (aMethodInfo->IsGetter())
+ method_name.AppendLiteral("get");
+ else
+ method_name.AppendLiteral("set");
+ method_name.Append(toupper(name[0]));
+ method_name.AppendASCII(name + 1);
+ } else {
+ method_name.Append(tolower(name[0]));
+ method_name.AppendASCII(name + 1);
+ // don't use Java keywords as method names
+ if (mJavaKeywords.Contains(method_name))
+ method_name.Append('_');
+ }
+ rv = out->Write(" ", 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write(method_name.get(), method_name.Length(), &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = out->Write("(", 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // write parameters
+ for (PRUint8 j = 0; j < paramCount; j++) {
+ const nsXPTParamInfo &paramInfo = aMethodInfo->GetParam(j);
+ if (paramInfo.IsRetval())
+ continue;
+
+ if (j != 0) {
+ rv = out->Write(kParamSeparator, sizeof(kParamSeparator) - 1, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ rv = WriteParam(out, aIInfo, aMethodIndex, &paramInfo, j + 1);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ rv = out->Write(kMethodDecl2, sizeof(kMethodDecl2) - 1, &count);
+ return rv;
+ }
+
+ nsresult WriteParam(nsIOutputStream* out, nsIInterfaceInfo* aIInfo,
+ PRUint16 aMethodIndex, const nsXPTParamInfo* aParamInfo,
+ PRUint8 aIndex)
+ {
+ const nsXPTType &type = aParamInfo->GetType();
+ nsresult rv = WriteType(out, &type, aIInfo, aMethodIndex, aParamInfo);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // if parameter is 'out' or 'inout', make it a Java array
+ PRUint32 count;
+ if (aParamInfo->IsOut() && !aParamInfo->IsRetval()) {
+ rv = out->Write("[]", 2, &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ // write name for parameter (but not for 'retval' param)
+ if (aIndex) {
+ char buf[10];
+ snprintf(buf, sizeof(buf), " arg%d", aIndex);
+ rv = out->Write(buf, strlen(buf), &count);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ return NS_OK;
+ }
+
+ /**
+ * Write out the Java type for the given XPIDL type.
+ *
+ * NOTE: Java doesn't support unsigned types. So for any unsigned XPIDL type,
+ * we move up to the next largest Java type. This way we ensure that we don't
+ * lose any info.
+ */
+ nsresult WriteType(nsIOutputStream* out, const nsXPTType* aType,
+ nsIInterfaceInfo* aIInfo, PRUint16 aMethodIndex,
+ const nsXPTParamInfo* aParamInfo)
+ {
+ nsresult rv;
+ PRUint32 count;
+ switch (aType->TagPart()) {
+ case nsXPTType::T_I8:
+ rv = out->Write("byte", 4, &count);
+ break;
+
+ case nsXPTType::T_I16:
+ case nsXPTType::T_U8:
+ rv = out->Write("short", 5, &count);
+ break;
+
+ case nsXPTType::T_I32:
+ case nsXPTType::T_U16:
+ rv = out->Write("int", 3, &count);
+ break;
+
+ case nsXPTType::T_I64:
+ case nsXPTType::T_U32:
+ rv = out->Write("long", 4, &count);
+ break;
+
+ case nsXPTType::T_FLOAT:
+ rv = out->Write("float", 5, &count);
+ break;
+
+ // XXX how should we handle 64-bit values?
+ case nsXPTType::T_U64:
+ case nsXPTType::T_DOUBLE:
+ rv = out->Write("double", 6, &count);
+ break;
+
+ case nsXPTType::T_BOOL:
+ rv = out->Write("boolean", 7, &count);
+ break;
+
+ case nsXPTType::T_CHAR:
+ case nsXPTType::T_WCHAR:
+ rv = out->Write("char", 4, &count);
+ break;
+
+ case nsXPTType::T_CHAR_STR:
+ case nsXPTType::T_WCHAR_STR:
+ case nsXPTType::T_IID:
+ case nsXPTType::T_ASTRING:
+ case nsXPTType::T_DOMSTRING:
+ case nsXPTType::T_UTF8STRING:
+ case nsXPTType::T_CSTRING:
+ case nsXPTType::T_PSTRING_SIZE_IS:
+ case nsXPTType::T_PWSTRING_SIZE_IS:
+ rv = out->Write("String", 6, &count);
+ break;
+
+ case nsXPTType::T_INTERFACE:
+ {
+ char* iface_name = nsnull;
+ rv = TypeInfo::GetInterfaceName(aIInfo, aMethodIndex, aParamInfo,
+ &iface_name);
+ if (NS_FAILED(rv) || !iface_name) {
+ rv = NS_ERROR_FAILURE;
+ break;
+ }
+
+ rv = out->Write(iface_name, strlen(iface_name), &count);
+ nsMemory::Free(iface_name);
+ break;
+ }
+
+ case nsXPTType::T_INTERFACE_IS:
+ rv = out->Write("nsISupports", 11, &count);
+ break;
+
+ case nsXPTType::T_VOID:
+ rv = out->Write("int", 3, &count);
+ break;
+
+ case nsXPTType::T_ARRAY:
+ {
+ // get array type
+ nsXPTType xpttype;
+ rv = aIInfo->GetTypeForParam(aMethodIndex, aParamInfo, 1, &xpttype);
+ if (NS_FAILED(rv))
+ break;
+
+ rv = WriteType(out, &xpttype, aIInfo, aMethodIndex, aParamInfo);
+ if (NS_FAILED(rv))
+ break;
+
+ rv = out->Write("[]", 2, &count);
+ break;
+ }
+
+ default:
+ fprintf(stderr, "WARNING: unexpected parameter type %d\n",
+ aType->TagPart());
+ return NS_ERROR_UNEXPECTED;
+ }
+
+ return rv;
+ }
+};
+
+void PrintUsage(char** argv)
+{
+ static const char usage_str[] =
+ "Usage: %s -d path\n"
+ " -d output directory for Java interface files\n";
+ fprintf(stderr, usage_str, argv[0]);
+}
+#ifdef VBOX
+#include <VBox/com/com.h>
+using namespace com;
+
+#include <iprt/initterm.h>
+#include <iprt/string.h>
+#include <iprt/alloca.h>
+#include <iprt/stream.h>
+#endif
+
+int main(int argc, char** argv)
+{
+ nsresult rv = NS_OK;
+ nsCOMPtr<nsILocalFile> output_dir;
+
+#ifdef VBOX
+#if defined(VBOX_PATH_APP_PRIVATE_ARCH) && defined(VBOX_PATH_SHARED_LIBS)
+ rv = RTR3InitExe(argc, &argv, 0);
+#else
+ const char *pszHome = getenv("VBOX_PROGRAM_PATH");
+ if (pszHome) {
+ size_t cchHome = strlen(pszHome);
+ char *pszExePath = (char *)alloca(cchHome + 32);
+ memcpy(pszExePath, pszHome, cchHome);
+ memcpy(pszExePath + cchHome, "/pythonfake", sizeof("/pythonfake"));
+ rc = RTR3InitEx(RTR3INIT_VER_CUR, 0, argc, &argv, pszExePath);
+ } else {
+ rv = RTR3InitExe(argc, &argv, 0);
+ }
+#endif
+#endif
+
+ // handle command line arguments
+ for (int i = 1; i < argc; i++) {
+ if (argv[i][0] != '-') {
+ rv = NS_ERROR_FAILURE;
+ break;
+ }
+
+ switch (argv[i][1]) {
+ case 'd': {
+ if (i + 1 == argc) {
+ fprintf(stderr, "ERROR: missing output directory after -d\n");
+ rv = NS_ERROR_FAILURE;
+ break;
+ }
+
+ // see if given path exists
+ rv = NS_NewNativeLocalFile(nsDependentCString(argv[++i]), PR_TRUE,
+ getter_AddRefs(output_dir));
+ PRBool val;
+ if (NS_FAILED(rv) || NS_FAILED(output_dir->Exists(&val)) || !val ||
+ NS_FAILED(output_dir->IsDirectory(&val)) || !val)
+ {
+ fprintf(stderr,
+ "ERROR: output directory doesn't exist / isn't a directory\n");
+ rv = NS_ERROR_FAILURE;
+ break;
+ }
+
+ break;
+ }
+
+ default: {
+ fprintf(stderr, "ERROR: unknown option %s\n", argv[i]);
+ rv = NS_ERROR_FAILURE;
+ break;
+ }
+ }
+ }
+
+ if (NS_FAILED(rv)) {
+ PrintUsage(argv);
+ return 1;
+ }
+
+#ifdef VBOX
+ rv = com::Initialize();
+#else
+ rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
+#endif
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ Generate gen(output_dir);
+ rv = gen.GenerateInterfaces();
+
+#ifdef VBOX
+ // very short-living XPCOM processes trigger problem on shutdown - ignoring it not a big deal anyway
+ //com::Shutdown();
+#else
+ NS_ShutdownXPCOM(nsnull);
+#endif
+ return rv;
+}
diff --git a/src/libs/xpcom18a4/java/tools/genjifaces.xsl b/src/libs/xpcom18a4/java/tools/genjifaces.xsl
new file mode 100644
index 00000000..7e754222
--- /dev/null
+++ b/src/libs/xpcom18a4/java/tools/genjifaces.xsl
@@ -0,0 +1,600 @@
+<xsl:stylesheet version = '1.0'
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+ xmlns:vbox="http://www.virtualbox.org/"
+ xmlns:exsl="http://exslt.org/common"
+ extension-element-prefixes="exsl">
+
+<!--
+ genjifaces.xsl:
+ XSLT stylesheet that generates Java XPCOM bridge interface code from VirtualBox.xidl.
+-->
+<!--
+ Copyright (C) 2010-2023 Oracle and/or its affiliates.
+
+ This file is part of VirtualBox base platform packages, as
+ available from https://www.virtualbox.org.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation, in version 3 of the
+ License.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <https://www.gnu.org/licenses>.
+
+ SPDX-License-Identifier: GPL-3.0-only
+-->
+
+<xsl:output
+ method="text"
+ version="1.0"
+ encoding="utf-8"
+ indent="no"/>
+
+<!-- - - - - - - - - - - - - - - - - - - - - - -
+ global XSLT variables
+ - - - - - - - - - - - - - - - - - - - - - - -->
+
+<xsl:variable name="G_xsltFilename" select="'genjifaces.xsl'" />
+
+
+<!-- - - - - - - - - - - - - - - - - - - - - - -
+ Keys for more efficiently looking up of types.
+- - - - - - - - - - - - - - - - - - - - - - -->
+<xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
+<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
+
+<!--
+ xsltprocNewlineOutputHack - emits a single new line.
+
+ Hack Alert! This template helps xsltproc split up the output text elements
+ and avoid reallocating them into the MB range. Calls to this
+ template is made occationally while generating larger output
+ file. It's not necessary for small stuff like header.
+
+ The trick we're playing on xsltproc has to do with CDATA
+ and/or the escape setting of the xsl:text element. It forces
+ xsltproc to allocate a new output element, thus preventing
+ things from growing out of proportions and slowing us down.
+
+ This was successfully employed to reduce a 18+ seconds run to
+ around one second (possibly less due to kmk overhead).
+ -->
+<xsl:template name="xsltprocNewlineOutputHack">
+ <xsl:text disable-output-escaping="yes"><![CDATA[
+]]></xsl:text>
+</xsl:template>
+
+<xsl:template name="uppercase">
+ <xsl:param name="str" select="."/>
+ <xsl:value-of select="translate($str, 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
+</xsl:template>
+
+<xsl:template name="capitalize">
+ <xsl:param name="str" select="."/>
+ <xsl:value-of select="
+ concat(translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
+ substring($str,2))"/>
+</xsl:template>
+
+<xsl:template name="makeGetterName">
+ <xsl:param name="attrname" />
+ <xsl:variable name="capsname">
+ <xsl:call-template name="capitalize">
+ <xsl:with-param name="str" select="$attrname" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="concat('get', $capsname)" />
+</xsl:template>
+
+<xsl:template name="makeSetterName">
+ <xsl:param name="attrname" />
+ <xsl:variable name="capsname">
+ <xsl:call-template name="capitalize">
+ <xsl:with-param name="str" select="$attrname" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="concat('set', $capsname)" />
+</xsl:template>
+
+<xsl:template name="fileheader">
+ <xsl:param name="name" />
+ <xsl:text>/** @file
+</xsl:text>
+ <xsl:value-of select="concat(' * ',$name)"/>
+<xsl:text>
+ *
+ * DO NOT EDIT! This is a generated file.
+ * Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's interface definitions in XML)
+ * Generator: src/VBox/src/libs/xpcom18a4/java/tools/genjifaces.xsl
+ */
+
+/*
+ * Copyright (C) 2010-2022 Oracle and/or its affiliates.
+ *
+ * This file is part of VirtualBox base platform packages, as
+ * available from https://www.virtualbox.org.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, in version 3 of the
+ * License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see &lt;https://www.gnu.org/licenses&gt;.
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+</xsl:text>
+</xsl:template>
+
+<xsl:template name="startFile">
+ <xsl:param name="file" />
+
+ <xsl:value-of select="concat('&#10;// ##### BEGINFILE &quot;', $file, '&quot;&#10;&#10;')" />
+ <xsl:call-template name="fileheader">
+ <xsl:with-param name="name" select="$file" />
+ </xsl:call-template>
+
+ <xsl:value-of select=" 'package org.mozilla.interfaces;&#10;&#10;'" />
+</xsl:template>
+
+<xsl:template name="endFile">
+ <xsl:param name="file" />
+ <xsl:value-of select="concat('&#10;// ##### ENDFILE &quot;', $file, '&quot;&#10;')" />
+ <xsl:call-template name="xsltprocNewlineOutputHack"/>
+</xsl:template>
+
+
+<xsl:template name="emitHandwritten">
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsISupports.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsISupports
+{
+ public static final String NS_ISUPPORTS_IID =
+ "{00000000-0000-0000-c000-000000000046}";
+
+ public nsISupports queryInterface(String arg1);
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsISupports.java'" />
+ </xsl:call-template>
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsIComponentManager.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsIComponentManager extends nsISupports
+{
+ public static final String NS_ICOMPONENTMANAGER_IID =
+ "{a88e5a60-205a-4bb1-94e1-2628daf51eae}";
+
+ public nsISupports getClassObject(String arg1, String arg2);
+
+ public nsISupports getClassObjectByContractID(String arg1, String arg2);
+
+ public nsISupports createInstance(String arg1, nsISupports arg2, String arg3);
+
+ public nsISupports createInstanceByContractID(String arg1, nsISupports arg2, String arg3);
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsIComponentManager.java'" />
+ </xsl:call-template>
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsIServiceManager.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsIServiceManager extends nsISupports
+{
+ public static final String NS_ISERVICEMANAGER_IID =
+ "{8bb35ed9-e332-462d-9155-4a002ab5c958}";
+
+ public nsISupports getService(String arg1, String arg2);
+
+ public nsISupports getServiceByContractID(String arg1, String arg2);
+
+ public boolean isServiceInstantiated(String arg1, String arg2);
+
+ public boolean isServiceInstantiatedByContractID(String arg1, String arg2);
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsIServiceManager.java'" />
+ </xsl:call-template>
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsIExceptionManager.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsIExceptionManager extends nsISupports
+{
+ public static final String NS_IEXCEPTIONMANAGER_IID =
+ "{efc9d00b-231c-4feb-852c-ac017266a415}";
+
+ public nsIException getCurrentException();
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsISupports.java'" />
+ </xsl:call-template>
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsIExceptionService.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsIExceptionService extends nsIExceptionManager
+{
+ public static final String NS_IEXCEPTIONSERVICE_IID =
+ "{35a88f54-f267-4414-92a7-191f6454ab52}";
+
+ public nsIExceptionManager getCurrentExceptionManager();
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsISupports.java'" />
+ </xsl:call-template>
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsIException.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsIException extends nsISupports
+{
+ public static final String NS_IEXCEPTION_IID =
+ "{f3a8d3b4-c424-4edc-8bf6-8974c983ba78}";
+
+ // No methods - placeholder
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsISupports.java'" />
+ </xsl:call-template>
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsIComponentRegistrar.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsIComponentRegistrar extends nsISupports
+{
+ public static final String NS_ICOMPONENTREGISTRAR_IID =
+ "{2417cbfe-65ad-48a6-b4b6-eb84db174392}";
+
+ // No methods - placeholder
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsIComponentRegistrar.java'" />
+ </xsl:call-template>
+
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsIFile.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsIFile extends nsISupports
+{
+ public static final String NS_IFILE_IID =
+ "{c8c0a080-0868-11d3-915f-d9d889d48e3c}";
+
+ // No methods - placeholder
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsIFile.java'" />
+ </xsl:call-template>
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="'nsILocalFile.java'" />
+ </xsl:call-template>
+
+ <xsl:text><![CDATA[
+public interface nsILocalFile extends nsIFile
+{
+ public static final String NS_ILOCALFILE_IID =
+ "{aa610f20-a889-11d3-8c81-000064657374}";
+
+ // No methods - placeholder
+}
+]]></xsl:text>
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="'nsILocalFile.java'" />
+ </xsl:call-template>
+
+</xsl:template>
+
+<xsl:template name="genEnum">
+ <xsl:param name="enumname" />
+ <xsl:param name="filename" />
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="$filename" />
+ </xsl:call-template>
+
+ <xsl:value-of select="concat('public interface ', $enumname, ' {&#10;&#10;')" />
+
+ <xsl:variable name="uppername">
+ <xsl:call-template name="uppercase">
+ <xsl:with-param name="str" select="$enumname" />
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="concat(' public static final String ', $uppername, '_IID = &#10;',
+ ' &quot;{',@uuid, '}&quot;;&#10;&#10;')" />
+
+ <xsl:for-each select="const">
+ <xsl:variable name="enumconst" select="@name" />
+ <xsl:value-of select="concat(' public static final long ', @name, ' = ', @value, 'L;&#10;&#10;')" />
+ </xsl:for-each>
+
+ <xsl:value-of select="'}&#10;&#10;'" />
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="$filename" />
+ </xsl:call-template>
+
+</xsl:template>
+
+<xsl:template name="typeIdl2Back">
+ <xsl:param name="type" />
+ <xsl:param name="safearray" />
+ <xsl:param name="forceelem" />
+
+ <xsl:variable name="needarray" select="($safearray='yes') and not($forceelem='yes')" />
+
+ <xsl:choose>
+ <xsl:when test="$type='unsigned long long'">
+ <!-- stupid, rewrite the bridge -->
+ <xsl:value-of select="'double'" />
+ </xsl:when>
+
+ <xsl:when test="$type='long long'">
+ <xsl:value-of select="'long'" />
+ </xsl:when>
+
+ <xsl:when test="$type='unsigned long'">
+ <xsl:value-of select="'long'" />
+ </xsl:when>
+
+ <xsl:when test="$type='long'">
+ <xsl:value-of select="'int'" />
+ </xsl:when>
+
+ <xsl:when test="$type='unsigned short'">
+ <xsl:value-of select="'int'" />
+ </xsl:when>
+
+ <xsl:when test="$type='short'">
+ <xsl:value-of select="'short'" />
+ </xsl:when>
+
+ <xsl:when test="$type='octet'">
+ <xsl:value-of select="'byte'" />
+ </xsl:when>
+
+ <xsl:when test="$type='boolean'">
+ <xsl:value-of select="'boolean'" />
+ </xsl:when>
+
+ <xsl:when test="$type='$unknown'">
+ <xsl:value-of select="'nsISupports'"/>
+ </xsl:when>
+
+ <xsl:when test="$type='wstring'">
+ <xsl:value-of select="'String'" />
+ </xsl:when>
+
+ <xsl:when test="$type='uuid'">
+ <xsl:value-of select="'String'" />
+ </xsl:when>
+
+ <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
+ <xsl:value-of select="$type" />
+ </xsl:when>
+
+ <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
+ <xsl:value-of select="'long'" />
+ </xsl:when>
+
+ </xsl:choose>
+
+ <xsl:if test="$needarray">
+ <xsl:value-of select="'[]'" />
+ </xsl:if>
+
+</xsl:template>
+
+<xsl:template name="genIface">
+ <xsl:param name="ifname" />
+ <xsl:param name="filename" />
+
+ <xsl:call-template name="startFile">
+ <xsl:with-param name="file" select="$filename" />
+ </xsl:call-template>
+
+ <xsl:variable name="extendsidl" select="key('G_keyInterfacesByName', $ifname)/@extends" />
+
+ <xsl:variable name="extends">
+ <xsl:choose>
+ <xsl:when test="($extendsidl = '$unknown') or ($extendsidl = '$dispatched') or ($extendsidl = '$errorinfo')">
+ <xsl:value-of select="'nsISupports'" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$extendsidl" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:value-of select="concat('public interface ', $ifname, ' extends ', $extends, ' {&#10;&#10;')" />
+
+ <xsl:variable name="uppername">
+ <xsl:call-template name="uppercase">
+ <xsl:with-param name="str" select="$ifname" />
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="concat(' public static final String ', $uppername, '_IID =&#10;',
+ ' &quot;{',@uuid, '}&quot;;&#10;&#10;')" />
+
+ <xsl:for-each select="attribute">
+ <xsl:variable name="attrname" select="@name" />
+ <xsl:variable name="attrtype" select="@type" />
+
+ <xsl:variable name="gettername">
+ <xsl:call-template name="makeGetterName">
+ <xsl:with-param name="attrname" select="$attrname" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="backtype">
+ <xsl:call-template name="typeIdl2Back">
+ <xsl:with-param name="type" select="$attrtype" />
+ <xsl:with-param name="safearray" select="@safearray" />
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="callparam">
+ <xsl:if test="@safearray='yes'">
+ <xsl:value-of select="concat(' long[] ', @name, 'Size')" />
+ </xsl:if>
+ </xsl:variable>
+
+ <xsl:value-of select="concat(' public ', $backtype, ' ', $gettername, '(',$callparam,');&#10;&#10;')" />
+
+ <xsl:if test="not(@readonly='yes')">
+ <xsl:variable name="settername">
+ <xsl:call-template name="makeSetterName">
+ <xsl:with-param name="attrname" select="$attrname" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="concat(' public void ', $settername, '(', $backtype, ' arg1);&#10;&#10;')" />
+ </xsl:if>
+
+ </xsl:for-each>
+
+ <xsl:for-each select="method">
+ <xsl:variable name="methodname" select="@name" />
+ <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
+ <xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
+
+ <xsl:variable name="returntype">
+ <xsl:choose>
+ <xsl:when test="$returnidltype">
+ <xsl:call-template name="typeIdl2Back">
+ <xsl:with-param name="type" select="$returnidltype" />
+ <xsl:with-param name="safearray" select="$returnidlsafearray" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>void</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:value-of select="concat(' public ', $returntype, ' ', $methodname, '(')" />
+ <xsl:for-each select="param">
+ <xsl:variable name="paramtype">
+ <xsl:call-template name="typeIdl2Back">
+ <xsl:with-param name="type" select="@type" />
+ <xsl:with-param name="safearray" select="@safearray" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="(@safearray='yes') and (@dir='return')">
+ <xsl:value-of select="concat('long[] ', @name)" />
+ </xsl:when>
+ <xsl:when test="(@safearray='yes') and (@dir='out')">
+ <xsl:value-of select="concat('long[] ', @name, 'Size, ', $paramtype, '[] ', @name)" />
+ </xsl:when>
+ <xsl:when test="(@safearray='yes') and (@dir='in') and (@type='octet')">
+ <xsl:value-of select="concat($paramtype, ' ', @name)" />
+ </xsl:when>
+ <xsl:when test="(@safearray='yes') and (@dir='in')">
+ <xsl:value-of select="concat('long ', @name, 'Size, ', $paramtype, ' ', @name)" />
+ </xsl:when>
+ <xsl:when test="@dir='out'">
+ <xsl:value-of select="concat($paramtype, '[] ', @name)" />
+ </xsl:when>
+ <xsl:when test="@dir='in'">
+ <xsl:value-of select="concat($paramtype, ' ', @name)" />
+ </xsl:when>
+ </xsl:choose>
+ <xsl:if test="not(position()=last()) and not(following-sibling::param[1]/@dir='return' and not(following-sibling::param[1]/@safearray='yes'))">
+ <xsl:value-of select="', '" />
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:value-of select=" ');&#10;&#10;'" />
+
+ </xsl:for-each>
+
+ <xsl:value-of select="'}&#10;&#10;'" />
+
+ <xsl:call-template name="endFile">
+ <xsl:with-param name="file" select="$filename" />
+ </xsl:call-template>
+
+</xsl:template>
+
+
+<xsl:template match="/">
+
+ <!-- Handwritten files -->
+ <xsl:call-template name="emitHandwritten"/>
+
+ <!-- Enums -->
+ <xsl:for-each select="//enum">
+ <xsl:call-template name="genEnum">
+ <xsl:with-param name="enumname" select="@name" />
+ <xsl:with-param name="filename" select="concat(@name, '.java')" />
+ </xsl:call-template>
+ </xsl:for-each>
+
+ <!-- Interfaces -->
+ <xsl:for-each select="//interface">
+ <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
+ <xsl:variable name="module" select="current()/ancestor::module/@name"/>
+
+ <!-- We don't need WSDL-specific nor MIDL-specific interfaces here -->
+ <xsl:if test="not($self_target='wsdl') and not($self_target='midl') and not($module)">
+ <xsl:call-template name="genIface">
+ <xsl:with-param name="ifname" select="@name" />
+ <xsl:with-param name="filename" select="concat(@name, '.java')" />
+ </xsl:call-template>
+ </xsl:if>
+
+ </xsl:for-each>
+
+</xsl:template>
+
+</xsl:stylesheet>