Mercurial > urweb
comparison src/lru_cache.sml @ 2240:88cc0f44c940
Rename C functions and remove functors nested inside modules.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Sun, 19 Jul 2015 19:03:11 -0700 |
parents | 2f7ed04332a0 |
children | c275bbc41194 |
comparison
equal
deleted
inserted
replaced
2239:f70a91f7810d | 2240:88cc0f44c940 |
---|---|
62 | 62 |
63 val revArgs = paramRepeatRev (fn p => "p" ^ p) ", " | 63 val revArgs = paramRepeatRev (fn p => "p" ^ p) ", " |
64 | 64 |
65 in | 65 in |
66 Print.box | 66 Print.box |
67 [string ("static Cache cacheStruct" ^ i ^ " = {"), | 67 [string ("static uw_sqlcache_Cache cacheStruct" ^ i ^ " = {"), |
68 newline, | 68 newline, |
69 string " .table = NULL,", | 69 string " .table = NULL,", |
70 newline, | 70 newline, |
71 string " .timeInvalid = 0,", | 71 string " .timeInvalid = 0,", |
72 newline, | 72 newline, |
73 string " .lru = NULL,", | 73 string " .lru = NULL,", |
74 newline, | 74 newline, |
75 string (" .height = " ^ Int.toString (params - 1) ^ "};"), | 75 string (" .height = " ^ Int.toString (params - 1) ^ "};"), |
76 newline, | 76 newline, |
77 string ("static Cache *cache" ^ i ^ " = &cacheStruct" ^ i ^ ";"), | 77 string ("static uw_sqlcache_Cache *cache" ^ i ^ " = &cacheStruct" ^ i ^ ";"), |
78 newline, | 78 newline, |
79 newline, | 79 newline, |
80 | 80 |
81 string ("static uw_Basis_string uw_Sqlcache_check" ^ i), | 81 string ("static uw_Basis_string uw_Sqlcache_check" ^ i), |
82 string ("(uw_context ctx" ^ typedArgs ^ ") {"), | 82 string ("(uw_context ctx" ^ typedArgs ^ ") {"), |
83 newline, | 83 newline, |
84 string (" char *ks[] = {" ^ revArgs ^ "};"), | 84 string (" char *ks[] = {" ^ revArgs ^ "};"), |
85 newline, | 85 newline, |
86 string (" CacheValue *v = check(cache" ^ i ^ ", ks);"), | 86 string (" uw_sqlcache_CacheValue *v = uw_sqlcache_check(cache" ^ i ^ ", ks);"), |
87 newline, | 87 newline, |
88 string " if (v) {", | 88 string " if (v) {", |
89 newline, | 89 newline, |
90 string (" puts(\"SQLCACHE: hit " ^ i ^ ".\");"), | 90 string (" puts(\"SQLCACHE: hit " ^ i ^ ".\");"), |
91 newline, | 91 newline, |
110 string ("static uw_unit uw_Sqlcache_store" ^ i), | 110 string ("static uw_unit uw_Sqlcache_store" ^ i), |
111 string ("(uw_context ctx, uw_Basis_string s" ^ typedArgs ^ ") {"), | 111 string ("(uw_context ctx, uw_Basis_string s" ^ typedArgs ^ ") {"), |
112 newline, | 112 newline, |
113 string (" char *ks[] = {" ^ revArgs ^ "};"), | 113 string (" char *ks[] = {" ^ revArgs ^ "};"), |
114 newline, | 114 newline, |
115 string (" CacheValue *v = malloc(sizeof(CacheValue));"), | 115 string (" uw_sqlcache_CacheValue *v = malloc(sizeof(uw_sqlcache_CacheValue));"), |
116 newline, | 116 newline, |
117 string " v->result = strdup(s);", | 117 string " v->result = strdup(s);", |
118 newline, | 118 newline, |
119 string " v->output = uw_recordingRead(ctx);", | 119 string " v->output = uw_recordingRead(ctx);", |
120 newline, | 120 newline, |
121 string (" puts(\"SQLCACHE: stored " ^ i ^ ".\");"), | 121 string (" puts(\"SQLCACHE: stored " ^ i ^ ".\");"), |
122 newline, | 122 newline, |
123 string (" store(cache" ^ i ^ ", ks, v);"), | 123 string (" uw_sqlcache_store(cache" ^ i ^ ", ks, v);"), |
124 newline, | 124 newline, |
125 string " return uw_unit_v;", | 125 string " return uw_unit_v;", |
126 newline, | 126 newline, |
127 string "}", | 127 string "}", |
128 newline, | 128 newline, |
131 string ("static uw_unit uw_Sqlcache_flush" ^ i), | 131 string ("static uw_unit uw_Sqlcache_flush" ^ i), |
132 string ("(uw_context ctx" ^ typedArgs ^ ") {"), | 132 string ("(uw_context ctx" ^ typedArgs ^ ") {"), |
133 newline, | 133 newline, |
134 string (" char *ks[] = {" ^ revArgs ^ "};"), | 134 string (" char *ks[] = {" ^ revArgs ^ "};"), |
135 newline, | 135 newline, |
136 string (" flush(cache" ^ i ^ ", ks);"), | 136 string (" uw_sqlcache_flush(cache" ^ i ^ ", ks);"), |
137 newline, | 137 newline, |
138 string " return uw_unit_v;", | 138 string " return uw_unit_v;", |
139 newline, | 139 newline, |
140 string "}", | 140 string "}", |
141 newline, | 141 newline, |