OLD | NEW |
1 /* | 1 /* |
2 ** 2010 August 28 | 2 ** 2010 August 28 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
11 ************************************************************************* | 11 ************************************************************************* |
12 ** Code for testing all sorts of SQLite interfaces. This code | 12 ** Code for testing all sorts of SQLite interfaces. This code |
13 ** is not included in the SQLite library. | 13 ** is not included in the SQLite library. |
14 */ | 14 */ |
15 | 15 |
16 #include "sqlite3.h" | 16 #include "sqlite3.h" |
17 #include <tcl.h> | 17 #if defined(INCLUDE_SQLITE_TCL_H) |
| 18 # include "sqlite_tcl.h" |
| 19 #else |
| 20 # include "tcl.h" |
| 21 #endif |
18 | 22 |
19 /* Solely for the UNUSED_PARAMETER() macro. */ | 23 /* Solely for the UNUSED_PARAMETER() macro. */ |
20 #include "sqliteInt.h" | 24 #include "sqliteInt.h" |
21 | 25 |
22 #ifdef SQLITE_ENABLE_RTREE | 26 #ifdef SQLITE_ENABLE_RTREE |
23 /* | 27 /* |
24 ** Type used to cache parameter information for the "circle" r-tree geometry | 28 ** Type used to cache parameter information for the "circle" r-tree geometry |
25 ** callback. | 29 ** callback. |
26 */ | 30 */ |
27 typedef struct Circle Circle; | 31 typedef struct Circle Circle; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 p->eWithin = NOT_WITHIN; | 350 p->eWithin = NOT_WITHIN; |
347 } | 351 } |
348 return SQLITE_OK; | 352 return SQLITE_OK; |
349 } | 353 } |
350 | 354 |
351 /* END of implementation of "circle" geometry callback. | 355 /* END of implementation of "circle" geometry callback. |
352 ************************************************************************** | 356 ************************************************************************** |
353 *************************************************************************/ | 357 *************************************************************************/ |
354 | 358 |
355 #include <assert.h> | 359 #include <assert.h> |
356 #include "tcl.h" | 360 #if defined(INCLUDE_SQLITE_TCL_H) |
| 361 # include "sqlite_tcl.h" |
| 362 #else |
| 363 # include "tcl.h" |
| 364 #endif |
357 | 365 |
358 typedef struct Cube Cube; | 366 typedef struct Cube Cube; |
359 struct Cube { | 367 struct Cube { |
360 double x; | 368 double x; |
361 double y; | 369 double y; |
362 double z; | 370 double z; |
363 double width; | 371 double width; |
364 double height; | 372 double height; |
365 double depth; | 373 double depth; |
366 }; | 374 }; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 && aCoord[4]<=(pCube->z+pCube->depth) | 433 && aCoord[4]<=(pCube->z+pCube->depth) |
426 && aCoord[5]>=pCube->z | 434 && aCoord[5]>=pCube->z |
427 ){ | 435 ){ |
428 *piRes = 1; | 436 *piRes = 1; |
429 } | 437 } |
430 | 438 |
431 return SQLITE_OK; | 439 return SQLITE_OK; |
432 } | 440 } |
433 #endif /* SQLITE_ENABLE_RTREE */ | 441 #endif /* SQLITE_ENABLE_RTREE */ |
434 | 442 |
435 static int register_cube_geom( | 443 static int SQLITE_TCLAPI register_cube_geom( |
436 void * clientData, | 444 void * clientData, |
437 Tcl_Interp *interp, | 445 Tcl_Interp *interp, |
438 int objc, | 446 int objc, |
439 Tcl_Obj *CONST objv[] | 447 Tcl_Obj *CONST objv[] |
440 ){ | 448 ){ |
441 #ifndef SQLITE_ENABLE_RTREE | 449 #ifndef SQLITE_ENABLE_RTREE |
442 UNUSED_PARAMETER(clientData); | 450 UNUSED_PARAMETER(clientData); |
443 UNUSED_PARAMETER(interp); | 451 UNUSED_PARAMETER(interp); |
444 UNUSED_PARAMETER(objc); | 452 UNUSED_PARAMETER(objc); |
445 UNUSED_PARAMETER(objv); | 453 UNUSED_PARAMETER(objv); |
446 #else | 454 #else |
447 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); | 455 extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**); |
448 extern const char *sqlite3ErrName(int); | 456 extern const char *sqlite3ErrName(int); |
449 sqlite3 *db; | 457 sqlite3 *db; |
450 int rc; | 458 int rc; |
451 | 459 |
452 if( objc!=2 ){ | 460 if( objc!=2 ){ |
453 Tcl_WrongNumArgs(interp, 1, objv, "DB"); | 461 Tcl_WrongNumArgs(interp, 1, objv, "DB"); |
454 return TCL_ERROR; | 462 return TCL_ERROR; |
455 } | 463 } |
456 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; | 464 if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; |
457 rc = sqlite3_rtree_geometry_callback(db, "cube", cube_geom, (void *)&gHere); | 465 rc = sqlite3_rtree_geometry_callback(db, "cube", cube_geom, (void *)&gHere); |
458 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); | 466 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
459 #endif | 467 #endif |
460 return TCL_OK; | 468 return TCL_OK; |
461 } | 469 } |
462 | 470 |
463 static int register_circle_geom( | 471 static int SQLITE_TCLAPI register_circle_geom( |
464 void * clientData, | 472 void * clientData, |
465 Tcl_Interp *interp, | 473 Tcl_Interp *interp, |
466 int objc, | 474 int objc, |
467 Tcl_Obj *CONST objv[] | 475 Tcl_Obj *CONST objv[] |
468 ){ | 476 ){ |
469 #ifndef SQLITE_ENABLE_RTREE | 477 #ifndef SQLITE_ENABLE_RTREE |
470 UNUSED_PARAMETER(clientData); | 478 UNUSED_PARAMETER(clientData); |
471 UNUSED_PARAMETER(interp); | 479 UNUSED_PARAMETER(interp); |
472 UNUSED_PARAMETER(objc); | 480 UNUSED_PARAMETER(objc); |
473 UNUSED_PARAMETER(objv); | 481 UNUSED_PARAMETER(objv); |
(...skipping 20 matching lines...) Expand all Loading... |
494 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); | 502 Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC); |
495 #endif | 503 #endif |
496 return TCL_OK; | 504 return TCL_OK; |
497 } | 505 } |
498 | 506 |
499 int Sqlitetestrtree_Init(Tcl_Interp *interp){ | 507 int Sqlitetestrtree_Init(Tcl_Interp *interp){ |
500 Tcl_CreateObjCommand(interp, "register_cube_geom", register_cube_geom, 0, 0); | 508 Tcl_CreateObjCommand(interp, "register_cube_geom", register_cube_geom, 0, 0); |
501 Tcl_CreateObjCommand(interp, "register_circle_geom",register_circle_geom,0,0); | 509 Tcl_CreateObjCommand(interp, "register_circle_geom",register_circle_geom,0,0); |
502 return TCL_OK; | 510 return TCL_OK; |
503 } | 511 } |
OLD | NEW |