kex module documentation has:
3.4. setbflag(flag [, branch])
flag - the index of the branch flag to be set. Can be integer or pseudo-variable with integer value.
are quotes "" always required?
setbflag(1);
does not give an error (or at least i cannot find one from among all those debug messages that seem to be on by default).
if quotes are required, is it sure that if string is an int, it will be evaluated when the script is processed and not when script is run?
-- juha
Juha,
On 30-05 10:13, Juha Heinanen wrote:
kex module documentation has:
3.4. setbflag(flag [, branch])
flag - the index of the branch flag to be set. Can be integer or pseudo-variable with integer value.
are quotes "" always required?
setbflag(1);
does not give an error (or at least i cannot find one from among all those debug messages that seem to be on by default).
The quotes are optional. I was curious about this too and checked that both variants (with and without quotes) work correctly.
if quotes are required, is it sure that if string is an int, it will be evaluated when the script is processed and not when script is run?
I am not sure about this, I guess this is a question for Daniel.
Jan.
Jan Janak writes:
The quotes are optional. I was curious about this too and checked that both variants (with and without quotes) work correctly.
this is too arbitrary. the syntax needs to be consistent. i would prefer int arg without quotes and string arg with quotes. if arg is pseudo variable, it should be written without quotes, because it is a VARIABLE.
I am not sure about this, I guess this is a question for Daniel.
daniel?
-- juha
On 01-06 17:43, Juha Heinanen wrote:
Jan Janak writes:
The quotes are optional. I was curious about this too and checked that both variants (with and without quotes) work correctly.
this is too arbitrary. the syntax needs to be consistent. i would prefer int arg without quotes and string arg with quotes. if arg is pseudo variable, it should be written without quotes, because it is a VARIABLE.
I didn't implement it this way, I was surprised that setbflag without quotes didn't produce an error and that's why I gave it a try.
I thought that all parameters of module functions had to be quoted, but apparently this is not needed anymore. It was probably changed when ser and kamailio module interfaces were merged.
Jan.
I am not sure about this, I guess this is a question for Daniel.
daniel?
-- juha
On 06/01/2009 05:43 PM, Juha Heinanen wrote:
Jan Janak writes:
The quotes are optional. I was curious about this too and checked that both variants (with and without quotes) work correctly.
this is too arbitrary. the syntax needs to be consistent. i would prefer int arg without quotes and string arg with quotes. if arg is pseudo variable, it should be written without quotes, because it is a VARIABLE.
I am not sure about this, I guess this is a question for Daniel.
daniel?
well, a quick look at config grammar and it seems that the module functions accept integer parameters. I was not aware of and don't know how they are passed to the function call. In K module functions are only with string parameters.
Even in SR I cannot see the way to specify the type of the parameters for module functions. Is there an example?
Cheers, Daniel
Daniel-Constantin Mierla writes:
well, a quick look at config grammar and it seems that the module functions accept integer parameters. I was not aware of and don't know how they are passed to the function call. In K module functions are only with string parameters.
if i write
isbflagset("15")
is "15" evaluated to the bit during compilation of the script or is "15" processed like a string that contains pseudo variables?
Even in SR I cannot see the way to specify the type of the parameters for module functions. Is there an example?
in my opinion, in the above case, because the function requires an int argument, only these two should be accepted:
isbflagset(int)
isbflagset($pv)
both without quotes and $pv has to contain an int value.
-- juha
On 06/01/2009 07:18 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
well, a quick look at config grammar and it seems that the module functions accept integer parameters. I was not aware of and don't know how they are passed to the function call. In K module functions are only with string parameters.
if i write
isbflagset("15")
is "15" evaluated to the bit during compilation of the script or is "15" processed like a string that contains pseudo variables?
it is evaluated to integer and at runtime calls the core function setbflag() that does shift and set operation.
Even in SR I cannot see the way to specify the type of the parameters for module functions. Is there an example?
in my opinion, in the above case, because the function requires an int argument, only these two should be accepted:
isbflagset(int)
isbflagset($pv)
both without quotes and $pv has to contain an int value.
The question is how I specify to a function exported by a module that the parameter is integer. While the config grammar accepts such case, the interface does not offer a way to do it (or I am missing something).
Cheers, Daniel
Daniel-Constantin Mierla writes:
The question is how I specify to a function exported by a module that the parameter is integer. While the config grammar accepts such case, the interface does not offer a way to do it (or I am missing something).
why would you need to be able to specify it? if i write
isbflagset(15)
the function will get an int value. if that is not correct, then you get an error whet you try to execute that function. the same thing as if i write
isbflagset($pv)
compiler cannot tell, if value of $pv is int or string.
-- juha
On 06/01/2009 07:36 PM, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
The question is how I specify to a function exported by a module that the parameter is integer. While the config grammar accepts such case, the interface does not offer a way to do it (or I am missing something).
why would you need to be able to specify it? if i write
I am talking about the definition of the function, in K the prototype takes char* parameters: http://www.asipto.com/pub/kamailio-devel-guide/#c16cmd_function
The you can have fixup functions that can convert from string to soemthing else.
All K modules' exported function are built with this architecture in mind - the parameters from script are passed as string during startup, they can convert to something else with fixups. Now, to understand that the int parameter in converted to string to be passed to fixup function?
Cheers, Daniel
isbflagset(15)
the function will get an int value. if that is not correct, then you get an error whet you try to execute that function. the same thing as if i write
isbflagset($pv)
compiler cannot tell, if value of $pv is int or string.
-- juha
Daniel-Constantin Mierla writes:
All K modules' exported function are built with this architecture in mind - the parameters from script are passed as string during startup, they can convert to something else with fixups. Now, to understand that the int parameter in converted to string to be passed to fixup function?
in that case, isbflagset (or other functions) should only accept string values. it is confusing if some of them accept also ints.
but in the long run, we could allow int and pv arguments without quotes.
-- juha