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