home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / jmcgen / src / Mcfb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  9.0 KB  |  321 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: 16 Apr 1997 08:37:58 GMT
  20.  * netscape/fonts/cfb 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 "Pcfb.h"
  30.  
  31. /* Include other interface headers: */
  32. #include "Mnffbp.h"
  33. #include "Mnffbu.h"
  34.  
  35. /*******************************************************************************
  36.  * cfb Methods
  37.  ******************************************************************************/
  38.  
  39. #ifndef OVERRIDE_cfb_getInterface
  40. JMC_PUBLIC_API(void*)
  41. _cfb_getInterface(struct cfb* self, jint op, const JMCInterfaceID* iid, JMCException* *exc)
  42. {
  43.     if (memcmp(iid, &cfb_ID, sizeof(JMCInterfaceID)) == 0)
  44.         return cfbImpl2cfb(cfb2cfbImpl(self));
  45.     if (memcmp(iid, &nffbp_ID, sizeof(JMCInterfaceID)) == 0)
  46.         return cfbImpl2nffbp(cfb2cfbImpl(self));
  47.     if (memcmp(iid, &nffbu_ID, sizeof(JMCInterfaceID)) == 0)
  48.         return cfbImpl2nffbu(cfb2cfbImpl(self));
  49.     return _cfb_getBackwardCompatibleInterface(self, iid, exc);
  50. }
  51. #endif
  52.  
  53. #ifndef OVERRIDE_cfb_addRef
  54. JMC_PUBLIC_API(void)
  55. _cfb_addRef(struct cfb* self, jint op, JMCException* *exc)
  56. {
  57.     cfbImplHeader* impl = (cfbImplHeader*)cfb2cfbImpl(self);
  58.     impl->refcount++;
  59. }
  60. #endif
  61.  
  62. #ifndef OVERRIDE_cfb_release
  63. JMC_PUBLIC_API(void)
  64. _cfb_release(struct cfb* self, jint op, JMCException* *exc)
  65. {
  66.     cfbImplHeader* impl = (cfbImplHeader*)cfb2cfbImpl(self);
  67.     if (--impl->refcount == 0) {
  68.         cfb_finalize(self, exc);
  69.     }
  70. }
  71. #endif
  72.  
  73. #ifndef OVERRIDE_cfb_hashCode
  74. JMC_PUBLIC_API(jint)
  75. _cfb_hashCode(struct cfb* self, jint op, JMCException* *exc)
  76. {
  77.     return (jint)self;
  78. }
  79. #endif
  80.  
  81. #ifndef OVERRIDE_cfb_equals
  82. JMC_PUBLIC_API(jbool)
  83. _cfb_equals(struct cfb* self, jint op, void* obj, JMCException* *exc)
  84. {
  85.     return self == obj;
  86. }
  87. #endif
  88.  
  89. #ifndef OVERRIDE_cfb_clone
  90. JMC_PUBLIC_API(void*)
  91. _cfb_clone(struct cfb* self, jint op, JMCException* *exc)
  92. {
  93.     cfbImpl* impl = cfb2cfbImpl(self);
  94.     cfbImpl* newImpl = (cfbImpl*)malloc(sizeof(cfbImpl));
  95.     if (newImpl == NULL) return NULL;
  96.     memcpy(newImpl, impl, sizeof(cfbImpl));
  97.     ((cfbImplHeader*)newImpl)->refcount = 1;
  98.     return newImpl;
  99. }
  100. #endif
  101.  
  102. #ifndef OVERRIDE_cfb_toString
  103. JMC_PUBLIC_API(const char*)
  104. _cfb_toString(struct cfb* self, jint op, JMCException* *exc)
  105. {
  106.     return NULL;
  107. }
  108. #endif
  109.  
  110. #ifndef OVERRIDE_cfb_finalize
  111. JMC_PUBLIC_API(void)
  112. _cfb_finalize(struct cfb* self, jint op, JMCException* *exc)
  113. {
  114.     /* Override this method and add your own finalization here. */
  115.     XP_FREEIF(self);
  116. }
  117. #endif
  118.  
  119. /*******************************************************************************
  120.  * nffbp Methods
  121.  ******************************************************************************/
  122.  
  123. JMC_PUBLIC_API(void*)
  124. _cfb_nffbp_getInterface(struct nffbp* self, jint op, const JMCInterfaceID* iid, JMCException* *exc)
  125. {
  126.     return _cfb_getInterface(cfbImpl2cfb(nffbp2cfbImpl(self)), op, iid, exc);
  127. }
  128.  
  129. JMC_PUBLIC_API(void)
  130. _cfb_nffbp_addRef(struct nffbp* self, jint op, JMCException* *exc)
  131. {
  132.     _cfb_addRef(cfbImpl2cfb(nffbp2cfbImpl(self)), op, exc);
  133. }
  134.  
  135. JMC_PUBLIC_API(void)
  136. _cfb_nffbp_release(struct nffbp* self, jint op, JMCException* *exc)
  137. {
  138.     _cfb_release(cfbImpl2cfb(nffbp2cfbImpl(self)), op, exc);
  139. }
  140.  
  141. JMC_PUBLIC_API(jint)
  142. _cfb_nffbp_hashCode(struct nffbp* self, jint op, JMCException* *exc)
  143. {
  144.     return _cfb_hashCode(cfbImpl2cfb(nffbp2cfbImpl(self)), op, exc);
  145. }
  146.  
  147. JMC_PUBLIC_API(jbool)
  148. _cfb_nffbp_equals(struct nffbp* self, jint op, void* other, JMCException* *exc)
  149. {
  150.     return _cfb_equals(cfbImpl2cfb(nffbp2cfbImpl(self)), op, other, exc);
  151. }
  152.  
  153. JMC_PUBLIC_API(void*)
  154. _cfb_nffbp_clone(struct nffbp* self, jint op, JMCException* *exc)
  155. {
  156.     return _cfb_clone(cfbImpl2cfb(nffbp2cfbImpl(self)), op, exc);
  157. }
  158.  
  159. JMC_PUBLIC_API(const char*)
  160. _cfb_nffbp_toString(struct nffbp* self, jint op, JMCException* *exc)
  161. {
  162.     return _cfb_toString(cfbImpl2cfb(nffbp2cfbImpl(self)), op, exc);
  163. }
  164.  
  165. JMC_PUBLIC_API(void)
  166. _cfb_nffbp_finalize(struct nffbp* self, jint op, JMCException* *exc)
  167. {
  168.     _cfb_finalize(cfbImpl2cfb(nffbp2cfbImpl(self)), op, exc);
  169. }
  170.  
  171. /*******************************************************************************
  172.  * nffbu Methods
  173.  ******************************************************************************/
  174.  
  175. JMC_PUBLIC_API(void*)
  176. _cfb_nffbu_getInterface(struct nffbu* self, jint op, const JMCInterfaceID* iid, JMCException* *exc)
  177. {
  178.     return _cfb_getInterface(cfbImpl2cfb(nffbu2cfbImpl(self)), op, iid, exc);
  179. }
  180.  
  181. JMC_PUBLIC_API(void)
  182. _cfb_nffbu_addRef(struct nffbu* self, jint op, JMCException* *exc)
  183. {
  184.     _cfb_addRef(cfbImpl2cfb(nffbu2cfbImpl(self)), op, exc);
  185. }
  186.  
  187. JMC_PUBLIC_API(void)
  188. _cfb_nffbu_release(struct nffbu* self, jint op, JMCException* *exc)
  189. {
  190.     _cfb_release(cfbImpl2cfb(nffbu2cfbImpl(self)), op, exc);
  191. }
  192.  
  193. JMC_PUBLIC_API(jint)
  194. _cfb_nffbu_hashCode(struct nffbu* self, jint op, JMCException* *exc)
  195. {
  196.     return _cfb_hashCode(cfbImpl2cfb(nffbu2cfbImpl(self)), op, exc);
  197. }
  198.  
  199. JMC_PUBLIC_API(jbool)
  200. _cfb_nffbu_equals(struct nffbu* self, jint op, void* other, JMCException* *exc)
  201. {
  202.     return _cfb_equals(cfbImpl2cfb(nffbu2cfbImpl(self)), op, other, exc);
  203. }
  204.  
  205. JMC_PUBLIC_API(void*)
  206. _cfb_nffbu_clone(struct nffbu* self, jint op, JMCException* *exc)
  207. {
  208.     return _cfb_clone(cfbImpl2cfb(nffbu2cfbImpl(self)), op, exc);
  209. }
  210.  
  211. JMC_PUBLIC_API(const char*)
  212. _cfb_nffbu_toString(struct nffbu* self, jint op, JMCException* *exc)
  213. {
  214.     return _cfb_toString(cfbImpl2cfb(nffbu2cfbImpl(self)), op, exc);
  215. }
  216.  
  217. JMC_PUBLIC_API(void)
  218. _cfb_nffbu_finalize(struct nffbu* self, jint op, JMCException* *exc)
  219. {
  220.     _cfb_finalize(cfbImpl2cfb(nffbu2cfbImpl(self)), op, exc);
  221. }
  222.  
  223. /*******************************************************************************
  224.  * Jump Tables
  225.  ******************************************************************************/
  226.  
  227. const struct cfbInterface cfbVtable = {
  228.     _cfb_getInterface,
  229.     _cfb_addRef,
  230.     _cfb_release,
  231.     _cfb_hashCode,
  232.     _cfb_equals,
  233.     _cfb_clone,
  234.     _cfb_toString,
  235.     _cfb_finalize,
  236.     _cfb_LookupFont,
  237.     _cfb_CreateFontFromUrl,
  238.     _cfb_CreateFontFromFile,
  239.     _cfb_ListFonts,
  240.     _cfb_ListSizes,
  241.     _cfb_GetBaseFont
  242. };
  243.  
  244. const struct nffbpInterface nffbpVtable = {
  245.     _cfb_nffbp_getInterface,
  246.     _cfb_nffbp_addRef,
  247.     _cfb_nffbp_release,
  248.     _cfb_nffbp_hashCode,
  249.     _cfb_nffbp_equals,
  250.     _cfb_nffbp_clone,
  251.     _cfb_nffbp_toString,
  252.     _cfb_nffbp_finalize,
  253.     _cfb_nffbp_RegisterFontDisplayer,
  254.     _cfb_nffbp_CreateFontDisplayerFromDLM,
  255.     _cfb_nffbp_ScanForFontDisplayers,
  256.     _cfb_nffbp_RfDone
  257. };
  258.  
  259. const struct nffbuInterface nffbuVtable = {
  260.     _cfb_nffbu_getInterface,
  261.     _cfb_nffbu_addRef,
  262.     _cfb_nffbu_release,
  263.     _cfb_nffbu_hashCode,
  264.     _cfb_nffbu_equals,
  265.     _cfb_nffbu_clone,
  266.     _cfb_nffbu_toString,
  267.     _cfb_nffbu_finalize,
  268.     _cfb_nffbu_CreateFontMatchInfo,
  269.     _cfb_nffbu_CreateRenderingContext,
  270.     _cfb_nffbu_CreateFontObserver,
  271.     _cfb_nffbu_malloc,
  272.     _cfb_nffbu_free,
  273.     _cfb_nffbu_realloc,
  274.     _cfb_nffbu_IsWebfontsEnabled,
  275.     _cfb_nffbu_EnableWebfonts,
  276.     _cfb_nffbu_DisableWebfonts,
  277.     _cfb_nffbu_ListFontDisplayers,
  278.     _cfb_nffbu_IsFontDisplayerEnabled,
  279.     _cfb_nffbu_ListFontDisplayersForMimetype,
  280.     _cfb_nffbu_FontDisplayerForMimetype,
  281.     _cfb_nffbu_EnableFontDisplayer,
  282.     _cfb_nffbu_DisableFontDisplayer,
  283.     _cfb_nffbu_EnableMimetype,
  284.     _cfb_nffbu_DisableMimetype,
  285.     _cfb_nffbu_LoadCatalog,
  286.     _cfb_nffbu_SaveCatalog,
  287.     _cfb_nffbu_LoadWebfont,
  288.     _cfb_nffbu_ReleaseWebfonts,
  289.     _cfb_nffbu_WebfontsNeedReload,
  290.     _cfb_nffbu_LookupFailed,
  291.     _cfb_nffbu_ToUnicode,
  292.     _cfb_nffbu_UnicodeLen
  293. };
  294.  
  295. /*******************************************************************************
  296.  * Factory Operations
  297.  ******************************************************************************/
  298.  
  299. JMC_PUBLIC_API(cfb*)
  300. cfbFactory_Create(JMCException* *exception)
  301. {
  302.     cfbImplHeader* impl = (cfbImplHeader*)XP_NEW_ZAP(cfbImpl);
  303.     cfb* self;
  304.     if (impl == NULL) {
  305.         JMC_EXCEPTION(exception, JMCEXCEPTION_OUT_OF_MEMORY);
  306.         return NULL;
  307.     }
  308.     self = cfbImpl2cfb(impl);
  309.     impl->vtablecfb = &cfbVtable;
  310.     impl->vtablenffbp = &nffbpVtable;
  311.     impl->vtablenffbu = &nffbuVtable;
  312.     impl->refcount = 1;
  313.     _cfb_init(self, exception);
  314.     if (JMC_EXCEPTION_RETURNED(exception)) {
  315.         XP_FREE(impl);
  316.         return NULL;
  317.     }
  318.     return self;
  319. }
  320.  
  321.