summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp
blob: 5108625fbf3602df7394d265a2cc30bf3da36b76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "JSCCharacterData.h"
#include "JSCNode.h"

namespace Arabica {
namespace DOM {


JSStaticValue JSCCharacterData::staticValues[] = {
	{ "data", dataAttrGetter, dataAttrSetter, kJSPropertyAttributeDontDelete },
	{ "length", lengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },

	{ 0, 0, 0, 0 }
};

JSStaticFunction JSCCharacterData::staticFunctions[] = {
	{ "substringData", substringDataCallback, kJSPropertyAttributeDontDelete },
	{ "appendData", appendDataCallback, kJSPropertyAttributeDontDelete },
	{ "insertData", insertDataCallback, kJSPropertyAttributeDontDelete },
	{ "deleteData", deleteDataCallback, kJSPropertyAttributeDontDelete },
	{ "replaceData", replaceDataCallback, kJSPropertyAttributeDontDelete },
	{ 0, 0, 0 }
};

JSValueRef JSCCharacterData::dataAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
	struct JSCCharacterDataPrivate* privData = static_cast<JSCCharacterData::JSCCharacterDataPrivate* >(JSObjectGetPrivate(thisObj));
	JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->getData().c_str());
	JSValueRef retObj = JSValueMakeString(ctx, retString);
	JSStringRelease(retString);
	return retObj;

}

JSValueRef JSCCharacterData::lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
	struct JSCCharacterDataPrivate* privData = static_cast<JSCCharacterData::JSCCharacterDataPrivate* >(JSObjectGetPrivate(thisObj));

	return JSValueMakeNumber(ctx, privData->arabicaThis->getLength());
}

}
}