MySQL 9.3.0
Source Code Documentation
shcore::polyglot::Scoped_global Class Referencefinal

Allows creating a temporary global variable with a random name which will only live until the execution context of the instance of this class ends. More...

#include <polyglot_language.h>

Public Member Functions

 Scoped_global ()=delete
 
 Scoped_global (const Polyglot_language *language, poly_value value=nullptr)
 
 Scoped_global (const Scoped_global &)=delete
 
Scoped_globaloperator= (const Scoped_global &)=delete
 
 Scoped_global (Scoped_global &&)=delete
 
Scoped_globaloperator= (Scoped_global &&)=delete
 
poly_value execute (const std::string &code)
 
 ~Scoped_global ()
 

Private Attributes

const Polyglot_languagem_language
 
std::string m_name
 

Detailed Description

Allows creating a temporary global variable with a random name which will only live until the execution context of the instance of this class ends.

The reason this is needed is because in graal, non primitive values originating from guest languages (like JS) are not sharable, this means:

  • A guest language specific object is not mappable to C++ equivalent, i.e. (i.e. undefined, ArrayBuffer)
  • There's no way we can generate a guest language specific object from C++ (i.e. undefined, ArrayBuffer or Exception Objects)

The way this problem is addressed, is by creating a temporary object in the global context, to create the object in the guest language and then if needed, storing it to create a reference so the object can be deleted from the main context (to avoid pollution) without actually losing the object, then the reference is provided to the guest language.

Additional Information: https://github.com/oracle/graaljs/issues/70#issuecomment-436257058 https://github.com/oracle/graal/blob/master/sdk/CHANGELOG.md#version-10-rc9

Constructor & Destructor Documentation

◆ Scoped_global() [1/4]

shcore::polyglot::Scoped_global::Scoped_global ( )
delete

◆ Scoped_global() [2/4]

shcore::polyglot::Scoped_global::Scoped_global ( const Polyglot_language language,
poly_value  value = nullptr 
)

◆ Scoped_global() [3/4]

shcore::polyglot::Scoped_global::Scoped_global ( const Scoped_global )
delete

◆ Scoped_global() [4/4]

shcore::polyglot::Scoped_global::Scoped_global ( Scoped_global &&  )
delete

◆ ~Scoped_global()

shcore::polyglot::Scoped_global::~Scoped_global ( )

Member Function Documentation

◆ execute()

poly_value shcore::polyglot::Scoped_global::execute ( const std::string &  code)

◆ operator=() [1/2]

Scoped_global & shcore::polyglot::Scoped_global::operator= ( const Scoped_global )
delete

◆ operator=() [2/2]

Scoped_global & shcore::polyglot::Scoped_global::operator= ( Scoped_global &&  )
delete

Member Data Documentation

◆ m_language

const Polyglot_language* shcore::polyglot::Scoped_global::m_language
private

◆ m_name

std::string shcore::polyglot::Scoped_global::m_name
private

The documentation for this class was generated from the following files: