binding/v8/jsi/dataaccess/StringProperty.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 StringProperty.cpp
22 
23  \brief Utility functions to register the StringProperty class into the Google JavaScript V8 engine.
24  */
25 
26 // TerraLib
27 #include "../../../../dataaccess/property/StringProperty.h"
28 #include "../../common/Utils.h"
29 #include "DataAccess.h"
30 
31 // Boost
32 #include <boost/cstdint.hpp>
33 
34 ::v8::Handle<::v8::Value> StringProperty_GetSubType(const ::v8::Arguments& args)
35 {
36  return ::v8::Undefined();
37 }
38 
39 ::v8::Handle<::v8::Value> StringProperty_SetSubType(const ::v8::Arguments& args)
40 {
41  return ::v8::Undefined();
42 }
43 
44 ::v8::Handle<::v8::Value> StringProperty_Size(const ::v8::Arguments& args)
45 {
46  return ::v8::Undefined();
47 }
48 
49 ::v8::Handle<::v8::Value> StringProperty_SetSize(const ::v8::Arguments& args)
50 {
51  return ::v8::Undefined();
52 }
53 
54 ::v8::Handle<::v8::Value> StringProperty_Clone(const ::v8::Arguments& args)
55 {
56  return ::v8::Undefined();
57 }
58 
59 ::v8::Handle<::v8::Value> StringProperty_Constructor(const ::v8::Arguments& args)
60 {
61  //::v8::HandleScope hs;
62 
63  //if(!args.IsConstructCall())
64  // return ::v8::ThrowException(::v8::String::New("In order to create a check constraint, you need to call its constructor like: var c = new TeStringProperty(dt, id);"));
65 
66  //if(args.Holder().IsEmpty())
67  // return ::v8::ThrowException(::v8::String::New("The StringProperty constructor must use object notation!"));
68 
69  //if(args.Length() != 0)
70  // return ::v8::ThrowException(::v8::String::New("The StringProperty constructor has no parameters!"));
71 
72  //std::auto_ptr<te::da::StringProperty> catalog(new te::da::StringProperty());
73 
74  //::v8::Local<::v8::Object> jcatalog = te::v8::common::Make(catalog.get(), te::v8::jsi::GetStringPropertyTemplate, true);
75 
76  //catalog.release();
77 
78  //return hs.Close(jcatalog);
79 
80  return ::v8::Undefined();
81 }
82 
83 void te::v8::jsi::RegisterStringProperty(::v8::Local<::v8::Object>& global)
84 {
85  ::v8::Local<::v8::FunctionTemplate> jstringproperty = ::v8::FunctionTemplate::New(StringProperty_Constructor);
86 
87  global->Set(::v8::String::New("TeStringProperty"), jstringproperty->GetFunction());
88 }
89 
90 static ::v8::Persistent<::v8::FunctionTemplate> sdset_stringproperty_template;
91 
92 ::v8::Persistent<::v8::FunctionTemplate>& te::v8::jsi::GetStringPropertyTemplate()
93 {
94  if(sdset_stringproperty_template.IsEmpty())
95  {
96  ::v8::Persistent<::v8::FunctionTemplate>& pTpl = GetSimplePropertyTemplate();
97  ::v8::Local<::v8::FunctionTemplate> result = ::v8::FunctionTemplate::New();
98  result->Inherit(pTpl);
99 
100  ::v8::Handle<::v8::ObjectTemplate> prototype = result->PrototypeTemplate();
101 
102  prototype->Set(::v8::String::NewSymbol("getSubType"), ::v8::FunctionTemplate::New(StringProperty_GetSubType));
103  prototype->Set(::v8::String::NewSymbol("setSubtype"), ::v8::FunctionTemplate::New(StringProperty_SetSubType));
104  prototype->Set(::v8::String::NewSymbol("size"), ::v8::FunctionTemplate::New(StringProperty_Size));
105  prototype->Set(::v8::String::NewSymbol("setSize"), ::v8::FunctionTemplate::New(StringProperty_SetSize));
106  prototype->Set(::v8::String::NewSymbol("clone"), ::v8::FunctionTemplate::New(StringProperty_Clone));
107 
108  sdset_stringproperty_template = ::v8::Persistent<::v8::FunctionTemplate>::New(result);
109  }
110 
112 }
::v8::Handle<::v8::Value > StringProperty_GetSubType(const ::v8::Arguments &args)
::v8::Persistent<::v8::FunctionTemplate > & GetSimplePropertyTemplate()
It returns a reference to the persistent template of a SimpleProperty object.
static::v8::Persistent<::v8::FunctionTemplate > sdset_stringproperty_template
::v8::Handle<::v8::Value > StringProperty_Size(const ::v8::Arguments &args)
JavaScript exporting routine for the TerraLib Data Access module.
::v8::Handle<::v8::Value > StringProperty_SetSize(const ::v8::Arguments &args)
void RegisterStringProperty(::v8::Local<::v8::Object > &global)
It registers the StringProperty class.
::v8::Handle<::v8::Value > StringProperty_Clone(const ::v8::Arguments &args)
::v8::Persistent<::v8::FunctionTemplate > & GetStringPropertyTemplate()
It returns a reference to the persistent template of a StringProperty object.
::v8::Handle<::v8::Value > StringProperty_Constructor(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > StringProperty_SetSubType(const ::v8::Arguments &args)