2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <CommonsJavaScript/Converter.h>
18 #include <CommonsJavaScript/Validator.h>
19 #include <CommonsJavaScript/JSUtils.h>
20 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
21 #include <Tizen/Common/JSTizenExceptionFactory.h>
22 #include <Tizen/Common/JSTizenException.h>
23 #include <Tizen/Common/SecurityExceptions.h>
24 #include "JSSimpleCoordinates.h"
25 #include "JSGeoCircleBounds.h"
31 #define LOG_TAG "TIZEN_POI"
34 using namespace WrtDeviceApis::CommonsJavaScript;
40 JSClassRef JSGeoCircleBounds::m_jsClassRef = NULL;
42 JSClassDefinition JSGeoCircleBounds::m_jsClassInfo = {
43 0, // current (and only) version is 0
44 kJSClassAttributeNone, //attributes
45 "GeoRectBounds", // class name
47 NULL, // static values
48 NULL, // static functions
49 JSGeoCircleBounds::initialize, // initialize
50 JSGeoCircleBounds::finalize,
54 NULL, //deleteProperty
55 NULL, //getPropertyNames
57 JSGeoCircleBounds::constructor, // constructor
58 JSGeoCircleBounds::hasInstance,
64 const JSClassRef JSGeoCircleBounds::getClassRef()
67 m_jsClassRef = JSClassCreate(&m_jsClassInfo);
72 const JSClassDefinition* JSGeoCircleBounds::getClassInfo()
74 return &m_jsClassInfo;
77 JSObjectRef JSGeoCircleBounds::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
78 JSValueRef convertedArguments[2];
79 for( unsigned int i = 0 ; i < 2; i++ ){
80 if( i < argumentCount )
81 convertedArguments[i] = arguments[i];
83 convertedArguments[i] = JSValueMakeUndefined(ctx);
86 if( !JSValueIsObjectOfClass(ctx, convertedArguments[0], TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getClassRef()) ){
87 *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "First argument is not SimpleCoordinates");
91 if( JSValueIsUndefined(ctx , convertedArguments[1] ) ){
92 *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::INVALID_VALUES_ERROR, "Second argument is not number");
96 JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);
98 LBSUtil::setProperty(ctx , obj ,"center" ,convertedArguments[0], kJSPropertyAttributeReadOnly );
99 LBSUtil::setProperty(ctx , obj ,"radius" ,convertedArguments[1], kJSPropertyAttributeReadOnly );
104 void JSGeoCircleBounds::initialize(JSContextRef ctx, JSObjectRef object)
108 void JSGeoCircleBounds::finalize(JSObjectRef object)
112 bool JSGeoCircleBounds::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
113 return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());