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 "JSGeoRectBounds.h"
31 #define LOG_TAG "TIZEN_POI"
34 using namespace WrtDeviceApis::CommonsJavaScript;
40 JSClassRef JSGeoRectBounds::m_jsClassRef = NULL;
42 JSClassDefinition JSGeoRectBounds::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 JSGeoRectBounds::initialize, // initialize
50 JSGeoRectBounds::finalize,
54 NULL, //deleteProperty
55 NULL, //getPropertyNames
57 JSGeoRectBounds::constructor, // constructor
58 JSGeoRectBounds::hasInstance,
64 const JSClassRef JSGeoRectBounds::getClassRef()
67 m_jsClassRef = JSClassCreate(&m_jsClassInfo);
72 const JSClassDefinition* JSGeoRectBounds::getClassInfo()
74 return &m_jsClassInfo;
77 JSObjectRef JSGeoRectBounds::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() ) || !JSValueIsObjectOfClass(ctx, convertedArguments[1],TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getClassRef() ) ){
87 *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Arguments are not SimpleCoordinates");
91 JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);
93 LBSUtil::setProperty(ctx , obj ,"northEast" ,convertedArguments[0], kJSPropertyAttributeReadOnly );
94 LBSUtil::setProperty(ctx , obj ,"southWest" ,convertedArguments[1], kJSPropertyAttributeReadOnly );
100 void JSGeoRectBounds::initialize(JSContextRef ctx, JSObjectRef object)
104 void JSGeoRectBounds::finalize(JSObjectRef object)
108 bool JSGeoRectBounds::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
109 return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());