#include <string>
#include "ycp/YCPValue.h"
#include "ycp/YCode.h"
#include "ycp/YBlock.h"
#include "ycp/SymbolEntryPtr.h"
#include "ycp/y2log.h"
Go to the source code of this file.
Classes | |
class | Y2CPPFunctionCallBase |
class | Y2CPPFunctionCall |
class | Y2CPPFunction |
Defines | |
#define | Y2FUNCTIONCALL(namespace, name, signature, impl_class, impl_func) |
Macro to declare a class for calling a C++-based method without parameters. | |
#define | Y2FUNCTIONCALL1(namespace, name, signature, param1type, impl_class, impl_func) |
Macro to declare a class for calling a C++-based method with a single parameter. | |
#define | Y2FUNCTIONCALL2(namespace, name, signature, param1type, param2type, impl_class, impl_func) |
Macro to declare a class for calling a C++-based method with two parameters. | |
#define | Y2FUNCTIONCALL3(namespace, name, signature, param1type, param2type, param3type, impl_class, impl_func) |
Macro to declare a class for calling a C++-based method with three parameters. | |
#define | Y2FUNCTIONCALL4(namespace, name, signature, param1type, param2type, param3type, param4type, impl_class, impl_func) |
Macro to declare a class for calling a C++-based method with three parameters. | |
#define | REGISTERFUNCTIONCALL(position, namespace, name) |
Registers a function without parameter in a namespace. | |
#define | REGISTERFUNCTIONCALL1(position, namespace, name) |
Registers a function with a single parameter in a namespace. | |
#define | REGISTERFUNCTIONCALL2(position, namespace, name) |
Registers a function with two parameters in a namespace. | |
#define | REGISTERFUNCTIONCALL3(position, namespace, name) |
Registers a function with three parameters in a namespace. | |
#define | REGISTERFUNCTIONCALL4(position, namespace, name) |
Registers a function with four parameters in a namespace. |
These macros and helper classes ease building a table of a functions to be avaiable to the rest of YaST.
Each function must be implemented using a class. The class declaration and all needed machinery are hidden in the Y2FUNCTIONCALL macros. Then, the macro must be registered at runtime using the corresponding REGISTERFUNCTIONCALL macro.
|
Value: do { \ Y2CPPFunction* mf = new Y2CPPFunction ( \ this, \ #name, \ new namespace##name##Function (this)); \ enterSymbol (mf->sentry (position), 0); \ } while (0) The function class must be already declared using the Y2FUNCTIONCALL macro. This macro registers the symbol in a table of globally visible symbols of the namespace.
|
|
Value: do { \ Y2CPPFunction* mf = new Y2CPPFunction ( \ this, \ #name, \ new namespace##name##Function1 (this)); \ enterSymbol (mf->sentry (position), 0); \ } while (0) The function class must be already declared using the Y2FUNCTIONCALL1 macro. This macro registers the symbol in a table of globally visible symbols of the namespace.
|
|
Value: do { \ Y2CPPFunction* mf = new Y2CPPFunction ( \ this, \ #name, \ new namespace##name##Function2 (this)); \ enterSymbol (mf->sentry (position), 0); \ } while (0) The function class must be already declared using the Y2FUNCTIONCALL2 macro. This macro registers the symbol in a table of globally visible symbols of the namespace.
|
|
Value: do { \ Y2CPPFunction* mf = new Y2CPPFunction ( \ this, \ #name, \ new namespace##name##Function3 (this)); \ enterSymbol (mf->sentry (position), 0); \ } while (0) The function class must be already declared using the Y2FUNCTIONCALL3 macro. This macro registers the symbol in a table of globally visible symbols of the namespace.
|
|
Value: do { \ Y2CPPFunction* mf = new Y2CPPFunction ( \ this, \ #name, \ new namespace##name##Function4 (this)); \ enterSymbol (mf->sentry (position), 0); \ } while (0) The function class must be already declared using the Y2FUNCTIONCALL4 macro. This macro registers the symbol in a table of globally visible symbols of the namespace.
|
|
Value: class namespace##name##Function : public Y2CPPFunctionCall <impl_class> { \ public: \ namespace##name##Function(impl_class* instance) : \ Y2CPPFunctionCall <impl_class> (signature, instance) \ {} \ virtual void registerParameters (YBlockPtr) \ { \ } \ virtual YCPValue evaluate (bool cse=false) \ { \ if (cse) return YCPNull (); \ return m_instance->impl_func (); \ } \ } The method impl_func must return a YCPValue.
Y2FUNCTIONCALL (Pkg, YouGetDirectory, "string ()", PkgModuleFunctions, YouGetDirectory) |
|
Value: class namespace##name##Function1 : public Y2CPPFunctionCall <impl_class> { \ public: \ namespace##name##Function1(impl_class* instance) : \ Y2CPPFunctionCall <impl_class> (signature, instance) \ {} \ virtual void registerParameters (YBlockPtr decl) \ { \ newParameter (decl, 1, Type::Const##param1type ); \ } \ virtual YCPValue evaluate (bool cse=false) \ { \ if (cse) return YCPNull (); \ YCPValue param1 = m_param1->value (); \ if (param1.isNull () || param1->isVoid ()) \ { \ ycperror ("Passing 'nil' to %s::%s", #namespace, #name); \ return YCPNull (); \ } \ return m_instance->impl_func (param1->as##param1type ()); \ } \ } The method impl_func must return a YCPValue. The type of a parameter is prefixed with YCP to get a valid YCPValue-based class. As a consequence, the parameter type must start with the uppercase letter, for example List for YCPList.
Y2FUNCTIONCALL1 (Pkg, IsAvailable, "boolean (string)", PkgModuleFunctions, IsAvailable) |
|
Value: class namespace##name##Function2 : public Y2CPPFunctionCall <impl_class> { \ public: \ namespace##name##Function2(impl_class* instance) : \ Y2CPPFunctionCall <impl_class> (signature, instance) \ {} \ virtual void registerParameters (YBlockPtr decl) \ { \ newParameter (decl, 1, Type::Const##param1type ); \ newParameter (decl, 2, Type::Const##param2type ); \ } \ virtual YCPValue evaluate (bool cse=false) \ { \ if (cse) return YCPNull (); \ YCPValue param1 = m_param1->value (); \ YCPValue param2 = m_param2->value (); \ if (param1.isNull () || param1->isVoid ()) \ { \ ycperror ("Passing 'nil' to %s::%s", #namespace, #name); \ return YCPNull (); \ } \ if (param2.isNull () || param2->isVoid ()) \ { \ ycperror ("Passing 'nil' to %s::%s", #namespace, #name); \ return YCPNull (); \ } \ return m_instance->impl_func ( \ param1->as##param1type () \ , param2->as##param2type ()); \ } \ } The method impl_func must return a YCPValue. The types of parameters are prefixed with YCP to get a valid YCPValue-based classes. As a consequence, the parameter type must start with the uppercase letter, for example List for YCPList.
Y2FUNCTIONCALL2 (Pkg, TargetInit, "boolean (string, boolean)", PkgModuleFunctions, TargetInit) |
|
Macro to declare a class for calling a C++-based method with three parameters. The method impl_func must return a YCPValue. The types of parameters are prefixed with YCP to get a valid YCPValue-based classes. As a consequence, the parameter type must start with the uppercase letter, for example List for YCPList.
Y2FUNCTIONCALL3 (Pkg, SourceProvideFile, "string (integer, integer, string)", PkgModuleFunctions, SourceProvideFile) |
|
Macro to declare a class for calling a C++-based method with three parameters. The method impl_func must return a YCPValue. The types of parameters are prefixed with YCP to get a valid YCPValue-based classes. As a consequence, the parameter type must start with the uppercase letter, for example List for YCPList.
Y2FUNCTIONCALL4 ( Pkg, FilterPackages, "list<string> (boolean, boolean, boolean, boolean)", Boolean, Boolean, Boolean, Boolean, PkgModuleFunctions, FilterPackages); |