home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / src / crc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.0 KB  |  162 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.  * crc.cpp
  20.  *
  21.  * Implements a link between the (crc) CRenderingContext Interface
  22.  * implementation and its C++ implementation viz (rc) RenderingContextObject.
  23.  *
  24.  * dp Suresh <dp@netscape.com>
  25.  */
  26.  
  27. #include "libfont.h"
  28.  
  29. #include "Mcrc.h"
  30. #include "Pcrc.h"
  31. #include "rc.h"
  32.  
  33. /****************************************************************************
  34.  *                 Implementation of common interface methods                    *
  35.  ****************************************************************************/
  36.  
  37. #ifdef OVERRIDE_crc_getInterface
  38. #include "Mnfrc.h"
  39.  
  40. extern "C" JMC_PUBLIC_API(void*)
  41. /* ARGSUSED */
  42. _crc_getInterface(struct crc* self, jint op, const JMCInterfaceID* iid, JMCException* *exc)
  43. {
  44.     if (memcmp(iid, &nfrc_ID, sizeof(JMCInterfaceID)) == 0)
  45.         return crcImpl2crc(crc2crcImpl(self));
  46.     return _crc_getBackwardCompatibleInterface(self, iid, exc);
  47. }
  48. #endif /* OVERRIDE_crc_getInterface */
  49.  
  50. extern "C" JMC_PUBLIC_API(void*)
  51. /*ARGSUSED*/
  52. _crc_getBackwardCompatibleInterface(struct crc* self,
  53.                                     const JMCInterfaceID* iid,
  54.                                     struct JMCException* *exceptionThrown)
  55. {
  56.     return(NULL);
  57. }
  58.  
  59. extern "C" JMC_PUBLIC_API(void)
  60. /*ARGSUSED*/
  61. _crc_init(struct crc* self, struct JMCException* *exceptionThrown,
  62.           jint majorType, jint minorType, void** args, jsize args_length)
  63. {
  64.     crcImpl *oimpl = crc2crcImpl(self);
  65.     RenderingContextObject *rcob = (RenderingContextObject *)oimpl->object;
  66.     rcob = new RenderingContextObject(majorType, minorType, args, args_length);
  67.     if (rcob == NULL)
  68.       {
  69.         JMC_EXCEPTION(exceptionThrown, JMCEXCEPTION_OUT_OF_MEMORY);
  70.       }
  71.     else
  72.       {
  73.         oimpl->object = rcob;
  74.       }
  75. }
  76.  
  77. #ifdef OVERRIDE_crc_finalize
  78. extern "C" JMC_PUBLIC_API(void)
  79. /*ARGSUSED*/
  80. _crc_finalize(struct crc* self, jint op, JMCException* *exception)
  81. {
  82.     struct crcImpl *oimpl = crc2crcImpl(self);
  83.     RenderingContextObject *rcob = (RenderingContextObject *)oimpl->object;
  84.     delete rcob;
  85.     
  86.     /* Finally, free the memory for the object containter. */
  87.     XP_FREEIF(self);
  88. }
  89. #endif /* OVERRIDE_crc_finalize */
  90.  
  91.  
  92. /****************************************************************************
  93.  *                 Implementation of Object specific methods                    *
  94.  ****************************************************************************/
  95.  
  96. extern "C" JMC_PUBLIC_API(jint)
  97. /*ARGSUSED*/
  98. _crc_GetMajorType(struct crc* self, jint op,
  99.                   struct JMCException* *exceptionThrown)
  100. {
  101.     crcImpl *oimpl = crc2crcImpl(self);
  102.     XP_ASSERT(oimpl->header.refcount);
  103.     RenderingContextObject *rcob = (RenderingContextObject *)oimpl->object;
  104.     return(rcob->GetMajorType());
  105. }
  106.  
  107. extern "C" JMC_PUBLIC_API(jint)
  108. /*ARGSUSED*/
  109. _crc_GetMinorType(struct crc* self, jint op,
  110.                   struct JMCException* *exceptionThrown)
  111. {
  112.     crcImpl *oimpl = crc2crcImpl(self);
  113.     XP_ASSERT(oimpl->header.refcount);
  114.     RenderingContextObject *rcob = (RenderingContextObject *)oimpl->object;
  115.     return(rcob->GetMinorType());
  116. }
  117.  
  118. extern "C" JMC_PUBLIC_API(jint)
  119. /*ARGSUSED*/
  120. _crc_IsEquivalent(struct crc* self, jint op, jint majorType, jint minorType,
  121.                   struct JMCException* *exceptionThrown)
  122. {
  123.     crcImpl *oimpl = crc2crcImpl(self);
  124.     XP_ASSERT(oimpl->header.refcount);
  125.     RenderingContextObject *rcob = (RenderingContextObject *)oimpl->object;
  126.     return(rcob->IsEquivalent(majorType, minorType));
  127. }
  128.  
  129. extern "C" JMC_PUBLIC_API(struct rc_data)
  130. /*ARGSUSED*/
  131. _crc_GetPlatformData(struct crc* self, jint op,
  132.                      struct JMCException* *exceptionThrown)
  133. {
  134.     crcImpl *oimpl = crc2crcImpl(self);
  135.     XP_ASSERT(oimpl->header.refcount);
  136.     RenderingContextObject *rcob = (RenderingContextObject *)oimpl->object;
  137.     return(rcob->GetPlatformData());
  138. }
  139.  
  140.  
  141. extern "C" JMC_PUBLIC_API(jint)
  142. /*ARGSUSED*/
  143. _crc_SetPlatformData(struct crc* self, jint op, struct rc_data *newRcData,
  144.                      struct JMCException* *exceptionThrown)
  145. {
  146.     crcImpl *oimpl = crc2crcImpl(self);
  147.     XP_ASSERT(oimpl->header.refcount);
  148.     RenderingContextObject *rcob = (RenderingContextObject *)oimpl->object;
  149.     return(rcob->SetPlatformData(newRcData));
  150. }
  151.  
  152. #ifndef NO_PERFORMANCE_HACK
  153. NF_PUBLIC_API_IMPLEMENT(struct rc_data *)
  154. /*ARGSUSED*/
  155. NF_GetRCNativeData(struct nfrc* rc)
  156. {
  157.     crcImpl *oimpl = nfrc2crcImpl(rc);
  158.     RenderingContextObject *rcob = (RenderingContextObject *)oimpl->object;
  159.     return (&rcob->rcData);
  160. }
  161. #endif /* NO_PERFORMANCE_HACK */
  162.