lbp_function.h
Go to the documentation of this file.
1 /** @file lbp_function.h luafaudes class to run scripts as rti functions */
2 
3 /* FAU Discrete Event Systems Library (libfaudes)
4 
5 Copyright (C) 2010 Thomas Moor
6 
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11 
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
20 
21 
22 #ifndef FAUDES_LBPFUNCTION_H
23 #define FAUDES_LBPFUNCTION_H
24 
25 #include "corefaudes.h"
26 
27 // forward
28 struct lua_State;
29 
30 namespace faudes{
31 
32 // forward
33 class LuaFunction;
34 class LuaState;
35 
36 /**
37  * A LuaFunctionDefinition is derived from FunctionDefinition to
38  * define a faudes-function by a Lua script. It has
39  * the Lua code as an additional member variable and uses a LuaFunction as a
40  * prototype object. In particular, LuaFunctionDefinitions are allways
41  * valid in the sense that hey have a prototype. The LuaFunction object
42  * implements DoTypeCheck and DoExecute to run the specifed Lua code.
43  * Thus, a LuaFunction can be tranparently accessed via the run-time interface
44  * and bahves like any other registered faudes function.
45  *
46  * Alternatively,
47  * you can use the Install() method to install a LuaFunctionDefinition to
48  * a LuaState. Then, the function can be accessed by the Lua interpreter.
49  * Install() will generate code to dispatch the function variants with the
50  * same semantics as the SWIG generated interface for other faudes functions.
51  * Again, integeration is transparent from the perspective of the Lua interpreter.
52  *
53  *
54  * The token io format is demonstrated by the
55  * following example:
56  *
57  * @code
58  * <LuaFunctionDefinition name="LuaExtension::LargeGenerator">
59  *
60  * <Documentation>
61  * Construct a generator by random.
62  * </Documentation>
63  * <Keywords> "luaextension" "example" </Keywords>
64  *
65  * <VariantSignatures>
66  * <Signature name="LargeGen(#Q,#Sigma,GRes)">
67  * <Parameter name="SizeQ" ftype="Integer" access="In"/>
68  * <Parameter name="SizeSigma" ftype="Integer" access="In"/>
69  * <Parameter name="Res" ftype="Generator" access="Out" />
70  * </Signature>
71  * </VariantSignatures>
72  *
73  * <LuaCode>
74  * <[CDATA[
75  *
76  * -- Extension reports on loading
77  * print('loading luaextension "LargeGenerator"')
78  *
79  * -- Define my function (mangled version of variant name)
80  * function faudes.LargeGen_Q_Sigma_GRes(qn,sn,gen)
81  *
82  * -- Function reports on execution
83  * print(string.format('LargeGen(...): qn=%d sn=%d',qn,sn))
84  *
85  * -- Exeution code
86  * gen:Clear()
87  * for i=1,qn do
88  * gen:InsState(i)
89  * end
90  * for i=1,sn do
91  * gen:InsEvent(string.format('ev_%d',i))
92  * end
93  *
94  * -- Done
95  * return
96  *
97  * -- End of function definition
98  * end
99  *
100  * -- Extension reports on loading
101  * print('loading luaextension: done')
102  *
103  * ]]>
104  * </LuaCode>
105  *
106  * </LuaFunctionDefinition>
107  * @endcode
108  *
109  * Restrictions and conventions:
110  * - Type-checking is done via the Cast() function of the faudes Type interface. As a
111  * consequence, you may only use types that are registered with the run-time-interface.
112  * - On execution, the LuaFunction instance has to locate the respective function
113  * in the supplied lua code. In order to allow for multiple variants, the convention is
114  * to have one lua function each with the name of the corresponding variant. Since
115  * variant names may contain funny characters, name matching is performed after
116  * so called mangeling: any sequence of non-alpha-numerics is replaced by a single "_",
117  * a trailing "_" is dropped. E.g. the variant <tt>res=a+b</tt> matches the Lua function <tt>res_a_b</tt>.
118  * - Parameters other than elementary (integer, boolean and string) are passed to
119  * the Lua function by reference. However, Lua will consistently interpret the reference itself
120  * as a parameter value. Thus, to assign a value to an <tt>access="Out"</tt> or <tt>access="InOut"</tt>
121  * parameter, you must use the assigment memberfunction Assign (as opposed to the assignment operator "=").
122  * - Elementary types (i.e. integers, booleans and strings) are passed to the Lua function by value.
123  * Thus, it would be pointless to have an elementary typed parameter with access attribute other than
124  * <tt>access="In"</tt>. In order to implement elementary typed return values, the respective
125  * Lua function must return the corresponding values by an approriate return statement. The signature
126  * should indicate this by the attribute <tt>creturn="true"</tt>. The current implementation
127  * will automatically imply <tt>creturn="true"</tt> for any <tt>access="Out"</tt> or
128  * <tt>access="InOut"</tt>.
129  * - Since luafaudes has no concept of const references, it is the responsability of the
130  * script programer to respect parameter <tt>access</tt> attributes.
131  * - When using Install() to install the function to a LuaState, a single wrapper function will be
132  * defined to dispatch variants. By convention, this function is located in <tt>faudes.name_of_fdef</tt>,
133  * where <tt>name_of_fdef</tt> is the name of the respective LuaFunctionDefinition.
134  *
135  *
136  *
137  * @ingroup LuabindingsPlugin
138  */
139 
141 
142  // faudes type
144 
145 public:
146 
147  /**
148  * Constructor.
149  *
150  * In contrast to the std FunctionDefinition, the default constructor
151  * sets up a valid lua function definition with a newly created LuaFunction
152  * as prototype.
153  * Of course, you will need to set the signatures and the lua code
154  * to obtain an operational function.
155  */
156  LuaFunctionDefinition(const std::string& name="");
157 
158  /**
159  * Copy constructor
160  */
162 
163  /**
164  * Destructor
165  */
166  virtual ~LuaFunctionDefinition(void){};
167 
168 
169  /**
170  * Clear documentation-data, signature and script (keep prototype)
171  */
172  void Clear(void);
173 
174  /**
175  * Get Lua code
176  *
177  * @return
178  * Lua code as std string
179  */
180  const std::string& LuaCode(void) const;
181 
182  /**
183  * Set Lua code
184  *
185  * @param rCode
186  * Lua code as std string
187  */
188  void LuaCode(const std::string& rCode);
189 
190  /**
191  * Set default lua state.
192  *
193  * Sets the default lua state on which functions that refer to
194  * this function definition will use for execution.
195  * If set to NULL (e.g. on consruction), the
196  * global state is used. However, the function object
197  * itself may overwrite the default.
198  *
199  * @param pL
200  * Lua state
201  */
202  void DefaultL(LuaState* pL);
203 
204  /**
205  * Get default lua state.
206  *
207  * @return
208  * Lua state
209  */
210  LuaState* DefaultL(void) const;
211 
212  /**
213  * Syntax check lua code.
214  *
215  * This routine instantiates a LuaFunction from this function definition
216  * and does all it needs to run the script, except to invoke the any of the
217  * variant functions. The reasoning is, that the script may hang and, thus,
218  * never return. Errors are indicated returned as an error string.
219  *
220  * @return
221  * Error message as string, or empty string on success
222  */
223  std::string SyntaxCheck(void);
224 
225  /**
226  * Evaluate lua code.
227  *
228  * This routine evaluates the LuaCode literally. This method is used to execute
229  * LuaCode that is not part of any particular variant. To execute a
230  * particular variant, instantiate a LuaFunction and invoke Execute().
231  *
232  * If you pass NULL as destination state, the global state will be used.
233  *
234  * @param pL
235  * Reference to the Lua state
236  * @return
237  * Error message as string, or empty string on success
238  */
239  std::string Evaluate(LuaState* pL=NULL);
240 
241  /**
242  * Install this function to a Lua state
243  *
244  * This routine installs the Lua code of this function
245  * definition to the table "faudes" of the specified Lua state.
246  * It also constructs a wrapper function
247  * to dispatch signatures and palces this in the table "faudes".
248  * Effectively, the resulting Lua state is prepared to execute the
249  * Lua function with the same semantics as used for SWIG generated wrappers
250  * of C++ functions.
251  *
252  * If you pass NULL as destination state, the global state will be used.
253  *
254  * @param pL
255  * Reference to the Lua state
256  */
257  void Install(LuaState* pL=NULL) const;
258 
259  /**
260  * Install this function to a Lua state.
261  *
262  * Alternative signature for applications that do not use the
263  * the LuaState wrapper class. See also Install(LuaState*).
264  *
265  * @param pLL
266  * Reference to the Lua state
267  */
268  void Install(lua_State* pLL) const;
269 
270 
271  /*
272  * Register LuaExtension with the run-time-interface.
273  *
274  * This static convenience method registers all LuaFunctionDefinitions found
275  * in an extension file with the FunctionRegistry. Thus, after registration
276  * you can use the Lua function via the run-time-interface as if they
277  * where C++ functions.
278  *
279  * Note: if you also want to use the provided functions within a Lua interpreter,
280  * you must also install the extension to a lua state. This can be done on
281  * a per-file basis by LuaState::Install(const std::string&) or for the any
282  * functions registered by LuaState::Reset().
283  *
284  *
285  * @param rFilename
286  * Source file (typically .flx)
287  */
288  static void Register(const std::string& rFilename);
289 
290 
291 protected:
292 
293  /**
294  * Std faudes type interface: assignment.
295  *
296  * @param rSrc
297  * Source to copy from
298  * @return Reference to this object.
299  */
300  virtual void DoAssign(const LuaFunctionDefinition& rSrc);
301 
302  /**
303  * Std faudes type interface: test equality
304  *
305  * @param rOther
306  * Other object to compare with.
307  * @return
308  * True on match.
309  */
310  virtual bool DoEqual(const LuaFunctionDefinition& rOther) const;
311 
312  /**
313  * Read configuration data of this object from TokenReader.
314  * Actual reading is done by DoReadCore.
315  *
316  * The section defaults to "LuaFunctionDefinition", context ignored.
317  *
318  * @param rTr
319  * TokenReader to read from
320  * @param rLabel
321  * Section to read
322  * @param pContext
323  * Read context to provide contextual information (ignored)
324  *
325  * @exception Exception
326  * - Token mismatch (id 50, 51, 52)
327  * - IO error (id 1)
328  */
329  virtual void DoRead(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
330 
331  /**
332  * Read configuration data of this object from TokenReader.
333  *
334  * This method reads members only, it does not read the section.
335  *
336  * @param rTr
337  * TokenReader to read from
338  *
339  * @exception Exception
340  * - Token mismatch (id 50, 51, 52)
341  * - IO error (id 1)
342  */
343  virtual void DoReadCore(TokenReader& rTr);
344 
345  /**
346  * Write configuration data of this object to TokenWriter.
347  *
348  * The section defaults to "LuaFunctionDefinition", context ignored.
349  *
350  * @param rTw
351  * Reference to TokenWriter
352  * @param rLabel
353  * Label of section to write
354  * @param pContext
355  * Write context to provide contextual information
356  *
357  * @exception Exception
358  * - IO errors (id 2)
359  */
360  virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
361 
362  /**
363  * Write configuration data of this object to TokenWriter.
364  *
365  * This method writes plain member data, the section lables are not
366  * written.
367  *
368  * @param rTw
369  * Reference to TokenWriter
370  *
371  * @exception Exception
372  * - IO errors (id 2)
373  */
374  virtual void DoWriteCore(TokenWriter& rTw) const;
375 
376 
377  /**
378  * Assign prototype object
379  *
380  * @param pFunc
381  * Function instance
382  *
383  */
384  virtual void Prototype(Function* pFunc);
385 
386  /** Typed prototype instance */
388 
389  /** Lua code */
390  std::string mLuaCode;
391 
392  /** Lua file */
393  std::string mLuaFile;
394 
395  /** Default lua state*/
397 
398 };
399 
400 
401 /**
402  * Wrapper class to maintain a Lua state.
403  *
404  * This class is still under construction. It aims for a sensible collection
405  * of operations that we may want to execute on a Lua state from the libFAUDES
406  * perspective. The current implementation provides static members that directly
407  * operate on a lua_State as well as a more comfortable interface that
408  * operates on thre wrapped faudes::LusState.
409  *
410  * @ingroup LuabindingsPlugin
411  */
412 
414 public:
415  /**
416  * Constructor
417  */
418  LuaState(void);
419 
420  /**
421  * Destructor
422  */
423  ~LuaState(void);
424 
425  /**
426  * Access Lua state.
427  */
428  lua_State* LL(void);
429 
430  /**
431  * Convenience global Lua state.
432  */
433  static LuaState* G(void);
434 
435  /**
436  * Reinitialize Lua state.
437  *
438  * This method reconstructs the internal Lua state.
439  * Any references become invalid. Any LuaFunctiondefinitions from
440  * the FunctionRegistry will be (re-)installed to the new state.
441  */
442  void Reset(void);
443 
444  /**
445  * Install LuaExtension to Lua state.
446  *
447  * This function instantiates a LuaFunctionDefinition objects from
448  * the file and uses the Install member function to install each function
449  * to the specified lua state. Thus, after the extension has been installed,
450  * the respective Lua functions can be invoked within Lua as if they where
451  * C++ function with SWIG generated wrappers.
452  *
453  * Note: if you want to use the extension via the run-time-interface, you
454  * must also register them with the FunctionRegistry; see also the static method
455  * LuaFunctionDefinition::Register(const std::string&).
456  *
457  * @param rFilename
458  * Source file (typically .flx)
459  */
460  void Install(const std::string& rFilename);
461 
462  /**
463  * Initialze.
464  *
465  * Loads std libraries and libFAUDES wrappers.
466  *
467  * Note: this static version is provided for applications
468  * that maintain their lua state themselves. If yo use
469  * the wrapper class LuaState, you dont need explicit
470  * initialisation.
471  *
472  * @param pLL
473  * Lua state
474  */
475  static void Initialize(lua_State* pLL);
476 
477  /**
478  * Install LuaExtension to Lua state.
479  *
480  * Note: this static version is provided for applications
481  * that maintain their lua state themselves. If yo use
482  * the wrapper class LuaState, you should use the Install(const std::string&) method.
483  *
484  * @param pLL
485  * Target lua state
486  * @param rFilename
487  * Source file
488  * @ingroup LuabindingsPlugin
489  */
490  static void Install(lua_State* pLL, const std::string& rFilename);
491 
492  /**
493  * Push faudes typed object on the Lua stack.
494  *
495  * This method uses SWIG generated constructors to instantiate new Lua userdata
496  * object of the same type as the specified data. It than invokes
497  * the faudes Assign method to assign a copy.
498  *
499  * @param fdata
500  * Data to push
501  * @exception Exception
502  * - Lua Error (id 49)
503  *
504  */
505  void Push(const Type* fdata);
506 
507  /**
508  * Push faudes typed object on the Lua stack.
509  *
510  * This static version is meant for applications that maintain
511  * their Lus state themselves. See also Push(const Type&)
512  *
513  * @param pLL
514  * Lua state
515  * @param fdata
516  * Data to push
517  * @exception Exception
518  * - Lua Error (id 49)
519  *
520  */
521  static void Push(lua_State* pLL, const Type* fdata);
522 
523  /**
524  * Pop faudes typed object from Lua stack.
525  *
526  * This method uses SWIG generated type casts to retrieve the
527  * faudes object from the userdata on the top of the stack.
528  * It then uses the faudes Copy() method to instantiate a copy,
529  * to be owned by the caller.
530  *
531  *
532  * @return
533  * Destination for pop data
534  * @exception Exception
535  * - Lua Error (id 49)
536  *
537  */
538  Type* Pop(void);
539 
540  /**
541  * Pop faudes typed object from Lua stack.
542  *
543  * This static version is meant for applications that maintain
544  * their Lua state themselves. See also Pop(const Type&)
545  *
546  * @param pLL
547  * Lua state
548  * @return
549  * Destination for pop data
550  * @exception Exception
551  * - Lua Error (id 49)
552  *
553  */
554  static Type* Pop(lua_State* pLL);
555 
556  /**
557  * Get/set global data
558  *
559  * This method provides access to global variables.
560  * To set a variable, provide a non-NULL fdata parameter.
561  * If you obmitt the fdata paraneter, the default will indicate a
562  * get operation. Here, the value is returned as a copy and
563  * owned by the caller.
564  *
565  * An expection is thrown if the variable either does not exist,
566  * or cannot be converted to a faudes::Type.
567  *
568  * @param gname
569  * Name of global variable
570  * @param fdata
571  * Data to set
572  * @exception Exception
573  * - Lua Error (id 49)
574  *
575  */
576  Type* Global(const std::string& gname, const Type* fdata=0);
577 
578  /**
579  * Get/set global data
580  *
581  * This static version is meant for applications that maintain
582  * their Lua state themselves. See also Globat(const std::string&, const Type*)
583  *
584  * @param pLL
585  * Lua state
586  * @param gname
587  * Name of global variable
588  * @param fdata
589  * Data to set
590  * @exception Exception
591  * - Lua Error (id 49)
592  *
593  */
594  static Type* Global(lua_State* pLL, const std::string& gname, const Type* fdata=0);
595 
596  /**
597  * Evaluate Lua expression.
598  *
599  * This method runs the Lua-interpreter on the specified expression.
600  * In the case of an error, an exception will be thrown.
601  *
602  * @exception Exception
603  * - Lua Error (id 49)
604  *
605  */
606  void Evaluate(const std::string& expr);
607 
608  /**
609  * Evaluate Lua expression.
610  *
611  * This static version is meant for applications that maintain
612  * their Lua state themselves. See also Evaluate(const std::string&)
613  *
614  * @param pLL
615  * Lua state
616  * @param expr
617  * Expression to evaluate
618  * @exception Exception
619  * - Lua Error (id 49)
620  *
621  */
622  static void Evaluate(lua_State* pLL, const std::string& expr);
623 
624  /**
625  * Complete Lua identifier
626  *
627  * This method uses a variation of Mike Pall's advaced readline
628  * support patch to fugure possible completions if a string
629  * to match a valid identifyer.
630  *
631  * @param word
632  * String to complete
633  * @return
634  * List of completions, first entry is longest common prefix.
635  */
636  std::list< std::string > Complete(const std::string& word);
637 
638  /**
639  * Complete Lua identifier
640  *
641  * This static version is meant for applications that maintain
642  * their Lua state themselves. See also Evaluate(const std::string&)
643  *
644  * @param pLL
645  * Lua state
646  * @param word
647  * String to complete
648  * @return
649  * List of completions, first entry is longest common prefix.
650  */
651  static std::list< std::string > Complete(lua_State* pLL, const std::string& word);
652 
653 
654 private:
655 
656  // disable copy constructor
657  LuaState(const LuaState&){};
658  // lua state
659  lua_State* mpLL;
660  // open/close lua state
661  void Open(void);
662  void Close(void);
663 };
664 
665 
666 /**
667  * A LuaFunction is a faudes-function that executes a luafaudes script.
668  *
669  * LuaFunction is derived from Function and implements the DoTypeCheck and DoExecute
670  * interface to run the lua code as supplied by the corresponding function defintion.
671  * Thus, it is considered an error to set the function definition to an object that
672  * does not cast to a LuaFunctionDefinition.
673  *
674  * @ingroup LuabindingsPlugin
675  */
676 
678 
679  public:
680  /**
681  * Constructor.
682  * For the function to be operational, a valid reference to the corresponding
683  * LuaFunctionDefinition is required. The only exception is the prototype function
684  * object used in the LuaFunctionDefinition itself.
685  */
687 
688  /** Destructor */
689  ~LuaFunction(void){};
690 
691  /**
692  * Construct on heap.
693  * Create a new instance of this function class and return pointer.
694  * The new instance will use the same function definition as this instance.
695  *
696  * @return
697  * Pointer to faudes::Function instance.
698  *
699  */
700  virtual LuaFunction* New() const;
701 
702 
703  /**
704  * Set function definition.
705  * Normally, functions are provided with a function definition on construction.
706  * The only exception are prototype objects used in function definitions themselfs
707  * and in the function registry.
708  *
709  * @param fdef
710  * Function definition to set.
711  *
712  */
713  void Definition(const FunctionDefinition* fdef);
714 
715 
716  /**
717  * Get function definition.
718  *
719  * @return
720  * Function definition used by this function.
721  *
722  */
723  const LuaFunctionDefinition* Definition(void) const;
724 
725 
726  /**
727  * Syntax check lua code.
728  *
729  * This routine does all it needs to run the script,
730  * except to invoke the specified function. The reasoning is, that
731  * the script may hang and, thus, never return. A consequence
732  * is, that you must set a variant and you must supply parameter
733  * values befor checking. You may use AllocateValues() and FreeValues()
734  * for this purpose. Errors are indicated by an exception.
735  *
736  * Note that the LuaFunctionDefinition provides a convenience wrapper
737  * that runs the check on all variants and cares about value allocation.
738  *
739  * @exception Exception
740  * - No such variant (id 47)
741  * - Error in Lua script (id 49)
742  */
743  void SyntaxCheck(void);
744 
745  /**
746  * Evaluate lua code.
747  *
748  * This routine avaluates the associated Lua code literally, i.e.
749  * no arguments are passed, no specific function is invoked.
750  * See also Execute().
751  *
752  * @exception Exception
753  * - Error in Lua script (id 49)
754  */
755  void Evaluate(void);
756 
757 
758  /**
759  * Set lua state
760  *
761  * Sets the lua state which this function will use for execution.
762  * If set to NULL (e.g. on consruction), the
763  * function definition's default state will be used. If
764  * this is not set either, the global state is used.
765  *
766  * @param l
767  * Lua state
768  */
769  void L(LuaState* l);
770 
771  /**
772  * Get default lua state
773  *
774  * @return
775  * Lua state
776  */
777  LuaState* L(void);
778 
779  protected:
780 
781  /*
782  * Do set variant from function definition.
783  *
784  * For LuaFunctions, we accept the special variant -1 for
785  * as "no variant", just run the script on execution.
786  *
787  * @param n
788  * Variant index
789  *
790  * @exception Exception
791  * - No function definition available (id 47)
792  * - No such variant (id 48)
793  */
794  virtual void DoVariant(int n);
795 
796 
797  /**
798  * Method to test the type of an assigned parameter with the
799  * specified faudes::Signature (i.e. their TypeDefinition label).
800  *
801  * Note: this method is called by Function::Execute() before actual function
802  * execution via DoExecute(). It may be used to perform a dynamic cast in
803  * preparation of DoExecute(). The latter is only called, if all types match.
804  *
805  * @param n
806  * Position of parameter to check
807  * @return
808  * True if type matches signature.
809  *
810  * @exception Exception
811  * - Signature undefined (id 48)
812  * - Parameter number out of range (id 48)
813  */
814  virtual bool DoTypeCheck(int n);
815 
816  /**
817  * Executes code as supplied by FunctionDefinition
818  *
819  * @exception Exception
820  * - Exception during lua setup (id 49)
821  * - Any exception during execution of script
822  */
823  virtual void DoExecute();
824 
825  /**
826  * Execute stages
827  *
828  * @exception Exception
829  * - Exception during lua setup (id 49)
830  */
831  virtual void DoExecuteA();
832 
833  /**
834  * Execute stages
835  *
836  * @exception Exception
837  * - Exception during lua setup (id 49)
838  */
839  virtual void DoExecuteB();
840 
841  /**
842  * Execute stages
843  *
844  * @exception Exception
845  * - Exception during lua setup (id 49)
846  * - Any exception during execution of script
847  */
848  virtual void DoExecuteC();
849 
850  /**
851  * Execute stages
852  *
853  * @exception Exception
854  * - Exception during lua setup (id 49)
855  */
856  virtual void DoExecuteD();
857 
858 
859  /**
860  * Execute stages
861  *
862  * @exception Exception
863  * - Exception during lua setup (id 49)
864  */
865  virtual void DoExecuteE();
866 
867 
868  /** Typed reference to definition */
870 
871  /** State of Lua interpreter */
873  lua_State* pLL;
874  int mFtable;
876  void* mFType;
877  std::vector<bool> mLReturn;
878  std::vector<bool> mLParameter;
881 };
882 
883 
884 
885 
886 
887 } // namespace
888 #endif
#define FAUDES_API
Interface export/import symbols: windows.
Definition: cfl_platform.h:81
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
faudes type declaration macro
Definition: cfl_types.h:867
A FunctionDefinition defines the interface to a faudes-function.
A faudes-function hosts parameter values of some faudes type and provides a method to perform an oper...
A LuaFunctionDefinition is derived from FunctionDefinition to define a faudes-function by a Lua scrip...
Definition: lbp_function.h:140
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
Read configuration data of this object from TokenReader.
virtual void DoWriteCore(TokenWriter &rTw) const
Write configuration data of this object to TokenWriter.
LuaState * pDefaultL
Default lua state.
Definition: lbp_function.h:396
virtual void DoReadCore(TokenReader &rTr)
Read configuration data of this object from TokenReader.
std::string mLuaFile
Lua file.
Definition: lbp_function.h:393
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
Write configuration data of this object to TokenWriter.
LuaFunction * pLuaFunction
Typed prototype instance.
Definition: lbp_function.h:387
std::string mLuaCode
Lua code.
Definition: lbp_function.h:390
static void Register(const std::string &rFilename)
virtual ~LuaFunctionDefinition(void)
Destructor.
Definition: lbp_function.h:166
A LuaFunction is a faudes-function that executes a luafaudes script.
Definition: lbp_function.h:677
void Definition(const FunctionDefinition *fdef)
Set function definition.
LuaState * L(void)
Get default lua state.
~LuaFunction(void)
Destructor.
Definition: lbp_function.h:689
virtual void DoExecuteC()
Execute stages.
std::vector< bool > mLParameter
Definition: lbp_function.h:878
void SyntaxCheck(void)
Syntax check lua code.
virtual void DoExecuteB()
Execute stages.
void L(LuaState *l)
Set lua state.
virtual void DoExecuteD()
Execute stages.
LuaState * pL
State of Lua interpreter.
Definition: lbp_function.h:872
virtual void DoExecute()
Executes code as supplied by FunctionDefinition.
LuaFunction(const LuaFunctionDefinition *fdef)
Constructor.
virtual void DoExecuteE()
Execute stages.
void Evaluate(void)
Evaluate lua code.
virtual bool DoTypeCheck(int n)
Method to test the type of an assigned parameter with the specified faudes::Signature (i....
virtual LuaFunction * New() const
Construct on heap.
const LuaFunctionDefinition * pLuaFuncDef
Typed reference to definition.
Definition: lbp_function.h:869
std::vector< bool > mLReturn
Definition: lbp_function.h:877
virtual void DoVariant(int n)
const LuaFunctionDefinition * Definition(void) const
Get function definition.
virtual void DoExecuteA()
Execute stages.
Wrapper class to maintain a Lua state.
Definition: lbp_function.h:413
lua_State * mpLL
Definition: lbp_function.h:657
static void Initialize(lua_State *pLL)
Initialze.
Type * Global(const std::string &gname, const Type *fdata=0)
Get/set global data.
static Type * Global(lua_State *pLL, const std::string &gname, const Type *fdata=0)
Get/set global data.
Type * Pop(void)
Pop faudes typed object from Lua stack.
static LuaState * G(void)
Convenience global Lua state.
static void Evaluate(lua_State *pLL, const std::string &expr)
Evaluate Lua expression.
static Type * Pop(lua_State *pLL)
Pop faudes typed object from Lua stack.
static void Push(lua_State *pLL, const Type *fdata)
Push faudes typed object on the Lua stack.
LuaState(const LuaState &)
Definition: lbp_function.h:657
void Install(const std::string &rFilename)
Install LuaExtension to Lua state.
void Close(void)
void Evaluate(const std::string &expr)
Evaluate Lua expression.
void Open(void)
void Reset(void)
Reinitialize Lua state.
lua_State * LL(void)
Access Lua state.
std::list< std::string > Complete(const std::string &word)
Complete Lua identifier.
void Push(const Type *fdata)
Push faudes typed object on the Lua stack.
static std::list< std::string > Complete(lua_State *pLL, const std::string &word)
Complete Lua identifier.
LuaState(void)
Constructor.
~LuaState(void)
Destructor.
A TokenReader reads sequential tokens from a file or string.
A TokenWriter writes sequential tokens to a file, a string or stdout.
Base class of all libFAUDES objects that participate in the run-time interface.
Definition: cfl_types.h:239
Includes all libFAUDES headers, no plugins.
static void Install(lua_State *pLL, const std::string &rFilename)
Install LuaExtension to Lua state.
libFAUDES resides within the namespace faudes.

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen