resonance 1.0.1
Loading...
Searching...
No Matches
scripteval.h File Reference

Script entry points whose result is a Python handle. More...

Include dependency graph for scripteval.h:

Go to the source code of this file.

Namespaces

namespace  Py
 C++ wrappers for the embedded Python interpreter's objects, types, and extension modules.

Functions

Py::Object EvalScriptTemplate (int nTemplate,...)
 Call one registered script template as an expression and take its value.
Py::Object EvalScriptExpression (const HxStr &expression)
 Run one piece of script text as an expression and take its value.
Py::Object CallScriptFunction (const HxStr &name, Py::Tuple args)
 Call a function the scripts define at module level, by name.

Variables

PyShell * g_pPyShell
 Single interpreter host, null until GetPythonScriptHost() creates it.

Detailed Description

Script entry points whose result is a Python handle.

These sit apart from script/scripthost.h so that a caller wanting only RunScript() or one of the void entry points does not pull the interpreter headers in through PyCXX. ScriptSink and Application are both such callers.

Function Documentation

◆ EvalScriptTemplate()

Py::Object EvalScriptTemplate ( int nTemplate,
... )

Call one registered script template as an expression and take its value.

The same shape as CallScriptTemplate(), running with Py_eval_input and returning the result.

Parameters
nTemplateThe template identifier.
Returns
A handle on the result.
Ghidra address:
NTSC-U/C: 0x0050a750
Ghidra address:
PAL: 0x00549b18

◆ EvalScriptExpression()

Py::Object EvalScriptExpression ( const HxStr & expression)

Run one piece of script text as an expression and take its value.

Parameters
expressionThe text to evaluate.
Returns
A handle on the result.
Ghidra address:
NTSC-U/C: 0x0050d6c0
Ghidra address:
PAL: 0x0054cb78

◆ CallScriptFunction()

Py::Object CallScriptFunction ( const HxStr & name,
Py::Tuple args )

Call a function the scripts define at module level, by name.

The name is looked up in PyShell::mDict. A name the dictionary does not have leaves the callee None, and the call then raises inside the interpreter. The lookup and the item fetch are released PyCXX's inline hasKey() and getItem(), expanded in place. No call site survives in the shipped program, and the name is inferred.

Parameters
nameThe function name.
argsThe positional arguments, taken by value.
Returns
A handle on the call's result.
Ghidra address:
NTSC-U/C: 0x0050a868
Ghidra address:
PAL: 0x00549c68

Variable Documentation

◆ g_pPyShell

PyShell* g_pPyShell
extern

Single interpreter host, null until GetPythonScriptHost() creates it.

Every free entry point of the script layer reads this global directly rather than through the accessor, so a call made before creation dereferences null. Application::Run() creates the host early enough that no recovered caller does that.

Ghidra address:
NTSC-U/C: 0x0070b288
Ghidra address:
PAL: 0x0074ede0