diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp | 75 |
1 files changed, 64 insertions, 11 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp index 465e4fd..d8dcbed 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp @@ -1,3 +1,4 @@ +#include "JSCNodeSet.h" #include "JSCXPathResult.h" namespace Arabica { @@ -21,26 +22,78 @@ JSStaticFunction JSCXPathResult::staticFunctions[] = { { 0, 0, 0 } }; -JSValueRef JSCXPathResult::numberValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - struct JSCXPathResultPrivate* privData = static_cast<JSCXPathResult::JSCXPathResultPrivate* >(JSObjectGetPrivate(thisObj)); +JSValueRef JSCXPathResult::numberValueAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(object); - return JSValueMakeNumber(ctx, privData->arabicaThis->asNumber()); + return JSValueMakeNumber(ctx, privData->nativeObj->asNumber()); } -JSValueRef JSCXPathResult::stringValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - struct JSCXPathResultPrivate* privData = static_cast<JSCXPathResult::JSCXPathResultPrivate* >(JSObjectGetPrivate(thisObj)); - JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->asString().c_str()); - JSValueRef retObj = JSValueMakeString(ctx, retString); - JSStringRelease(retString); + +JSValueRef JSCXPathResult::stringValueAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(object); + JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->asString().c_str()); + return JSValueMakeString(ctx, stringRef); +} + + +JSValueRef JSCXPathResult::booleanValueAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { + struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(object); + + return JSValueMakeNumber(ctx, privData->nativeObj->asBool()); +} + +JSValueRef JSCXPathResult::asNodeSetCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + + struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(thisObj); + + + Arabica::XPath::NodeSet<std::string>* retVal = new Arabica::XPath::NodeSet<std::string>(privData->nativeObj->asNodeSet()); + JSClassRef retClass = JSCNodeSet::getTmpl(); + + struct JSCNodeSet::JSCNodeSetPrivate* retPrivData = new JSCNodeSet::JSCNodeSetPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; } -JSValueRef JSCXPathResult::booleanValueAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) { - struct JSCXPathResultPrivate* privData = static_cast<JSCXPathResult::JSCXPathResultPrivate* >(JSObjectGetPrivate(thisObj)); +JSValueRef JSCXPathResult::asBoolCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + + struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(thisObj); + - return JSValueMakeBoolean(ctx, privData->arabicaThis->asBool()); + bool retVal = privData->nativeObj->asBool(); + + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; +} + +JSValueRef JSCXPathResult::asStringCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + + struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(thisObj); + + + std::string retVal = privData->nativeObj->asString(); + + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + return jscRetVal; } +JSValueRef JSCXPathResult::asNumberCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + + struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(thisObj); + + + double retVal = privData->nativeObj->asNumber(); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; +} + + } } |