xpidl_java.c revision 18c69e356f013090fd1890c717eb2e723393edc0
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 Sun Microsystems,
* Inc. Portions created by Sun are
* Copyright (C) 1999 Sun Microsystems, Inc. All
* Rights Reserved.
*
* Contributor(s):
* Michael Allen (michael.allen@sun.com)
* Frank Mitchell (frank.mitchell@sun.com)
*/
/*
* Generate Java interfaces from XPIDL.
*/
#include "xpidl.h"
#include <ctype.h>
#include <glib.h>
struct java_priv_data {
};
static gboolean
{
const char *iidName;
/* backcompat naming styles */
} else {
}
while (*iidName) {
}
return TRUE;
}
static gboolean
{
const char *basename;
const char *ext;
#endif
return FALSE;
/* XXX report error */
return FALSE;
}
/*
* First pass
*/
if (!ext)
"/**\n"
" * NOTE: THIS IS A GENERATED FILE. PLEASE CONSULT THE ORIGINAL IDL FILE\n"
" * FOR THE FULL DOCUMENTATION AND LICENSE.\n"
" *\n"
" * @see <a href=\"http://lxr.mozilla.org/mozilla/search?string=interface+%.*s\">\n"
" **/\n"
"\n"
"package org.mozilla.interfaces;\n\n"
"import java.math.BigInteger;\n\n"
"\n"
#else
fputs("/*\n * ************* DO NOT EDIT THIS FILE ***********\n",
" *\n * This file was automatically generated from %s.idl.\n",
#endif
return TRUE;
}
static gboolean
{
/* points to other elements of the tree, so just destroy the table */
/*
* Last pass
*/
#endif
return TRUE;
}
static gboolean
{
/*
* Java doesn't need forward declarations unless the declared
* class resides in a different package.
*/
#if 0
const char *pkgName = "org.mozilla.xpcom";
if (!className)
return FALSE;
/* XXX: Get package name and compare */
#endif
return TRUE;
}
static gboolean
{
return FALSE;
/*
* Write out JavaDoc comment
*/
#endif
#ifndef LIBIDL_MAJOR_VERSION
#else
#endif
} else {
}
#endif
/*
* Write "public interface <foo>"
*/
/*
* Check for inheritence, and iterator over the inherited names,
* if any.
*/
do {
}
}
if (iid) {
/*
* Write interface constants for IID
*/
#else
#endif
/* XXX s.b just "IID" ? */
return FALSE;
}
while (*iid) {
}
#else
/* XXX s.b just "IID" ? */
return FALSE;
}
#endif
}
/*
* Advance the state of the tree, go on to process more
*/
return FALSE;
}
return TRUE;
}
static gboolean
{
/* To make the diffing simple, group the constants, methods and attributes. */
if (!xpidl_process_node(state))
return FALSE;
}
}
if (!xpidl_process_node(state))
return FALSE;
}
}
if (!xpidl_process_node(state))
return FALSE;
}
}
if (!xpidl_process_node(state))
return FALSE;
}
}
#else
if (!xpidl_process_node(state))
return FALSE;
}
#endif
return TRUE;
}
static gboolean
{
/*
* Skip non-scriptable interfaces.
*/
return TRUE;
/*
* GROSS HACK: If the interface isn't the same as the file name,
* temporarily switch output file.
*/
if (state->real_outname) {
if ( ext
sprintf(tmp,"%.*s/%s.java", (int)(basename - state->real_outname - 1), state->real_outname, interface_name);
else
perror("error opening output file");
return FALSE;
}
}
}
}
return rc;
}
#endif /* VBOX_XPIDL_EMULATE_GENJIFACES */
static gboolean
{
return TRUE;
}
case IDLN_TYPE_INTEGER: {
case IDL_INTEGER_TYPE_SHORT:
else
#else
#endif
break;
case IDL_INTEGER_TYPE_LONG:
else
#else
#endif
break;
else
#else
#endif
break;
default:
g_error(" Unknown integer type: %d\n",
return FALSE;
}
break;
}
case IDLN_TYPE_CHAR:
case IDLN_TYPE_WIDE_CHAR:
break;
case IDLN_TYPE_WIDE_STRING:
case IDLN_TYPE_STRING:
break;
case IDLN_TYPE_BOOLEAN:
break;
case IDLN_TYPE_OCTET:
#else
#endif
break;
case IDLN_TYPE_FLOAT:
case IDL_FLOAT_TYPE_FLOAT:
break;
case IDL_FLOAT_TYPE_DOUBLE:
break;
default:
g_error(" Unknown floating point typ: %d\n",
break;
}
break;
case IDLN_IDENT:
#else
#endif
}
/* XXX: s.b test for "iid" attribute */
/* XXX: special class for nsIDs */
#else
#endif
}
else {
/* XXX: special class for opaque types */
#else
#endif
}
} else {
/* XXX: big kludge; s.b. way to match to typedefs */
}
}
}
}
}
#else
}
}
}
}
#endif
}
}
/* XXX: Use find_underlying_type instead? */
}
}
/* In Javaconnect, we handle weak references internally; no need for the
|nsIWeakReference| interface. So just return |nsISupports|. */
}
#endif
else {
if (real_type) {
}
else {
}
}
}
break;
case IDLN_TYPE_ENUM:
case IDLN_TYPE_OBJECT:
default:
g_error(" Unknown type: %d\n",
break;
}
return TRUE;
}
static gboolean
#else
#endif
{
/*
* Put in type of parameter
*/
if (!xpcom_to_java_type(state)) {
return FALSE;
}
/*
* If the parameter is out or inout, make it a Java array of the
* appropriate type
*/
/* XXX: Causes nsILineInputStream::readLine(String[] arg1) where genjifaces drops the []. */
#endif
}
/*XXX: nsIConsoleService::getMessageArray ends up with [][] arg1... */
}
#endif
/*
* Put in name of parameter
*/
#else
#endif
return TRUE;
}
{
static const char * const 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 */
};
unsigned i;
for (i = 0; i < sizeof(kJavaKeywords) / sizeof(kJavaKeywords[0]); i++) {
return TRUE;
}
}
return FALSE;
}
#endif
static gboolean
{
/*
* Unlike C, Java has no type declaration directive.
* Instead, we record the mapping, and look up the actual type
* when needed.
*/
/* XXX: check for illegal types */
type);
return TRUE;
}
static gboolean
{
/* IDL_tree method_tree = state->tree; */
unsigned nparam = 0;
#endif
return FALSE;
/*
* Skip most (todo) non-scriptable and not-xpcom methods.
*/
if (method_noscript || method_notxpcom) {
return TRUE;
}
#endif
#endif
/*
* Write beginning of method declaration
*/
#else
#endif
if (!method_noscript) {
/* Nonscriptable methods become package-protected */
}
/*
* Write return type
* Unlike C++ headers, Java interfaces return the declared
* return value; an exception indicates XPCOM method failure.
*/
if (!xpcom_to_java_type(state)) {
return FALSE;
}
} else {
/* Check for retval attribute */
"retval")) {
/*
* Put in type of parameter
*/
if (!xpcom_to_java_type(state)) {
return FALSE;
}
}
#endif
}
}
if (retval_param == NULL) {
}
}
/*
* Write method name
*/
} else {
}
#else
#endif
/*
* Write parameters
*/
/* Skip "retval" */
if (iterator == retval_param) {
continue;
}
}
#else
if (!xpcom_to_java_param(state)) {
#endif
return FALSE;
}
}
if (method->raises_expr) {
while (iter) {
}
}
return TRUE;
}
static gboolean
{
return FALSE;
/* Could be a typedef; try to map it to the real type. */
#endif
# else
# endif
else
fprintf(state->file, "long %s = %" IDL_LL "uL;\n", name, IDL_INTEGER(declaration->const_exp).value);
} else {
fprintf(state->file, "short %s = %" IDL_LL "d;\n", name, IDL_INTEGER(declaration->const_exp).value);
else
}
#else /* !VBOX_XPIDL_EMULATE_GENJIFACES */
? "long" : "short"),
#endif /* !VBOX_XPIDL_EMULATE_GENJIFACES */
return TRUE;
}
static gboolean
{
/*
* Skip most non-scriptable attributes.
*/
if (method_noscript) {
return TRUE;
}
#endif
#if 0
/*
* Disabled here because I can't verify this check against possible
* users of the java xpidl backend.
*/
return FALSE;
#endif
/* Comment */
#endif
/*
* Write access permission ("public" unless nonscriptable)
*/
#else
#endif
if (!method_noscript) {
}
/*
* Write the proper Java return value for the get operation
*/
if (!xpcom_to_java_type(state)) {
return FALSE;
}
/*
* Write the name of the accessor ("get") method.
*/
if (!read_only) {
/* Nonscriptable methods become package-protected */
#else
#endif
if (!method_noscript) {
}
/*
* Write attribute access method name and return type
*/
toupper(attribute_name[0]),
attribute_name+1);
/*
* Write the proper Java type for the set operation
*/
if (!xpcom_to_java_type(state)) {
return FALSE;
}
/*
* Write the name of the formal parameter.
*/
#else
#endif
}
return TRUE;
}
static gboolean
{
"enums not supported, enum \'%s\' ignored",
return TRUE;
}
backend *
xpidl_java_dispatch(void)
{
if (!initialized) {
#else
#endif
initialized = TRUE;
}
return &result;
}