JSDOMCDATA.cpp
上传用户:xqtpzdz
上传日期:2022-05-21
资源大小:1764k
文件大小:3k
源码类别:

xml/soap/webservice

开发平台:

Visual C++

  1. /****************License************************************************
  2.  * Vocalocity OpenVXI
  3.  * Copyright (C) 2004-2005 by Vocalocity, Inc. All Rights Reserved.
  4.  * This program is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU General Public License
  6.  * as published by the Free Software Foundation; either version 2
  7.  * of the License, or (at your option) any later version.
  8.  *  
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  17.  * Vocalocity, the Vocalocity logo, and VocalOS are trademarks or 
  18.  * registered trademarks of Vocalocity, Inc. 
  19.  * OpenVXI is a trademark of Scansoft, Inc. and used under license 
  20.  * by Vocalocity.
  21.  ***********************************************************************/
  22. #include "JSDOMCDATA.hpp"
  23. // JavaScript class definition
  24. JSClass JSDOMCDATA::_jsClass = {
  25. "CDATASection", JSCLASS_HAS_PRIVATE,
  26. JS_PropertyStub, JS_PropertyStub,
  27. JSDOMCDATA::JSGetProperty, JS_PropertyStub,
  28. JS_EnumerateStub, JS_ResolveStub,
  29. JS_ConvertStub, JSDOMCDATA::JSDestructor,
  30. 0, 0, 0, 0, 
  31. 0, 0, 0, 0
  32. };
  33. // JavaScript Initialization Method
  34. JSObject *JSDOMCDATA::JSInit(JSContext *cx, JSObject *obj) {
  35. if (obj==NULL)
  36. obj = JS_GetGlobalObject(cx);
  37. jsval oldobj;
  38. if (JS_TRUE == JS_LookupProperty(cx, obj, JSDOMCDATA::_jsClass.name, &oldobj) && JSVAL_IS_OBJECT(oldobj))
  39. return JSVAL_TO_OBJECT(oldobj);
  40. JSObject *newobj = JS_InitClass(cx, obj, NULL, &JSDOMCDATA::_jsClass,
  41.                                       NULL, 0,
  42.                                       NULL, NULL,
  43.                                       NULL, NULL);
  44. if (newobj) {
  45. InitTextObject(cx, newobj);
  46. }
  47. return newobj;
  48. }
  49. // JavaScript Destructor
  50. void JSDOMCDATA::JSDestructor(JSContext *cx, JSObject *obj) {
  51. JSDOMCDATA *p = (JSDOMCDATA*)JS_GetPrivate(cx, obj);
  52. if (p) delete p;
  53. }
  54. JSBool JSDOMCDATA::JSGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
  55. return JSDOMText::JSGetProperty(cx, obj, id, vp);
  56. }
  57. // JavaScript Object Linking
  58. JSObject *JSDOMCDATA::getJSObject(JSContext *cx) {
  59. if (!cx) return NULL;
  60. if (!_JSinternal.o) {
  61. _JSinternal.o = newJSObject(cx);
  62. _JSinternal.c = cx;
  63. if (!JS_SetPrivate(cx, _JSinternal.o, this)) return NULL;
  64. }
  65. return _JSinternal.o;
  66. }
  67. JSObject *JSDOMCDATA::newJSObject(JSContext *cx) {
  68. return JS_NewObject(cx, &JSDOMCDATA::_jsClass, NULL, NULL);
  69. }
  70. JSDOMCDATA::JSDOMCDATA( DOMCDATASection *cdata, JSDOMDocument *doc ) : JSDOMText(cdata,doc)
  71. {
  72. }