Ver Fonte

Update the parameters validation mask for "create_function/create_aggregate" to allow pass the optional user_data parameter to created functions.

mingodad há 13 anos atrás
pai
commit
36500b4e84
2 ficheiros alterados com 6 adições e 3 exclusões
  1. 2 2
      SquiLu-ext/sq_sqlite3.cpp
  2. 4 1
      SquiLu/samples/test-sqlite3.nut

+ 2 - 2
SquiLu-ext/sq_sqlite3.cpp

@@ -2002,8 +2002,8 @@ static SQRegFunction sq_sqlite3_methods[] =
 	_DECL_FUNC(trace,  -2, _SC("x c|o .")),
 	_DECL_FUNC(busy_handler,  -2, _SC("x c|o .")),
 	_DECL_FUNC(busy_timeout,  2, _SC("xi")),
-	_DECL_FUNC(create_function,  4, _SC("xsic")),
-	_DECL_FUNC(create_aggregate,  5, _SC("xsicc")),
+	_DECL_FUNC(create_function,  -4, _SC("xsic.")),
+	_DECL_FUNC(create_aggregate,  -5, _SC("xsicc.")),
 #ifndef WIN32
 	_DECL_FUNC(temp_directory,  2, _SC("xs")),
 #endif

+ 4 - 1
SquiLu/samples/test-sqlite3.nut

@@ -1,7 +1,10 @@
 local db = SQLite3(":memory:");
 print(db);
 
-db.create_function("multiply3",3,function(ctx,a,b,c){ctx.result_double(a*b*c);});
+db.create_function("multiply3",3,function(ctx,a,b,c){
+		//print(ctx.user_data());
+		ctx.result_double(a*b*c);
+	}, "user_data_any");
 
 local sql = "select 1.2*2.5*3.6;";
 local sql_squilu = "select multiply3(1.2,2.5,3.6);";