| |
|
|||||||
|
|
||||||||
|
Public Member Functions |
Static Public Member Functions |
Protected Member Functions |
Protected Attributes |
List of all members
faudes::LuaFunctionDefinition Class Reference Detailed DescriptionA LuaFunctionDefinition is derived from FunctionDefinition to define a faudes-function by a Lua script. It has the Lua code as an additional member variable and uses a LuaFunction as a prototype object. In particular, LuaFunctionDefinitions are allways valid in the sense that hey have a prototype. The LuaFunction object implements DoTypeCheck and DoExecute to run the specifed Lua code. Thus, a LuaFunction can be tranparently accessed via the run-time interface and bahves like any other registered faudes function. Alternatively, you can use the Install() method to install a LuaFunctionDefinition to a LuaState. Then, the function can be accessed by the Lua interpreter. Install() will generate code to dispatch the function variants with the same semantics as the SWIG generated interface for other faudes functions. Again, integeration is transparent from the perspective of the Lua interpreter. The token io format is demonstrated by the following example: <LuaFunctionDefinition name="LuaExtension::LargeGenerator">
Construct a generator by random.
<VariantSignatures>
<Signature name="LargeGen(#Q,#Sigma,GRes)">
</Signature>
</VariantSignatures>
<LuaCode>
<[CDATA[
-- Extension reports on loading
print('loading luaextension "LargeGenerator"')
-- Define my function (mangled version of variant name)
function faudes.LargeGen_Q_Sigma_GRes(qn,sn,gen)
-- Function reports on execution
print(string.format('LargeGen(...): qn=%d sn=%d',qn,sn))
-- Exeution code
gen:Clear()
for i=1,qn do
gen:InsState(i)
end
for i=1,sn do
gen:InsEvent(string.format('ev_%d',i))
end
-- Done
return
-- End of function definition
end
-- Extension reports on loading
print('loading luaextension: done')
]]>
</LuaCode>
Definition cfl_types.h:1334 Definition cfl_functions.h:720 const std::string & LuaCode(void) const Definition lbp_function.cpp:245 Definition cfl_functions.h:45 Definition cfl_functions.h:220 Definition cfl_agenerator.h:43 Restrictions and conventions:
Definition at line 142 of file lbp_function.h.
Constructor & Destructor Documentation◆ LuaFunctionDefinition() [1/2]
Constructor. In contrast to the std FunctionDefinition, the default constructor sets up a valid lua function definition with a newly created LuaFunction as prototype. Of course, you will need to set the signatures and the lua code to obtain an operational function. Definition at line 181 of file lbp_function.cpp. ◆ LuaFunctionDefinition() [2/2]
Copy constructor Definition at line 192 of file lbp_function.cpp. ◆ ~LuaFunctionDefinition()
Destructor Definition at line 168 of file lbp_function.h. Member Function Documentation◆ Clear()
Clear documentation-data, signature and script (keep prototype) Reimplemented from faudes::FunctionDefinition. Definition at line 227 of file lbp_function.cpp. ◆ DefaultL() [1/2]
Set default lua state. Sets the default lua state on which functions that refer to this function definition will use for execution. If set to NULL (e.g. on consruction), the global state is used. However, the function object itself may overwrite the default.
Definition at line 261 of file lbp_function.cpp. ◆ DefaultL() [2/2]
◆ DoCopy()
Std faudes type interface: assignment.
Definition at line 201 of file lbp_function.cpp. ◆ DoEqual()
Std faudes type interface: test equality
Definition at line 217 of file lbp_function.cpp. ◆ DoRead()
Read configuration data of this object from TokenReader. Actual reading is done by DoReadCore. The section defaults to "LuaFunctionDefinition", context ignored.
Reimplemented from faudes::FunctionDefinition. Definition at line 534 of file lbp_function.cpp. ◆ DoReadCore()
Read configuration data of this object from TokenReader. This method reads members only, it does not read the section.
Reimplemented from faudes::FunctionDefinition. Definition at line 573 of file lbp_function.cpp. ◆ DoWrite()
Write configuration data of this object to TokenWriter. The section defaults to "LuaFunctionDefinition", context ignored.
Reimplemented from faudes::FunctionDefinition. Definition at line 598 of file lbp_function.cpp. ◆ DoWriteCore()
Write configuration data of this object to TokenWriter. This method writes plain member data, the section lables are not written.
Reimplemented from faudes::FunctionDefinition. Definition at line 607 of file lbp_function.cpp. ◆ Evaluate()
Evaluate lua code. This routine evaluates the LuaCode literally. This method is used to execute LuaCode that is not part of any particular variant. To execute a particular variant, instantiate a LuaFunction and invoke Execute(). If you pass NULL as destination state, the global state will be used.
Definition at line 304 of file lbp_function.cpp. ◆ Install() [1/2]
Install this function to a Lua state. Alternative signature for applications that do not use the the LuaState wrapper class. See also Install(LuaState*).
Definition at line 327 of file lbp_function.cpp. ◆ Install() [2/2]
Install this function to a Lua state This routine installs the Lua code of this function definition to the table "faudes" of the specified Lua state. It also constructs a wrapper function to dispatch signatures and palces this in the table "faudes". Effectively, the resulting Lua state is prepared to execute the Lua function with the same semantics as used for SWIG generated wrappers of C++ functions. If you pass NULL as destination state, the global state will be used.
Definition at line 321 of file lbp_function.cpp. ◆ LuaCode() [1/2]
Set Lua code
Definition at line 250 of file lbp_function.cpp. ◆ LuaCode() [2/2]
◆ Prototype()
Copy prototype object
Reimplemented from faudes::FunctionDefinition. Definition at line 237 of file lbp_function.cpp. ◆ Register()
Definition at line 549 of file lbp_function.cpp. ◆ SyntaxCheck()
Syntax check lua code. This routine instantiates a LuaFunction from this function definition and does all it needs to run the script, except to invoke the any of the variant functions. The reasoning is, that the script may hang and, thus, never return. Errors are indicated returned as an error string.
Definition at line 266 of file lbp_function.cpp. Member Data Documentation◆ mLuaCode
Lua code Definition at line 391 of file lbp_function.h. ◆ mLuaFile
Lua file Definition at line 394 of file lbp_function.h. ◆ pDefaultL
Default lua state Definition at line 397 of file lbp_function.h. ◆ pLuaFunction
Typed prototype instance Definition at line 388 of file lbp_function.h. The documentation for this class was generated from the following files: libFAUDES 2.34e --- 2026.03.16 --- c++ api documentaion by doxygen |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||