UNPKG

2.05 kBtext/x-cView Raw
1/*
2 Source File : PDFSymbolDriver.cpp
3
4
5 Copyright 2013 Gal Kahana HummusJS
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19 */
20#include "PDFSymbolDriver.h"
21#include "RefCountPtr.h"
22#include "ConstructorsHolder.h"
23using namespace v8;
24
25
26
27DEF_SUBORDINATE_INIT(PDFSymbolDriver::Init)
28{
29 CREATE_ISOLATE_CONTEXT;
30
31 Local<FunctionTemplate> t = NEW_FUNCTION_TEMPLATE_EXTERNAL(New);
32
33 t->SetClassName(NEW_STRING("PDFSymbol"));
34 t->InstanceTemplate()->SetInternalFieldCount(1);
35
36 SET_ACCESSOR_METHOD(t, "value", GetValue);
37 PDFObjectDriver::Init(t);
38
39 // save in factory
40 EXPOSE_EXTERNAL_FOR_INIT(ConstructorsHolder, holder)
41 SET_CONSTRUCTOR(holder->PDFSymbol_constructor, t);
42 SET_CONSTRUCTOR_TEMPLATE(holder->PDFSymbol_constructor_template, t);
43}
44
45METHOD_RETURN_TYPE PDFSymbolDriver::New(const ARGS_TYPE& args)
46{
47 CREATE_ISOLATE_CONTEXT;
48 CREATE_ESCAPABLE_SCOPE;
49 EXPOSE_EXTERNAL_ARGS(ConstructorsHolder, externalHolder)
50
51 PDFSymbolDriver* driver = new PDFSymbolDriver();
52 driver->holder = externalHolder;
53 driver->Wrap(args.This());
54 SET_FUNCTION_RETURN_VALUE(args.This())
55}
56
57PDFObject* PDFSymbolDriver::GetObject()
58{
59 return TheObject.GetPtr();
60}
61
62METHOD_RETURN_TYPE PDFSymbolDriver::GetValue(Local<String> property, const PROPERTY_TYPE &info)
63{
64 CREATE_ISOLATE_CONTEXT;
65 CREATE_ESCAPABLE_SCOPE;
66
67 Local<String> result = NEW_STRING(ObjectWrap::Unwrap<PDFSymbolDriver>(info.Holder())->TheObject->GetValue().c_str());
68 SET_ACCESSOR_RETURN_VALUE(result)
69}
70
71