|
1 | 1 | # scalar functions
|
2 | 2 | function registerfunc(db::SQLiteDB, nargs::Integer, func::Function, isdeterm::Bool=true; name="")
|
3 |
| - @assert sizeof(name) <= 255 "size of function name must be <= 255" |
4 |
| - @assert (-1 <= nargs <= 127) "nargs must follow the inequality -1 <= nargs <= 127" |
| 3 | + @assert nargs <= 127 "only varargs functions can have more than 127 arguments" |
| 4 | + # assume any negative number means a varargs function |
| 5 | + nargs < -1 && (nargs = -1) |
5 | 6 |
|
6 | 7 | name = isempty(name) ? string(func) : name::String
|
| 8 | + @assert sizeof(name) <= 255 "size of function name must be <= 255" |
| 9 | + |
7 | 10 | cfunc = cfunction(func, Nothing, (Ptr{Void}, Cint, Ptr{Ptr{Void}}))
|
8 | 11 |
|
9 | 12 | # TODO: allow the other encodings
|
|
17 | 20 |
|
18 | 21 | # aggregate functions
|
19 | 22 | function registerfunc(db::SQLiteDB, nargs::Integer, step::Function, final::Function, isdeterm::Bool=true; name="")
|
20 |
| - @assert (-1 <= nargs <= 127) "nargs must follow the inequality -1 <= nargs <= 127" |
| 23 | + @assert nargs <= 127 "only varargs functions can have more than 127 arguments" |
| 24 | + # assume any negative number means a varargs function |
| 25 | + nargs < -1 && (nargs = -1) |
21 | 26 |
|
22 | 27 | name = isempty(name) ? string(step) : name::String
|
23 | 28 | cstep = cfunction(step, Nothing, (Ptr{Void}, Cint, Ptr{Ptr{Void}}))
|
@@ -94,7 +99,6 @@ macro scalarfunc(args...)
|
94 | 99 | end
|
95 | 100 | end
|
96 | 101 |
|
97 |
| - |
98 | 102 | # annotate types because the MethodError makes more sense that way
|
99 | 103 | @scalarfunc regexp(r::String, s::String) = ismatch(Regex(r), s)
|
100 | 104 | # macro for preserving the special characters in a string
|
|
0 commit comments