PythonMonkey   v0.8.2 (dev)
Loading...
Searching...
No Matches
jsTypeFactory.cc File Reference
#include "include/jsTypeFactory.hh"
#include "include/modules/pythonmonkey/pythonmonkey.hh"
#include "include/JSFunctionProxy.hh"
#include "include/JSMethodProxy.hh"
#include "include/JSObjectProxy.hh"
#include "include/JSArrayProxy.hh"
#include "include/PyDictProxyHandler.hh"
#include "include/JSStringProxy.hh"
#include "include/PyListProxyHandler.hh"
#include "include/PyObjectProxyHandler.hh"
#include "include/PyIterableProxyHandler.hh"
#include "include/pyTypeFactory.hh"
#include "include/IntType.hh"
#include "include/PromiseType.hh"
#include "include/DateType.hh"
#include "include/ExceptionType.hh"
#include "include/BufferType.hh"
#include "include/setSpiderMonkeyException.hh"
#include <jsapi.h>
#include <jsfriendapi.h>
#include <js/Equality.h>
#include <js/Proxy.h>
#include <js/Array.h>
#include <Python.h>
#include <datetime.h>
#include <unordered_map>
Include dependency graph for jsTypeFactory.cc:

Macros

#define HIGH_SURROGATE_START   0xD800
 
#define LOW_SURROGATE_START   0xDC00
 
#define LOW_SURROGATE_END   0xDFFF
 
#define BMP_END   0x10000
 

Functions

size_t UCS4ToUTF16 (const uint32_t *chars, size_t length, uint16_t **outStr)
 
JS::Value jsTypeFactory (JSContext *cx, PyObject *object)
 Function that takes a PyObject and returns a corresponding JS::Value, doing shared memory management when necessary.
 
JS::Value jsTypeFactorySafe (JSContext *cx, PyObject *object)
 same to jsTypeFactory, but it's guaranteed that no error would be set on the Python error stack, instead return JS null on error, and output a warning in Python-land
 
bool setPyException (JSContext *cx)
 
bool callPyFunc (JSContext *cx, unsigned int argc, JS::Value *vp)
 Helper function for jsTypeFactory to create a JSFunction* through JS_NewFunction that knows how to call a python function.
 

Variables

std::unordered_map< PyObject *, size_t > externalStringObjToRefCountMap
 
PythonExternalString PythonExternalStringCallbacks = {}
 

Detailed Description

Author
Caleb Aikens (caleb.nosp@m.@dis.nosp@m.tribu.nosp@m.tive.nosp@m..netw.nosp@m.ork) and Philippe Laporte (phili.nosp@m.ppe@.nosp@m.distr.nosp@m.ibut.nosp@m.ive.n.nosp@m.etwo.nosp@m.rk)
Date
2023-02-15

Macro Definition Documentation

◆ BMP_END

#define BMP_END   0x10000

◆ HIGH_SURROGATE_START

#define HIGH_SURROGATE_START   0xD800

◆ LOW_SURROGATE_END

#define LOW_SURROGATE_END   0xDFFF

◆ LOW_SURROGATE_START

#define LOW_SURROGATE_START   0xDC00

Function Documentation

◆ callPyFunc()

bool callPyFunc ( JSContext *  cx,
unsigned int  argc,
JS::Value *  vp 
)

Helper function for jsTypeFactory to create a JSFunction* through JS_NewFunction that knows how to call a python function.

Parameters
cx- Pointer to the JSContext
argc- The number of arguments the JSFunction expects
vp- The return value of the JSFunction
Returns
true - Function executed successfully
false - Function did not execute successfully and an exception has been set

◆ jsTypeFactory()

JS::Value jsTypeFactory ( JSContext *  cx,
PyObject *  object 
)

Function that takes a PyObject and returns a corresponding JS::Value, doing shared memory management when necessary.

Parameters
cx- Pointer to the JSContext
object- Pointer to the PyObject who's type and value we wish to encapsulate
Returns
JS::Value - A JS::Value corresponding to the PyType

◆ jsTypeFactorySafe()

JS::Value jsTypeFactorySafe ( JSContext *  cx,
PyObject *  object 
)

same to jsTypeFactory, but it's guaranteed that no error would be set on the Python error stack, instead return JS null on error, and output a warning in Python-land

◆ setPyException()

bool setPyException ( JSContext *  cx)

◆ UCS4ToUTF16()

size_t UCS4ToUTF16 ( const uint32_t *  chars,
size_t  length,
uint16_t **  outStr 
)

Variable Documentation

◆ externalStringObjToRefCountMap

std::unordered_map<PyObject *, size_t> externalStringObjToRefCountMap

◆ PythonExternalStringCallbacks

PythonExternalString PythonExternalStringCallbacks = {}