chibi-scheme embedded: calling scheme function with multiple params from C - chibi-scheme

The following site shows an sample of embedding chibi scheme into a c program:
http://synthcode.com/scheme/chibi/
/* construct a Scheme expression to eval */
obj1 = sexp_intern(ctx, "my-procedure", -1);
obj2 = sexp_cons(ctx, obj1, SEXP_NULL);
sexp_eval(ctx, obj2, NULL);
That snippet shows how to call a procedure. Now, I'm trying to call a procedure with an argument, but I'm not getting it to work.
I'm both new at scheme and at chibi. This is how I thought it would be:
obj1 = sexp_intern(ctx, "my-procedure", -1);
obj2 = sexp_make_fixnum(3);
tmp = sexp_cons(ctx, obj1, obj2);
sym = sexp_cons(ctx, tmp, SEXP_NULL);
res = sexp_eval(ctx, sym, NULL);
I get this error back from chibi: dotted list in source
How can I call a procedure with multiple params?

This did it:
// (define (addValues a) (+ a 5))
obj1 = sexp_intern(ctx, "addValues", -1);
obj2 = sexp_make_fixnum(3);
tmp = sexp_list1(ctx, obj2);
tmp = sexp_cons(ctx, obj1, tmp);
res = sexp_eval(ctx, tmp, NULL);
if (sexp_numberp(res)) {
auto x = sexp_unbox_fixnum(res);
std::cout << "addValues:" << x << "\n";
}

Related

something wrong when I declare an int64 global variable in llvm

I'm trying using llvm to build my own dsl.
Here I meet a strange problem when I'm using VS2017 win32 mode.
I defined a int64 global variable in one module with value 3 by external linkage.
Then when I declare this variable in another module and load it's value, I got 12884901891(same as 0x300000003). When I try this on Linux, it works well.
Hope someone can help me.
Blow is my code.CJITEngine is a simple singleton package.
PS. If I define the global variable with other type rather than int64, such as int32,float,double, this code can run well.
int main()
{
CJITEngine::Instance().Init();
DataLayout &layout = CJITEngine::Instance().GetDataLayout();
using fpType = void(*)(int64_t*);
fpType fp = nullptr;
string name("aaaaaaaa");
{
unique_ptr<Module> pModule = CJITEngine::Instance().CreateModule("module1");
IRBuilder<>& m_oBuilder = CJITEngine::Instance().GetIRBuilder();
Type* pType = m_oBuilder.getInt64Ty();
GlobalVariable* pVarValue = new GlobalVariable(*pModule, pType, false, GlobalValue::ExternalLinkage,
m_oBuilder.getInt64(3), name);
pVarValue->setAlignment(layout.getABITypeAlignment(pType));
pVarValue->setDSOLocal(true);
pModule->addModuleFlag(Module::Error, "NumRegisterParameters", m_oBuilder.getInt32(0));
pModule->addModuleFlag(Module::Error, "wchar_size", m_oBuilder.getInt32(2));
pModule->print(outs(), nullptr);
std::cout << "--------------------------------------------------------" << std::endl;
CJITEngine::Instance().AddModule(std::move(pModule));
}
/////////////////////////////////////////////////////////
{
unique_ptr<Module> pModule = CJITEngine::Instance().CreateModule("module2");
LLVMContext& m_oContext = CJITEngine::Instance().GetContext();
IRBuilder<>& m_oBuilder = CJITEngine::Instance().GetIRBuilder();
Type* pType = m_oBuilder.getInt64Ty();
GlobalVariable* pVarValue = new GlobalVariable(*pModule, pType, false, GlobalValue::ExternalLinkage,
nullptr, name);
pVarValue->setAlignment(layout.getABITypeAlignment(pType));
pVarValue->setDSOLocal(true);
FunctionType* pFuncType = FunctionType::get(m_oBuilder.getVoidTy(), {Type::getInt64PtrTy(m_oContext)}, false);
Function* pFunc = Function::Create(pFuncType, Function::ExternalLinkage, "func", pModule.get());
pFunc->setDSOLocal(true);
BasicBlock* pEntryBlock = BasicBlock::Create(m_oContext, "entry", pFunc);
BasicBlock* pExitBlock = BasicBlock::Create(m_oContext, "exit");
m_oBuilder.SetInsertPoint(pEntryBlock);
auto agr = pFunc->args().begin();
AllocaInst* pParam = m_oBuilder.CreateAlloca(agr->getType());
pParam->setAlignment(layout.getABITypeAlignment(Type::getInt64PtrTy(m_oContext)));
m_oBuilder.CreateAlignedStore(agr, pParam, layout.getABITypeAlignment(Type::getInt64PtrTy(m_oContext)));
Value* pStr = m_oBuilder.CreateAlignedLoad(pVarValue, layout.getABITypeAlignment(Type::getInt64Ty(m_oContext)));
Value* ppp= m_oBuilder.CreateAlignedLoad(pParam, layout.getABITypeAlignment(Type::getInt64PtrTy(m_oContext)));
m_oBuilder.CreateAlignedStore(pStr, ppp, layout.getABITypeAlignment(Type::getInt64Ty(m_oContext)));
m_oBuilder.CreateRetVoid();
pModule->addModuleFlag(Module::Error, "NumRegisterParameters", m_oBuilder.getInt32(0));
pModule->addModuleFlag(Module::Error, "wchar_size", m_oBuilder.getInt32(2));
pModule->print(outs(), nullptr);
CJITEngine::Instance().AddModule(std::move(pModule));
JITSymbol symbol = CJITEngine::Instance().FindSymbol("func");
fp = (fpType)static_cast<intptr_t>(cantFail(symbol.getAddress()));
int64_t x = 10;
fp(&x);
std::cout << hex << x << endl; // x is 0x300000003 here
}
return 0;
}

implementing __index metafunction in C/c++

I have a script to C++ callback/functor system that can call any "registered" C++ function using strings and/or variants.
//REMOVED ERROR CHECKS AND ERRONEOUS STUFF FOR THIS POST
int LuaGameObject::LuaCallFunction( lua_State *luaState )
{
if ( lua_isuserdata( luaState, 1 ) == 1 )
{
int nArgs = lua_gettop( luaState );
//Get GameObject
OGameObject* pGameObject = static_cast<OGameObject*>(lua_touserdata( luaState, 1 ));
if ( pGameObject )
{
//Get FunctionName
const char* functionNameString = lua_tostring( luaState, 2 );
//Get Args
std::vector<OVariant> args;
for ( int i = 3; i <= nArgs; ++i )
{
OVariant variant;
variant.SetFromLua( luaState, i );
args.push_back( variant );
}
//Call it!
CallGameObjectFunction( luaState, pGameObject, functionNameString, args );
return 1;
}
}
return 0;
}
OVariant LuaGameObject::ExecuteLua()
{
lua_State *lState = luaL_newstate();
luaL_openlibs( lState );
lua_register( lState, "Call", LuaCallFunction );
luaL_loadstring( lState, m_pScript );
//now run it
lua_pcall( lState, 0, 1, 0 );
//process return values
OVariant result;
result.SetFromLua( lState, -1 );
lua_close( lState );
return result;
}
In lua I can do something like this...
local king = Call("EmpireManager","GetKing")
Call("MapCamera","ZoomToActor",king)
However, I am feeling that I can use the __index metamethod to simplify the lua...
local king = EmpireManager:GetKing()
MapCamera:ZoomToActor(king)
I was hoping to achieve the simplified lua by using the following implemenation of the __index metamethod
Here is how I register the __index metafunction... (mostly copied from online examples)
void LuaGameObject::Register( lua_State * l )
{
luaL_Reg sRegs[] =
{
{ "__index", &LuaGameObject::LuaCallFunction },
{ NULL, NULL }
};
luaL_newmetatable( l, "luaL_EmpireManager" );
// Register the C functions into the metatable we just created.
luaL_setfuncs( l, sRegs, 0 );
lua_pushvalue( l, -1 );
// Set the "__index" field of the metatable to point to itself
// This pops the stack
lua_setfield( l, -1, "__index" );
// Now we use setglobal to officially expose the luaL_EmpireManager metatable
// to Lua. And we use the name "EmpireManager".
lua_setglobal( l, "EmpireManager" );
}
Unfortunately, I cant seem to get the callback setup right. Lua correctly calls my LuaGameObject::LuaCallFunction, but the stack does not contain what I would like. From within the LuaGameObject::LuaCallFunction, I can find the function name and EmpireManager object on the stack. But, I cant find the args on the stack. What is the proper way to set this up? Or is it not possible?
It is definitely possible to add methods to a userdata type in Lua, as explained in the Programming in Lua guide from the official website.
When you type the following Lua code:
myUserdata:someMethod(arg1,arg2,arg3)
Assuming myUserdata is a "userdata" object, the interpreter will do the following.
Call getmetatable(myUserdata).__index(myUserdata,"someMethod") to get the value of someMethod.
Call someMethod(myUserdata,arg1,arg2,arg3). someMethod can be anything callable from Lua. Examples: a Lua or C function, or a table/userdata with a __call metamethod.
Your __index metamethod should just return a function (or another object callable from Lua) implementing the method. Something like this:
// IMO, quite a misleading name for the __index metamethod (there is a __call metamethod)
int LuaGameObject::LuaCallFunction( lua_State *l)
{
// todo: error checking
OGameObject* pGameObject = static_cast<OGameObject*>(lua_touserdata( luaState, 1 ));
std::string memberName = lua_tostring( luaState, 2 );
int result = 1;
if (memberName == "method1") {
lua_pushcfunction(l,LuaGameObject::luaMethod1);
} else if (memberName == "method2") {
lua_pushcfunction(l,LuaGameObject::luaMethod2);
} else {
result = 0;
}
return result;
}
Basic skeleton of the functions returned by the __index metamethod:
int LuaGameObject::luaMethod1(lua_State* l) {
// todo: error checking.
OGameObject* pGameObject = static_cast<OGameObject*>(lua_touserdata(l, 1));
float arg1 = lua_tonumber(l, 2);
// get other args
pGameObject->method1(arg1 /*, more args if any.*/);
// optionally push return values on the stack.
return 0; // <-- number of return values.
}
Ok so after more research, I now believe that I cannot use __index metafunction to call a c functor with arguments. It only passes the table name and the key to the callback.
However, for anyone interested, it can be used for table-like objects, but not functions (as arguments are not pushed onto the stack). I will it for my "property" objects. They have no arguments and can be used in lua as follows...
local king = EmpireManager:king
king:name = "Arthur"
local name = king:name
These properly link to and call the appropriate C++ objects.functions
Actor::SetName(std::string name)
std::string Actor::GetName()
I had the same problem to call a method from my object and have used this post to develop the solution.
I hope that the example below can be useful to you.
#include <iostream>
#include <string>
#include <map>
#include <functional>
extern "C" {
#include "lua/lua.h"
#include "lua/lauxlib.h"
#include "lua/lualib.h"
}
//template<class UserdataType> // if will be work with lua garbage collector, use a function like that to delete the this_ptr (1st param)
//int DeletePtr(lua_State *lua_state) { // It's necessary register the metatable.__gc and to trust in gc (create just pointer of LuaObjects
// UserdataType** this_ptr = reinterpret_cast<UserdataType**>(lua_touserdata(lua_state, 1));
// delete (*this_ptr);
// return 0;
//}
template<class UserdataType>
int Closure(lua_State *lua_state) {
UserdataType** ptr = reinterpret_cast<UserdataType**>(lua_touserdata(lua_state, 1)); // This closure is being called by call operator ()
return (*ptr)->CallFunction(lua_state); // To access the function name called use lua stack index with lua_upvalueindex(-1)
} // Call the object method to resolve this called there
template<class UserdataType>
int ReturnClosure(lua_State *lua_state) { // This function is called as a lookup of metatable.__index
lua_pushcclosure(lua_state, Closure<UserdataType>, 1); // then we will return a closure to be called through call operator ()
return 1; // The 1st param (the only one) is the action name of function
} // Then a closure will grant access to ReturnClosure params as upvalues (lua_upvalueindex)
class LuaObject {
public:
LuaObject() : userdata_name("userdata1") {
}
void CreateNewUserData(lua_State* lua_ptr, const std::string& global_name) {
RegisterUserData(lua_ptr);
LuaObject** this_ptr = reinterpret_cast<LuaObject**>(lua_newuserdata(lua_ptr, sizeof(LuaObject*)));
*this_ptr = this;
luaL_getmetatable(lua_ptr, userdata_name.c_str());
lua_setmetatable(lua_ptr, -2); // setmetatable(this_ptr, userdata_name)
lua_setglobal(lua_ptr, global_name.c_str()); // store to global scope
}
int CallFunction(lua_State* lua_state) const {
std::string name = lua_tostring(lua_state, lua_upvalueindex(1)); // userdata:<function>(param2, param3)
auto it = functions.find(name); // <function> lua_tostring(lua_state, lua_upvalueindex(1))
if (it != functions.end()) { // <implicit this> lua_touserdata(l, 1)
return it->second(lua_state); // <param #1> lua_touserdata(l, 2)
} // <param #2> lua_touserdata(l, 3)
return 0; // <param #n> lua_touserdata(l, n+1)
}
void NewFunction(const std::string& name, std::function<int(lua_State*)> func) {
functions[name] = func;
}
private:
void RegisterUserData(lua_State* lua_ptr) {
luaL_getmetatable(lua_ptr, userdata_name.c_str());
if (lua_type(lua_ptr, -1) == LUA_TNIL) {
/* create metatable for userdata_name */
luaL_newmetatable(lua_ptr, userdata_name.c_str());
lua_pushvalue(lua_ptr, -1); /* push metatable */
/* metatable.__gc = DeletePtr<LuaObject> */
//lua_pushcfunction(lua_ptr, DeletePtr<LuaObject>);
//lua_setfield(lua_ptr, -2, "__gc");
/* metatable.__index = ReturnClosure<LuaObject> */
lua_pushcfunction(lua_ptr, ReturnClosure<LuaObject>);
lua_setfield(lua_ptr, -2, "__index");
}
}
std::map<std::string, std::function<int(lua_State*)>> functions;
std::string userdata_name;
};
int main(int argc, char* argv[]) {
lua_State* lua_state = luaL_newstate();
luaL_openlibs(lua_state);
LuaObject luaobj;
luaobj.CreateNewUserData(lua_state, "test_obj");
luaobj.NewFunction("action", [](lua_State* l)->int {
std::string result = "action has been executed";
LuaObject** ptr = reinterpret_cast<LuaObject**>(lua_touserdata(l, 1));
result += "\n #1 param is user_data (self == this) value = " + std::to_string(reinterpret_cast<size_t>(*ptr));
for (int i = 2; i <= lua_gettop(l); ++i) {
result += "\n #" + std::to_string(i)+ " = " + lua_tostring(l, i);
}
result += "\n #n param is passed on call operator () #n = " + std::to_string(lua_gettop(l));
lua_pushfstring(l, result.c_str());
return 1;
});
std::string lua_code;
lua_code += "print(test_obj:unknown_function()) \n";
lua_code += "print(test_obj:action()) \n";
lua_code += "print(test_obj:action(1)) \n";
lua_code += "print(test_obj:action(1, 2)) \n";
lua_code += "print(test_obj:action(1, 2, 'abc'))\n";
if (!(luaL_loadbuffer(lua_state, lua_code.c_str(), lua_code.length(), NULL) == 0 && lua_pcall(lua_state, 0, LUA_MULTRET, 0) == 0)) {
std::cerr << "Lua Code Fail: " << lua_tostring(lua_state, -1) << std::endl;
}
lua_close(lua_state);
return 0;
}
Output:
action has been executed
#1 param is user_data (self == this) value = 13629232
#n param is passed on call operator () #n = 1
action has been executed
#1 param is user_data (self == this) value = 13629232
#2 = 1
#n param is passed on call operator () #n = 2
action has been executed
#1 param is user_data (self == this) value = 13629232
#2 = 1
#3 = 2
#n param is passed on call operator () #n = 3
action has been executed
#1 param is user_data (self == this) value = 13629232
#2 = 1
#3 = 2
#4 = abc
#n param is passed on call operator () #n = 4

How can I get the result of a request after executing the request using c++ builder XE6 and Firebird?

After connecting to a Firebird database with C++ builder, I cannot get a result from a simple select request.
I have some confusion about a lot of members of classes:
void __fastcall TForm2::btn1Click(TObject *Sender)
{ TSQLConnection co = new TSQLConnection(this);
Base_Firebird *fb = new Base_Firebird() ;
bool bl = fb->Connecter(co);
String sqlstring = "select nom_action from T_ACTION where CLE_ACTION=6 ";
if (bl)
TSQLQuery *req = new TSQLQuery(NULL) ;
req->SQLConnection = co ;
req->SQL->Add(sqlstring);
req->Open() ;
}
My problem is here after opening the TSQLQuery, I don't know how I can get the result and execute the command.
Try changing the end of your subroutine to something like this:
if (bl)
{ /// you forgot compound operator here !!!!!
TSQLQuery *req = new TSQLQuery(this) ;
req->SQLConnection = co ;
req->SQL->Text = sqlstring;
req->Open() ;
int j = 0;
while( !req->EOF() )
{
++j;
String Value = req->Fields[0]->AsString;
ShowMessageFmt( "Row %d ==> Value: %s ", ARRAYOFCONST(( j, Value )) );
// String MSG = Format( "Row %d ==> Value: %s ", ARRAYOFCONST(( j, Value )) );
// ShowMessage( MSG );
req -> Next();
};
req->Close();
ShowMessage("Data over.");
}
req -> Free(); // maybe "delete req;" would work too, dunno
}
To check:
http://docwiki.embarcadero.com/Libraries/Seattle/en/Vcl.Dialogs.ShowMessageFmt
http://docwiki.embarcadero.com/Libraries/Seattle/en/System.SysUtils.Format
https://osdn.net/projects/cc1101driver/scm/svn/blobs/head/trunk/VC_test/Cpp_builder_2009/Cpp_Builder_test/documents/JVC_20120502/jvcl/examples/JvProgressDialog/BCB/JvProgressDialogMain.cpp
http://www.texttransformer.com/d2chelp/cbuilderarrayofconst.htm
http://docwiki.embarcadero.com/RADStudio/Seattle/en/Open_Arrays#C.2B.2B_functions_that_take_open_array_arguments
http://docwiki.embarcadero.com/RADStudio/Seattle/en/Support_for_Object_Pascal_Data_Types_and_Language_Concepts
Read Embarcadero's documentation. There are whole chapters on how to work the SQL components you are using, including:
How To Perform Database Procedures
Navigating Datasets
Using dbExpress
Using dbExpress Components Index
Using TSQLQuery
Data.SqlExpr.TSQLQuery
For example:
void __fastcall TForm2::btn1Click(TObject *Sender)
{
TSQLConnection *co = new TSQLConnection(NULL);
Base_Firebird *fb = new Base_Firebird();
if (fb->Connecter(co))
{
TSQLQuery *req = new TSQLQuery(NULL);
req->SQLConnection = co;
req->SQL->Text = "select nom_action from T_ACTION where CLE_ACTION=6";
req->Open();
while (!req->Eof)
{
// use req->Fields as needed...
req->Next();
}
delete req;
}
delete fb;
delete co;
}

Pass pure lua object to C function and get value

In Lua Code
Test = {}
function Test:new()
local obj = {}
setmetatable(obj, self)
self.__index = self
return obj
end
local a = Test:new()
a.ID = "abc123"
callCfunc(a)
In C Code
int callCfunc(lua_State * l)
{
void* obj = lua_topointer(l, 1); //I hope get lua's a variable
lua_pushlightuserdata(l, obj);
lua_getfield(l, 1, "ID");
std::string id = lua_tostring(l, 1); //I hoe get the value "abc123"
...
return 0;
}
But My C result is
id = null
Why? How to modify code to work fine ?
PS: I don't hope create C Test Class mapping to lua
==== update1 ====
In addition, I have added the test code to confirm correct incoming parameters.
int callCfunc(lua_State * l)
{
std::string typeName = lua_typename(l, lua_type(l, 1)); // the typeName=="table"
void* obj = lua_topointer(l, 1); //I hope get lua's a variable
lua_pushlightuserdata(l, obj);
lua_getfield(l, 1, "ID");
std::string id = lua_tostring(l, 1); //I hoe get the value "abc123"
...
return 0;
}
the result
typeName == "table"
so incoming parameter type is Correct
I found the reason
Correct c code should is ...
In C Code
int callCfunc(lua_State * l)
{
lua_getfield(l, 1, "ID");
std::string id = lua_tostring(l, -1); //-1
...
return 0;
}
Maybe this - haven't tested sorry - don't have a compiler handy
Input is the table from lua on top of the stack, so getfield(l,1, "ID") should get the field ID from the table at the top of the stack - which in this case is your input table. It then pushes the result to the top of the stack
int callCfunc(lua_State * l)
{
lua_getfield(l, 1, "ID");
std::string id = lua_tostring(l, 1); //I hoe get the value "abc123"
...
return 0;
}

C++ Embeded Python :pass Tuple declared in C++ to a method of a python class

it's ok to pass a tuple as argument of a method, but as soon as I want to pass the tuple to a method of a class it doesn't work(I get a Run Failed at the row "ret = PyEval_CallObject(method,args);"
thanks a lot if someone knows why it doesn't work
the following code used is:
enter code Python Code:
class cVector:
def __init__(self,msg):
self.value = msg
def ComputeNorm(self,vecData):
#don't use vecData for instance
result = 12.
return(result)
enter C++ Code
PyObject *ret, *mymod, *pclass, *method, *args, *object;
float retValue;
Py_Initialize();
PySys_SetPath(".");
// Module
mymod = PyImport_ImportModule("mModule8");
if (mymod == NULL){
cout << "Can't Open a module:\n" ;
Py_DECREF(mymod);
}
// Class
pclass = PyObject_GetAttrString(mymod, "cVector");
if (pclass == NULL) {
Py_DECREF(pclass);
cout << "Can't find class\n";
}
// Parameters/Values
args = Py_BuildValue("(f)", 100.0);
if (args == NULL) {
Py_DECREF(args);
cout << "Can't build argument list for class instance\n";
}
// Object with parameter/value
object = PyEval_CallObject(pclass, args);
if (object == NULL) {
Py_DECREF(object);
cout << "Can't create object instance:\n";
}
// Decrement the argument counter as we'll be using this again
Py_DECREF(args);
// Get the object method - note we use the object as the object
// from which we access the attribute by name, not the class
method = PyObject_GetAttrString(object, "ComputeNorm");
if (method == NULL) {
Py_DECREF(method);
cout << "Can't find method\n";
}
// Decrement the counter for our object, since we now just need
// the method reference
Py_DECREF(object);
// Build our argument list - an empty tuple because there aren't
// any arguments
cout << "Prepare the Tuple:\n" ;
// WE pass a tuple
args = PyTuple_New( 3 );
if (args == NULL) {
Py_DECREF(args);
cout << "Can't build argument list for method call\n";
}
PyObject *py_argument;
// 1st argument
py_argument = PyFloat_FromDouble(5.);
PyTuple_SetItem(args, 0, py_argument);
// 2nd argument
py_argument = PyFloat_FromDouble(10.);
PyTuple_SetItem(args, 1, py_argument);
// 3nd argument
py_argument = PyFloat_FromDouble(15.);
PyTuple_SetItem(args, 2, py_argument);
cout << "Before the Exec:\n" ;
// Call our object method with arguments
ret = PyEval_CallObject(method,args);
//ret = PyObject_CallObject(method,args);
if (ret == NULL) {
Py_DECREF(ret);
cout << "Couldn't call method\n";
}
// Convert the return value back into a C variable and display it
PyArg_Parse(ret, "f", &retValue);
printf("RetValue: %f\n", retValue);
// Kill the remaining objects we don't need
Py_DECREF(method);
Py_DECREF(ret);
// Close off the interpreter and terminate
Py_Finalize();
You don't show how you obtain method. You have to get it from an instance for this to work (here I assume that inst is a PyObject* pointing to an instance of cVector class):
PyObject *method = PyObject_GetAttrString(inst, "ComputeNorm");
Always check for errors:
if (method == NULL)
return NULL;
(or do other appropriate thing, depending on the context)
Then, your code can be greatly shortened:
PyObject *args = Py_BuildValue("(ddd)", 5.0, 10.0, 15.0);
(this creates a tuple with three Python floats made from C doubles)
or even combined with the call:
PyObject *ret = PyObject_CallFunction(method, "(ddd)", 5.0, 10.0, 15.0);
You call even combine everything in one call:
PyObject *ret = PyObject_CallMethod(inst, "ComputeNorm",
"(ddd)", 5.0, 10.0, 15.0);
Again, remeber to check for errors:
if (ret == NULL)
return NULL;
And always decref all the objects you create and don't need anymore (otherwise you will be leaking memory):
Py_DECREF(ret);
(assuming you've used the PyObject_CallMethod, otherwise you might have to decref args and method as well)