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