/* -*- Mode: C; tab-width: 4; 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.
 */

/*******************************************************************************
 * Source date: 22 Feb 1997 07:07:50 GMT
 * netscape/libimg/PSIMGCB module C stub file
 * Generated by jmc version 1.8 -- DO NOT EDIT
 ******************************************************************************/

#include <stdlib.h>
#include <string.h>
#include "xp_mem.h"

/* Include the implementation-specific header: */
#include "PPSIMGCB.h"

/* Include other interface headers: */

/*******************************************************************************
 * PSIMGCB Methods
 ******************************************************************************/

#ifndef OVERRIDE_PSIMGCB_getInterface
JMC_PUBLIC_API(void*)
_PSIMGCB_getInterface(struct PSIMGCB* self, jint op, const JMCInterfaceID* iid, JMCException* *exc)
{
	if (memcmp(iid, &PSIMGCB_ID, sizeof(JMCInterfaceID)) == 0)
		return PSIMGCBImpl2PSIMGCB(PSIMGCB2PSIMGCBImpl(self));
	return _PSIMGCB_getBackwardCompatibleInterface(self, iid, exc);
}
#endif

#ifndef OVERRIDE_PSIMGCB_addRef
JMC_PUBLIC_API(void)
_PSIMGCB_addRef(struct PSIMGCB* self, jint op, JMCException* *exc)
{
	PSIMGCBImplHeader* impl = (PSIMGCBImplHeader*)PSIMGCB2PSIMGCBImpl(self);
	impl->refcount++;
}
#endif

#ifndef OVERRIDE_PSIMGCB_release
JMC_PUBLIC_API(void)
_PSIMGCB_release(struct PSIMGCB* self, jint op, JMCException* *exc)
{
	PSIMGCBImplHeader* impl = (PSIMGCBImplHeader*)PSIMGCB2PSIMGCBImpl(self);
	if (--impl->refcount == 0) {
		PSIMGCB_finalize(self, exc);
	}
}
#endif

#ifndef OVERRIDE_PSIMGCB_hashCode
JMC_PUBLIC_API(jint)
_PSIMGCB_hashCode(struct PSIMGCB* self, jint op, JMCException* *exc)
{
	return (jint)self;
}
#endif

#ifndef OVERRIDE_PSIMGCB_equals
JMC_PUBLIC_API(jbool)
_PSIMGCB_equals(struct PSIMGCB* self, jint op, void* obj, JMCException* *exc)
{
	return self == obj;
}
#endif

#ifndef OVERRIDE_PSIMGCB_clone
JMC_PUBLIC_API(void*)
_PSIMGCB_clone(struct PSIMGCB* self, jint op, JMCException* *exc)
{
	PSIMGCBImpl* impl = PSIMGCB2PSIMGCBImpl(self);
	PSIMGCBImpl* newImpl = (PSIMGCBImpl*)malloc(sizeof(PSIMGCBImpl));
	if (newImpl == NULL) return NULL;
	memcpy(newImpl, impl, sizeof(PSIMGCBImpl));
	((PSIMGCBImplHeader*)newImpl)->refcount = 1;
	return newImpl;
}
#endif

#ifndef OVERRIDE_PSIMGCB_toString
JMC_PUBLIC_API(const char*)
_PSIMGCB_toString(struct PSIMGCB* self, jint op, JMCException* *exc)
{
	return NULL;
}
#endif

#ifndef OVERRIDE_PSIMGCB_finalize
JMC_PUBLIC_API(void)
_PSIMGCB_finalize(struct PSIMGCB* self, jint op, JMCException* *exc)
{
	/* Override this method and add your own finalization here. */
	XP_FREEIF(self);
}
#endif

/*******************************************************************************
 * Jump Tables
 ******************************************************************************/

const struct PSIMGCBInterface PSIMGCBVtable = {
	_PSIMGCB_getInterface,
	_PSIMGCB_addRef,
	_PSIMGCB_release,
	_PSIMGCB_hashCode,
	_PSIMGCB_equals,
	_PSIMGCB_clone,
	_PSIMGCB_toString,
	_PSIMGCB_finalize,
	_PSIMGCB_NewPixmap,
	_PSIMGCB_UpdatePixmap,
	_PSIMGCB_ControlPixmapBits,
	_PSIMGCB_DestroyPixmap,
	_PSIMGCB_DisplayPixmap,
	_PSIMGCB_DisplayIcon,
	_PSIMGCB_GetIconDimensions
};

/*******************************************************************************
 * Factory Operations
 ******************************************************************************/

JMC_PUBLIC_API(PSIMGCB*)
PSIMGCBFactory_Create(JMCException* *exception)
{
	PSIMGCBImplHeader* impl = (PSIMGCBImplHeader*)XP_NEW_ZAP(PSIMGCBImpl);
	PSIMGCB* self;
	if (impl == NULL) {
		JMC_EXCEPTION(exception, JMCEXCEPTION_OUT_OF_MEMORY);
		return NULL;
	}
	self = PSIMGCBImpl2PSIMGCB(impl);
	impl->vtablePSIMGCB = &PSIMGCBVtable;
	impl->refcount = 1;
	_PSIMGCB_init(self, exception);
	if (JMC_EXCEPTION_RETURNED(exception)) {
		XP_FREE(impl);
		return NULL;
	}
	return self;
}

