home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / jmcgen / src / Mcfp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.5 KB  |  165 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*******************************************************************************
  19.  * Source date: 9 Apr 1997 21:45:13 GMT
  20.  * netscape/fonts/cfp module C stub file
  21.  * Generated by jmc version 1.8 -- DO NOT EDIT
  22.  ******************************************************************************/
  23.  
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include "xp_mem.h"
  27.  
  28. /* Include the implementation-specific header: */
  29. #include "Pcfp.h"
  30.  
  31. /* Include other interface headers: */
  32.  
  33. /*******************************************************************************
  34.  * cfp Methods
  35.  ******************************************************************************/
  36.  
  37. #ifndef OVERRIDE_cfp_getInterface
  38. JMC_PUBLIC_API(void*)
  39. _cfp_getInterface(struct cfp* self, jint op, const JMCInterfaceID* iid, JMCException* *exc)
  40. {
  41.     if (memcmp(iid, &cfp_ID, sizeof(JMCInterfaceID)) == 0)
  42.         return cfpImpl2cfp(cfp2cfpImpl(self));
  43.     return _cfp_getBackwardCompatibleInterface(self, iid, exc);
  44. }
  45. #endif
  46.  
  47. #ifndef OVERRIDE_cfp_addRef
  48. JMC_PUBLIC_API(void)
  49. _cfp_addRef(struct cfp* self, jint op, JMCException* *exc)
  50. {
  51.     cfpImplHeader* impl = (cfpImplHeader*)cfp2cfpImpl(self);
  52.     impl->refcount++;
  53. }
  54. #endif
  55.  
  56. #ifndef OVERRIDE_cfp_release
  57. JMC_PUBLIC_API(void)
  58. _cfp_release(struct cfp* self, jint op, JMCException* *exc)
  59. {
  60.     cfpImplHeader* impl = (cfpImplHeader*)cfp2cfpImpl(self);
  61.     if (--impl->refcount == 0) {
  62.         cfp_finalize(self, exc);
  63.     }
  64. }
  65. #endif
  66.  
  67. #ifndef OVERRIDE_cfp_hashCode
  68. JMC_PUBLIC_API(jint)
  69. _cfp_hashCode(struct cfp* self, jint op, JMCException* *exc)
  70. {
  71.     return (jint)self;
  72. }
  73. #endif
  74.  
  75. #ifndef OVERRIDE_cfp_equals
  76. JMC_PUBLIC_API(jbool)
  77. _cfp_equals(struct cfp* self, jint op, void* obj, JMCException* *exc)
  78. {
  79.     return self == obj;
  80. }
  81. #endif
  82.  
  83. #ifndef OVERRIDE_cfp_clone
  84. JMC_PUBLIC_API(void*)
  85. _cfp_clone(struct cfp* self, jint op, JMCException* *exc)
  86. {
  87.     cfpImpl* impl = cfp2cfpImpl(self);
  88.     cfpImpl* newImpl = (cfpImpl*)malloc(sizeof(cfpImpl));
  89.     if (newImpl == NULL) return NULL;
  90.     memcpy(newImpl, impl, sizeof(cfpImpl));
  91.     ((cfpImplHeader*)newImpl)->refcount = 1;
  92.     return newImpl;
  93. }
  94. #endif
  95.  
  96. #ifndef OVERRIDE_cfp_toString
  97. JMC_PUBLIC_API(const char*)
  98. _cfp_toString(struct cfp* self, jint op, JMCException* *exc)
  99. {
  100.     return NULL;
  101. }
  102. #endif
  103.  
  104. #ifndef OVERRIDE_cfp_finalize
  105. JMC_PUBLIC_API(void)
  106. _cfp_finalize(struct cfp* self, jint op, JMCException* *exc)
  107. {
  108.     /* Override this method and add your own finalization here. */
  109.     XP_FREEIF(self);
  110. }
  111. #endif
  112.  
  113. /*******************************************************************************
  114.  * Jump Tables
  115.  ******************************************************************************/
  116.  
  117. const struct cfpInterface cfpVtable = {
  118.     _cfp_getInterface,
  119.     _cfp_addRef,
  120.     _cfp_release,
  121.     _cfp_hashCode,
  122.     _cfp_equals,
  123.     _cfp_clone,
  124.     _cfp_toString,
  125.     _cfp_finalize,
  126.     _cfp_LookupFont,
  127.     _cfp_CreateFontFromFile,
  128.     _cfp_CreateFontStreamHandler,
  129.     _cfp_EnumerateSizes,
  130.     _cfp_ReleaseFontHandle,
  131.     _cfp_GetMatchInfo,
  132.     _cfp_GetRenderableFont,
  133.     _cfp_Name,
  134.     _cfp_Description,
  135.     _cfp_EnumerateMimeTypes,
  136.     _cfp_ListFonts,
  137.     _cfp_ListSizes,
  138.     _cfp_CacheFontInfo
  139. };
  140.  
  141. /*******************************************************************************
  142.  * Factory Operations
  143.  ******************************************************************************/
  144.  
  145. JMC_PUBLIC_API(cfp*)
  146. cfpFactory_Create(JMCException* *exception, struct nffbp* a)
  147. {
  148.     cfpImplHeader* impl = (cfpImplHeader*)XP_NEW_ZAP(cfpImpl);
  149.     cfp* self;
  150.     if (impl == NULL) {
  151.         JMC_EXCEPTION(exception, JMCEXCEPTION_OUT_OF_MEMORY);
  152.         return NULL;
  153.     }
  154.     self = cfpImpl2cfp(impl);
  155.     impl->vtablecfp = &cfpVtable;
  156.     impl->refcount = 1;
  157.     _cfp_init(self, exception, a);
  158.     if (JMC_EXCEPTION_RETURNED(exception)) {
  159.         XP_FREE(impl);
  160.         return NULL;
  161.     }
  162.     return self;
  163. }
  164.  
  165.