This commit is contained in:
rjc%netscape.com 1999-02-26 02:14:51 +00:00
Родитель d24631f345
Коммит 434f71e75d
11 изменённых файлов: 795 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,10 @@
interface RDFCore : BaseAppCore
{
/* IID: { 0xdf365f00, 0xcc53, 0x11d2, \
{ 0x8f, 0xdf, 0x0, 0x08, 0xc7, 0x0a, 0xdc, 0x7b } } */
void RDFCore();
void doSort(in Node node, in DOMString sortResource);
};

Двоичные данные
xpfe/AppCores/macbuild/AppCores.mcp

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#ifndef nsIDOMRDFCore_h__
#define nsIDOMRDFCore_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
#include "nsIDOMBaseAppCore.h"
class nsIDOMNode;
#define NS_IDOMRDFCORE_IID \
{ 0xdf365f00, 0xcc53, 0x11d2, \
{ 0x8f, 0xdf, 0x0, 0x08, 0xc7, 0x0a, 0xdc, 0x7b } }
class nsIDOMRDFCore : public nsIDOMBaseAppCore {
public:
static const nsIID& IID() { static nsIID iid = NS_IDOMRDFCORE_IID; return iid; }
NS_IMETHOD DoSort(nsIDOMNode* aNode, const nsString& aSortResource)=0;
};
#define NS_DECL_IDOMRDFCORE \
NS_IMETHOD DoSort(nsIDOMNode* aNode, const nsString& aSortResource); \
#define NS_FORWARD_IDOMRDFCORE(_to) \
NS_IMETHOD DoSort(nsIDOMNode* aNode, const nsString& aSortResource) { return _to##DoSort(aNode, aSortResource); } \
extern "C" NS_DOM nsresult NS_InitRDFCoreClass(nsIScriptContext *aContext, void **aPrototype);
extern "C" NS_DOM nsresult NS_NewScriptRDFCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
#endif // nsIDOMRDFCore_h__

Просмотреть файл

@ -30,6 +30,8 @@ MODULE=raptor
CPPSRCS= \
nsBaseAppCore.cpp \
nsMailCore.cpp \
nsRDFCore.cpp \
nsRDFCoreFactory.cpp \
nsAppCoresNameSet.cpp \
nsEditorAppCore.cpp \
nsEditorAppCoreFactory.cpp \
@ -47,6 +49,7 @@ CPPSRCS= \
nsJSAppCoresManager.cpp \
nsJSEditorAppCore.cpp \
nsJSMailCore.cpp \
nsJSRDFCore.cpp \
nsJSToolbarCore.cpp \
nsJSToolkitCore.cpp \
nsJSBrowserAppCore.cpp \

Просмотреть файл

@ -61,6 +61,8 @@ LLIBS = \
OBJS = \
.\$(OBJDIR)\nsBaseAppCore.obj \
.\$(OBJDIR)\nsMailCore.obj \
.\$(OBJDIR)\nsRDFCore.obj \
.\$(OBJDIR)\nsRDFCoreFactory.obj \
.\$(OBJDIR)\nsAppCoresNameSet.obj \
.\$(OBJDIR)\nsToolbarCore.obj \
.\$(OBJDIR)\nsToolkitCore.obj \
@ -74,6 +76,7 @@ OBJS = \
.\$(OBJDIR)\nsJSBaseAppCore.obj \
.\$(OBJDIR)\nsJSAppCoresManager.obj \
.\$(OBJDIR)\nsJSMailCore.obj \
.\$(OBJDIR)\nsJSRDFCore.obj \
.\$(OBJDIR)\nsJSToolbarCore.obj \
.\$(OBJDIR)\nsJSToolkitCore.obj \
.\$(OBJDIR)\nsJSBrowserAppCore.obj \

Просмотреть файл

@ -27,6 +27,7 @@
#include "nsIDOMAppCoresManager.h"
#include "nsIDOMToolkitCore.h"
#include "nsIDOMMailCore.h"
#include "nsIDOMRDFCore.h"
#include "nsIDOMToolbarCore.h"
#include "nsIDOMBrowserAppCore.h"
#include "nsIDOMEditorAppCore.h"
@ -37,6 +38,7 @@ static NS_DEFINE_IID(kIScriptExternalNameSetIID, NS_ISCRIPTEXTERNALNAMESET_IID);
static NS_DEFINE_IID(kAppCoresCID, NS_APPCORESMANAGER_CID);
static NS_DEFINE_IID(kToolkitCoreCID, NS_TOOLKITCORE_CID);
static NS_DEFINE_IID(kMailCoreCID, NS_MAILCORE_CID);
static NS_DEFINE_IID(kRDFCoreCID, NS_RDFCORE_CID);
static NS_DEFINE_IID(kToolbarCoreCID, NS_TOOLBARCORE_CID);
static NS_DEFINE_IID(kBrowserAppCoreCID, NS_BROWSERAPPCORE_CID);
static NS_DEFINE_IID(kEditorAppCoreCID, NS_EDITORAPPCORE_CID);
@ -68,6 +70,7 @@ nsAppCoresNameSet::InitializeClasses(nsIScriptContext* aScriptContext)
result = NS_InitBrowserAppCoreClass(aScriptContext, nsnull);
result = NS_InitEditorAppCoreClass(aScriptContext, nsnull);
result = NS_InitToolkitCoreClass(aScriptContext, nsnull);
result = NS_InitRDFCoreClass(aScriptContext, nsnull);
return result;
}
@ -90,6 +93,12 @@ nsAppCoresNameSet::AddNameSet(nsIScriptContext* aScriptContext)
if (NS_OK != result) return result;
result = manager->RegisterGlobalName("RDFCore",
kRDFCoreCID,
PR_TRUE);
if (NS_OK != result) return result;
result = manager->RegisterGlobalName("ToolbarCore",
kToolbarCoreCID,
PR_TRUE);

Просмотреть файл

@ -0,0 +1,362 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nsJSUtils.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsIJSScriptObject.h"
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMNode.h"
#include "nsIDOMRDFCore.h"
#include "nsIScriptNameSpaceManager.h"
#include "nsRepository.h"
#include "nsDOMCID.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kIRDFCoreIID, NS_IDOMRDFCORE_IID);
NS_DEF_PTR(nsIDOMNode);
NS_DEF_PTR(nsIDOMRDFCore);
/***********************************************************************/
//
// RDFCore Properties Getter
//
PR_STATIC_CALLBACK(JSBool)
GetRDFCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMRDFCore *a = (nsIDOMRDFCore*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
}
}
else {
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
}
return PR_TRUE;
}
/***********************************************************************/
//
// RDFCore Properties Setter
//
PR_STATIC_CALLBACK(JSBool)
SetRDFCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMRDFCore *a = (nsIDOMRDFCore*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0:
default:
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
}
}
else {
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
}
return PR_TRUE;
}
//
// RDFCore finalizer
//
PR_STATIC_CALLBACK(void)
FinalizeRDFCore(JSContext *cx, JSObject *obj)
{
nsJSUtils::nsGenericFinalize(cx, obj);
}
//
// RDFCore enumerate
//
PR_STATIC_CALLBACK(JSBool)
EnumerateRDFCore(JSContext *cx, JSObject *obj)
{
return nsJSUtils::nsGenericEnumerate(cx, obj);
}
//
// RDFCore resolve
//
PR_STATIC_CALLBACK(JSBool)
ResolveRDFCore(JSContext *cx, JSObject *obj, jsval id)
{
return nsJSUtils::nsGenericResolve(cx, obj, id);
}
//
// Native method DoSort
//
PR_STATIC_CALLBACK(JSBool)
RDFCoreDoSort(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMRDFCore *nativeThis = (nsIDOMRDFCore*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMNodePtr b0;
nsAutoString b1;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 2) {
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
kINodeIID,
"Node",
cx,
argv[0])) {
return JS_FALSE;
}
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
if (NS_OK != nativeThis->DoSort(b0, b1)) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function doSort requires 2 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for RDFCore
//
JSClass RDFCoreClass = {
"RDFCore",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
GetRDFCoreProperty,
SetRDFCoreProperty,
EnumerateRDFCore,
ResolveRDFCore,
JS_ConvertStub,
FinalizeRDFCore
};
//
// RDFCore class properties
//
static JSPropertySpec RDFCoreProperties[] =
{
{0}
};
//
// RDFCore class methods
//
static JSFunctionSpec RDFCoreMethods[] =
{
{"doSort", RDFCoreDoSort, 2},
{0}
};
//
// RDFCore constructor
//
PR_STATIC_CALLBACK(JSBool)
RDFCore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsresult result;
nsIID classID;
nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx);
nsIScriptNameSpaceManager* manager;
nsIDOMRDFCore *nativeThis;
nsIScriptObjectOwner *owner = nsnull;
static NS_DEFINE_IID(kIDOMRDFCoreIID, NS_IDOMRDFCORE_IID);
result = context->GetNameSpaceManager(&manager);
if (NS_OK != result) {
return JS_FALSE;
}
result = manager->LookupName("RDFCore", PR_TRUE, classID);
NS_RELEASE(manager);
if (NS_OK != result) {
return JS_FALSE;
}
result = nsRepository::CreateInstance(classID,
nsnull,
kIDOMRDFCoreIID,
(void **)&nativeThis);
if (NS_OK != result) {
return JS_FALSE;
}
// XXX We should be calling Init() on the instance
result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner);
if (NS_OK != result) {
NS_RELEASE(nativeThis);
return JS_FALSE;
}
owner->SetScriptObject((void *)obj);
JS_SetPrivate(cx, obj, nativeThis);
NS_RELEASE(owner);
return JS_TRUE;
}
//
// RDFCore class initialization
//
extern "C" NS_DOM nsresult NS_InitRDFCoreClass(nsIScriptContext *aContext, void **aPrototype)
{
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
JSObject *proto = nsnull;
JSObject *constructor = nsnull;
JSObject *parent_proto = nsnull;
JSObject *global = JS_GetGlobalObject(jscontext);
jsval vp;
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "RDFCore", &vp)) ||
!JSVAL_IS_OBJECT(vp) ||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
!JSVAL_IS_OBJECT(vp)) {
if (NS_OK != NS_InitBaseAppCoreClass(aContext, (void **)&parent_proto)) {
return NS_ERROR_FAILURE;
}
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&RDFCoreClass, // JSClass
RDFCore, // JSNative ctor
0, // ctor args
RDFCoreProperties, // proto props
RDFCoreMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
return NS_ERROR_FAILURE;
}
}
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
proto = JSVAL_TO_OBJECT(vp);
}
else {
return NS_ERROR_FAILURE;
}
if (aPrototype) {
*aPrototype = proto;
}
return NS_OK;
}
//
// Method for creating a new RDFCore JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptRDFCore(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptRDFCore");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
nsresult result = NS_OK;
nsIDOMRDFCore *aRDFCore;
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitRDFCoreClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
result = aSupports->QueryInterface(kIRDFCoreIID, (void **)&aRDFCore);
if (NS_OK != result) {
return result;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &RDFCoreClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aRDFCore);
}
else {
NS_RELEASE(aRDFCore);
return NS_ERROR_FAILURE;
}
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,161 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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 Communicator client 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.
*/
#include "nsRDFCore.h"
#include "nsIBrowserWindow.h"
#include "nsIWebShell.h"
#include "pratom.h"
#include "nsRepository.h"
#include "nsAppCores.h"
#include "nsAppCoresCIDs.h"
#include "nsAppCoresManager.h"
#include "nsIScriptContext.h"
#include "nsIScriptContextOwner.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIDOMWindow.h"
// Globals
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIRDFCoreIID, NS_IDOMRDFCORE_IID);
static NS_DEFINE_IID(kIDOMDocumentIID, nsIDOMDocument::IID());
static NS_DEFINE_IID(kIDocumentIID, nsIDocument::IID());
static NS_DEFINE_IID(kRDFCoreCID, NS_RDFCORE_CID);
static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
/////////////////////////////////////////////////////////////////////////
// nsRDFCore
/////////////////////////////////////////////////////////////////////////
nsRDFCore::nsRDFCore()
{
printf("Created nsRDFCore\n");
mScriptObject = nsnull;
mScriptContext = nsnull;
/*
mWindow = nsnull;
*/
IncInstanceCount();
NS_INIT_REFCNT();
}
nsRDFCore::~nsRDFCore()
{
NS_IF_RELEASE(mScriptContext);
/*
NS_IF_RELEASE(mWindow);
*/
DecInstanceCount();
}
NS_IMPL_ADDREF(nsRDFCore)
NS_IMPL_RELEASE(nsRDFCore)
NS_IMETHODIMP
nsRDFCore::QueryInterface(REFNSIID aIID,void** aInstancePtr)
{
if (aInstancePtr == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aInstancePtr = NULL;
printf("About to compare RDFCOREIIDs\n");
if ( aIID.Equals(kIRDFCoreIID) ) {
*aInstancePtr = (void*) ((nsIDOMRDFCore*)this);
AddRef();
return NS_OK;
}
printf("RDFCOREIIDs did not matched.\n");
return nsBaseAppCore::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
nsRDFCore::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
{
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
nsresult res = NS_OK;
if (nsnull == mScriptObject)
{
res = NS_NewScriptRDFCore(aContext,
(nsISupports *)(nsIDOMRDFCore*)this,
nsnull,
&mScriptObject);
}
*aScriptObject = mScriptObject;
return res;
}
NS_IMETHODIMP
nsRDFCore::Init(const nsString& aId)
{
nsBaseAppCore::Init(aId);
nsAppCoresManager* sdm = new nsAppCoresManager();
sdm->Add((nsIDOMBaseAppCore *)(nsBaseAppCore *)this);
delete sdm;
return NS_OK;
}
NS_IMETHODIMP
nsRDFCore::DoSort(nsIDOMNode* node, const nsString& sortResource)
{
printf("nsRDFCore::DoSort entered!!!\n");
/*
if (nsnull == mScriptContext) {
return NS_ERROR_FAILURE;
}
*/
printf("----------------------------\n");
printf("-- Sort \n");
printf("----------------------------\n");
printf("Column: %s \n", sortResource.ToNewCString());
printf("----------------------------\n");
/*
if (nsnull != mScriptContext) {
const char* url = "";
PRBool isUndefined = PR_FALSE;
nsString rVal;
mScriptContext->EvaluateString(mScript, url, 0, rVal, &isUndefined);
}
*/
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsRDFCorePrivate_h___
#define nsRDFCorePrivate_h___
//#include "nsAppCores.h"
#include "nscore.h"
#include "nsString.h"
#include "nsISupports.h"
#include "nsIDOMRDFCore.h"
#include "nsBaseAppCore.h"
class nsIScriptContext;
class nsIDOMNode;
////////////////////////////////////////////////////////////////////////////////
// nsRDFCore:
////////////////////////////////////////////////////////////////////////////////
class nsRDFCore : public nsBaseAppCore,
public nsIDOMRDFCore
{
public:
nsRDFCore();
virtual ~nsRDFCore();
NS_DECL_ISUPPORTS
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
NS_IMETHOD Init(const nsString& aId);
NS_IMETHOD GetId(nsString& aId) { return nsBaseAppCore::GetId(aId); }
NS_IMETHOD DoSort(nsIDOMNode* node, const nsString& sortResource);
protected:
nsString mScript;
nsIScriptContext *mScriptContext;
};
#endif // nsRDFCore_h___

Просмотреть файл

@ -0,0 +1,131 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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 Communicator client 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.
*/
#include "nsAppCores.h"
#include "nsRDFCoreFactory.h"
#include "nsRDFCore.h"
#include "pratom.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
/////////////////////////////////////////////////////////////////////////
// nsRDFCoreFactory
/////////////////////////////////////////////////////////////////////////
nsRDFCoreFactory::nsRDFCoreFactory(void)
{
mRefCnt=0;
IncInstanceCount();
}
nsRDFCoreFactory::~nsRDFCoreFactory(void)
{
DecInstanceCount();
}
NS_IMETHODIMP
nsRDFCoreFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr)
{
if (aInstancePtr == NULL)
{
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aInstancePtr = NULL;
if ( aIID.Equals(kISupportsIID) )
{
*aInstancePtr = (void*) this;
}
else if ( aIID.Equals(kIFactoryIID) )
{
*aInstancePtr = (void*) this;
}
if (aInstancePtr == NULL)
{
return NS_ERROR_NO_INTERFACE;
}
AddRef();
return NS_OK;
}
NS_IMETHODIMP
nsRDFCoreFactory::AddRef(void)
{
return ++mRefCnt;
}
NS_IMETHODIMP
nsRDFCoreFactory::Release(void)
{
if (--mRefCnt ==0)
{
// delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}
NS_IMETHODIMP
nsRDFCoreFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aResult == NULL)
{
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
/* do I have to use iSupports? */
nsRDFCore *inst = new nsRDFCore();
if (inst == NULL)
return NS_ERROR_OUT_OF_MEMORY;
nsresult result = inst->QueryInterface(aIID, aResult);
if (result != NS_OK)
delete inst;
return result;
}
NS_IMETHODIMP
nsRDFCoreFactory::LockFactory(PRBool aLock)
{
if (aLock)
IncLockCount();
else
DecLockCount();
return NS_OK;
}

Просмотреть файл