2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
25 #include <dpl/log/log.h>
26 #include <CommonsJavaScript/PrivateObject.h>
27 #include <CommonsJavaScript/Converter.h>
28 #include "JSFeature.h"
29 #include "JSFeatureParam.h"
36 const char* PLUGIN_NAME = "Feature";
37 const char* ATTRIBUTE_URI = "uri";
40 JSClassDefinition JSFeature::m_classInfo =
43 kJSClassAttributeNone,
53 NULL, //deleteProperty,
54 NULL, //getPropertyNames,
61 JSStaticValue JSFeature::m_properties[] = {
62 { ATTRIBUTE_URI, getProperty, NULL, kJSPropertyAttributeReadOnly },
66 const JSClassDefinition* JSFeature::getClassInfo()
71 JSClassRef JSFeature::m_classRef = JSClassCreate(JSFeature::getClassInfo());
73 void JSFeature::initialize(JSContextRef context, JSObjectRef object)
75 //LogDebug("entered");
76 //private object should be passed to JSObjectMake function.
80 void JSFeature::finalize(JSObjectRef object)
83 JSFeaturePrivateObject* priv =
84 static_cast<JSFeaturePrivateObject*>(JSObjectGetPrivate(object));
88 JSClassRef JSFeature::getClassRef()
91 m_classRef = JSClassCreate(&m_classInfo);
96 JSValueRef JSFeature::getProperty(JSContextRef context, JSObjectRef object,
97 JSStringRef propertyName, JSValueRef* exception)
100 JSFeaturePrivateObject* priv =
101 static_cast<JSFeaturePrivateObject*>(JSObjectGetPrivate(object));
103 LogError("no private object");
104 return JSValueMakeUndefined(context);
108 WrtDeviceApis::CommonsJavaScript::Converter converter(context);
109 if (JSStringIsEqualToUTF8CString(propertyName, ATTRIBUTE_URI)) {
110 return converter.toJSValueRef(priv->getObject()->getName() );
113 Catch(WrtDeviceApis::Commons::Exception)
115 LogError("error during conversion");
117 return JSValueMakeUndefined(context);