summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEventCustom.cpp
blob: 0209467a6fb76ef30519afd6e4dc88dc31163f09 (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
#include "JSCSCXMLEvent.h"

namespace Arabica {
namespace DOM {

JSValueRef JSCSCXMLEvent::eventTypeCustomAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
	struct JSCSCXMLEventPrivate* privData = (struct JSCSCXMLEventPrivate*)JSObjectGetPrivate(thisObj);
	JSStringRef stringRef;

	switch (privData->nativeObj->eventType) {
	case uscxml::Event::INTERNAL:
		stringRef = JSStringCreateWithUTF8CString("internal");
		break;
	case uscxml::Event::EXTERNAL:
		stringRef = JSStringCreateWithUTF8CString("external");
		break;
	case uscxml::Event::PLATFORM:
		stringRef = JSStringCreateWithUTF8CString("platform");
		break;
	default:
		stringRef = JSStringCreateWithUTF8CString("undefined");
		break;
	}

	JSValueRef retVal = JSValueMakeString(ctx, stringRef);
	JSStringRelease(stringRef);
	return retVal;
}

JSValueRef JSCSCXMLEvent::sendidCustomAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
	struct JSCSCXMLEventPrivate* privData = (struct JSCSCXMLEventPrivate*)JSObjectGetPrivate(thisObj);
	JSStringRef stringRef;

	if (privData->nativeObj->sendid.length() == 0 || privData->nativeObj->hideSendId) {
		return JSValueMakeUndefined(ctx);
	} else {
		stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->sendid.c_str());
		JSValueRef retVal = JSValueMakeString(ctx, stringRef);
		JSStringRelease(stringRef);
		return retVal;
	}
}

}
}