mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Checked in new BlackConnect version
This commit is contained in:
parent
634bad7e60
commit
d29b87b0cf
36
java/xpcom/Makefile
Normal file
36
java/xpcom/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../..
|
||||
topsrcdir = ../..
|
||||
VPATH = .
|
||||
srcdir = .
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= \
|
||||
connect \
|
||||
xpcom \
|
||||
java \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
36
java/xpcom/Makefile.in
Normal file
36
java/xpcom/Makefile.in
Normal file
@ -0,0 +1,36 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= \
|
||||
connect \
|
||||
xpcom \
|
||||
java \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
55
java/xpcom/README
Normal file
55
java/xpcom/README
Normal file
@ -0,0 +1,55 @@
|
||||
Black Connect
|
||||
================================
|
||||
|
||||
This directory contains the Black Connect
|
||||
|
||||
The sources is divided into three directories
|
||||
|
||||
connect
|
||||
public headers.
|
||||
ORB implementation.
|
||||
|
||||
xpcom
|
||||
XPCOM stubs and proxy implementation
|
||||
|
||||
java
|
||||
JAVA stubs and proxy implementation
|
||||
Java component loader
|
||||
|
||||
===============================================
|
||||
Solaris directions
|
||||
===============================================
|
||||
|
||||
Requirements:
|
||||
|
||||
* current mozilla built tree
|
||||
|
||||
* JDK1.3
|
||||
|
||||
* Perl 5 perl.exe must be in your path
|
||||
|
||||
How To Build:
|
||||
|
||||
* make sure the environment var JDKHOME is set to your jdk installation
|
||||
directory, ie export JDKHOME=/usr/local/jdk1.3
|
||||
|
||||
* Add following directories to to your LD_LIBRARY_PATH:
|
||||
|
||||
|
||||
$MOZILLA_FIVE_HOME:$JDKHOME/jre/lib/$HOSTTYPE/native_threads:$JDKHOME/jre/lib/$HOSTTYPE/classic:
|
||||
$JDKHOME/jre/lib/$HOSTTYPE/:
|
||||
|
||||
* Set CONNECT_SRC environment variable to connect directoty,
|
||||
ie /ws/mozilla/mozilla/java/xpcom/connect
|
||||
|
||||
* type "gmake"
|
||||
|
||||
===============================================
|
||||
How to run test java component
|
||||
===============================================
|
||||
* cd java/test
|
||||
* gmake
|
||||
|
||||
Test component would be placed in dist/bin/componets and loaded on mozilla
|
||||
sturtup
|
||||
|
34
java/xpcom/connect/Makefile.in
Normal file
34
java/xpcom/connect/Makefile.in
Normal file
@ -0,0 +1,34 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= \
|
||||
xpcom \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
79
java/xpcom/connect/public/bcDefs.h
Normal file
79
java/xpcom/connect/public/bcDefs.h
Normal file
@ -0,0 +1,79 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcDefs_h
|
||||
#define __bcDefs_h
|
||||
#include "prtypes.h"
|
||||
#include "nsID.h"
|
||||
|
||||
enum bcXPType {
|
||||
bc_T_I8 = 1, bc_T_U8, bc_T_I16, bc_T_U16,
|
||||
bc_T_I32, bc_T_U32, bc_T_I64, bc_T_U64,
|
||||
bc_T_FLOAT, bc_T_DOUBLE, bc_T_BOOL,
|
||||
bc_T_CHAR, bc_T_WCHAR,
|
||||
bc_T_IID ,
|
||||
bc_T_CHAR_STR, bc_T_WCHAR_STR,
|
||||
bc_T_ARRAY,
|
||||
bc_T_INTERFACE
|
||||
};
|
||||
|
||||
typedef long bcOID;
|
||||
typedef nsID bcIID;
|
||||
typedef long bcTID ;
|
||||
|
||||
typedef unsigned int bcMID;
|
||||
typedef unsigned int size_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
35
java/xpcom/connect/public/bcIAllocator.h
Normal file
35
java/xpcom/connect/public/bcIAllocator.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcIAllocator_h
|
||||
#define __bcIAllocator_h
|
||||
#include "bcDefs.h"
|
||||
|
||||
class bcIAllocator {
|
||||
public:
|
||||
virtual void * Alloc(size_t size) = 0;
|
||||
virtual void Free(void *ptr) = 0;
|
||||
virtual void * Realloc(void* ptr, size_t size) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
48
java/xpcom/connect/public/bcICall.h
Normal file
48
java/xpcom/connect/public/bcICall.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcICall_h
|
||||
#define __bcICall_h
|
||||
#include "bcIMarshaler.h"
|
||||
#include "bcIUnMarshaler.h"
|
||||
|
||||
class bcIORB;
|
||||
|
||||
class bcICall {
|
||||
public:
|
||||
virtual int GetParams(bcIID *, bcOID *, bcMID *) = 0;
|
||||
virtual bcIMarshaler * GetMarshaler() = 0;
|
||||
virtual bcIUnMarshaler * GetUnMarshaler() = 0;
|
||||
virtual bcIORB * GetORB() = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
36
java/xpcom/connect/public/bcIMarshaler.h
Normal file
36
java/xpcom/connect/public/bcIMarshaler.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcIMarshaler_h
|
||||
#define __bcIMarshaler_h
|
||||
#include "bcIAllocator.h"
|
||||
#include "bcDefs.h"
|
||||
|
||||
class bcIMarshaler {
|
||||
public:
|
||||
virtual int WriteSimple(void *ptr, bcXPType type) = 0;
|
||||
virtual int WriteString(void *ptr, size_t size) = 0;
|
||||
virtual int WriteArray(void *ptr, size_t length, bcXPType type) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
38
java/xpcom/connect/public/bcIORB.h
Normal file
38
java/xpcom/connect/public/bcIORB.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcIORB_h
|
||||
#define __bcIORB_h
|
||||
#include "bcICall.h"
|
||||
#include "bcDefs.h"
|
||||
#include "bcIStub.h"
|
||||
|
||||
|
||||
class bcIORB {
|
||||
public:
|
||||
virtual bcOID RegisterStub(bcIStub *stub) = 0;
|
||||
virtual bcICall * CreateCall(bcIID *, bcOID *, bcMID) = 0;
|
||||
virtual int SendReceive(bcICall *) = 0;
|
||||
//virtual IThread * GetThread(TID) = 0;
|
||||
};
|
||||
|
||||
#endif
|
31
java/xpcom/connect/public/bcIStub.h
Normal file
31
java/xpcom/connect/public/bcIStub.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcIStub_h
|
||||
#define __bcIStub_h
|
||||
#include "bcICall.h"
|
||||
|
||||
class bcIStub {
|
||||
public:
|
||||
virtual void Dispatch(bcICall *call) = 0;
|
||||
//nb shortcut
|
||||
};
|
||||
#endif
|
29
java/xpcom/connect/public/bcIThread.h
Normal file
29
java/xpcom/connect/public/bcIThread.h
Normal file
@ -0,0 +1,29 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcIThread_h
|
||||
#define __bcIThread_h
|
||||
|
||||
class bcIThread {
|
||||
public:
|
||||
virtual AttachCall(bcICall *, short isAsync) = 0;
|
||||
};
|
||||
#endif
|
36
java/xpcom/connect/public/bcIUnMarshaler.h
Normal file
36
java/xpcom/connect/public/bcIUnMarshaler.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcIUnMarshaler_h
|
||||
#define __bcIUnMarshaler_h
|
||||
#include "bcIAllocator.h"
|
||||
#include "bcDefs.h"
|
||||
|
||||
class bcIUnMarshaler {
|
||||
public:
|
||||
virtual int ReadSimple(void *ptr, bcXPType type) = 0;
|
||||
virtual int ReadString(void *ptr, size_t *size, bcIAllocator * allocator = 0) = 0;
|
||||
virtual int ReadArray(void *ptr, size_t *length, bcXPType type, bcIAllocator * allocator) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
46
java/xpcom/connect/src/Allocator.cpp
Normal file
46
java/xpcom/connect/src/Allocator.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "Allocator.h"
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
Allocator::Allocator() {
|
||||
}
|
||||
|
||||
Allocator::~Allocator() {
|
||||
}
|
||||
|
||||
void * Allocator::Alloc(size_t size) {
|
||||
cout<<"Allocator::Alloc("<<size<<")\n";
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void Allocator::Free(void *ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void * Allocator::Realloc(void *ptr, size_t size) {
|
||||
return realloc(ptr,size);
|
||||
}
|
||||
|
||||
|
35
java/xpcom/connect/src/Allocator.h
Normal file
35
java/xpcom/connect/src/Allocator.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __Allocator_h
|
||||
#define __Allocator_h
|
||||
#include "bcIAllocator.h"
|
||||
|
||||
class Allocator : public bcIAllocator {
|
||||
public:
|
||||
Allocator();
|
||||
virtual ~Allocator();
|
||||
virtual void * Alloc(size_t size);
|
||||
virtual void Free(void *ptr);
|
||||
virtual void * Realloc(void* ptr, size_t size);
|
||||
};
|
||||
#endif
|
78
java/xpcom/connect/src/Call.cpp
Normal file
78
java/xpcom/connect/src/Call.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "Call.h"
|
||||
#include "Marshaler.h"
|
||||
#include "UnMarshaler.h"
|
||||
|
||||
Call::Call() {
|
||||
}
|
||||
|
||||
Call::Call(bcIID *_iid, bcOID *_oid, bcMID _mid, bcIORB *_orb):out(0),in(0) {
|
||||
iid = *_iid;
|
||||
oid = *_oid;
|
||||
mid = _mid;
|
||||
orb = _orb;
|
||||
}
|
||||
|
||||
Call::~Call() {
|
||||
if (out)
|
||||
delete out;
|
||||
if (in)
|
||||
delete in;
|
||||
}
|
||||
|
||||
int Call::GetParams(bcIID *_iid, bcOID *_oid, bcMID *_mid) {
|
||||
*_iid = iid;
|
||||
*_oid = oid;
|
||||
*_mid = mid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bcIMarshaler * Call::GetMarshaler() {
|
||||
out = new ostrstream();
|
||||
return new Marshaler(out);
|
||||
}
|
||||
|
||||
bcIUnMarshaler * Call::GetUnMarshaler() {
|
||||
if (!out) {
|
||||
return NULL;
|
||||
}
|
||||
char *buf = out->str();
|
||||
cout<<"Call::GetUnMarshaler "<<out->pcount()<<"\n";
|
||||
#if 0
|
||||
cout<<"Call::GetUnMarshaler buf:\n";
|
||||
for (int i = 0; i < out->pcount(); i++) {
|
||||
cout<<" buf["<<i<<"]"<<(unsigned)buf[i]<<"\n";
|
||||
}
|
||||
#endif
|
||||
if (out->pcount()) {
|
||||
in = new istrstream(buf,out->pcount());
|
||||
}
|
||||
return new UnMarshaler(in);
|
||||
}
|
||||
|
||||
bcIORB * Call::GetORB() {
|
||||
return orb;
|
||||
}
|
||||
|
||||
|
46
java/xpcom/connect/src/Call.h
Normal file
46
java/xpcom/connect/src/Call.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __Call_h
|
||||
#define __Call_h
|
||||
#include <strstream.h>
|
||||
#include "bcICall.h"
|
||||
|
||||
class Call : public bcICall {
|
||||
public:
|
||||
Call();
|
||||
Call(bcIID *, bcOID *, bcMID, bcIORB *orb);
|
||||
virtual ~Call();
|
||||
virtual int GetParams(bcIID *, bcOID *, bcMID*);
|
||||
virtual bcIORB * GetORB();
|
||||
virtual bcIMarshaler * GetMarshaler();
|
||||
virtual bcIUnMarshaler * GetUnMarshaler();
|
||||
private :
|
||||
ostrstream *out;
|
||||
istrstream *in;
|
||||
bcIID iid;
|
||||
bcOID oid;
|
||||
bcMID mid;
|
||||
bcIORB *orb;
|
||||
};
|
||||
|
||||
#endif
|
79
java/xpcom/connect/src/Marshaler.cpp
Normal file
79
java/xpcom/connect/src/Marshaler.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include <iostream.h>
|
||||
#include <strings.h>
|
||||
#include "Marshaler.h"
|
||||
#include "util.h"
|
||||
|
||||
Marshaler::Marshaler(ostream *_out) {
|
||||
out = _out;
|
||||
}
|
||||
|
||||
Marshaler::~Marshaler() {
|
||||
}
|
||||
|
||||
int Marshaler::WriteSimple(void *ptr, bcXPType type) {
|
||||
out->write((const char*)ptr, type2size(type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Marshaler::WriteString(void *ptr, size_t size) {
|
||||
if (!size
|
||||
&& ptr) {
|
||||
size = 1;
|
||||
}
|
||||
WriteArray(ptr,size, bc_T_CHAR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Marshaler::WriteArray(void *ptr, size_t length, bcXPType type) {
|
||||
if (!ptr) {
|
||||
length = 0;
|
||||
}
|
||||
cout<<"Marshaler::WriteArray("<<length<<")\n";
|
||||
out->write((const char*)&length, sizeof(size_t));
|
||||
switch (type) {
|
||||
case bc_T_CHAR_STR:
|
||||
case bc_T_WCHAR_STR:
|
||||
{
|
||||
for (int i = 0; i < length; i++) {
|
||||
char *str = ((char**)ptr)[i];
|
||||
size_t size = (!str) ? 0 : strlen(str)+1; //we want to store \0
|
||||
WriteString((void *)str, size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (length) {
|
||||
out->write((const char*)ptr,type2size(type)*length);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
42
java/xpcom/connect/src/Marshaler.h
Normal file
42
java/xpcom/connect/src/Marshaler.h
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __Marshaler_h
|
||||
#define __Marshaler_h
|
||||
#include <iostream.h>
|
||||
#include "bcIMarshaler.h"
|
||||
|
||||
|
||||
class Marshaler : public bcIMarshaler {
|
||||
public:
|
||||
Marshaler(ostream *out);
|
||||
virtual ~Marshaler();
|
||||
virtual int WriteSimple(void *ptr, bcXPType type);
|
||||
virtual int WriteString(void *ptr, size_t size);
|
||||
virtual int WriteArray(void *ptr, size_t length, bcXPType type);
|
||||
private:
|
||||
ostream * out;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
65
java/xpcom/connect/src/ORB.cpp
Normal file
65
java/xpcom/connect/src/ORB.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "ORB.h"
|
||||
#include "Call.h"
|
||||
|
||||
ORB::ORB() {
|
||||
currentID = 0;
|
||||
for (int i = 0; i < STUBS_COUNT; i++) {
|
||||
stubs[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ORB::~ORB() {
|
||||
}
|
||||
|
||||
bcOID ORB::RegisterStub(bcIStub *stub) {
|
||||
stubs[currentID] = stub;
|
||||
return currentID++;
|
||||
}
|
||||
|
||||
bcICall * ORB::CreateCall(bcIID *iid, bcOID *oid, bcMID mid) {
|
||||
return new Call(iid, oid, mid,this);
|
||||
}
|
||||
|
||||
int ORB::SendReceive(bcICall *call) {
|
||||
bcIID iid;
|
||||
bcOID oid;
|
||||
bcMID mid;
|
||||
call->GetParams(&iid,&oid,&mid);
|
||||
bcIStub *stub = GetStub(&oid);
|
||||
if (stub) {
|
||||
stub->Dispatch(call);
|
||||
return 0;
|
||||
} else {
|
||||
return 1; //nb need to think about error values
|
||||
}
|
||||
}
|
||||
|
||||
bcIStub * ORB::GetStub(bcOID *oid) {
|
||||
return stubs[*oid];
|
||||
}
|
||||
|
||||
|
||||
|
40
java/xpcom/connect/src/ORB.h
Normal file
40
java/xpcom/connect/src/ORB.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __ORB_h
|
||||
#define __ORB_h
|
||||
#include "bcIORB.h"
|
||||
|
||||
#define STUBS_COUNT (100)
|
||||
class ORB : public bcIORB {
|
||||
public:
|
||||
ORB();
|
||||
virtual ~ORB();
|
||||
virtual bcOID RegisterStub(bcIStub *stub);
|
||||
virtual bcICall * CreateCall(bcIID *, bcOID *, bcMID);
|
||||
virtual int SendReceive(bcICall *);
|
||||
private:
|
||||
bcIStub * GetStub(bcOID *);
|
||||
bcIStub * stubs[STUBS_COUNT]; //nb :) it's jast for now. (Mon Mar 13 16:53:03 PST 2000)
|
||||
int currentID;
|
||||
};
|
||||
#endif
|
129
java/xpcom/connect/src/UnMarshaler.cpp
Normal file
129
java/xpcom/connect/src/UnMarshaler.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "UnMarshaler.h"
|
||||
#include "util.h"
|
||||
|
||||
UnMarshaler::UnMarshaler(istream *_in) {
|
||||
in = _in;
|
||||
}
|
||||
|
||||
UnMarshaler::~UnMarshaler() {
|
||||
}
|
||||
|
||||
int UnMarshaler::ReadSimple(void *ptr, bcXPType type) {
|
||||
char *p = (char *)ptr;
|
||||
int size = type2size(type);
|
||||
in->read(p,size );
|
||||
return 0;
|
||||
}
|
||||
int UnMarshaler::ReadString(void *ptr, size_t *size, bcIAllocator * allocator) {
|
||||
ReadArray(ptr, size, bc_T_CHAR, allocator);
|
||||
if (*size == 1) {
|
||||
if (!(*(char**)ptr)[0]) {
|
||||
*size = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UnMarshaler::ReadArray(void *ptr, size_t *length, bcXPType type, bcIAllocator * allocator) {
|
||||
in->read((char*)length,sizeof(size_t));
|
||||
cout<<"UnMarshaler *length "<<*length<<"\n";
|
||||
|
||||
if (!length) {
|
||||
ptr = 0;
|
||||
}
|
||||
switch (type) {
|
||||
case bc_T_CHAR_STR:
|
||||
case bc_T_WCHAR_STR:
|
||||
{
|
||||
char **strArray = *(char***)ptr;
|
||||
*strArray = (char*)allocator->Alloc(*length * sizeof(char*));
|
||||
|
||||
for (int i = 0; i < *length; i++) {
|
||||
char * str;
|
||||
size_t size;
|
||||
ReadString((void*)&str, &size, allocator);
|
||||
strArray[i] = str;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
char *p = *(char**)ptr = (char *)allocator->Alloc(*length * type2size(type));
|
||||
if (*length) {
|
||||
in->read(p,*length * type2size(type));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
39
java/xpcom/connect/src/UnMarshaler.h
Normal file
39
java/xpcom/connect/src/UnMarshaler.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __UnMarshaler_h
|
||||
#define __UnMarshaler_h
|
||||
#include <iostream.h>
|
||||
#include "bcIUnMarshaler.h"
|
||||
|
||||
class UnMarshaler : public bcIUnMarshaler {
|
||||
public:
|
||||
UnMarshaler(istream *in);
|
||||
virtual ~UnMarshaler();
|
||||
virtual int ReadSimple(void *ptr, bcXPType type);
|
||||
virtual int ReadString(void *ptr, size_t *size, bcIAllocator * allocator);
|
||||
virtual int ReadArray(void *ptr, size_t *length, bcXPType type, bcIAllocator * allocator);
|
||||
private:
|
||||
istream *in;
|
||||
};
|
||||
|
||||
#endif
|
72
java/xpcom/connect/src/util.cpp
Normal file
72
java/xpcom/connect/src/util.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
#include "bcDefs.h"
|
||||
|
||||
size_t type2size(bcXPType type) {
|
||||
size_t res = 0;
|
||||
switch (type) {
|
||||
case bc_T_CHAR :
|
||||
res = sizeof(char);
|
||||
break;
|
||||
case bc_T_WCHAR:
|
||||
res = 2; //nb
|
||||
break;
|
||||
case bc_T_I8:
|
||||
case bc_T_U8:
|
||||
res = sizeof(PRInt8);
|
||||
break;
|
||||
case bc_T_I16:
|
||||
case bc_T_U16:
|
||||
res = sizeof(PRInt16);
|
||||
break;
|
||||
case bc_T_I32:
|
||||
case bc_T_U32:
|
||||
res = sizeof(PRInt32);
|
||||
break;
|
||||
case bc_T_I64:
|
||||
case bc_T_U64:
|
||||
res = sizeof(PRInt64);
|
||||
break;
|
||||
case bc_T_FLOAT:
|
||||
res = sizeof(float);
|
||||
break;
|
||||
case bc_T_DOUBLE:
|
||||
res = sizeof(double);
|
||||
break;
|
||||
case bc_T_BOOL:
|
||||
res = sizeof(PRBool);
|
||||
break;
|
||||
case bc_T_IID:
|
||||
res = sizeof(nsID);
|
||||
break;
|
||||
case bc_T_INTERFACE:
|
||||
res = sizeof(bcOID);
|
||||
break;
|
||||
default:
|
||||
res = 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
27
java/xpcom/connect/src/util.h
Normal file
27
java/xpcom/connect/src/util.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __util_h
|
||||
#define __util_h
|
||||
#include "bcDefs.h"
|
||||
|
||||
size_t type2size(bcXPType type);
|
||||
#endif
|
77
java/xpcom/connect/xpcom/Makefile.in
Normal file
77
java/xpcom/connect/xpcom/Makefile.in
Normal file
@ -0,0 +1,77 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH=../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = bcorb
|
||||
MODULE = bcorb
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
bcORB.cpp \
|
||||
../src/Allocator.cpp \
|
||||
../src/Call.cpp \
|
||||
../src/Marshaler.cpp \
|
||||
../src/ORB.cpp \
|
||||
../src/UnMarshaler.cpp \
|
||||
../src/util.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
bcORB.h \
|
||||
../public/bcIORB.h \
|
||||
../public/bcDefs.h \
|
||||
../public/bcICall.h \
|
||||
../public/bcIUnMarshaler.h \
|
||||
../public/bcIAllocator.h \
|
||||
../public/bcIMarshaler.h \
|
||||
../public/bcIStub.h \
|
||||
../public/bcIThread.h
|
||||
|
||||
|
||||
CXXFLAGS += -I../public -I../src
|
||||
|
||||
DSO_LDOPTS += \
|
||||
-L$(JDKHOME)/jre/lib/$(HOSTTYPE)/ \
|
||||
-L$(JDKHOME)/jre/lib/$(HOSTTYPE)/classic \
|
||||
-ljava -ljvm \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(OS_ARCH), Linux)
|
||||
DSO_LDOPTS += \
|
||||
-lthread -lXm -lX11 -lXt -lm
|
||||
endif
|
||||
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
75
java/xpcom/connect/xpcom/bcORB.cpp
Normal file
75
java/xpcom/connect/xpcom/bcORB.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "bcORB.h"
|
||||
#include "../src/ORB.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(bcORB);
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
"Black Connect ORB",
|
||||
BC_ORB_CID,
|
||||
BC_ORB_PROGID,
|
||||
bcORBConstructor
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("BlackConnectORB",components);
|
||||
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcORB,NS_GET_IID(bcORB));
|
||||
|
||||
bcORB::bcORB() :
|
||||
orb(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
bcORB::~bcORB() {
|
||||
if (orb) {
|
||||
delete orb; //nb should we destroy it?
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcORB::GetORB(bcIORB **_orb) {
|
||||
if (!_orb) {
|
||||
printf("--bcORB::GetORB\n");
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (!orb) {
|
||||
orb = new ORB();
|
||||
}
|
||||
*_orb = orb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
53
java/xpcom/connect/xpcom/bcORB.h
Normal file
53
java/xpcom/connect/xpcom/bcORB.h
Normal file
@ -0,0 +1,53 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef _bcORB_h
|
||||
#define _bcORB_h
|
||||
#include "nsISupports.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
|
||||
/*29bde10c-1dd2-11b2-ab23-ebe06c6baec5*/
|
||||
#define BC_ORB_IID \
|
||||
{ 0x29bde10c, 0x1dd2, 0x11b2, \
|
||||
{0xab, 0x23, 0xeb, 0xe0, 0x6c, 0x6b, 0xae, 0xc5}}
|
||||
|
||||
|
||||
#define BC_ORB_PROGID "component://netscape/blackwood/blackconnect/orb"
|
||||
|
||||
/*ffa0d768-1dd1-11b2-8bf2-ab56f26ea844*/
|
||||
#define BC_ORB_CID \
|
||||
{ 0xffa0d768, 0x1dd1, 0x11b2, \
|
||||
{0x8b, 0xf2, 0xab, 0x56, 0xf2, 0x6e, 0xa8, 0x44 }}
|
||||
|
||||
|
||||
class bcORB : public nsISupports {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(BC_ORB_IID)
|
||||
NS_IMETHOD GetORB(bcIORB **orb);
|
||||
bcORB();
|
||||
virtual ~bcORB();
|
||||
private:
|
||||
bcIORB *orb;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
37
java/xpcom/java/Makefile.in
Normal file
37
java/xpcom/java/Makefile.in
Normal file
@ -0,0 +1,37 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS= \
|
||||
loader \
|
||||
src \
|
||||
classes \
|
||||
test \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
43
java/xpcom/java/classes/Makefile.in
Normal file
43
java/xpcom/java/classes/Makefile.in
Normal file
@ -0,0 +1,43 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
JAVA_OR_NSJVM=1
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
|
||||
JAR_PLUGLET_CLASSES = \
|
||||
org/mozilla/xpcom \
|
||||
$(NULL)
|
||||
|
||||
JDIRS = $(JAR_PLUGLET_CLASSES)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
JAVAC=$(JDKHOME)/bin/javac -classpath .:$(CLASSPATH) -d $(DIST)/classes
|
||||
|
@ -0,0 +1,62 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.URL;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.jar.Attributes;
|
||||
import java.io.InputStream;
|
||||
import java.io.File;
|
||||
|
||||
public class ComponentLoader {
|
||||
// path to jar file. Name of main class sould to be in MANIFEST.
|
||||
public static Object loadComponent(String location) {
|
||||
try {
|
||||
File file = (new File(location)).getCanonicalFile(); //To avoid spelling diffs, e.g c: and C:
|
||||
location = file.getAbsolutePath();
|
||||
if (File.separatorChar != '/') {
|
||||
location = location.replace(File.separatorChar,'/');
|
||||
}
|
||||
if (!location.startsWith("/")) {
|
||||
location = "/" + location;
|
||||
}
|
||||
URL url = new URL("file:"+location);
|
||||
URLClassLoader loader = URLClassLoader.newInstance(new URL[]{url});
|
||||
URL manifestURL = new URL("jar:file:"+location+"!/META-INF/MANIFEST.MF");
|
||||
InputStream inputStream = manifestURL.openStream();
|
||||
Manifest manifest = new Manifest(inputStream);
|
||||
Attributes attr = manifest.getMainAttributes();
|
||||
String componentClassName = attr.getValue("Component-Class");
|
||||
if (componentClassName == null) {
|
||||
//nb
|
||||
return null;
|
||||
}
|
||||
Object object = loader.loadClass(componentClassName).newInstance();
|
||||
return object;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
55
java/xpcom/java/classes/org/mozilla/xpcom/IID.java
Normal file
55
java/xpcom/java/classes/org/mozilla/xpcom/IID.java
Normal file
@ -0,0 +1,55 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
public class IID {
|
||||
public IID(String iid) {
|
||||
this.iid = (iid == null) ? "" : iid;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
if (! (obj instanceof IID)) {
|
||||
return false;
|
||||
}
|
||||
boolean res = iid.equals(((IID)obj).iid);
|
||||
return res;
|
||||
}
|
||||
public String toString() {
|
||||
return "org.mozilla.xpcom.IID@"+iid;
|
||||
}
|
||||
public int hashCode() {
|
||||
int h = iid.hashCode();
|
||||
return h;
|
||||
}
|
||||
public String getString() {
|
||||
return iid;
|
||||
}
|
||||
private String iid;
|
||||
public static Class TYPE;
|
||||
static {
|
||||
try {
|
||||
TYPE = Class.forName("org.mozilla.xpcom.Proxy");
|
||||
} catch (Exception e) { //it could not happen
|
||||
TYPE = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
77
java/xpcom/java/classes/org/mozilla/xpcom/ProxyClass.java
Normal file
77
java/xpcom/java/classes/org/mozilla/xpcom/ProxyClass.java
Normal file
@ -0,0 +1,77 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ProxyClass { //nb it should not be public
|
||||
public ProxyClass(IID _iid, Method[] _methods) { //nb it should not be public
|
||||
iid = _iid;
|
||||
methods = _methods;
|
||||
if (classes == null) {
|
||||
classes = new Hashtable();
|
||||
}
|
||||
classes.put(iid, this);
|
||||
}
|
||||
Method getMethodByIndex(int mid) { //first method has index equal to 'offset'
|
||||
System.out.println("--[java]ProxyClass.GetMehodByIndex "+mid);
|
||||
Method result = null;
|
||||
try {
|
||||
result = methods[mid-offset];
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int getIndexByMethod(Method method) {
|
||||
int result = 0;
|
||||
if (method == null
|
||||
||methods == null) {
|
||||
return result;
|
||||
}
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
if (methods[i].equals(method)) {
|
||||
result = i + offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static ProxyClass getProxyClass(IID iid) {
|
||||
ProxyClass result = null;
|
||||
Object obj = null;
|
||||
if (classes != null) {
|
||||
obj = classes.get(iid);
|
||||
if (obj != null
|
||||
&& (obj instanceof ProxyClass)) {
|
||||
result = (ProxyClass)obj;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private IID iid;
|
||||
private Method[] methods;
|
||||
private final int offset = 3; //from xpcom
|
||||
static Hashtable classes = null;
|
||||
}
|
97
java/xpcom/java/classes/org/mozilla/xpcom/ProxyFactory.java
Normal file
97
java/xpcom/java/classes/org/mozilla/xpcom/ProxyFactory.java
Normal file
@ -0,0 +1,97 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.ref.*;
|
||||
|
||||
class ProxyKey {
|
||||
ProxyKey(long _oid, IID _iid) {
|
||||
oid = new Long(_oid);
|
||||
iid = _iid;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
if (! (obj instanceof ProxyKey)) {
|
||||
return false;
|
||||
}
|
||||
return (oid.equals(((ProxyKey)obj).oid) && iid.equals(((ProxyKey)obj).iid));
|
||||
}
|
||||
public int hashCode() {
|
||||
return oid.hashCode();
|
||||
}
|
||||
public String toString() {
|
||||
return "org.mozilla.xpcom.ProxyFactory.ProxyKey "+oid+" "+iid;
|
||||
}
|
||||
Long oid;
|
||||
IID iid;
|
||||
}
|
||||
|
||||
public class ProxyFactory {
|
||||
public static void registerInterfaceForIID(Class inter, IID iid) {
|
||||
System.out.println("--[java] ProxyFactory.registerInterfaceForIID "+iid);
|
||||
if (interfaces == null) {
|
||||
interfaces = new Hashtable();
|
||||
}
|
||||
interfaces.put(iid, inter); //nb who is gonna remove object from cache?
|
||||
}
|
||||
public static Object getProxy(long oid, IID iid, long orb) {
|
||||
System.out.println("--[java] ProxyFactory.getProxy "+iid);
|
||||
ProxyKey key = new ProxyKey(oid, iid);
|
||||
Object obj = null;
|
||||
Object result = null;
|
||||
if (proxies != null) {
|
||||
obj = proxies.get(key);
|
||||
if (obj != null
|
||||
&& (obj instanceof Reference)) {
|
||||
result = ((Reference)obj).get();
|
||||
}
|
||||
} else {
|
||||
proxies = new Hashtable();
|
||||
}
|
||||
if (result == null) {
|
||||
if (interfaces != null) {
|
||||
obj = interfaces.get(iid);
|
||||
if (obj == null) {
|
||||
System.out.println("--[java] ProxyFactory.getProxy obj == null");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!(obj instanceof Class)) {
|
||||
System.out.println("--[java] ProxyFactory.getProxy !(obj instanceof Class"+obj);
|
||||
return null;
|
||||
}
|
||||
Class inter = (Class) obj;
|
||||
InvocationHandler handler = new ProxyHandler(oid, iid, orb);
|
||||
result = Proxy.newProxyInstance(inter.getClassLoader(), new Class[] {inter},handler);
|
||||
proxies.put(new WeakReference(result), key);
|
||||
}
|
||||
System.out.println("--[java] ProxyFactory.getProxy end"+result);
|
||||
return result;
|
||||
}
|
||||
protected static Hashtable proxies = null;
|
||||
private static Hashtable interfaces = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
41
java/xpcom/java/classes/org/mozilla/xpcom/ProxyHandler.java
Normal file
41
java/xpcom/java/classes/org/mozilla/xpcom/ProxyHandler.java
Normal file
@ -0,0 +1,41 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
class ProxyHandler implements InvocationHandler {
|
||||
ProxyHandler(long _oid, IID _iid, long _orb) {
|
||||
oid = _oid;
|
||||
iid = _iid;
|
||||
orb = _orb;
|
||||
}
|
||||
public Object invoke(Object proxy,
|
||||
Method method,
|
||||
Object[] args) throws Throwable {
|
||||
return Utilities.callMethod(oid, method, iid, orb, args);
|
||||
|
||||
}
|
||||
private long oid;
|
||||
private IID iid;
|
||||
private long orb;
|
||||
}
|
78
java/xpcom/java/classes/org/mozilla/xpcom/Utilities.java
Normal file
78
java/xpcom/java/classes/org/mozilla/xpcom/Utilities.java
Normal file
@ -0,0 +1,78 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
package org.mozilla.xpcom;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
public class Utilities {
|
||||
static Object callMethodByIndex(Object obj, IID iid, int mid, Object[] args) {
|
||||
System.out.println("--org.mozilla.xpcom.Utilities.callMethodByIndex "+args.length+" "+mid);
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
System.out.println("--callMethodByIndex args["+i+"] = "+args[i]);
|
||||
}
|
||||
Method method = getMethodByIndex(mid,iid);
|
||||
System.out.println("--callMethodByIndex method "+method);
|
||||
try {
|
||||
if (method != null) {
|
||||
method.invoke(obj,args);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null; //nb for testing
|
||||
}
|
||||
static Object callMethod(long oid, Method method, IID iid, long orb , Object[] args) {
|
||||
System.out.println("--[java]Utilities.callMethod "+method);
|
||||
int mid = getIndexByMethod(method, iid);
|
||||
if (mid <= 0) {
|
||||
return null;
|
||||
}
|
||||
System.out.println("--[java]Utilities.callMethod "+mid);
|
||||
return callMethodByIndex(oid,mid,iid.getString(), orb, args);
|
||||
}
|
||||
|
||||
private static Method getMethodByIndex(int index, IID iid) {
|
||||
Method result = null;
|
||||
ProxyClass proxyClass = ProxyClass.getProxyClass(iid);
|
||||
if (proxyClass != null) {
|
||||
result = proxyClass.getMethodByIndex(index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static int getIndexByMethod(Method method, IID iid) {
|
||||
int result = 0;
|
||||
ProxyClass proxyClass = ProxyClass.getProxyClass(iid);
|
||||
if (proxyClass != null) {
|
||||
result = proxyClass.getIndexByMethod(method);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static native Object callMethodByIndex(long oid, int index, String iid, long orb, Object[] args);
|
||||
static {
|
||||
System.loadLibrary("bcjavastubs");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
46
java/xpcom/java/loader/Makefile.in
Normal file
46
java/xpcom/java/loader/Makefile.in
Normal file
@ -0,0 +1,46 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = javaloader
|
||||
LIBRARY_NAME = javaloader
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = bcJavaComponentLoader.cpp bcJavaModule.cpp bcJavaComponentFactory.cpp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifneq ($(OS_ARCH),BeOS)
|
||||
LIBS += -lmozjs -lxpcom $(NSPR_LIBS)
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
89
java/xpcom/java/loader/bcJavaComponentFactory.cpp
Normal file
89
java/xpcom/java/loader/bcJavaComponentFactory.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCRT.h"
|
||||
#include "bcJavaComponentFactory.h"
|
||||
#include "bcJavaStubsAndProxies.h"
|
||||
#include "bcXPCOMStubsAndProxies.h"
|
||||
#include "bcORB.h"
|
||||
|
||||
static NS_DEFINE_CID(kJavaStubsAndProxies,BC_JAVASTUBSANDPROXIES_CID);
|
||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||
static NS_DEFINE_CID(kORBCIID,BC_ORB_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS1(bcJavaComponentFactory, nsIFactory)
|
||||
|
||||
|
||||
bcJavaComponentFactory::bcJavaComponentFactory(const char *_location) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
location = nsCRT::strdup(_location);
|
||||
}
|
||||
|
||||
bcJavaComponentFactory::~bcJavaComponentFactory() {
|
||||
nsCRT::free((char*)location);
|
||||
}
|
||||
|
||||
/* void CreateInstance (in nsISupports aOuter, in nsIIDRef iid, [iid_is (iid), retval] out nsQIResult result);
|
||||
*/
|
||||
NS_IMETHODIMP bcJavaComponentFactory::CreateInstance(nsISupports *aOuter, const nsIID & iid, void * *result) {
|
||||
printf("--bcJavaComponentFactory::CreateInstance\n");
|
||||
nsresult r;
|
||||
NS_WITH_SERVICE(bcJavaStubsAndProxies, javaStubsAndProxies, kJavaStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--bcJavaComponentFactory::CreateInstance javaStubsAndProxies failed \n");
|
||||
return r;
|
||||
}
|
||||
NS_WITH_SERVICE(bcXPCOMStubsAndProxies, xpcomStubsAndProxies, kXPCOMStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--bcJavaComponentFactory::CreateInstance xpcomStubsAndProxies failed \n");
|
||||
return r;
|
||||
}
|
||||
NS_WITH_SERVICE(bcORB, _orb, kORBCIID, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
printf("--bcJavaComponentFactory::CreateInstance bcORB failed \n");
|
||||
return r;
|
||||
}
|
||||
bcIORB *orb;
|
||||
_orb->GetORB(&orb);
|
||||
bcOID oid;
|
||||
r = javaStubsAndProxies->GetOID(location, &oid);
|
||||
printf("--bcJavaComponentFactory::CreateInstance after GetOID");
|
||||
nsISupports *proxy;
|
||||
xpcomStubsAndProxies->GetProxy(oid, iid, orb, &proxy);
|
||||
*result = proxy;
|
||||
printf("--bcJavaComponentFactory::CreateInstance end");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void LockFactory (in PRBool lock); */
|
||||
NS_IMETHODIMP bcJavaComponentFactory::LockFactory(PRBool lock)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
39
java/xpcom/java/loader/bcJavaComponentFactory.h
Normal file
39
java/xpcom/java/loader/bcJavaComponentFactory.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcJavaComponentFactory_h
|
||||
#define __bcJavaComponentFactory_h
|
||||
#include "nsIFactory.h"
|
||||
|
||||
class bcJavaComponentFactory : public nsIFactory {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFACTORY
|
||||
bcJavaComponentFactory(const char *location);
|
||||
virtual ~bcJavaComponentFactory();
|
||||
private:
|
||||
char *location;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
632
java/xpcom/java/loader/bcJavaComponentLoader.cpp
Normal file
632
java/xpcom/java/loader/bcJavaComponentLoader.cpp
Normal file
@ -0,0 +1,632 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
A bunch of stuff was copied from mozJSComponentLoader.cpp
|
||||
*/
|
||||
#include "bcJavaComponentLoader.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "bcJavaModule.h"
|
||||
|
||||
|
||||
/*********************************************************************************/
|
||||
|
||||
//#include "bcIJavaSample.h"
|
||||
#include "unistd.h"
|
||||
#include "signal.h"
|
||||
|
||||
|
||||
/********************************************************************************/
|
||||
|
||||
const char javaComponentTypeName[] = JAVACOMPONENTTYPENAME;
|
||||
extern const char xpcomKeyName[];
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcJavaComponentLoader,NS_GET_IID(nsIComponentLoader));
|
||||
|
||||
bcJavaComponentLoader::bcJavaComponentLoader()
|
||||
: mCompMgr(NULL),
|
||||
|
||||
mXPCOMKey(0)
|
||||
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
printf("--bcJavaComponentLoader::bcJavaComponentLoader \n");
|
||||
}
|
||||
|
||||
bcJavaComponentLoader::~bcJavaComponentLoader() { //nb
|
||||
printf("--bcJavaComponentLoader::~bcJavaComponentLoader \n");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the factory for a given component.
|
||||
*/
|
||||
/* nsIFactory getFactory (in nsIIDRef aCID, in string aLocation, in string aType); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::GetFactory(const nsIID & aCID, const char *aLocation, const char *aType, nsIFactory **_retval) {
|
||||
printf("--bcJavaComponentLoader::GetFactory \n");
|
||||
if (!_retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
#ifdef DEBUG
|
||||
char *cidString = aCID.ToString();
|
||||
fprintf(stderr, "--bcJavaComponentLoader::GetFactory(%s,%s,%s)\n", cidString, aLocation, aType);
|
||||
delete [] cidString;
|
||||
#endif
|
||||
nsIModule * module = ModuleForLocation(aLocation, 0);
|
||||
if (!module) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "ERROR: couldn't get module for %s\n", aLocation);
|
||||
#endif
|
||||
return NS_ERROR_FACTORY_NOT_LOADED;
|
||||
}
|
||||
|
||||
nsresult rv = module->GetClassObject(mCompMgr, aCID,
|
||||
NS_GET_IID(nsIFactory),
|
||||
(void **)_retval);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "GetClassObject %s\n", NS_FAILED(rv) ? "FAILED" : "ok");
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the loader.
|
||||
*
|
||||
* We use nsISupports here because nsIRegistry isn't IDLized yet.
|
||||
*/
|
||||
/* void init (in nsIComponentManager aCompMgr, in nsISupports aRegistry); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupports *aReg) {
|
||||
printf("--bcJavaComponentLoader::Init \n");
|
||||
nsresult rv;
|
||||
mCompMgr = aCompMgr;
|
||||
mRegistry = do_QueryInterface(aReg, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mRegistry->GetSubtree(nsIRegistry::Common, xpcomKeyName,
|
||||
&mXPCOMKey);
|
||||
if (NS_FAILED(rv))
|
||||
/* if we can't get the XPCOM key, just skip all registry ops */
|
||||
mRegistry = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a component of the appropriate type is registered,
|
||||
* to give the component loader an opportunity to do things like
|
||||
* annotate the registry and such.
|
||||
*/
|
||||
/* void onRegister (in nsIIDRef aCID, in string aType, in string aClassName, in string aProgID, in string aLocation, in boolean aReplace, in boolean aPersist); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::OnRegister(const nsIID & aCID, const char *aType, const char *aClassName, const char *aProgID, const char *aLocation, PRBool aReplace, PRBool aPersist) { //nb
|
||||
printf("--bcJavaComponentLoader::OnRegister \n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* AutoRegister components in the given directory.
|
||||
*/
|
||||
/* void autoRegisterComponents (in long aWhen, in nsIFile aDirectory); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::AutoRegisterComponents(PRInt32 aWhen, nsIFile *aDirectory) {
|
||||
//printf("--bcJavaComponentLoader::AutoRegisterComponents \n");
|
||||
return RegisterComponentsInDir(aWhen,aDirectory);
|
||||
}
|
||||
|
||||
nsresult bcJavaComponentLoader::RegisterComponentsInDir(PRInt32 when, nsIFile *dir)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool isDir;
|
||||
|
||||
if (NS_FAILED(rv = dir->IsDirectory(&isDir)))
|
||||
return rv;
|
||||
|
||||
if (!isDir)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// Create a directory iterator
|
||||
nsCOMPtr<nsISimpleEnumerator> dirIterator;
|
||||
rv = dir->GetDirectoryEntries(getter_AddRefs(dirIterator));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// whip through the directory to register every file
|
||||
nsIFile *dirEntry = NULL;
|
||||
PRBool more = PR_FALSE;
|
||||
|
||||
rv = dirIterator->HasMoreElements(&more);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
while (more == PR_TRUE)
|
||||
{
|
||||
rv = dirIterator->GetNext((nsISupports**)&dirEntry);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = dirEntry->IsDirectory(&isDir);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
if (isDir == PR_TRUE)
|
||||
{
|
||||
// This is a directory. Grovel for components into the directory.
|
||||
rv = RegisterComponentsInDir(when, dirEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
PRBool registered;
|
||||
// This is a file. Try to register it.
|
||||
rv = AutoRegisterComponent(when, dirEntry, ®istered);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(dirEntry);
|
||||
}
|
||||
rv = dirIterator->HasMoreElements(&more);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* AutoRegister the given component.
|
||||
*
|
||||
* Returns true if the component was registered, false if it couldn't
|
||||
* attempt to register the component (wrong type) and ``throws'' an
|
||||
* NS_FAILED code if there was an error during registration.
|
||||
*/
|
||||
/* boolean autoRegisterComponent (in long aWhen, in nsIFile aComponent); */
|
||||
|
||||
/* copied from mozJSComponentLoader.cpp */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::AutoRegisterComponent(PRInt32 when, nsIFile *component, PRBool *registered) {
|
||||
//printf("--bcJavaComponentLoader::AutoRegisterComponent \n");
|
||||
nsresult rv;
|
||||
if (!registered)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
const char javaExtension[] = ".jar.info";
|
||||
int javaExtensionLen = 9;
|
||||
nsXPIDLCString leafName;
|
||||
|
||||
*registered = PR_FALSE;
|
||||
|
||||
/* we only do files */
|
||||
PRBool isFile = PR_FALSE;
|
||||
if (NS_FAILED(rv = component->IsFile(&isFile)) || !isFile)
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = component->GetLeafName(getter_Copies(leafName))))
|
||||
return rv;
|
||||
int len = PL_strlen(leafName);
|
||||
|
||||
/* if it's not javaExtension return now */
|
||||
if (len < javaExtensionLen || // too short
|
||||
PL_strcasecmp(leafName + len - javaExtensionLen, javaExtension))
|
||||
return NS_OK;
|
||||
|
||||
printf("--bcJavaComponentLoader: registering bcJavaComponent component %s\n",(const char *)leafName);
|
||||
rv = AttemptRegistration(component, PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
printf("registered module %s\n", (const char *)leafName);
|
||||
else if (rv == NS_ERROR_FACTORY_REGISTER_AGAIN)
|
||||
printf("deferred module %s\n", (const char *)leafName);
|
||||
else
|
||||
printf("failed to register %s\n", (const char *)leafName);
|
||||
*registered = (PRBool) NS_SUCCEEDED(rv);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsresult bcJavaComponentLoader::AttemptRegistration(nsIFile *component,
|
||||
PRBool deferred) {
|
||||
nsXPIDLCString registryLocation;
|
||||
nsresult rv;
|
||||
nsIModule *module;
|
||||
|
||||
rv = mCompMgr->RegistryLocationForSpec(component,
|
||||
getter_Copies(registryLocation));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
/* no need to check registry data on deferred reg */
|
||||
if (deferred || HasChanged(registryLocation, component)) {
|
||||
module = ModuleForLocation(registryLocation, component);
|
||||
if (module) {
|
||||
rv = module->RegisterSelf(mCompMgr, component, registryLocation,
|
||||
javaComponentTypeName);
|
||||
if (rv == NS_ERROR_FACTORY_REGISTER_AGAIN) {
|
||||
mDeferredComponents.AppendElement(component);
|
||||
/*
|
||||
* we don't enter in the registry because we may want to
|
||||
* try again on a later autoreg, in case a dependency has
|
||||
* become available.
|
||||
*/
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
SetRegistryInfo(registryLocation, component);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult bcJavaComponentLoader::SetRegistryInfo(const char *registryLocation,
|
||||
nsIFile *component)
|
||||
{
|
||||
if (!mRegistry.get())
|
||||
return NS_OK; // silent failure
|
||||
|
||||
nsresult rv;
|
||||
nsRegistryKey key;
|
||||
|
||||
rv = mRegistry->AddSubtreeRaw(mXPCOMKey, registryLocation, &key);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRInt64 modDate;
|
||||
|
||||
if (NS_FAILED(rv = component->GetLastModificationDate(&modDate)) ||
|
||||
NS_FAILED(rv = mRegistry->SetLongLong(key, lastModValueName, &modDate)))
|
||||
return rv;
|
||||
|
||||
PRInt64 fileSize;
|
||||
if (NS_FAILED(rv = component->GetFileSize(&fileSize)) ||
|
||||
NS_FAILED(rv = mRegistry->SetLongLong(key, fileSizeValueName, &fileSize)))
|
||||
return rv;
|
||||
printf("SetRegistryInfo(%s) => (%d,%d)\n", registryLocation,
|
||||
modDate, fileSize);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool bcJavaComponentLoader::HasChanged(const char *registryLocation, nsIFile *component) {
|
||||
/* if we don't have a registry handle, force registration of component */
|
||||
if (!mRegistry)
|
||||
return PR_TRUE;
|
||||
|
||||
nsRegistryKey key;
|
||||
if (NS_FAILED(mRegistry->GetSubtreeRaw(mXPCOMKey, registryLocation, &key)))
|
||||
return PR_TRUE;
|
||||
|
||||
/* check modification date */
|
||||
PRInt64 regTime, lastTime;
|
||||
if (NS_FAILED(mRegistry->GetLongLong(key, lastModValueName, ®Time)))
|
||||
return PR_TRUE;
|
||||
|
||||
if (NS_FAILED(component->GetLastModificationDate(&lastTime)) || LL_NE(lastTime, regTime))
|
||||
return PR_TRUE;
|
||||
|
||||
/* check file size */
|
||||
PRInt64 regSize;
|
||||
if (NS_FAILED(mRegistry->GetLongLong(key, fileSizeValueName, ®Size)))
|
||||
return PR_TRUE;
|
||||
PRInt64 size;
|
||||
if (NS_FAILED(component->GetFileSize(&size)) || LL_NE(size,regSize) )
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsIModule * bcJavaComponentLoader::ModuleForLocation(const char *registryLocation, nsIFile *component) {
|
||||
nsStringKey key(registryLocation);
|
||||
nsIModule *res = NULL;
|
||||
res = (nsIModule*)mModules.Get(&key);
|
||||
PRBool needRelease = PR_FALSE;
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
if (!component) {
|
||||
if (NS_FAILED(mCompMgr->SpecForRegistryLocation(registryLocation, &component)))
|
||||
return NULL;
|
||||
needRelease = PR_TRUE;
|
||||
}
|
||||
res = new bcJavaModule(registryLocation, component);
|
||||
if (needRelease) {
|
||||
NS_IF_RELEASE(component);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
mModules.Put(&key,res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* Register any deferred (NS_ERROR_FACTORY_REGISTER_AGAIN) components.
|
||||
* Return registered-any-components?
|
||||
*/
|
||||
/* boolean registerDeferredComponents (in long aWhen); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::RegisterDeferredComponents(PRInt32 aWhen, PRBool *aRegistered) {
|
||||
printf("--bcJavaComponentLoader::RegisterDeferredComponents \n");
|
||||
nsresult rv;
|
||||
*aRegistered = PR_FALSE;
|
||||
PRUint32 count;
|
||||
rv = mDeferredComponents.Count(&count);
|
||||
printf("mJCL: registering deferred (%d)\n", count);
|
||||
if (NS_FAILED(rv) || !count)
|
||||
return NS_OK;
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
nsCOMPtr<nsIFile> component;
|
||||
|
||||
rv = mDeferredComponents.GetElementAt(i, getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
component = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
rv = AttemptRegistration(component, PR_TRUE /* deferred */);
|
||||
if (rv != NS_ERROR_FACTORY_REGISTER_AGAIN) {
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*aRegistered = PR_TRUE;
|
||||
mDeferredComponents.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
rv = mDeferredComponents.Count(&count);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (*aRegistered)
|
||||
printf("mJCL: registered deferred, %d left\n", count);
|
||||
else
|
||||
printf("mJCL: didn't register any components, %d left\n", count);
|
||||
}
|
||||
/* are there any fatal errors? */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unload all components that are willing.
|
||||
*/
|
||||
/* void unloadAll (in long aWhen); */
|
||||
NS_IMETHODIMP bcJavaComponentLoader::UnloadAll(PRInt32 aWhen) { //nb
|
||||
printf("--bcJavaComponentLoader::UnloadAll \n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(bcJavaComponentLoader)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
"Java Component Loader",
|
||||
BC_JAVACOMPONENTLOADER_CID,
|
||||
BC_JAVACOMPONENTLOADER_PROGID,
|
||||
bcJavaComponentLoaderConstructor
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* copied-and-pasted from mozJSComponentLoader */
|
||||
#include "nsHashtable.h"
|
||||
class bcJavaComponentLoaderModule : public nsIModule
|
||||
{
|
||||
public:
|
||||
bcJavaComponentLoaderModule(const char *moduleName, PRUint32 componentCount,
|
||||
nsModuleComponentInfo *components);
|
||||
virtual ~bcJavaComponentLoaderModule();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMODULE
|
||||
|
||||
protected:
|
||||
nsresult Initialize();
|
||||
|
||||
void Shutdown();
|
||||
|
||||
PRBool mInitialized;
|
||||
const char* mModuleName;
|
||||
PRUint32 mComponentCount;
|
||||
nsModuleComponentInfo* mComponents;
|
||||
nsSupportsHashtable mFactories;
|
||||
};
|
||||
|
||||
bcJavaComponentLoaderModule::bcJavaComponentLoaderModule(const char* moduleName, PRUint32 componentCount,
|
||||
nsModuleComponentInfo* aComponents)
|
||||
: mInitialized(PR_FALSE),
|
||||
mModuleName(moduleName),
|
||||
mComponentCount(componentCount),
|
||||
mComponents(aComponents),
|
||||
mFactories(8, PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
bcJavaComponentLoaderModule::~bcJavaComponentLoaderModule()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(bcJavaComponentLoaderModule, nsIModule)
|
||||
|
||||
// Perform our one-time intialization for this module
|
||||
nsresult
|
||||
bcJavaComponentLoaderModule::Initialize()
|
||||
{
|
||||
if (mInitialized) {
|
||||
return NS_OK;
|
||||
}
|
||||
mInitialized = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Shutdown this module, releasing all of the module resources
|
||||
void
|
||||
bcJavaComponentLoaderModule::Shutdown()
|
||||
{
|
||||
// Release the factory objects
|
||||
mFactories.Reset();
|
||||
}
|
||||
|
||||
// Create a factory object for creating instances of aClass.
|
||||
NS_IMETHODIMP
|
||||
bcJavaComponentLoaderModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
const nsCID& aClass,
|
||||
const nsIID& aIID,
|
||||
void** r_classObj)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Defensive programming: Initialize *r_classObj in case of error below
|
||||
if (!r_classObj) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
*r_classObj = NULL;
|
||||
|
||||
// Do one-time-only initialization if necessary
|
||||
if (!mInitialized) {
|
||||
rv = Initialize();
|
||||
if (NS_FAILED(rv)) {
|
||||
// Initialization failed! yikes!
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Choose the appropriate factory, based on the desired instance
|
||||
// class type (aClass).
|
||||
nsIDKey key(aClass);
|
||||
nsCOMPtr<nsIGenericFactory> fact = getter_AddRefs(NS_REINTERPRET_CAST(nsIGenericFactory *, mFactories.Get(&key)));
|
||||
if (fact == nsnull) {
|
||||
nsModuleComponentInfo* desc = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
if (desc->mCID.Equals(aClass)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), desc->mConstructor);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
(void)mFactories.Put(&key, fact);
|
||||
goto found;
|
||||
}
|
||||
desc++;
|
||||
}
|
||||
// not found in descriptions
|
||||
#ifdef DEBUG
|
||||
char* cs = aClass.ToString();
|
||||
printf("+++ nsGenericModule %s: unable to create factory for %s\n", mModuleName, cs);
|
||||
nsCRT::free(cs);
|
||||
#endif
|
||||
// XXX put in stop-gap so that we don't search for this one again
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
}
|
||||
found:
|
||||
rv = fact->QueryInterface(aIID, r_classObj);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bcJavaComponentLoaderModule::RegisterSelf(nsIComponentManager *aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* registryLocation,
|
||||
const char* componentType)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("*** Registering %s components (all right -- an almost-generic module!)\n", mModuleName);
|
||||
#endif
|
||||
|
||||
nsModuleComponentInfo* cp = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
rv = aCompMgr->RegisterComponentSpec(cp->mCID, cp->mDescription,
|
||||
cp->mProgID, aPath, PR_TRUE,
|
||||
PR_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
#ifdef DEBUG
|
||||
printf("nsGenericModule %s: unable to register %s component => %x\n",
|
||||
mModuleName, cp->mDescription, rv);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
printf("JavaComponentLoaderModule::RegisterSelf \n");
|
||||
return aCompMgr->RegisterComponentLoader(javaComponentTypeName,
|
||||
BC_JAVACOMPONENTLOADER_PROGID,
|
||||
PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bcJavaComponentLoaderModule::UnregisterSelf(nsIComponentManager* aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* registryLocation)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("*** Unregistering %s components (all right -- an almost-generic module!)\n", mModuleName);
|
||||
#endif
|
||||
nsModuleComponentInfo* cp = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
nsresult rv = aCompMgr->UnregisterComponentSpec(cp->mCID, aPath);
|
||||
if (NS_FAILED(rv)) {
|
||||
#ifdef DEBUG
|
||||
printf("nsGenericModule %s: unable to unregister %s component => %x\n",
|
||||
mModuleName, cp->mDescription, rv);
|
||||
#endif
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
bcJavaComponentLoaderModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
|
||||
{
|
||||
printf("--bcJavaComponentLoaderModule::CanUnload\n");
|
||||
if (!okToUnload) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
*okToUnload = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_EXPORT nsresult
|
||||
NS_NewJavaComponentLoaderModule(const char* moduleName,
|
||||
PRUint32 componentCount,
|
||||
nsModuleComponentInfo* aComponents,
|
||||
nsIModule* *result)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ASSERTION(result, "Null argument");
|
||||
|
||||
// Create and initialize the module instance
|
||||
bcJavaComponentLoaderModule *m = new bcJavaComponentLoaderModule(moduleName, componentCount, aComponents);
|
||||
if (!m) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Increase refcnt and store away nsIModule interface to m in return_cobj
|
||||
rv = m->QueryInterface(NS_GET_IID(nsIModule), (void**)result);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete m;
|
||||
m = nsnull;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *compMgr,
|
||||
nsIFile *location,
|
||||
nsIModule** result)
|
||||
{
|
||||
return NS_NewJavaComponentLoaderModule("bcJavaComponentLoaderModule",
|
||||
sizeof(components) / sizeof(components[0]),
|
||||
components, result);
|
||||
}
|
||||
|
67
java/xpcom/java/loader/bcJavaComponentLoader.h
Normal file
67
java/xpcom/java/loader/bcJavaComponentLoader.h
Normal file
@ -0,0 +1,67 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef _bcJavaComponentLoader_h
|
||||
#define _bcJavaComponentLoader_h
|
||||
#include "nsIComponentLoader.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsSupportsArray.h"
|
||||
|
||||
#define BC_JAVACOMPONENTLOADER_PROGID \
|
||||
"component://netscape/blackwood/blackconnect/java-component-loader"
|
||||
|
||||
/* 0d6b5198-1dd2-11b2-b2f0-ed49ba755db8 */
|
||||
#define BC_JAVACOMPONENTLOADER_CID \
|
||||
{ 0x0d6b5198, 0x1dd2, 0x11b2, \
|
||||
{0xb2, 0xf0, 0xed, 0x49, 0xba, 0x75, 0x5d, 0xb8 }}
|
||||
|
||||
#define JAVACOMPONENTTYPENAME "text/java"
|
||||
|
||||
class bcJavaComponentLoader : public nsIComponentLoader {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICOMPONENTLOADER
|
||||
|
||||
bcJavaComponentLoader();
|
||||
virtual ~bcJavaComponentLoader();
|
||||
protected:
|
||||
nsHashtable mModules;
|
||||
nsCOMPtr<nsIRegistry> mRegistry;
|
||||
nsIComponentManager* mCompMgr; // weak ref, should make it strong?
|
||||
nsRegistryKey mXPCOMKey;
|
||||
nsSupportsArray mDeferredComponents;
|
||||
|
||||
nsresult RegisterComponentsInDir(PRInt32 when, nsIFile *dir);
|
||||
nsresult AttemptRegistration(nsIFile *component, PRBool deferred);
|
||||
nsIModule * ModuleForLocation(const char *registryLocation, nsIFile *component);
|
||||
PRBool HasChanged(const char *registryLocation, nsIFile *component);
|
||||
nsresult SetRegistryInfo(const char *registryLocation, nsIFile *component);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
88
java/xpcom/java/loader/bcJavaModule.cpp
Normal file
88
java/xpcom/java/loader/bcJavaModule.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include <fstream.h>
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "bcJavaModule.h"
|
||||
#include "bcJavaComponentFactory.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcJavaModule,NS_GET_IID(nsIModule));
|
||||
bcJavaModule::bcJavaModule(const char *registryLocation, nsIFile *component)
|
||||
: location(NULL) {
|
||||
NS_INIT_REFCNT();
|
||||
nsXPIDLCString str;
|
||||
component->GetPath(getter_Copies(str));
|
||||
location = nsCRT::strdup(str);
|
||||
printf("--JavaModule::JavaModule %s\n",(const char*)str);
|
||||
}
|
||||
|
||||
bcJavaModule::~bcJavaModule() {
|
||||
if (location) {
|
||||
nsCRT::free((char*)location);
|
||||
}
|
||||
}
|
||||
|
||||
/* void getClassObject (in nsIComponentManager aCompMgr, in nsCIDRef aClass, in nsIIDRef aIID, [iid_is (aIID), retval] out nsQIResult result); */
|
||||
NS_IMETHODIMP bcJavaModule::GetClassObject(nsIComponentManager *aCompMgr, const nsCID & aClass, const nsIID & aIID, void * *result) {
|
||||
printf("--JavaModule::GetClassObject\n");
|
||||
nsIFactory *f;
|
||||
f = new bcJavaComponentFactory(location);
|
||||
NS_ADDREF(f);
|
||||
*result = f;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void registerSelf (in nsIComponentManager aCompMgr, in nsIFile location, in string registryLocation, in string componentType); */
|
||||
NS_IMETHODIMP bcJavaModule::RegisterSelf(nsIComponentManager *aCompMgr, nsIFile *_location, const char *registryLocation, const char *componentType) {
|
||||
nsresult result;
|
||||
printf("--JavaModule::RegisterSelf\n");
|
||||
ifstream in(location);
|
||||
char cidStr[500], progid[1000], desc[1000];
|
||||
in.getline(cidStr,1000);
|
||||
in.getline(progid,1000);
|
||||
in.getline(desc,1000);
|
||||
printf("%s %s %s", cidStr, progid, desc);
|
||||
nsCID cid;
|
||||
cid.Parse((const char *)cidStr);
|
||||
aCompMgr->RegisterComponentWithType(cid, desc, progid, _location, registryLocation, PR_TRUE, PR_TRUE, componentType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void unregisterSelf (in nsIComponentManager aCompMgr, in nsIFile location, in string registryLocation); */
|
||||
NS_IMETHODIMP bcJavaModule::UnregisterSelf(nsIComponentManager *aCompMgr, nsIFile *_location, const char *registryLocation) { //nb
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean canUnload (in nsIComponentManager aCompMgr); */
|
||||
NS_IMETHODIMP bcJavaModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *_retval) {
|
||||
if (!_retval) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
35
java/xpcom/java/loader/bcJavaModule.h
Normal file
35
java/xpcom/java/loader/bcJavaModule.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef _bcJavaModule_h
|
||||
#define _bcJavaModule_h
|
||||
#include "nsIModule.h"
|
||||
|
||||
class bcJavaModule : public nsIModule {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMODULE
|
||||
|
||||
bcJavaModule(const char *registryLocation, nsIFile *component);
|
||||
virtual ~bcJavaModule();
|
||||
protected:
|
||||
const char *location;
|
||||
};
|
||||
#endif
|
69
java/xpcom/java/src/Makefile.in
Normal file
69
java/xpcom/java/src/Makefile.in
Normal file
@ -0,0 +1,69 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
|
||||
DEPTH=../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = bcjavastubs
|
||||
MODULE = bcjavastubs
|
||||
IS_COMPONENT = 1
|
||||
|
||||
EXPORTS = \
|
||||
bcJavaStubsAndProxies.h
|
||||
|
||||
CPPSRCS = \
|
||||
bcJavaMarshalToolkit.cpp \
|
||||
bcJavaStub.cpp \
|
||||
bcJavaGlobal.cpp \
|
||||
bcJavaStubsAndProxies.cpp \
|
||||
bcIIDJava.cpp \
|
||||
org_mozilla_xpcom_Utilities.cpp \
|
||||
$(NULL)
|
||||
|
||||
CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS) -D_REENTRANT -DOJI_DISABLE -I$(CONNECT_SRC)/public
|
||||
|
||||
DSO_LDOPTS += \
|
||||
-L$(JDKHOME)/jre/lib/$(HOSTTYPE)/ \
|
||||
-L$(JDKHOME)/jre/lib/$(HOSTTYPE)/classic \
|
||||
-ljava -ljvm \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(OS_ARCH), Linux)
|
||||
DSO_LDOPTS += \
|
||||
-lthread -lXm -lX11 -lXt -lm
|
||||
endif
|
||||
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
99
java/xpcom/java/src/bcIIDJava.cpp
Normal file
99
java/xpcom/java/src/bcIIDJava.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "bcIIDJava.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
|
||||
jclass bcIIDJava::iidClass = NULL;
|
||||
jmethodID bcIIDJava::iidInitMID = NULL;
|
||||
jmethodID bcIIDJava::getStringMID = NULL;
|
||||
|
||||
|
||||
void bcIIDJava::Init(void) {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (env) {
|
||||
if (!(iidClass = env->FindClass("org/mozilla/xpcom/IID"))
|
||||
|| !(iidClass = (jclass) env->NewGlobalRef(iidClass))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(iidInitMID = env->GetMethodID(iidClass,"<init>","(Ljava/lang/String;)V"))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
if (!(getStringMID = env->GetMethodID(iidClass,"getString","()Ljava/lang/String;"))) {
|
||||
env->ExceptionDescribe();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void bcIIDJava::Destroy() {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (env) {
|
||||
if (iidClass) {
|
||||
env->DeleteGlobalRef(iidClass);
|
||||
iidClass = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jobject bcIIDJava::GetObject(nsIID *iid) {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (!iid
|
||||
|| !env ) {
|
||||
return NULL;
|
||||
}
|
||||
if (!iidClass) {
|
||||
Init();
|
||||
}
|
||||
char *str = iid->ToString(); //nb free ?
|
||||
jstring jstr = NULL;
|
||||
if (str) {
|
||||
char *siid = str+1; //we do need to have {_fdsf_}
|
||||
siid[strlen(siid)-1] = 0;
|
||||
jstr = env->NewStringUTF((const char *)siid);
|
||||
}
|
||||
return env->NewObject(iidClass,iidInitMID,jstr);
|
||||
}
|
||||
|
||||
jclass bcIIDJava::GetClass() {
|
||||
return iidClass;
|
||||
}
|
||||
|
||||
nsIID bcIIDJava::GetIID(jobject obj) {
|
||||
nsIID iid;
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
if (env) {
|
||||
if (!iidClass) {
|
||||
Init();
|
||||
}
|
||||
jstring jstr = (jstring)env->CallObjectMethod(obj, getStringMID);
|
||||
const char * str = NULL;
|
||||
str = env->GetStringUTFChars(jstr,NULL);
|
||||
iid.Parse(str);
|
||||
env->ReleaseStringUTFChars(jstr,str);
|
||||
|
||||
}
|
||||
return iid;
|
||||
}
|
41
java/xpcom/java/src/bcIIDJava.h
Normal file
41
java/xpcom/java/src/bcIIDJava.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcIIDJava_H
|
||||
#define __bcIIDJava_H
|
||||
|
||||
#include "nsIID.h"
|
||||
#include "jni.h"
|
||||
|
||||
class bcIIDJava {
|
||||
public:
|
||||
static jobject GetObject(nsIID * iid);
|
||||
static nsIID GetIID(jobject obj);
|
||||
static jclass GetClass();
|
||||
private:
|
||||
static jclass iidClass;
|
||||
static jmethodID iidInitMID;
|
||||
static jmethodID getStringMID;
|
||||
static void Init(void);
|
||||
static void Destroy(void);
|
||||
};
|
||||
|
||||
#endif
|
68
java/xpcom/java/src/bcJavaGlobal.cpp
Normal file
68
java/xpcom/java/src/bcJavaGlobal.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "bcJavaGlobal.h"
|
||||
#include "prenv.h"
|
||||
|
||||
|
||||
JavaVM *bcJavaGlobal::jvm = NULL;
|
||||
|
||||
#define PATH_SEPARATOR ':'
|
||||
JNIEnv * bcJavaGlobal::GetJNIEnv(void) {
|
||||
JNIEnv * res;
|
||||
if (!jvm) {
|
||||
StartJVM();
|
||||
}
|
||||
if (jvm) {
|
||||
jvm->AttachCurrentThread(&res,NULL);
|
||||
}
|
||||
printf("--bcJavaGlobal::GetJNIEnv \n");
|
||||
return res;
|
||||
}
|
||||
|
||||
void bcJavaGlobal::StartJVM() {
|
||||
JNIEnv *env = NULL;
|
||||
jint res;
|
||||
jsize jvmCount;
|
||||
JNI_GetCreatedJavaVMs(&jvm, 1, &jvmCount);
|
||||
if (jvmCount) {
|
||||
return;
|
||||
}
|
||||
JDK1_1InitArgs vm_args;
|
||||
char classpath[1024];
|
||||
JNI_GetDefaultJavaVMInitArgs(&vm_args);
|
||||
vm_args.version = 0x00010001;
|
||||
/* Append USER_CLASSPATH to the default system class path */
|
||||
sprintf(classpath, "%s%c%s",
|
||||
vm_args.classpath, PATH_SEPARATOR, PR_GetEnv("CLASSPATH"));
|
||||
char **props = new char*[2];
|
||||
props[0]="java.compiler=NONE";
|
||||
props[1]=0;
|
||||
vm_args.properties = props;
|
||||
vm_args.classpath = classpath;
|
||||
/* Create the Java VM */
|
||||
res = JNI_CreateJavaVM(&jvm, &env, &vm_args);
|
||||
printf("--bcJavaGlobal::StartJVM jvm started\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
33
java/xpcom/java/src/bcJavaGlobal.h
Normal file
33
java/xpcom/java/src/bcJavaGlobal.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcJavaGlobal_h_
|
||||
#define __bcJavaGlobal_h_
|
||||
#include "jni.h"
|
||||
|
||||
class bcJavaGlobal {
|
||||
public:
|
||||
static JNIEnv * GetJNIEnv(void);
|
||||
private:
|
||||
static JavaVM *jvm;
|
||||
static void StartJVM(void);
|
||||
};
|
||||
#endif
|
534
java/xpcom/java/src/bcJavaMarshalToolkit.cpp
Normal file
534
java/xpcom/java/src/bcJavaMarshalToolkit.cpp
Normal file
@ -0,0 +1,534 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "bcJavaMarshalToolkit.h"
|
||||
#include "bcIIDJava.h"
|
||||
#include "bcJavaStubsAndProxies.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
jclass bcJavaMarshalToolkit::objectClass = NULL;
|
||||
jclass bcJavaMarshalToolkit::booleanClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::booleanInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::booleanValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::characterClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::characterInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::characterValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::byteClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::byteInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::byteValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::shortClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::shortInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::shortValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::integerClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::integerInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::integerValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::longClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::longInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::longValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::floatClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::floatInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::floatValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::doubleClass = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::doubleInitMID = NULL;
|
||||
jmethodID bcJavaMarshalToolkit::doubleValueMID = NULL;
|
||||
|
||||
jclass bcJavaMarshalToolkit::stringClass = NULL;
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kJavaStubsAndProxies,BC_JAVASTUBSANDPROXIES_CID);
|
||||
|
||||
bcJavaMarshalToolkit::bcJavaMarshalToolkit(PRUint16 _methodIndex,
|
||||
nsIInterfaceInfo *_interfaceInfo, jobjectArray _args, JNIEnv *_env, int isOnServer, bcIORB *_orb) {
|
||||
env = _env;
|
||||
callSide = (isOnServer) ? onServer : onClient;
|
||||
methodIndex = _methodIndex;
|
||||
interfaceInfo = _interfaceInfo;
|
||||
interfaceInfo->GetMethodInfo(methodIndex,(const nsXPTMethodInfo **)&info); // These do *not* make copies ***explicit bending of XPCOM rules***
|
||||
args = _args;
|
||||
if(!objectClass) {
|
||||
InitializeStatic();
|
||||
if(!objectClass) {
|
||||
//nb ? we do not have java classes. What could we do?
|
||||
}
|
||||
}
|
||||
orb = _orb;
|
||||
}
|
||||
|
||||
bcJavaMarshalToolkit::~bcJavaMarshalToolkit() {
|
||||
}
|
||||
|
||||
nsresult bcJavaMarshalToolkit::Marshal(bcIMarshaler *m) {
|
||||
//nb todo
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
class javaAllocator : public bcIAllocator {
|
||||
public:
|
||||
javaAllocator(nsIAllocator *_allocator) {
|
||||
allocator = _allocator;
|
||||
}
|
||||
virtual ~javaAllocator() {}
|
||||
virtual void * Alloc(size_t size) {
|
||||
return allocator->Alloc(size);
|
||||
}
|
||||
virtual void Free(void *ptr) {
|
||||
allocator->Free(ptr);
|
||||
}
|
||||
virtual void * Realloc(void* ptr, size_t size) {
|
||||
return allocator->Realloc(ptr,size);
|
||||
}
|
||||
private:
|
||||
nsCOMPtr<nsIAllocator> allocator;
|
||||
};
|
||||
|
||||
nsresult bcJavaMarshalToolkit::UnMarshal(bcIUnMarshaler *um) {
|
||||
printf("--nsresult bcJavaMarshalToolkit::UnMarshal\n");
|
||||
bcIAllocator * allocator = new javaAllocator(nsAllocator::GetGlobalAllocator());
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
jobject value;
|
||||
void * data = allocator->Alloc(sizeof(nsXPTCMiniVariant)); // sizeof(nsXPTCMiniVariant) is ok
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
nsXPTParamInfo param = info->GetParam(i);
|
||||
PRBool isOut = param.IsOut();
|
||||
nsXPTType type = param.GetType();
|
||||
if ( (callSide == onServer && !param.IsIn()
|
||||
|| (callSide == onClient && !param.IsOut()))){
|
||||
if (callSide == onServer
|
||||
&& isOut) { //we need to allocate memory for out parametr
|
||||
value = Native2Java(NULL,XPTType2bcXPType(type.TagPart()),1);
|
||||
env->SetObjectArrayElement(args,i,value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
switch(type.TagPart()) {
|
||||
case nsXPTType::T_IID :
|
||||
case nsXPTType::T_I8 :
|
||||
case nsXPTType::T_U8 :
|
||||
case nsXPTType::T_I16 :
|
||||
case nsXPTType::T_U16 :
|
||||
case nsXPTType::T_I32 :
|
||||
case nsXPTType::T_U32 :
|
||||
case nsXPTType::T_I64 :
|
||||
case nsXPTType::T_U64 :
|
||||
case nsXPTType::T_FLOAT :
|
||||
case nsXPTType::T_DOUBLE :
|
||||
case nsXPTType::T_BOOL :
|
||||
case nsXPTType::T_CHAR :
|
||||
case nsXPTType::T_WCHAR :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type.TagPart()));
|
||||
value = Native2Java(data,XPTType2bcXPType(type.TagPart()),isOut);
|
||||
break;
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
size_t size;
|
||||
um->ReadString(data,&size,allocator);
|
||||
//nb to do
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
{
|
||||
printf("--[c++] we have an interface\n");
|
||||
bcOID oid;
|
||||
um->ReadSimple(&oid,XPTType2bcXPType(type.TagPart()));
|
||||
printf("%d oid", oid);
|
||||
nsIID iid;
|
||||
um->ReadSimple(&iid,bc_T_IID);
|
||||
void * p[2];
|
||||
p[0]=&oid; p[1]= &iid;
|
||||
data = p;
|
||||
value = Native2Java(data,bc_T_INTERFACE,isOut);
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_ARRAY:
|
||||
{
|
||||
nsXPTType datumType;
|
||||
if(NS_FAILED(interfaceInfo->GetTypeForParam(methodIndex, ¶m, 1,&datumType))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
//nb to do array
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
env->SetObjectArrayElement(args,i,value);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
bcXPType bcJavaMarshalToolkit::XPTType2bcXPType(uint8 type) {
|
||||
switch(type) {
|
||||
case nsXPTType::T_I8 :
|
||||
return bc_T_I8;
|
||||
case nsXPTType::T_U8 :
|
||||
return bc_T_U8;
|
||||
case nsXPTType::T_I16 :
|
||||
return bc_T_I16;
|
||||
case nsXPTType::T_U16 :
|
||||
return bc_T_U16;
|
||||
case nsXPTType::T_I32 :
|
||||
return bc_T_I32;
|
||||
case nsXPTType::T_U32 :
|
||||
return bc_T_U32;
|
||||
case nsXPTType::T_I64 :
|
||||
return bc_T_I64;
|
||||
case nsXPTType::T_U64 :
|
||||
return bc_T_U64;
|
||||
case nsXPTType::T_FLOAT :
|
||||
return bc_T_FLOAT;
|
||||
case nsXPTType::T_DOUBLE :
|
||||
return bc_T_DOUBLE;
|
||||
case nsXPTType::T_BOOL :
|
||||
return bc_T_BOOL;
|
||||
case nsXPTType::T_CHAR :
|
||||
return bc_T_CHAR;
|
||||
case nsXPTType::T_WCHAR :
|
||||
return bc_T_WCHAR;
|
||||
case nsXPTType::T_IID :
|
||||
return bc_T_IID;
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
return bc_T_CHAR_STR;
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
return bc_T_WCHAR_STR;
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
return bc_T_INTERFACE;
|
||||
case nsXPTType::T_ARRAY:
|
||||
return bc_T_ARRAY;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if p == 0 and isOut than return one element array
|
||||
jobject bcJavaMarshalToolkit::Native2Java(void *p, bcXPType type, int isOut) {
|
||||
//nb we shoud care about endianes. should we?
|
||||
printf("--[c++]bcJavaMarshalToolkit::Native2Java \n");
|
||||
jobject res = NULL;
|
||||
if (!p
|
||||
&& !isOut) {
|
||||
printf("--[c++]bcJavaMarshalToolkit::Native2Java !p && !isOut\n");
|
||||
return res;
|
||||
}
|
||||
switch (type) {
|
||||
case bc_T_I8:
|
||||
case bc_T_U8:
|
||||
if (isOut) {
|
||||
res = env->NewByteArray(1);
|
||||
if (p) {
|
||||
env->SetByteArrayRegion((jbyteArray)res,0,1,(jbyte*)p);
|
||||
}
|
||||
} else {
|
||||
res = env->NewObject(byteClass,byteInitMID,*(jbyte*)p);
|
||||
}
|
||||
break;
|
||||
case bc_T_I16:
|
||||
case bc_T_U16:
|
||||
if (isOut) {
|
||||
res = env->NewShortArray(1);
|
||||
if (p) {
|
||||
env->SetShortArrayRegion((jshortArray)res,0,1,(jshort*)p);
|
||||
}
|
||||
} else {
|
||||
res = env->NewObject(shortClass,shortInitMID,*(jshort*)p);
|
||||
}
|
||||
break;
|
||||
case bc_T_I32:
|
||||
case bc_T_U32:
|
||||
if (isOut) {
|
||||
res = env->NewIntArray(1);
|
||||
if (p) {
|
||||
env->SetIntArrayRegion((jintArray)res,0,1,(jint*)p);
|
||||
}
|
||||
} else {
|
||||
res = env->NewObject(integerClass,integerInitMID,*(jint*)p);
|
||||
printf("--bcJavaMarshalToolkit::Native2Java we'v got i32\n");
|
||||
}
|
||||
break;
|
||||
case bc_T_I64:
|
||||
case bc_T_U64:
|
||||
if (isOut) {
|
||||
res = env->NewLongArray(1);
|
||||
if (p) {
|
||||
env->SetLongArrayRegion((jlongArray)res,0,1,(jlong*)p);
|
||||
}
|
||||
} else {
|
||||
res = env->NewObject(longClass,longInitMID,*(jlong*)p);
|
||||
}
|
||||
break;
|
||||
case bc_T_FLOAT:
|
||||
if (isOut) {
|
||||
res = env->NewFloatArray(1);
|
||||
if (p) {
|
||||
env->SetFloatArrayRegion((jfloatArray)res,0,1,(jfloat*)p);
|
||||
}
|
||||
} else {
|
||||
res = env->NewObject(floatClass,floatInitMID,*(jfloat*)p);
|
||||
}
|
||||
break;
|
||||
case bc_T_DOUBLE:
|
||||
if (isOut) {
|
||||
res = env->NewDoubleArray(1);
|
||||
if (p) {
|
||||
env->SetDoubleArrayRegion((jdoubleArray)res,0,1,(jdouble*)p);
|
||||
}
|
||||
} else {
|
||||
res = env->NewObject(doubleClass,doubleInitMID,*(jdouble*)p);
|
||||
}
|
||||
break;
|
||||
case bc_T_BOOL:
|
||||
if (isOut) {
|
||||
res = env->NewBooleanArray(1);
|
||||
if (p) {
|
||||
env->SetBooleanArrayRegion((jbooleanArray)res,0,1,(jboolean*)p);
|
||||
}
|
||||
} else {
|
||||
res = env->NewObject(booleanClass,booleanInitMID,*(jboolean*)p);
|
||||
}
|
||||
break;
|
||||
case bc_T_CHAR:
|
||||
case bc_T_WCHAR:
|
||||
if (isOut) {
|
||||
res = env->NewCharArray(1);
|
||||
if (p) {
|
||||
env->SetCharArrayRegion((jcharArray)res,0,1,(jchar*)p);
|
||||
}
|
||||
} else {
|
||||
res = env->NewObject(characterClass,characterInitMID,*(jchar*)p);
|
||||
}
|
||||
break;
|
||||
case bc_T_CHAR_STR:
|
||||
case bc_T_WCHAR_STR: //nb not sure about this
|
||||
{
|
||||
jstring str = NULL;
|
||||
if (p) {
|
||||
str = env->NewStringUTF((const char*)p);
|
||||
}
|
||||
if (isOut) {
|
||||
res = env->NewObjectArray(1,stringClass,NULL);
|
||||
if (str) {
|
||||
env->SetObjectArrayElement((jobjectArray)res,0,str);
|
||||
}
|
||||
} else {
|
||||
res = str;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case bc_T_IID:
|
||||
{
|
||||
jobject iid = NULL;
|
||||
if (p) {
|
||||
iid = bcIIDJava::GetObject((nsIID*)p);
|
||||
}
|
||||
if (isOut) {
|
||||
res = env->NewObjectArray(1,bcIIDJava::GetClass(),NULL);
|
||||
env->SetObjectArrayElement((jobjectArray)res,0,iid);
|
||||
} else {
|
||||
res = iid;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case bc_T_INTERFACE:
|
||||
{
|
||||
printf("--[c++]bcJavaMarshalToolkit::... we have an Interfaces \n");
|
||||
jobject obj = NULL;
|
||||
nsresult r;
|
||||
nsIID *iid;
|
||||
bcOID *oid;
|
||||
jobject proxy;
|
||||
if (p) {
|
||||
oid = (bcOID*)((void**)p)[0];
|
||||
iid = (bcIID*)((void**)p)[1];
|
||||
NS_WITH_SERVICE(bcJavaStubsAndProxies, javaStubsAndProxies, kJavaStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
return NULL;
|
||||
}
|
||||
javaStubsAndProxies->GetProxy(*oid, *iid, orb, &proxy);
|
||||
|
||||
}
|
||||
if (isOut) { //nb to do
|
||||
/*
|
||||
res = env->NewObjectArray(1,bcIIDJava::GetClass(),NULL);
|
||||
env->SetObjectArrayElement((jobjectArray)res,0,proxy);
|
||||
*/
|
||||
} else {
|
||||
res = proxy;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
void bcJavaMarshalToolkit::InitializeStatic() {
|
||||
jclass clazz;
|
||||
if (!(clazz = env->FindClass("java/lang/Object"))
|
||||
|| !(objectClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(clazz = env->FindClass("java/lang/Boolean"))
|
||||
|| !(booleanClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(clazz = env->FindClass("java/lang/Character"))
|
||||
|| !(characterClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Byte"))
|
||||
|| !(byteClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Short"))
|
||||
|| !(shortClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Integer"))
|
||||
|| !(integerClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Long"))
|
||||
|| !(longClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Float"))
|
||||
|| !(floatClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(clazz = env->FindClass("java/lang/Double"))
|
||||
|| !(doubleClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(clazz = env->FindClass("java/lang/String"))
|
||||
|| !(stringClass = (jclass) env->NewGlobalRef(clazz))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(booleanInitMID = env->GetMethodID(booleanClass,"<init>","(Z)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(booleanValueMID = env->GetMethodID(booleanClass,"booleanValue","()Z"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(characterInitMID = env->GetMethodID(characterClass,"<init>","(C)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(characterValueMID = env->GetMethodID(characterClass,"charValue","()C"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(byteInitMID = env->GetMethodID(byteClass,"<init>","(B)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(byteValueMID = env->GetMethodID(byteClass,"byteValue","()B"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(shortInitMID = env->GetMethodID(shortClass,"<init>","(S)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(shortValueMID = env->GetMethodID(shortClass,"shortValue","()S"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(integerInitMID = env->GetMethodID(integerClass,"<init>","(I)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(integerValueMID = env->GetMethodID(integerClass,"intValue","()I"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(longInitMID = env->GetMethodID(longClass,"<init>","(J)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(longValueMID = env->GetMethodID(longClass,"longValue","()J"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(floatInitMID = env->GetMethodID(floatClass,"<init>","(F)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(floatValueMID = env->GetMethodID(floatClass,"floatValue","()F"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(doubleInitMID = env->GetMethodID(doubleClass,"<init>","(D)V"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
if (!(doubleValueMID = env->GetMethodID(doubleClass,"doubleValue","()D"))) {
|
||||
DeInitializeStatic();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void bcJavaMarshalToolkit::DeInitializeStatic() { //nb need to do
|
||||
|
||||
}
|
||||
|
85
java/xpcom/java/src/bcJavaMarshalToolkit.h
Normal file
85
java/xpcom/java/src/bcJavaMarshalToolkit.h
Normal file
@ -0,0 +1,85 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef _bcJavaMarshalToolkit_h
|
||||
#define _bcJavaMarshalToolkit_h
|
||||
|
||||
#include "jni.h"
|
||||
#include "nsISupports.h"
|
||||
#include "xptcall.h"
|
||||
#include "bcIMarshaler.h"
|
||||
#include "bcIUnMarshaler.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
class bcJavaMarshalToolkit {
|
||||
public:
|
||||
bcJavaMarshalToolkit(PRUint16 methodIndex,
|
||||
nsIInterfaceInfo *interfaceInfo, jobjectArray args,
|
||||
JNIEnv *env, int isOnServer, bcIORB *orb) ;
|
||||
virtual ~bcJavaMarshalToolkit();
|
||||
nsresult Marshal(bcIMarshaler *);
|
||||
nsresult UnMarshal(bcIUnMarshaler *);
|
||||
private:
|
||||
enum { unDefined, onServer, onClient } callSide;
|
||||
JNIEnv *env;
|
||||
PRUint16 methodIndex;
|
||||
nsXPTMethodInfo *info;
|
||||
nsIInterfaceInfo * interfaceInfo;
|
||||
bcIORB *orb;
|
||||
jobjectArray args;
|
||||
|
||||
static jclass objectClass;
|
||||
static jclass booleanClass;
|
||||
static jmethodID booleanInitMID;
|
||||
static jmethodID booleanValueMID;
|
||||
static jclass characterClass;
|
||||
static jmethodID characterInitMID;
|
||||
static jmethodID characterValueMID;
|
||||
static jclass byteClass;
|
||||
static jmethodID byteInitMID;
|
||||
static jmethodID byteValueMID;
|
||||
static jclass shortClass;
|
||||
static jmethodID shortInitMID;
|
||||
static jmethodID shortValueMID;
|
||||
static jclass integerClass;
|
||||
static jmethodID integerInitMID;
|
||||
static jmethodID integerValueMID;
|
||||
static jclass longClass;
|
||||
static jmethodID longInitMID;
|
||||
static jmethodID longValueMID;
|
||||
static jclass floatClass;
|
||||
static jmethodID floatInitMID;
|
||||
static jmethodID floatValueMID;
|
||||
static jclass doubleClass;
|
||||
static jmethodID doubleInitMID;
|
||||
static jmethodID doubleValueMID;
|
||||
|
||||
static jclass stringClass;
|
||||
|
||||
void InitializeStatic();
|
||||
void DeInitializeStatic();
|
||||
bcXPType XPTType2bcXPType(uint8 type);
|
||||
jobject Native2Java(void *,bcXPType type,int isOut = 0);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
40
java/xpcom/java/src/bcJavaProxy.h
Normal file
40
java/xpcom/java/src/bcJavaProxy.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcJavaProxy_h
|
||||
#define __bcJavaProxy_h
|
||||
#include "jni.h"
|
||||
#include "bcDefs.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
class bcJavaProxy {
|
||||
public:
|
||||
bcJavaProxy(bcOID oid, bcIID * iid, bcIORB *orb);
|
||||
virtual ~bcJavaProxy();
|
||||
jobject GetObject();
|
||||
private:
|
||||
bcIORB *orb;
|
||||
bcOID oid;
|
||||
bcIID iid;
|
||||
|
||||
};
|
||||
#endif
|
113
java/xpcom/java/src/bcJavaStub.cpp
Normal file
113
java/xpcom/java/src/bcJavaStub.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "bcJavaStub.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptcall.h"
|
||||
#include "bcJavaMarshalToolkit.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
#include "bcIIDJava.h"
|
||||
#include "unistd.h"
|
||||
#include "signal.h"
|
||||
|
||||
jclass bcJavaStub::objectClass = NULL;
|
||||
jclass bcJavaStub::utilitiesClass = NULL;
|
||||
jmethodID bcJavaStub::callMethodByIndexMID = NULL;
|
||||
|
||||
bcJavaStub::bcJavaStub(jobject obj) {
|
||||
printf("--bcJavaStub::bcJavaStub \n");
|
||||
if (!obj) {
|
||||
printf("--bcJavaStub::bcJavaStub obj== 0\n");
|
||||
return;
|
||||
}
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
object = env->NewGlobalRef(obj);
|
||||
}
|
||||
|
||||
|
||||
bcJavaStub::~bcJavaStub() {
|
||||
bcJavaGlobal::GetJNIEnv()->DeleteGlobalRef(object);
|
||||
}
|
||||
|
||||
void bcJavaStub::Dispatch(bcICall *call) {
|
||||
//sigsend(P_PID, getpid(),SIGINT);
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
jobjectArray args;
|
||||
call->GetParams(&iid, &oid, &mid);
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if(iimgr = XPTI_GetInterfaceInfoManager()) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
return; //nb exception handling
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
nsXPTMethodInfo* info;
|
||||
interfaceInfo->GetMethodInfo(mid,(const nsXPTMethodInfo **)&info);
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
args = env->NewObjectArray(paramCount, objectClass,NULL);
|
||||
bcJavaMarshalToolkit * mt = new bcJavaMarshalToolkit(mid, interfaceInfo, args, env,1, call->GetORB());
|
||||
bcIUnMarshaler * um = call->GetUnMarshaler();
|
||||
mt->UnMarshal(um);
|
||||
if (!objectClass) {
|
||||
Init();
|
||||
if (!objectClass) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
jobject jiid = bcIIDJava::GetObject(&iid);
|
||||
bcJavaGlobal::GetJNIEnv()->CallStaticObjectMethod(utilitiesClass, callMethodByIndexMID, object, jiid, (jint)mid, args);
|
||||
//nb return value; excepion handling
|
||||
bcIMarshaler * m = call->GetMarshaler(); //nb ** to do
|
||||
mt->Marshal(m);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void bcJavaStub::Init() {
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
objectClass = (jclass)env->NewGlobalRef(env->FindClass("java/lang/Object"));
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return;
|
||||
}
|
||||
|
||||
utilitiesClass = (jclass)env->NewGlobalRef(env->FindClass("org/mozilla/xpcom/Utilities"));
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return;
|
||||
}
|
||||
callMethodByIndexMID = env->GetStaticMethodID(utilitiesClass,"callMethodByIndex","(Ljava/lang/Object;Lorg/mozilla/xpcom/IID;I[Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
41
java/xpcom/java/src/bcJavaStub.h
Normal file
41
java/xpcom/java/src/bcJavaStub.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcJavaStub_h
|
||||
#define __bcJavaStub_h
|
||||
#include "bcIStub.h"
|
||||
#include "jni.h"
|
||||
|
||||
class bcJavaStub : public bcIStub {
|
||||
public:
|
||||
bcJavaStub(jobject obj);
|
||||
virtual ~bcJavaStub();
|
||||
virtual void Dispatch(bcICall *call) ;
|
||||
private:
|
||||
jobject object;
|
||||
static jclass objectClass;
|
||||
static jclass utilitiesClass;
|
||||
static jmethodID callMethodByIndexMID;
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif
|
149
java/xpcom/java/src/bcJavaStubsAndProxies.cpp
Normal file
149
java/xpcom/java/src/bcJavaStubsAndProxies.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "bcJavaStubsAndProxies.h"
|
||||
#include "bcJavaStub.h"
|
||||
#include "bcJavaGlobal.h"
|
||||
#include "bcORB.h"
|
||||
#include "bcIIDJava.h"
|
||||
|
||||
jclass bcJavaStubsAndProxies::componentLoader = 0;
|
||||
jmethodID bcJavaStubsAndProxies::loadComponentID = 0;
|
||||
|
||||
jclass bcJavaStubsAndProxies::proxyFactory = 0;
|
||||
jmethodID bcJavaStubsAndProxies::getProxyID = 0;
|
||||
|
||||
NS_DEFINE_CID(kORBCIID,BC_ORB_CID);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(bcJavaStubsAndProxies);
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
"Black Connect Java stubs and proxies",
|
||||
BC_JAVASTUBSANDPROXIES_CID,
|
||||
BC_JAVASTUBSANDPROXIES_PROGID,
|
||||
bcJavaStubsAndProxiesConstructor
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("BlackConnect Java stubs and proxies",components);
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcJavaStubsAndProxies,NS_GET_IID(bcJavaStubsAndProxies));
|
||||
|
||||
|
||||
bcJavaStubsAndProxies::bcJavaStubsAndProxies() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
bcJavaStubsAndProxies::~bcJavaStubsAndProxies() {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetStub(jobject obj, bcIStub **stub) {
|
||||
if (!stub) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*stub = new bcJavaStub(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetProxy(bcOID oid, const nsIID &iid, bcIORB *orb, jobject *proxy) {
|
||||
printf("--[c++] bcJavaStubsAndProxies::GetProxy\n");
|
||||
if (!componentLoader) {
|
||||
Init();
|
||||
}
|
||||
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
jobject jiid = bcIIDJava::GetObject((nsIID*)&iid);
|
||||
*proxy = env->CallStaticObjectMethod(proxyFactory,getProxyID, (jlong)oid, jiid, (jlong)orb);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP bcJavaStubsAndProxies::GetOID(char *location, bcOID *oid) {
|
||||
printf("--bcJavaStubsAndProxies::GetOID %s\n",location);
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
nsresult result;
|
||||
|
||||
if (!componentLoader) {
|
||||
Init();
|
||||
}
|
||||
location[strlen(location)-5] = 0; //nb dirty hack. location is xyz.jar.info
|
||||
jstring jstr = env->NewStringUTF(location);
|
||||
jobject object = env->CallStaticObjectMethod(componentLoader, loadComponentID, jstr);
|
||||
bcIStub *stub = new bcJavaStub(object);
|
||||
NS_WITH_SERVICE(bcORB,_orb,kORBCIID,&result);
|
||||
if (NS_FAILED(result)) {
|
||||
printf("--bcJavaStubsAndProxies::GetOID failed\n");
|
||||
return result;
|
||||
}
|
||||
bcIORB *orb;
|
||||
_orb->GetORB(&orb);
|
||||
*oid = orb->RegisterStub(stub);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void bcJavaStubsAndProxies::Init(void) {
|
||||
printf("--[c++]bcJavaStubsAndProxies::Init\n");
|
||||
JNIEnv * env = bcJavaGlobal::GetJNIEnv();
|
||||
componentLoader = env->FindClass("org/mozilla/xpcom/ComponentLoader");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
componentLoader = (jclass)env->NewGlobalRef(componentLoader);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
loadComponentID = env->GetStaticMethodID(componentLoader,"loadComponent","(Ljava/lang/String;)Ljava/lang/Object;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
proxyFactory = env->FindClass("org/mozilla/xpcom/ProxyFactory");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
proxyFactory = (jclass)env->NewGlobalRef(proxyFactory);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
getProxyID = env->GetStaticMethodID(proxyFactory, "getProxy","(JLorg/mozilla/xpcom/IID;J)Ljava/lang/Object;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
componentLoader = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
63
java/xpcom/java/src/bcJavaStubsAndProxies.h
Normal file
63
java/xpcom/java/src/bcJavaStubsAndProxies.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#ifndef __bcJavaStubsAndProxies_h
|
||||
#define __bcJavaStubsAndProxies_h
|
||||
#include "nsISupports.h"
|
||||
#include "jni.h"
|
||||
#include "bcDefs.h"
|
||||
#include "bcIStub.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
/* 58034ea6-1dd2-11b2-9b58-8630abb8af47 */
|
||||
|
||||
#define BC_JAVASTUBSANDPROXIES_IID \
|
||||
{0x58034ea6, 0x1dd2, 0x11b2, \
|
||||
{0x9b, 0x58, 0x86, 0x30, 0xab, 0xb8, 0xaf,0x47}}
|
||||
|
||||
#define BC_JAVASTUBSANDPROXIES_PROGID "component://netscape/blackwood/blackconnect/java-stubs-and-proxies"
|
||||
|
||||
/* 7cadf6e8-1dd2-11b2-9a6e-b1c37844e004 */
|
||||
#define BC_JAVASTUBSANDPROXIES_CID \
|
||||
{0x7cadf6e8, 0x1dd2, 0x11b2, \
|
||||
{0x9a, 0x6e, 0xb1, 0xc3, 0x78,0x44, 0xe0, 0x04}}
|
||||
|
||||
class bcJavaStubsAndProxies : public nsISupports {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(BC_JAVASTUBSANDPROXIES_IID)
|
||||
NS_IMETHOD GetStub(jobject obj, bcIStub **stub);
|
||||
NS_IMETHOD GetOID(char *location, bcOID *); //load component by location
|
||||
NS_IMETHOD GetProxy(bcOID oid, const nsIID &iid, bcIORB *orb, jobject *proxy);
|
||||
bcJavaStubsAndProxies();
|
||||
virtual ~bcJavaStubsAndProxies();
|
||||
protected:
|
||||
void Init(void);
|
||||
static jclass componentLoader;
|
||||
static jmethodID loadComponentID;
|
||||
static jclass proxyFactory;
|
||||
static jmethodID getProxyID;
|
||||
};
|
||||
|
||||
#endif /* __bcJavaStubsAndProxies_h */
|
||||
|
||||
|
||||
|
||||
|
49
java/xpcom/java/src/org_mozilla_xpcom_Utilities.cpp
Normal file
49
java/xpcom/java/src/org_mozilla_xpcom_Utilities.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "nsISupports.h"
|
||||
#include "org_mozilla_xpcom_Utilities.h"
|
||||
#include "bcIORB.h"
|
||||
#include "bcICall.h"
|
||||
#include "bcDefs.h"
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_xpcom_Utilities
|
||||
* Method: callMethodByIndex
|
||||
* Signature: (JILjava/lang/String;J[Ljava/lang/Object;)Ljava/lang/Object;
|
||||
*/
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_Utilities_callMethodByIndex
|
||||
(JNIEnv *env, jclass clazz, jlong _oid, jint mid, jstring jiid, jlong _orb, jobjectArray) {
|
||||
bcIORB * orb = (bcIORB*) _orb;
|
||||
bcOID oid = (bcOID)_oid;
|
||||
nsIID iid;
|
||||
printf("--[c++] jni %d\n",(int)mid);
|
||||
const char * str = NULL;
|
||||
str = env->GetStringUTFChars(jiid,NULL);
|
||||
iid.Parse(str);
|
||||
env->ReleaseStringUTFChars(jiid,str);
|
||||
bcICall *call = orb->CreateCall(&iid, &oid, mid);
|
||||
orb->SendReceive(call);
|
||||
return NULL;
|
||||
}
|
||||
|
21
java/xpcom/java/src/org_mozilla_xpcom_Utilities.h
Normal file
21
java/xpcom/java/src/org_mozilla_xpcom_Utilities.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_mozilla_xpcom_Utilities */
|
||||
|
||||
#ifndef _Included_org_mozilla_xpcom_Utilities
|
||||
#define _Included_org_mozilla_xpcom_Utilities
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_mozilla_xpcom_Utilities
|
||||
* Method: callMethodByIndex
|
||||
* Signature: (JILjava/lang/String;J[Ljava/lang/Object;)Ljava/lang/Object;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_xpcom_Utilities_callMethodByIndex
|
||||
(JNIEnv *, jclass, jlong, jint, jstring, jlong, jobjectArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
51
java/xpcom/java/test/Makefile.in
Normal file
51
java/xpcom/java/test/Makefile.in
Normal file
@ -0,0 +1,51 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = ../../../..
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = javaSample
|
||||
LIBRARY_NAME = javaSample
|
||||
IS_COMPONENT = 1
|
||||
XPIDLSRCS = bcIJavaSample.idl
|
||||
CPPSRCS = bcJavaSample.cpp
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
bcJavaSample.jar: manifest bcIJavaSample.class bcJavaSample.class
|
||||
$(JDKHOME)/bin/jar cvfm bcJavaSample.jar manifest *.class
|
||||
.java.class:
|
||||
$(JDKHOME)/bin/javac -classpath .:../classes $<
|
||||
install-component: bcJavaSample.jar bcJavaSample.jar.info
|
||||
cp bcJavaSample.jar bcJavaSample.jar.info $(DEPTH)/dist/bin/components/
|
||||
|
||||
clobber-java:
|
||||
rm -f *.class *.jar
|
||||
clobber:: clobber-java
|
||||
clobber_all:: clobber-java
|
||||
install:: install-component
|
||||
|
9
java/xpcom/java/test/bcIJavaSample.idl
Normal file
9
java/xpcom/java/test/bcIJavaSample.idl
Normal file
@ -0,0 +1,9 @@
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(ca1e2656-1dd1-11b2-9c4e-f49ea557abde)]
|
||||
interface bcIJavaSample : nsISupports
|
||||
{
|
||||
void test0();
|
||||
void test1(in long l);
|
||||
void test2(in bcIJavaSample o);
|
||||
};
|
14
java/xpcom/java/test/bcIJavaSample.java
Normal file
14
java/xpcom/java/test/bcIJavaSample.java
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Interface nsISample
|
||||
*
|
||||
* IID: 0xca1e2656-1dd1-11b2-9c4e-f49ea557abde
|
||||
*/
|
||||
|
||||
public interface bcIJavaSample
|
||||
{
|
||||
public static final String BC_IJAVASAMPLE_IID_STRING =
|
||||
"ca1e2656-1dd1-11b2-9c4e-f49ea557abde";
|
||||
void test0();
|
||||
void test1(int l);
|
||||
void test2(bcIJavaSample o);
|
||||
}
|
103
java/xpcom/java/test/bcJavaSample.cpp
Normal file
103
java/xpcom/java/test/bcJavaSample.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "bcIJavaSample.h"
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
|
||||
#define BC_JAVA_SAMPLE_CID \
|
||||
{0x072fa586, 0x1dd2, 0x11b2, \
|
||||
{ 0xb2, 0x3a, 0x81, 0xe8, 0x16, 0x49, 0xe8, 0x8b }}
|
||||
|
||||
#define BC_JAVA_SAMPLE_PROGID "javaSample.cpp"
|
||||
|
||||
|
||||
|
||||
class bcJavaSample : public bcIJavaSample {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_BCIJAVASAMPLE
|
||||
bcJavaSample();
|
||||
virtual ~bcJavaSample();
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(bcJavaSample, bcIJavaSample)
|
||||
|
||||
bcJavaSample::bcJavaSample()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
bcJavaSample::~bcJavaSample()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcJavaSample::Test0()
|
||||
{ printf("--[c++] bcJavaSample::Test0() \n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void test1 (in long l); */
|
||||
NS_IMETHODIMP bcJavaSample::Test1(PRInt32 l)
|
||||
{
|
||||
printf("--[c++] bcJavaSample.test1\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void test2 (in bcIJavaSample o); */
|
||||
NS_IMETHODIMP bcJavaSample::Test2(bcIJavaSample *o)
|
||||
{ printf("--[c++] bcJavaSample.test2\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
void test() {
|
||||
printf("--BlackConnect test start\n");
|
||||
nsresult r;
|
||||
bcIJavaSample *test;
|
||||
bcIJavaSample *a = new bcJavaSample();
|
||||
r = nsComponentManager::CreateInstance("bcJavaSample",
|
||||
nsnull,
|
||||
NS_GET_IID(bcIJavaSample),
|
||||
(void**)&test);
|
||||
//sigsend(P_PID, getpid(),SIGINT);
|
||||
//test->Test1(2000);
|
||||
//test->Test1(1000);
|
||||
test->Test2(a);
|
||||
printf("--BlackConnect test end\n");
|
||||
}
|
||||
|
||||
static int counter = 0; //we do not need to call it on unload time;
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *compMgr,
|
||||
nsIFile *location,
|
||||
nsIModule** result) //I am using it for runnig test *only*
|
||||
{
|
||||
if (counter == 0) {
|
||||
counter ++;
|
||||
printf("--bcJavaSample before test\n");
|
||||
test();
|
||||
printf("--bcJavaSample after test\n");
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
3
java/xpcom/java/test/bcJavaSample.jar.info
Normal file
3
java/xpcom/java/test/bcJavaSample.jar.info
Normal file
@ -0,0 +1,3 @@
|
||||
6b701852-1dd2-11b2-91bd-d3ab05f89834
|
||||
bcJavaSample
|
||||
bcJavaSample
|
73
java/xpcom/java/test/bcJavaSample.java
Normal file
73
java/xpcom/java/test/bcJavaSample.java
Normal file
@ -0,0 +1,73 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
import org.mozilla.xpcom.*;
|
||||
import java.lang.reflect.*;
|
||||
public class bcJavaSample implements bcIJavaSample {
|
||||
public bcJavaSample() {
|
||||
System.out.println("--[java]bcJavaSample constructor");
|
||||
}
|
||||
public void test0() {
|
||||
System.out.println("--[java]bcJavaSample.test0 ");
|
||||
}
|
||||
public void test1(int l) {
|
||||
try {
|
||||
System.out.println("--[java]bcJavaSample.test1 "+l);
|
||||
System.out.println("--[java]bcJavaSample.test1\n :)))) Hey Hong"+l);
|
||||
Object obj = ProxyFactory.getProxy(0,iid,0);
|
||||
if (obj instanceof bcIJavaSample) {
|
||||
bcIJavaSample proxy = (bcIJavaSample)obj;
|
||||
proxy.test2(null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void test2(bcIJavaSample o) {
|
||||
System.out.println("--[java]bcJavaSample.test2");
|
||||
System.out.println("--[java]bcJavaSample.test2 :)))) Hey Hong");
|
||||
if (o != null) {
|
||||
System.out.println("--[java]bcJavaSample.test2 o!= null");
|
||||
o.test0();
|
||||
} else {
|
||||
System.out.println("--[java]bcJavaSample.test2 o== null");
|
||||
}
|
||||
}
|
||||
static IID iid;
|
||||
static {
|
||||
try {
|
||||
Method[] methods = null;
|
||||
Class bcIJavaSampleClass = Class.forName("bcIJavaSample");
|
||||
Method[] javaSampleMethods = bcIJavaSampleClass.getMethods();
|
||||
methods = new Method[3];
|
||||
methods[0] = javaSampleMethods[javaSampleMethods.length-3];
|
||||
methods[1] = javaSampleMethods[javaSampleMethods.length-2];
|
||||
methods[2] = javaSampleMethods[javaSampleMethods.length-1];
|
||||
System.out.println(methods[0]+" "+methods[1]+" "+methods[2]);
|
||||
iid = new IID(bcIJavaSample.BC_IJAVASAMPLE_IID_STRING);
|
||||
|
||||
ProxyFactory.registerInterfaceForIID(bcIJavaSampleClass,iid);
|
||||
new ProxyClass(iid, methods);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
};
|
1
java/xpcom/java/test/manifest
Normal file
1
java/xpcom/java/test/manifest
Normal file
@ -0,0 +1 @@
|
||||
Component-Class: bcJavaSample
|
54
java/xpcom/xpcom/Makefile.in
Normal file
54
java/xpcom/xpcom/Makefile.in
Normal file
@ -0,0 +1,54 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Igor Kushnirskiy <idk@eng.sun.com>
|
||||
#
|
||||
DEPTH = ../../../
|
||||
topsrcdir = $(DEPTH)
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
LIBRARY_NAME = bcxpcomstubs
|
||||
MODULE = bcxpcomstubs
|
||||
IS_COMPONENT = 1
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
CXXFLAGS += -I$(CONNECT_SRC)/public
|
||||
CPPSRCS = \
|
||||
bcXPCOMProxy.cpp bcXPCOMStub.cpp bcXPCOMMarshalToolkit.cpp bcXPCOMStubsAndProxies.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
bcXPCOMStubsAndProxies.h
|
||||
|
||||
LIBS = \
|
||||
-lxpcom \
|
||||
-lxptinfo \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
|
||||
|
||||
|
355
java/xpcom/xpcom/bcXPCOMMarshalToolkit.cpp
Normal file
355
java/xpcom/xpcom/bcXPCOMMarshalToolkit.cpp
Normal file
@ -0,0 +1,355 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "bcXPCOMMarshalToolkit.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "bcORB.h"
|
||||
#include "bcXPCOMStubsAndProxies.h"
|
||||
|
||||
static NS_DEFINE_CID(kORBCIID,BC_ORB_CID);
|
||||
static NS_DEFINE_CID(kXPCOMStubsAndProxies,BC_XPCOMSTUBSANDPROXIES_CID);
|
||||
|
||||
bcXPCOMMarshalToolkit::bcXPCOMMarshalToolkit(PRUint16 _methodIndex, nsIInterfaceInfo *_interfaceInfo,
|
||||
nsXPTCMiniVariant* _params) {
|
||||
callSide = onClient;
|
||||
methodIndex = _methodIndex;
|
||||
interfaceInfo = _interfaceInfo;
|
||||
interfaceInfo->GetMethodInfo(methodIndex,(const nsXPTMethodInfo**) &info); // These do *not* make copies ***explicit bending of XPCOM rules***
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
if (paramCount > 0) {
|
||||
params = (nsXPTCVariant*)malloc(sizeof(nsXPTCVariant) * paramCount);
|
||||
if (params == nsnull) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
(params)[i].Init(_params[i], info->GetParam(i).GetType());
|
||||
if (info->GetParam(i).IsOut()) {
|
||||
params[i].flags |= nsXPTCVariant::PTR_IS_DATA;
|
||||
params[i].ptr = params[i].val.p = _params[i].val.p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bcXPCOMMarshalToolkit::bcXPCOMMarshalToolkit(PRUint16 _methodIndex, nsIInterfaceInfo *_interfaceInfo,
|
||||
nsXPTCVariant* _params) {
|
||||
callSide = onServer;
|
||||
methodIndex = _methodIndex;
|
||||
interfaceInfo = _interfaceInfo;
|
||||
interfaceInfo->GetMethodInfo(methodIndex,(const nsXPTMethodInfo **)&info); // These do *not* make copies ***explicit bending of XPCOM rules***
|
||||
params = _params;
|
||||
}
|
||||
|
||||
bcXPCOMMarshalToolkit::~bcXPCOMMarshalToolkit() {
|
||||
//nb
|
||||
}
|
||||
|
||||
nsresult bcXPCOMMarshalToolkit::Marshal(bcIMarshaler *m) {
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
nsXPTParamInfo param = info->GetParam(i);
|
||||
nsXPTType type = param.GetType();
|
||||
PRBool isOut = param.IsOut();
|
||||
if ((callSide == onClient && !param.IsIn())
|
||||
|| (callSide == onServer && !param.IsOut())) {
|
||||
continue;
|
||||
}
|
||||
nsXPTCVariant *value = & params[i];
|
||||
void *data = (isOut)? value->val.p : value;
|
||||
|
||||
nsresult r;
|
||||
switch(type.TagPart()) {
|
||||
case nsXPTType::T_IID :
|
||||
data = *(char**)data;
|
||||
case nsXPTType::T_I8 :
|
||||
case nsXPTType::T_I16 :
|
||||
case nsXPTType::T_I32 :
|
||||
case nsXPTType::T_I64 :
|
||||
case nsXPTType::T_U8 :
|
||||
case nsXPTType::T_U16 :
|
||||
case nsXPTType::T_U32 :
|
||||
case nsXPTType::T_U64 :
|
||||
case nsXPTType::T_FLOAT :
|
||||
case nsXPTType::T_DOUBLE :
|
||||
case nsXPTType::T_BOOL :
|
||||
case nsXPTType::T_CHAR :
|
||||
case nsXPTType::T_WCHAR :
|
||||
m->WriteSimple(data, XPTType2bcXPType(type.TagPart()));
|
||||
break;
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
data = *(char **)data;
|
||||
m->WriteString(data,strlen((char*)data)+1);
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
{
|
||||
nsIID *iid;
|
||||
if (type.TagPart() == nsXPTType::T_INTERFACE) {
|
||||
if(NS_FAILED(r = interfaceInfo->
|
||||
GetIIDForParam(methodIndex, ¶m, &iid))) {
|
||||
return r;
|
||||
}
|
||||
} else {
|
||||
uint8 argnum;
|
||||
if (NS_FAILED(r = interfaceInfo->GetInterfaceIsArgNumberForParam(methodIndex,
|
||||
¶m, &argnum))) {
|
||||
return r;
|
||||
}
|
||||
const nsXPTParamInfo& arg_param = info->GetParam(argnum);
|
||||
const nsXPTType& arg_type = arg_param.GetType();
|
||||
if(arg_type.IsPointer() &&
|
||||
arg_type.TagPart() == nsXPTType::T_IID) {
|
||||
if(arg_param.IsOut())
|
||||
iid =*((nsID**)params[argnum].val.p);
|
||||
else
|
||||
iid = (nsID*)params[argnum].val.p;
|
||||
}
|
||||
}
|
||||
printf("--[c++]XPCOMMarshallToolkit INTERFACE iid=%s\n",iid->ToString());
|
||||
NS_WITH_SERVICE(bcORB, _orb, kORBCIID, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
return r; //nb am I sure about that?
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(bcXPCOMStubsAndProxies, xpcomStubsAndProxies, kXPCOMStubsAndProxies, &r);
|
||||
if (NS_FAILED(r)) {
|
||||
return r;
|
||||
}
|
||||
|
||||
bcIORB *orb;
|
||||
_orb->GetORB(&orb);
|
||||
bcIStub *stub = NULL;
|
||||
xpcomStubsAndProxies->GetStub(*(nsISupports**)data, &stub);
|
||||
bcOID oid = orb->RegisterStub(stub);
|
||||
m->WriteSimple(&oid, XPTType2bcXPType(type.TagPart()));
|
||||
m->WriteSimple(iid,bc_T_IID);
|
||||
break;
|
||||
}
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
|
||||
break;
|
||||
case nsXPTType::T_ARRAY:
|
||||
{
|
||||
PRUint32 arraySize;
|
||||
if(!GetArraySizeFromParam(interfaceInfo,info,param,methodIndex,i,params,GET_LENGTH, &arraySize)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (type.TagPart() == nsXPTType::T_ARRAY) {
|
||||
nsXPTType datumType;
|
||||
if(NS_FAILED(interfaceInfo->GetTypeForParam(methodIndex, ¶m, 1,&datumType))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
//nb array need to do
|
||||
} else {
|
||||
m->WriteString(data, arraySize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class xpAllocator : public bcIAllocator {
|
||||
public:
|
||||
xpAllocator(nsIAllocator *_allocator) {
|
||||
allocator = _allocator;
|
||||
}
|
||||
virtual ~xpAllocator() {}
|
||||
virtual void * Alloc(size_t size) {
|
||||
return allocator->Alloc(size);
|
||||
}
|
||||
virtual void Free(void *ptr) {
|
||||
allocator->Free(ptr);
|
||||
}
|
||||
virtual void * Realloc(void* ptr, size_t size) {
|
||||
return allocator->Realloc(ptr,size);
|
||||
}
|
||||
private:
|
||||
nsCOMPtr<nsIAllocator> allocator;
|
||||
};
|
||||
|
||||
nsresult bcXPCOMMarshalToolkit::UnMarshal(bcIUnMarshaler *um) {
|
||||
bcIAllocator * allocator = new xpAllocator(nsAllocator::GetGlobalAllocator());
|
||||
PRUint32 paramCount = info->GetParamCount();
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
nsXPTParamInfo param = info->GetParam(i);
|
||||
PRBool isOut = param.IsOut();
|
||||
nsXPTCMiniVariant tmpValue = params[i]; //we need to set value for client side
|
||||
nsXPTCMiniVariant * value;
|
||||
value = &tmpValue;
|
||||
nsXPTType type = param.GetType();
|
||||
|
||||
if (callSide == onServer
|
||||
&& param.IsOut()) { //we need to allocate memory for out parametr
|
||||
value->val.p = allocator->Alloc(sizeof(nsXPTCMiniVariant)); // sizeof(nsXPTCMiniVariant) is good
|
||||
params[i].Init(*value,type);
|
||||
params[i].ptr = params[i].val.p = value->val.p;
|
||||
params[i].flags |= nsXPTCVariant::PTR_IS_DATA;
|
||||
}
|
||||
|
||||
if ( (callSide == onServer && !param.IsIn()
|
||||
|| (callSide == onClient && !param.IsOut()))){
|
||||
continue;
|
||||
}
|
||||
|
||||
void *data = (isOut)? value->val.p : value;
|
||||
switch(type.TagPart()) {
|
||||
case nsXPTType::T_IID :
|
||||
data = *(char**)data;
|
||||
case nsXPTType::T_I8 :
|
||||
case nsXPTType::T_I16 :
|
||||
case nsXPTType::T_I32 :
|
||||
case nsXPTType::T_I64 :
|
||||
case nsXPTType::T_U8 :
|
||||
case nsXPTType::T_U16 :
|
||||
case nsXPTType::T_U32 :
|
||||
case nsXPTType::T_U64 :
|
||||
case nsXPTType::T_FLOAT :
|
||||
case nsXPTType::T_DOUBLE :
|
||||
case nsXPTType::T_BOOL :
|
||||
case nsXPTType::T_CHAR :
|
||||
case nsXPTType::T_WCHAR :
|
||||
um->ReadSimple(data,XPTType2bcXPType(type.TagPart()));
|
||||
break;
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
size_t size;
|
||||
um->ReadString(data,&size,allocator);
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
//nb to do interface
|
||||
break;
|
||||
case nsXPTType::T_ARRAY:
|
||||
{
|
||||
nsXPTType datumType;
|
||||
if(NS_FAILED(interfaceInfo->GetTypeForParam(methodIndex, ¶m, 1,&datumType))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
//nb to do array
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
params[i].Init(*value,type);
|
||||
if (isOut) {
|
||||
params[i].flags |= nsXPTCVariant::PTR_IS_DATA; //nb ?
|
||||
params[i].ptr = params[i].val.p = value->val.p;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult bcXPCOMMarshalToolkit::GetArraySizeFromParam( nsIInterfaceInfo *_interfaceInfo,
|
||||
const nsXPTMethodInfo* method,
|
||||
const nsXPTParamInfo& param,
|
||||
uint16 _methodIndex,
|
||||
uint8 paramIndex,
|
||||
nsXPTCVariant* nativeParams,
|
||||
SizeMode mode,
|
||||
PRUint32* result) {
|
||||
//code borrowed from mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp
|
||||
uint8 argnum;
|
||||
nsresult rv;
|
||||
if(mode == GET_SIZE) {
|
||||
rv = _interfaceInfo->GetSizeIsArgNumberForParam(_methodIndex, ¶m, 0, &argnum);
|
||||
} else {
|
||||
rv = _interfaceInfo->GetLengthIsArgNumberForParam(_methodIndex, ¶m, 0, &argnum);
|
||||
}
|
||||
if(NS_FAILED(rv)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
const nsXPTParamInfo& arg_param = method->GetParam(argnum);
|
||||
const nsXPTType& arg_type = arg_param.GetType();
|
||||
|
||||
// XXX require PRUint32 here - need to require in compiler too!
|
||||
if(arg_type.IsPointer() || arg_type.TagPart() != nsXPTType::T_U32)
|
||||
return PR_FALSE;
|
||||
|
||||
if(arg_param.IsOut())
|
||||
*result = *(PRUint32*)nativeParams[argnum].val.p;
|
||||
else
|
||||
*result = nativeParams[argnum].val.u32;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
bcXPType bcXPCOMMarshalToolkit::XPTType2bcXPType(uint8 type) {
|
||||
switch(type) {
|
||||
case nsXPTType::T_I8 :
|
||||
return bc_T_I8;
|
||||
case nsXPTType::T_U8 :
|
||||
return bc_T_U8;
|
||||
case nsXPTType::T_I16 :
|
||||
return bc_T_I16;
|
||||
case nsXPTType::T_U16 :
|
||||
return bc_T_U16;
|
||||
case nsXPTType::T_I32 :
|
||||
return bc_T_I32;
|
||||
case nsXPTType::T_U32 :
|
||||
return bc_T_U32;
|
||||
case nsXPTType::T_I64 :
|
||||
return bc_T_I64;
|
||||
case nsXPTType::T_U64 :
|
||||
return bc_T_U64;
|
||||
case nsXPTType::T_FLOAT :
|
||||
return bc_T_FLOAT;
|
||||
case nsXPTType::T_DOUBLE :
|
||||
return bc_T_DOUBLE;
|
||||
case nsXPTType::T_BOOL :
|
||||
return bc_T_BOOL;
|
||||
case nsXPTType::T_CHAR :
|
||||
return bc_T_CHAR;
|
||||
case nsXPTType::T_WCHAR :
|
||||
return bc_T_WCHAR;
|
||||
case nsXPTType::T_IID :
|
||||
return bc_T_IID;
|
||||
case nsXPTType::T_CHAR_STR :
|
||||
case nsXPTType::T_PSTRING_SIZE_IS:
|
||||
return bc_T_CHAR_STR;
|
||||
case nsXPTType::T_WCHAR_STR :
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS:
|
||||
return bc_T_WCHAR_STR;
|
||||
case nsXPTType::T_INTERFACE :
|
||||
case nsXPTType::T_INTERFACE_IS :
|
||||
return bc_T_INTERFACE;
|
||||
case nsXPTType::T_ARRAY:
|
||||
return bc_T_ARRAY;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
60
java/xpcom/xpcom/bcXPCOMMarshalToolkit.h
Normal file
60
java/xpcom/xpcom/bcXPCOMMarshalToolkit.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcXPCOMMarshalToolkit_h
|
||||
#define __bcXPCOMMarshalToolkit_h
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "xptcall.h"
|
||||
#include "bcIMarshaler.h"
|
||||
#include "bcIUnMarshaler.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
class bcXPCOMMarshalToolkit {
|
||||
public:
|
||||
bcXPCOMMarshalToolkit(PRUint16 methodIndex,
|
||||
nsIInterfaceInfo *interfaceInfo, nsXPTCMiniVariant* params);
|
||||
bcXPCOMMarshalToolkit(PRUint16 methodIndex,
|
||||
nsIInterfaceInfo *interfaceInfo, nsXPTCVariant* params);
|
||||
virtual ~bcXPCOMMarshalToolkit();
|
||||
nsresult Marshal(bcIMarshaler *);
|
||||
nsresult UnMarshal(bcIUnMarshaler *);
|
||||
private:
|
||||
enum { unDefined, onServer, onClient } callSide;
|
||||
enum SizeMode { GET_SIZE, GET_LENGTH };
|
||||
PRUint16 methodIndex;
|
||||
nsXPTMethodInfo *info;
|
||||
nsXPTCVariant *params;
|
||||
nsIInterfaceInfo * interfaceInfo;
|
||||
nsresult GetArraySizeFromParam( nsIInterfaceInfo *interfaceInfo,
|
||||
const nsXPTMethodInfo* method,
|
||||
const nsXPTParamInfo& param,
|
||||
uint16 methodIndex,
|
||||
uint8 paramIndex,
|
||||
nsXPTCVariant* nativeParams,
|
||||
SizeMode mode,
|
||||
PRUint32* result);
|
||||
bcXPType XPTType2bcXPType(uint8 type); //conversion from xpcom to our own types system
|
||||
};
|
||||
|
||||
#endif /* __XPCOMMarshalToolkit_h */
|
||||
|
89
java/xpcom/xpcom/bcXPCOMProxy.cpp
Normal file
89
java/xpcom/xpcom/bcXPCOMProxy.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
|
||||
#include "bcXPCOMProxy.h"
|
||||
#include "bcXPCOMMarshalToolkit.h"
|
||||
|
||||
#include "unistd.h"
|
||||
#include "signal.h"
|
||||
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcXPCOMProxy, NS_GET_IID(bcXPCOMProxy));
|
||||
|
||||
|
||||
bcXPCOMProxy::bcXPCOMProxy(bcOID _oid, const nsIID &_iid, bcIORB *_orb) {
|
||||
NS_INIT_REFCNT();
|
||||
oid = _oid;
|
||||
iid = _iid;
|
||||
orb = _orb;
|
||||
interfaceInfo = NULL;
|
||||
}
|
||||
|
||||
bcXPCOMProxy::~bcXPCOMProxy() {
|
||||
NS_IF_RELEASE(interfaceInfo);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP bcXPCOMProxy::GetInterfaceInfo(nsIInterfaceInfo** info) {
|
||||
if(!info) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!interfaceInfo) {
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if(iimgr = XPTI_GetInterfaceInfoManager()) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
printf("--bcXPCOMProxy::GetInterfaceInfo failed\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
NS_ADDREF(interfaceInfo);
|
||||
*info = interfaceInfo;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcXPCOMProxy::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* params) {
|
||||
printf("--bcXPCOMProxy::CallMethod %d\n",methodIndex);
|
||||
//sigsend(P_PID, getpid(),SIGINT);
|
||||
bcICall *call = orb->CreateCall(&iid, &oid, methodIndex);
|
||||
bcIMarshaler *marshaler = call->GetMarshaler();
|
||||
bcXPCOMMarshalToolkit * mt = new bcXPCOMMarshalToolkit(methodIndex, interfaceInfo, params);
|
||||
mt->Marshal(marshaler);
|
||||
orb->SendReceive(call);
|
||||
bcIUnMarshaler * unmarshaler = call->GetUnMarshaler();
|
||||
//nb *******
|
||||
delete call; delete marshaler; delete unmarshaler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
55
java/xpcom/xpcom/bcXPCOMProxy.h
Normal file
55
java/xpcom/xpcom/bcXPCOMProxy.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcXPCOMProxy_h
|
||||
#define __bcXPCOMProxy_h
|
||||
|
||||
#include "xptcall.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
|
||||
#include "bcDefs.h"
|
||||
#include "bcIORB.h"
|
||||
|
||||
// {a67aeec0-1dd1-11b2-b4a5-cb39ec760f0d}
|
||||
#define BC_XPCOMPROXY_IID \
|
||||
{ 0xa67aeec0, 0x1dd1, 0x11b2, { 0xb4, 0xa5, 0xcb, 0x39, 0xec, 0x76, 0x0f, 0x0d } }
|
||||
|
||||
class bcXPCOMProxy : public nsXPTCStubBase {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(BC_XPCOMPROXY_IID)
|
||||
NS_DECL_ISUPPORTS
|
||||
bcXPCOMProxy(bcOID oid, const nsIID &iid, bcIORB *orb);
|
||||
virtual ~bcXPCOMProxy();
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
// call this method and return result
|
||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
private:
|
||||
bcOID oid;
|
||||
nsID iid;
|
||||
bcIORB *orb;
|
||||
nsIInterfaceInfo * interfaceInfo;
|
||||
};
|
||||
#endif
|
||||
|
76
java/xpcom/xpcom/bcXPCOMStub.cpp
Normal file
76
java/xpcom/xpcom/bcXPCOMStub.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xptcall.h"
|
||||
#include "bcXPCOMMarshalToolkit.h"
|
||||
#include "bcXPCOMStub.h"
|
||||
|
||||
bcXPCOMStub::bcXPCOMStub(nsISupports *o) {
|
||||
object = o;
|
||||
NS_ADDREF(object);
|
||||
}
|
||||
|
||||
bcXPCOMStub::~bcXPCOMStub() {
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
|
||||
void bcXPCOMStub::Dispatch(bcICall *call) {
|
||||
bcIID iid; bcOID oid; bcMID mid;
|
||||
call->GetParams(&iid, &oid, &mid);
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
nsIInterfaceInfoManager* iimgr;
|
||||
if(iimgr = XPTI_GetInterfaceInfoManager()) {
|
||||
if (NS_FAILED(iimgr->GetInfoForIID(&iid, &interfaceInfo))) {
|
||||
return; //nb exception handling
|
||||
}
|
||||
NS_RELEASE(iimgr);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
nsXPTCVariant *params;
|
||||
nsXPTMethodInfo* info;
|
||||
interfaceInfo->GetMethodInfo(mid,(const nsXPTMethodInfo **)&info);
|
||||
int paramCount = info->GetParamCount();
|
||||
bcXPCOMMarshalToolkit * mt;
|
||||
if (paramCount > 0) {
|
||||
printf("--[c++]bcXPCOMStub paramCount %d\n",paramCount);
|
||||
params = (nsXPTCVariant *) malloc(sizeof(nsXPTCVariant)*paramCount);
|
||||
mt = new bcXPCOMMarshalToolkit(mid, interfaceInfo, params);
|
||||
bcIUnMarshaler * um = call->GetUnMarshaler(); //nb ** to do
|
||||
mt->UnMarshal(um);
|
||||
}
|
||||
//nb return value; excepion handling
|
||||
XPTC_InvokeByIndex(object, mid, paramCount, params);
|
||||
bcIMarshaler * m = call->GetMarshaler(); //nb ** to do
|
||||
mt->Marshal(m);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
37
java/xpcom/xpcom/bcXPCOMStub.h
Normal file
37
java/xpcom/xpcom/bcXPCOMStub.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcXPCOMStub_h
|
||||
#define __bcXPCOMStub_h
|
||||
#include "nsISupports.h"
|
||||
#include "bcIStub.h"
|
||||
|
||||
class bcXPCOMStub : public bcIStub {
|
||||
public:
|
||||
bcXPCOMStub(nsISupports *obj);
|
||||
~bcXPCOMStub();
|
||||
virtual void Dispatch(bcICall *call) ;
|
||||
private:
|
||||
nsISupports *object;
|
||||
};
|
||||
|
||||
#endif
|
72
java/xpcom/xpcom/bcXPCOMStubsAndProxies.cpp
Normal file
72
java/xpcom/xpcom/bcXPCOMStubsAndProxies.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIModule.h"
|
||||
#include "bcXPCOMStubsAndProxies.h"
|
||||
#include "bcXPCOMStub.h"
|
||||
#include "bcXPCOMProxy.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(bcXPCOMStubsAndProxies);
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
"Black Connect XPCOM stubs and proxies",
|
||||
BC_XPCOMSTUBSANDPROXIES_CID,
|
||||
BC_XPCOMSTUBSANDPROXIES_PROGID,
|
||||
bcXPCOMStubsAndProxiesConstructor
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("BlackConnect XPCOM stubs and proxies",components);
|
||||
|
||||
NS_IMPL_ISUPPORTS(bcXPCOMStubsAndProxies,NS_GET_IID(bcXPCOMStubsAndProxies));
|
||||
|
||||
|
||||
bcXPCOMStubsAndProxies::bcXPCOMStubsAndProxies() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
bcXPCOMStubsAndProxies::~bcXPCOMStubsAndProxies() {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcXPCOMStubsAndProxies::GetStub(nsISupports *obj, bcIStub **stub) {
|
||||
if (!stub) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*stub = new bcXPCOMStub(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP bcXPCOMStubsAndProxies::GetProxy(bcOID oid, const nsIID &iid, bcIORB *orb, nsISupports **proxy) {
|
||||
printf("--bcXPCOMStubsAndProxies::GetProxy\n");
|
||||
if (!proxy) {
|
||||
printf("--bcXPCOMStubsAndProxies::GetProxy failed\n");
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*proxy = new bcXPCOMProxy(oid,iid,orb);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
50
java/xpcom/xpcom/bcXPCOMStubsAndProxies.h
Normal file
50
java/xpcom/xpcom/bcXPCOMStubsAndProxies.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* -*- 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):
|
||||
* Igor Kushnirskiy <idk@eng.sun.com>
|
||||
*/
|
||||
|
||||
#ifndef __bcXPCOMStubsAndProxies_h
|
||||
#define __bcXPCOMStubsAndProxies_h
|
||||
#include "nsISupports.h"
|
||||
#include "bcIORB.h"
|
||||
#include "bcIStub.h"
|
||||
|
||||
|
||||
/* 843ff582-1dd2-11b2-84b5-b43ba3ad3ef4 */
|
||||
|
||||
#define BC_XPCOMSTUBSANDPROXIES_IID \
|
||||
{0x843ff582, 0x1dd2, 0x11b2, \
|
||||
{0x84, 0xb5,0xb4, 0x3b, 0xa3, 0xad, 0x3e, 0xf4}}
|
||||
|
||||
#define BC_XPCOMSTUBSANDPROXIES_PROGID "component://netscape/blackwood/blackconnect/xpcom-stubs-and-proxies"
|
||||
|
||||
#define BC_XPCOMSTUBSANDPROXIES_CID \
|
||||
{0x7de11df0, 0x1dd2, 0x11b2, \
|
||||
{0xb1, 0xe1, 0xd9, 0xd5, 0xc6, 0xdd, 0x06, 0x8b }}
|
||||
|
||||
class bcXPCOMStubsAndProxies : public nsISupports {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(BC_XPCOMSTUBSANDPROXIES_IID)
|
||||
NS_IMETHOD GetStub(nsISupports *obj, bcIStub **stub);
|
||||
NS_IMETHOD GetProxy(bcOID oid, const nsIID &iid, bcIORB *orb, nsISupports **proxy);
|
||||
bcXPCOMStubsAndProxies();
|
||||
virtual ~bcXPCOMStubsAndProxies();
|
||||
};
|
||||
#endif /* __bcXPCOMStubsAndProxies_h */
|
Loading…
Reference in New Issue
Block a user