binding/v8/jsi/dataaccess/ArrayProperty.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file ArrayProperty.cpp
22 
23  \brief Utility functions to register the ArrayProperty class into the Google JavaScript V8 engine.
24  */
25 
26 // TerraLib
27 #include "../../../../dataaccess/property/ArrayProperty.h"
28 #include "../../common/Utils.h"
29 #include "DataAccess.h"
30 
31 // Boost
32 #include <boost/cstdint.hpp>
33 
34 ::v8::Handle<::v8::Value> ArrayProperty_GetElementType(const ::v8::Arguments& /*args*/)
35 {
36  return ::v8::Undefined();
37 }
38 
39 ::v8::Handle<::v8::Value> ArrayProperty_SetElementType(const ::v8::Arguments& /*args*/)
40 {
41  return ::v8::Undefined();
42 }
43 
44 ::v8::Handle<::v8::Value> ArrayProperty_Constructor(const ::v8::Arguments& /*args*/)
45 {
46  //::v8::HandleScope hs;
47 
48  //if(!args.IsConstructCall())
49  // return ::v8::ThrowException(::v8::String::New("In order to create a check constraint, you need to call its constructor like: var c = new TeArrayProperty(dt, id);"));
50 
51  //if(args.Holder().IsEmpty())
52  // return ::v8::ThrowException(::v8::String::New("The ArrayProperty constructor must use object notation!"));
53 
54  //if(args.Length() != 0)
55  // return ::v8::ThrowException(::v8::String::New("The ArrayProperty constructor has no parameters!"));
56 
57  //std::auto_ptr<te::da::ArrayProperty> catalog(new te::da::ArrayProperty());
58 
59  //::v8::Local<::v8::Object> jcatalog = te::v8::common::Make(catalog.get(), te::v8::jsi::GetArrayPropertyTemplate, true);
60 
61  //catalog.release();
62 
63  //return hs.Close(jcatalog);
64 
65  return ::v8::Undefined();
66 }
67 
68 void te::v8::jsi::RegisterArrayProperty(::v8::Local<::v8::Object>& global)
69 {
70  ::v8::Local<::v8::FunctionTemplate> jarrayproperty = ::v8::FunctionTemplate::New(ArrayProperty_Constructor);
71 
72  global->Set(::v8::String::New("TeArrayProperty"), jarrayproperty->GetFunction());
73 }
74 
75 static ::v8::Persistent<::v8::FunctionTemplate> sg_arrayproperty_template;
76 
77 ::v8::Persistent<::v8::FunctionTemplate>& te::v8::jsi::GetArrayPropertyTemplate()
78 {
79  if(sg_arrayproperty_template.IsEmpty())
80  {
81  ::v8::Persistent<::v8::FunctionTemplate>& pTpl = GetSimplePropertyTemplate();
82  ::v8::Local<::v8::FunctionTemplate> result = ::v8::FunctionTemplate::New();
83  result->Inherit(pTpl);
84 
85  ::v8::Handle<::v8::ObjectTemplate> prototype = result->PrototypeTemplate();
86 
87  prototype->Set(::v8::String::NewSymbol("getElementType"), ::v8::FunctionTemplate::New(ArrayProperty_GetElementType));
88  prototype->Set(::v8::String::NewSymbol("setElementType"), ::v8::FunctionTemplate::New(ArrayProperty_SetElementType));
89 
90  sg_arrayproperty_template = ::v8::Persistent<::v8::FunctionTemplate>::New(result);
91  }
92 
94 }
::v8::Persistent<::v8::FunctionTemplate > & GetSimplePropertyTemplate()
It returns a reference to the persistent template of a SimpleProperty object.
JavaScript exporting routine for the TerraLib Data Access module.
::v8::Persistent<::v8::FunctionTemplate > & GetArrayPropertyTemplate()
It returns a reference to the persistent template of a ArrayProperty object.
::v8::Handle<::v8::Value > ArrayProperty_SetElementType(const ::v8::Arguments &)
::v8::Handle<::v8::Value > ArrayProperty_Constructor(const ::v8::Arguments &)
static::v8::Persistent<::v8::FunctionTemplate > sg_arrayproperty_template
void RegisterArrayProperty(::v8::Local<::v8::Object > &global)
It registers the ArrayProperty class.
::v8::Handle<::v8::Value > ArrayProperty_GetElementType(const ::v8::Arguments &)