Home » U++ Library support » U++ MT-multithreading and servers » How to call a C++ function in Witz template?
Re: How to call a C++ function in Witz template? [message #39168 is a reply to message #39167] |
Thu, 21 February 2013 12:08  |
|
Hi Peter,
Peter wrote on Thu, 21 February 2013 11:47 | I assumed I just had to pass a pointer to my function as a value of shared variable MYFUN to make it visible in Witz template, but apparently that's not how it works. What's the correct way to do it?
|
It would be nice if it would work this way, but unfortunately it doesn't (at least not yet ). You have to register the function and it has to have correct signature. The simple increment function from your example can be done like this (not tested):
Value Fun(const Vector<Value>& arg, const Renderer *)
{
if(arg.GetCount() != 1 && !IsNumber(arg[0]))
return "ERROR";
return (int)arg[0] + 1;
}
INITBLOCK {
Compiler::Register("fun", Fun);
};
This code should be placed in .icpp file, to make sure it is linked correctly. Now you can call the function in witz using $fun(MYVAR), it does not have to be passed to the Http.
Is that clearer now? Further examples can be found in Skylark/StdLib.icpp.
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Sat May 10 07:01:48 CEST 2025
Total time taken to generate the page: 0.02625 seconds
|