wasm-port: broaden native LinuxCNC interpreter probes
This commit is contained in:
3
wasm-port/runtime/core/shims/boost/python/dict.hpp
Normal file
3
wasm-port/runtime/core/shims/boost/python/dict.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "boost/python/object_fwd.hpp"
|
||||
3
wasm-port/runtime/core/shims/boost/python/extract.hpp
Normal file
3
wasm-port/runtime/core/shims/boost/python/extract.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "boost/python/object_fwd.hpp"
|
||||
3
wasm-port/runtime/core/shims/boost/python/import.hpp
Normal file
3
wasm-port/runtime/core/shims/boost/python/import.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "boost/python/object_fwd.hpp"
|
||||
3
wasm-port/runtime/core/shims/boost/python/list.hpp
Normal file
3
wasm-port/runtime/core/shims/boost/python/list.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "boost/python/object_fwd.hpp"
|
||||
@@ -1,9 +1,88 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
struct _typeobject {
|
||||
const char *tp_name = "standalone-python-shim";
|
||||
};
|
||||
|
||||
struct _object {
|
||||
_typeobject *ob_type = nullptr;
|
||||
};
|
||||
typedef _object PyObject;
|
||||
|
||||
inline int PyCallable_Check(PyObject *) { return 0; }
|
||||
inline int PyErr_ExceptionMatches(PyObject *) { return 0; }
|
||||
inline void PyErr_Clear() {}
|
||||
inline int PyUnicode_Check(PyObject *) { return 0; }
|
||||
inline int PyLong_Check(PyObject *) { return 0; }
|
||||
inline int PyFloat_Check(PyObject *) { return 0; }
|
||||
inline PyObject *PyObject_Str(PyObject *) { return nullptr; }
|
||||
inline void Py_XDECREF(PyObject *) {}
|
||||
inline const char *PyUnicode_AsUTF8(PyObject *) { return ""; }
|
||||
|
||||
inline PyObject *PyExc_KeyError = nullptr;
|
||||
inline PyObject *Py_None = nullptr;
|
||||
|
||||
namespace boost {
|
||||
namespace python {
|
||||
|
||||
class object {};
|
||||
class error_already_set {};
|
||||
|
||||
class object {
|
||||
public:
|
||||
object() = default;
|
||||
|
||||
template <typename T>
|
||||
explicit object(const T &) {}
|
||||
|
||||
object attr(const char *) const { return object(); }
|
||||
object operator[](const char *) const { return object(); }
|
||||
object operator[](const std::string &) const { return object(); }
|
||||
object operator[](int) const { return object(); }
|
||||
PyObject *ptr() const { return nullptr; }
|
||||
};
|
||||
|
||||
class list : public object {
|
||||
public:
|
||||
using object::object;
|
||||
list() = default;
|
||||
explicit list(const object &) {}
|
||||
|
||||
template <typename T>
|
||||
void append(const T &) {}
|
||||
};
|
||||
|
||||
class tuple : public object {
|
||||
public:
|
||||
tuple() = default;
|
||||
explicit tuple(const list &) {}
|
||||
};
|
||||
|
||||
class dict : public object {
|
||||
public:
|
||||
object keys() const { return object(); }
|
||||
};
|
||||
|
||||
class scope {
|
||||
public:
|
||||
explicit scope(const object &) {}
|
||||
object attr(const char *) const { return object(); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
object import(const T &) { return object(); }
|
||||
|
||||
template <typename T>
|
||||
class extract {
|
||||
public:
|
||||
explicit extract(const object &) {}
|
||||
|
||||
operator T() const { return T(); }
|
||||
};
|
||||
|
||||
inline int len(const object &) { return 0; }
|
||||
inline void handle_exception() {}
|
||||
|
||||
} // namespace python
|
||||
} // namespace boost
|
||||
|
||||
3
wasm-port/runtime/core/shims/boost/python/scope.hpp
Normal file
3
wasm-port/runtime/core/shims/boost/python/scope.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "boost/python/object_fwd.hpp"
|
||||
3
wasm-port/runtime/core/shims/boost/python/tuple.hpp
Normal file
3
wasm-port/runtime/core/shims/boost/python/tuple.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "boost/python/object_fwd.hpp"
|
||||
30
wasm-port/runtime/core/shims/hal.h
Normal file
30
wasm-port/runtime/core/shims/hal.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define HAL_NAME_LEN 64
|
||||
|
||||
typedef enum {
|
||||
HAL_TYPE_UNINITIALIZED = 0,
|
||||
HAL_BIT,
|
||||
HAL_FLOAT,
|
||||
HAL_S32,
|
||||
HAL_U32,
|
||||
HAL_S64,
|
||||
HAL_U64
|
||||
} hal_type_t;
|
||||
|
||||
typedef union {
|
||||
bool b;
|
||||
double f;
|
||||
int s;
|
||||
unsigned int u;
|
||||
long long ls;
|
||||
unsigned long long lu;
|
||||
} hal_data_u;
|
||||
|
||||
int hal_init(const char *);
|
||||
int hal_ready(int);
|
||||
int hal_get_pin_value_by_name(const char *, hal_type_t *, hal_data_u **, bool *);
|
||||
int hal_get_signal_value_by_name(const char *, hal_type_t *, hal_data_u **, bool *);
|
||||
int hal_get_param_value_by_name(const char *, hal_type_t *, hal_data_u **);
|
||||
16
wasm-port/runtime/core/shims/interp_python.hh
Normal file
16
wasm-port/runtime/core/shims/interp_python.hh
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "boost/python/object_fwd.hpp"
|
||||
|
||||
struct pycontext_impl {
|
||||
boost::python::object tupleargs;
|
||||
boost::python::object kwargs;
|
||||
int py_return_type = 0;
|
||||
double py_returned_double = 0.0;
|
||||
int py_returned_int = 0;
|
||||
boost::python::object generator_next;
|
||||
};
|
||||
|
||||
std::string handle_pyerror();
|
||||
@@ -2,12 +2,37 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "boost/python/object_fwd.hpp"
|
||||
|
||||
enum pp_status {
|
||||
PLUGIN_NO_SECTION = -1,
|
||||
PLUGIN_OK = 0,
|
||||
PLUGIN_NO_CALLABLE = 1,
|
||||
PLUGIN_EXCEPTION = 2
|
||||
};
|
||||
|
||||
std::string handle_pyerror();
|
||||
|
||||
class PythonPlugin {
|
||||
public:
|
||||
static PythonPlugin *instantiate(struct _inittab * = nullptr);
|
||||
int configure(const char * = nullptr, const char * = nullptr) { return PLUGIN_NO_SECTION; }
|
||||
bool is_callable(const char *, const char *) { return false; }
|
||||
int call(const char *, const char *, boost::python::object, boost::python::object,
|
||||
boost::python::object &) { return PLUGIN_NO_CALLABLE; }
|
||||
int run_string(const char *, boost::python::object &, bool = false) { return PLUGIN_NO_CALLABLE; }
|
||||
int call_method(boost::python::object, boost::python::object &) { return PLUGIN_NO_CALLABLE; }
|
||||
int plugin_status() const { return PLUGIN_NO_SECTION; }
|
||||
bool usable() const { return false; }
|
||||
int plugin_status() const { return 0; }
|
||||
int initialize() { return PLUGIN_NO_SECTION; }
|
||||
const std::string &last_exception() const {
|
||||
static std::string empty;
|
||||
return empty;
|
||||
}
|
||||
const std::string &last_errmsg() const {
|
||||
static std::string empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
boost::python::object main_namespace;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "emc/nml_intf/emctool.h"
|
||||
#include "linuxcnc_tool_adapter.hh"
|
||||
|
||||
enum {
|
||||
IDX_OK = 0,
|
||||
@@ -8,22 +9,15 @@ enum {
|
||||
|
||||
inline CANON_TOOL_TABLE tooldata_entry_init()
|
||||
{
|
||||
CANON_TOOL_TABLE tool{};
|
||||
tool.toolno = 0;
|
||||
tool.pocketno = 0;
|
||||
return tool;
|
||||
return standalone::tool_entry_init();
|
||||
}
|
||||
|
||||
inline int tooldata_find_index_for_tool(int toolno)
|
||||
{
|
||||
return toolno == 0 ? 0 : -1;
|
||||
return standalone::find_tool_index_for_tool(toolno);
|
||||
}
|
||||
|
||||
inline int tooldata_get(CANON_TOOL_TABLE *tool, int index)
|
||||
{
|
||||
if ((tool == nullptr) || (index != 0)) {
|
||||
return -1;
|
||||
}
|
||||
*tool = tooldata_entry_init();
|
||||
return IDX_OK;
|
||||
return standalone::get_tool_entry(tool, index) == 0 ? IDX_OK : -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user