home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / jmcgen / src / Mcrc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.3 KB  |  157 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:12 GMT
  20.  * netscape/fonts/crc 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 "Pcrc.h"
  30.  
  31. /* Include other interface headers: */
  32.  
  33. /*******************************************************************************
  34.  * crc Methods
  35.  ******************************************************************************/
  36.  
  37. #ifndef OVERRIDE_crc_getInterface
  38. JMC_PUBLIC_API(void*)
  39. _crc_getInterface(struct crc* self, jint op, const JMCInterfaceID* iid, JMCException* *exc)
  40. {
  41.     if (memcmp(iid, &crc_ID, sizeof(JMCInterfaceID)) == 0)
  42.         return crcImpl2crc(crc2crcImpl(self));
  43.     return _crc_getBackwardCompatibleInterface(self, iid, exc);
  44. }
  45. #endif
  46.  
  47. #ifndef OVERRIDE_crc_addRef
  48. JMC_PUBLIC_API(void)
  49. _crc_addRef(struct crc* self, jint op, JMCException* *exc)
  50. {
  51.     crcImplHeader* impl = (crcImplHeader*)crc2crcImpl(self);
  52.     impl->refcount++;
  53. }
  54. #endif
  55.  
  56. #ifndef OVERRIDE_crc_release
  57. JMC_PUBLIC_API(void)
  58. _crc_release(struct crc* self, jint op, JMCException* *exc)
  59. {
  60.     crcImplHeader* impl = (crcImplHeader*)crc2crcImpl(self);
  61.     if (--impl->refcount == 0) {
  62.         crc_finalize(self, exc);
  63.     }
  64. }
  65. #endif
  66.  
  67. #ifndef OVERRIDE_crc_hashCode
  68. JMC_PUBLIC_API(jint)
  69. _crc_hashCode(struct crc* self, jint op, JMCException* *exc)
  70. {
  71.     return (jint)self;
  72. }
  73. #endif
  74.  
  75. #ifndef OVERRIDE_crc_equals
  76. JMC_PUBLIC_API(jbool)
  77. _crc_equals(struct crc* self, jint op, void* obj, JMCException* *exc)
  78. {
  79.     return self == obj;
  80. }
  81. #endif
  82.  
  83. #ifndef OVERRIDE_crc_clone
  84. JMC_PUBLIC_API(void*)
  85. _crc_clone(struct crc* self, jint op, JMCException* *exc)
  86. {
  87.     crcImpl* impl = crc2crcImpl(self);
  88.     crcImpl* newImpl = (crcImpl*)malloc(sizeof(crcImpl));
  89.     if (newImpl == NULL) return NULL;
  90.     memcpy(newImpl, impl, sizeof(crcImpl));
  91.     ((crcImplHeader*)newImpl)->refcount = 1;
  92.     return newImpl;
  93. }
  94. #endif
  95.  
  96. #ifndef OVERRIDE_crc_toString
  97. JMC_PUBLIC_API(const char*)
  98. _crc_toString(struct crc* self, jint op, JMCException* *exc)
  99. {
  100.     return NULL;
  101. }
  102. #endif
  103.  
  104. #ifndef OVERRIDE_crc_finalize
  105. JMC_PUBLIC_API(void)
  106. _crc_finalize(struct crc* 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 crcInterface crcVtable = {
  118.     _crc_getInterface,
  119.     _crc_addRef,
  120.     _crc_release,
  121.     _crc_hashCode,
  122.     _crc_equals,
  123.     _crc_clone,
  124.     _crc_toString,
  125.     _crc_finalize,
  126.     _crc_GetMajorType,
  127.     _crc_GetMinorType,
  128.     _crc_IsEquivalent,
  129.     _crc_GetPlatformData,
  130.     _crc_SetPlatformData
  131. };
  132.  
  133. /*******************************************************************************
  134.  * Factory Operations
  135.  ******************************************************************************/
  136.  
  137. JMC_PUBLIC_API(crc*)
  138. crcFactory_Create(JMCException* *exception, jint a, jint b, void** c, jsize c_length)
  139. {
  140.     crcImplHeader* impl = (crcImplHeader*)XP_NEW_ZAP(crcImpl);
  141.     crc* self;
  142.     if (impl == NULL) {
  143.         JMC_EXCEPTION(exception, JMCEXCEPTION_OUT_OF_MEMORY);
  144.         return NULL;
  145.     }
  146.     self = crcImpl2crc(impl);
  147.     impl->vtablecrc = &crcVtable;
  148.     impl->refcount = 1;
  149.     _crc_init(self, exception, a, b, c, c_length);
  150.     if (JMC_EXCEPTION_RETURNED(exception)) {
  151.         XP_FREE(impl);
  152.         return NULL;
  153.     }
  154.     return self;
  155. }
  156.  
  157.