te::v8::common Namespace Reference

Classes

class  JsContext
 A class for keeping reference to a persistent context. More...
 
class  JsContextManager
 A singleton for managing JavaScript contexts. More...
 
struct  JsObject
 An auxiliary data structure for helping to control the garbage collection of wrapped C++ objects associated to JavaScript objects in Google's V8 engine. More...
 
class  Module
 This singleton defines the TerraLib's Google JavaScript V8 Common Runtime module entry. More...
 

Functions

TEV8COMMONEXPORT void Cache (::v8::Local<::v8::Object > &obj, const std::string &methodName,::v8::Persistent<::v8::Function > &outFtor)
 It caches the object method into the persistent output functor. More...
 
void Convert2Cpp (const ::v8::Local<::v8::Object > &jsmap, std::map< std::string, std::string > &cppmap)
 It converts the input map to an object representing the associative conteiner. More...
 
inline::v8::Local<::v8::Object > Convert2Js (const std::map< std::string, std::string > &m)
 It converts the input map to an object representing the associative conteiner. More...
 
template<class T >
void JsObjectRelease (::v8::Persistent<::v8::Value > obj, void *parameter)
 The call-back function for releasing objects. More...
 
template<class T >
void LooseOwnership (::v8::Handle<::v8::Object > obj)
 An utility function that extracts the C++ object from a wrapped object. More...
 
template<class T , class TF >
::v8::Local<::v8::Object > Make (T *obj, TF tfunc, const bool isOwner)
 It creates a new JavaScript object from a C++ object (obj). More...
 
TEV8COMMONEXPORT::v8::Handle<::v8::Value > Print (const ::v8::Arguments &args)
 This function will print all the arguments to the standard output. More...
 
TEV8COMMONEXPORT::v8::Handle<::v8::String > ReadFile (const std::string &fileName)
 It reads a file into a v8 string. More...
 
template<class T >
T * Unwrap (::v8::Handle<::v8::Object > obj)
 An utility function that extracts the C++ object from a wrapped object. More...
 
template<class T >
T * UnwrapAndLooseOwnership (::v8::Handle<::v8::Object > obj)
 An utility function that extracts the C++ object from a wrapped object. More...
 

Function Documentation

void te::v8::common::Cache ( ::v8::Local<::v8::Object > &  obj,
const std::string &  methodName,
::v8::Persistent<::v8::Function > &  outFtor 
)

It caches the object method into the persistent output functor.

Parameters
objThe object that must have a method called methodName.
methodNameThe name of a method belonging to obj.
outFtorA persistent function where the reference to the method will me cached.
Exceptions
ExceptionIt throws an exception if it can not find the method or something goes wrong.
Precondition
A HandleScope must exist before calling this method.

Definition at line 67 of file src/terralib/binding/v8/common/Utils.cpp.

References TR_V8COMMON.

Referenced by te::v8::plugin::PluginEngine::load().

void te::v8::common::Convert2Cpp ( const ::v8::Local<::v8::Object > &  jsmap,
std::map< std::string, std::string > &  cppmap 
)
inline

It converts the input map to an object representing the associative conteiner.

Parameters
mAn input map to be converted to a JavsScript object.
Precondition
There must be a valid HandleScope before calling this routine.
Returns
An object representing the associative conteiner.

Definition at line 238 of file src/terralib/binding/v8/common/Utils.h.

Referenced by DataSource_Open(), DataSource_SetConnectionInfo(), and DataSourceManager_Open().

inline ::v8::Local<::v8::Object> te::v8::common::Convert2Js ( const std::map< std::string, std::string > &  m)

It converts the input map to an object representing the associative conteiner.

Parameters
mAn input map to be converted to a JavsScript object.
Precondition
There must be a valid HandleScope before calling this routine.
Returns
An object representing the associative conteiner.

Definition at line 209 of file src/terralib/binding/v8/common/Utils.h.

Referenced by DataSource_GetConnectionInfo().

template<class T >
void te::v8::common::JsObjectRelease ( ::v8::Persistent<::v8::Value >  obj,
void *  parameter 
)

The call-back function for releasing objects.

Parameters
objThe object to be disposed.
parameterThe C++ pointer to be released.
Precondition
There must be a valid HandleScope before calling this routine.

Definition at line 145 of file src/terralib/binding/v8/common/Utils.h.

References p.

template<class T >
void te::v8::common::LooseOwnership ( ::v8::Handle<::v8::Object >  obj)
inline

An utility function that extracts the C++ object from a wrapped object.

Parameters
objThe object holding the C++ pointer.
Returns
The C++ pointer casted to the right type.
Precondition
There must be a valid HandleScope before calling this routine.

Definition at line 128 of file src/terralib/binding/v8/common/Utils.h.

References te::v8::common::JsObject< T >::m_isOwner, and p.

template<class T , class TF >
::v8::Local<::v8::Object> te::v8::common::Make ( T *  obj,
TF  tfunc,
const bool  isOwner 
)
inline

It creates a new JavaScript object from a C++ object (obj).

The new object will have tfunc as its object template. If isOwner is true the JavaScript object will be the owner of the given C++ object pointer.

Parameters
objA valid pointer to a C++ object.
tfuncA function with no arguments that returns the object template to be applied.
isOwnerIf true when the JavaSript object goes out if the scope it automatically release the C++ object, otherwise, it doesn't.
Precondition
There must be a valid HandleScope before calling this routine.

Definition at line 176 of file src/terralib/binding/v8/common/Utils.h.

Referenced by Coord2D_Constructor(), Curve_GetEndPoint(), Curve_GetStartPoint(), DataSet_GetType(), DataSource_GetCatalog(), DataSource_GetTransactor(), DataSourceCatalog_Clone(), DataSourceCatalog_Constructor(), DataSourceCatalog_GetDataSource(), DataSourceFactory_Make(), DataSourceManager_Find(), DataSourceManager_Make(), DataSourceManager_Open(), DataSourceTransactor_GetDataSet(), Envelope_Constructor(), ForeignKey_Clone(), Geometry_GetMBR(), te::v8::jsi::Geometry_Make(), GeometryCollection_Constructor(), LinearRing_Constructor(), LineString_Constructor(), LineString_GetCoordinates(), LineString_GetPointN(), MultiLineString_Constructor(), MultiPoint_Constructor(), MultiPolygon_Constructor(), MultiSurface_GetCentroid(), MultiSurface_GetCentroidCoord(), MultiSurface_GetCoordOnSurface(), MultiSurface_GetPointOnSurface(), Point_Constructor(), PointM_Constructor(), PointZ_Constructor(), PointZM_Constructor(), Polygon_Constructor(), Polygon_GetExteriorRing(), Polygon_GetInteriorRingN(), Polygon_GetRingN(), Polygon_GetRings(), PrimaryKey_Clone(), Surface_GetCentroid(), Surface_GetCentroidCoord(), Surface_GetCoordOnSurface(), Surface_GetPointOnSurface(), and UniqueKey_Clone().

v8::Handle<::v8::Value > te::v8::common::Print ( const ::v8::Arguments &  args)

This function will print all the arguments to the standard output.

Parameters
argsThe arguments to be printed.
Returns
An undefinded V8 value just to allow the function to be exported to JavaScript environment!

Definition at line 84 of file src/terralib/binding/v8/common/Utils.cpp.

Referenced by te::v8::plugin::PluginEngine::load().

v8::Handle<::v8::String > te::v8::common::ReadFile ( const std::string &  fileName)

It reads a file into a v8 string.

Parameters
fileNameThe name of the file to be read.
Returns
A v8 string with the file content.
Exceptions
ExceptionIt throws an exception if it can not read the file.
Precondition
A HandleScope must exist before calling this method.

Definition at line 36 of file src/terralib/binding/v8/common/Utils.cpp.

References file(), te::core::CharEncoding::fromUTF8(), and TR_V8COMMON.

Referenced by te::v8::plugin::PluginEngine::load().

template<class T >
T* te::v8::common::Unwrap ( ::v8::Handle<::v8::Object >  obj)
inline

An utility function that extracts the C++ object from a wrapped object.

Parameters
objThe object holding the C++ pointer.
Returns
The C++ pointer casted to the right type.
Precondition
There must be a valid HandleScope before calling this routine.

Definition at line 93 of file src/terralib/binding/v8/common/Utils.h.

References te::v8::common::JsObject< T >::m_handle, and p.

template<class T >
T* te::v8::common::UnwrapAndLooseOwnership ( ::v8::Handle<::v8::Object >  obj)
inline

An utility function that extracts the C++ object from a wrapped object.

Parameters
objThe object holding the C++ pointer.
Returns
The C++ pointer casted to the right type.
Precondition
There must be a valid HandleScope before calling this routine.

Definition at line 110 of file src/terralib/binding/v8/common/Utils.h.

References te::v8::common::JsObject< T >::m_handle, te::v8::common::JsObject< T >::m_isOwner, and p.