summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp
blob: 4259b8607db7db9b00299acd2cb5ff608032f816 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "JSCAttr.h"
#include "JSCElement.h"
#include "JSCNode.h"

namespace Arabica {
namespace DOM {


JSStaticValue JSCAttr::staticValues[] = {
	{ "name", nameAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
	{ "specified", specifiedAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
	{ "value", valueAttrGetter, valueAttrSetter, kJSPropertyAttributeDontDelete },
	{ "ownerElement", ownerElementAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },

	{ 0, 0, 0, 0 }
};

JSStaticFunction JSCAttr::staticFunctions[] = {
	{ 0, 0, 0 }
};

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

}

JSValueRef JSCAttr::specifiedAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
	struct JSCAttrPrivate* privData = static_cast<JSCAttr::JSCAttrPrivate* >(JSObjectGetPrivate(thisObj));

	return JSValueMakeBoolean(ctx, privData->arabicaThis->getSpecified());
}

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

}

JSValueRef JSCAttr::ownerElementAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
	struct JSCAttrPrivate* privData = static_cast<JSCAttr::JSCAttrPrivate* >(JSObjectGetPrivate(thisObj));
	Arabica::DOM::Element<std::string>* arbaicaRet = new Arabica::DOM::Element<std::string>(privData->arabicaThis->getOwnerElement());

	struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate();
	retPrivData->dom = privData->dom;
	retPrivData->arabicaThis = arbaicaRet;

	JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSCElement::getTmpl(), retPrivData);
	return arbaicaRetObj;

}

}
}