Remove JavaScript binding for NativeImage, NinePatchImage, ImageActor and ShaderEffect
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / src / image / image-api.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "image-api.h"
20
21 // INTERNAL INCLUDES
22 #include <v8-utils.h>
23 #include <image/image-wrapper.h>
24
25 namespace Dali
26 {
27
28 namespace V8Plugin
29 {
30
31 Image ImageApi::GetImage( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
32 {
33   v8::HandleScope handleScope( isolate );
34
35   v8::Local<v8::Object> object = args.This();
36   v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
37   void* ptr = field->Value();
38
39   ImageWrapper* wrapper = static_cast< ImageWrapper *>(ptr);
40   return wrapper->GetImage();
41 }
42
43 /**
44  * @constructor Image
45  * @method Image
46  * @for Image
47  * @return {Object} Image
48  */
49 Image ImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
50 {
51   v8::Isolate* isolate = args.GetIsolate();
52   v8::HandleScope handleScope( isolate );
53   DALI_SCRIPT_EXCEPTION( isolate, "Image base class can not be constructed, try new dali.ResourceImage()");
54   return Image();
55 }
56
57 /**
58  * Return the image width in pixels
59  * @method getWidth
60  * @for Image
61  */
62 void ImageApi::GetWidth( const v8::FunctionCallbackInfo< v8::Value >& args )
63 {
64   v8::Isolate* isolate = args.GetIsolate();
65   v8::HandleScope handleScope( isolate );
66
67   Image image = GetImage( isolate, args );
68
69   args.GetReturnValue().Set( v8::Integer::New( isolate, image.GetWidth() ) );
70 }
71 /**
72  * Return the image height in pixels
73  * @method getHeight
74  * @for Image
75  */
76 void ImageApi::GetHeight( const v8::FunctionCallbackInfo< v8::Value >& args )
77 {
78   v8::Isolate* isolate = args.GetIsolate();
79   v8::HandleScope handleScope( isolate );
80
81   Image image = GetImage( isolate, args );
82
83   args.GetReturnValue().Set( v8::Integer::New( isolate, image.GetHeight() ) );
84 }
85
86 } // namespace V8Plugin
87
88 } // namespace Dali