comparison src/cjr_print.sml @ 2221:278e10629ba1

Basic field-resolution invalidation.
author Ziv Scully <ziv@mit.edu>
date Sat, 29 Nov 2014 03:37:59 -0500
parents 70ec9bb337be
children 9410959d296f
comparison
equal deleted inserted replaced
2220:794017f378de 2221:278e10629ba1
3408 f (params - 1) 3408 f (params - 1)
3409 end 3409 end
3410 fun paramRepeatInit itemi sep = 3410 fun paramRepeatInit itemi sep =
3411 if params = 0 then "" else sep ^ paramRepeat itemi sep 3411 if params = 0 then "" else sep ^ paramRepeat itemi sep
3412 val args = paramRepeatInit (fn p => "uw_Basis_string p" ^ p) ", " 3412 val args = paramRepeatInit (fn p => "uw_Basis_string p" ^ p) ", "
3413 val decls = paramRepeat (fn p => "uw_Basis_string param" ^ i ^ "_" ^ p ^ " = NULL;") "\n" 3413 val decls = paramRepeat (fn p => "uw_Basis_string param" ^ i ^ "_"
3414 ^ p ^ " = NULL;")
3415 "\n"
3414 val sets = paramRepeat (fn p => "param" ^ i ^ "_" ^ p 3416 val sets = paramRepeat (fn p => "param" ^ i ^ "_" ^ p
3415 ^ " = strdup(p" ^ p ^ ");") "\n" 3417 ^ " = strdup(p" ^ p ^ ");")
3416 val frees = paramRepeat (fn p => "free(param" ^ i ^ "_" ^ p ^ ");") "\n" 3418 "\n"
3417 (* Starting || makes logic easier when there are no parameters. *) 3419 val frees = paramRepeat (fn p => "free(param" ^ i ^ "_" ^ p ^ ");")
3420 "\n"
3418 val eqs = paramRepeatInit (fn p => "strcmp(param" ^ i ^ "_" ^ p 3421 val eqs = paramRepeatInit (fn p => "strcmp(param" ^ i ^ "_" ^ p
3419 ^ ", p" ^ p ^ ")") 3422 ^ ", p" ^ p ^ ")")
3420 " || " 3423 " || "
3424 (* Using [!=] instead of [==] to mimic [strcmp]. *)
3425 val eqsNull = paramRepeatInit (fn p => "(p" ^ p ^ " == NULL || "
3426 ^ "!strcmp(param" ^ i ^ "_"
3427 ^ p ^ ", p" ^ p ^ "))")
3428 " && "
3421 in box [string "static char *cacheQuery", 3429 in box [string "static char *cacheQuery",
3422 string i, 3430 string i,
3423 string " = NULL;", 3431 string " = NULL;",
3424 newline, 3432 newline,
3425 string "static char *cacheWrite", 3433 string "static char *cacheWrite",
3469 string i, 3477 string i,
3470 string ".\");\n return uw_unit_v;\n };", 3478 string ".\");\n return uw_unit_v;\n };",
3471 newline, 3479 newline,
3472 string "static uw_unit uw_Sqlcache_flush", 3480 string "static uw_unit uw_Sqlcache_flush",
3473 string i, 3481 string i,
3474 string "(uw_context ctx) {\n free(cacheQuery", 3482 string "(uw_context ctx",
3483 string args,
3484 string ") {\n if (cacheQuery",
3485 string i,
3486 string " != NULL",
3487 string eqsNull,
3488 string ") {\n free(cacheQuery",
3475 string i, 3489 string i,
3476 string ");\n cacheQuery", 3490 string ");\n cacheQuery",
3477 string i, 3491 string i,
3478 string " = NULL;\n puts(\"SQLCACHE: flushed ", 3492 string " = NULL;\n puts(\"SQLCACHE: flushed ",
3479 string i, 3493 string i,
3480 string ".\");\n return uw_unit_v;\n };", 3494 string ".\");}\n else { puts(\"SQLCACHE: keeping ",
3495 string i,
3496 string "\"); } return uw_unit_v;\n };",
3481 newline, 3497 newline,
3482 newline] 3498 newline]
3483 end) 3499 end)
3484 (Sqlcache.getFfiInfo ())), 3500 (Sqlcache.getFfiInfo ())),
3485 newline, 3501 newline,