| 81 | } |
| 82 | |
| 83 | void Module_dasSQLITE::initMain() { |
| 84 | |
| 85 | addExtern<DAS_BIND_FUN(sqlite3_exec)>(*this,lib,"sqlite3_exec", |
| 86 | SideEffects::worstDefault, "sqlite3_exec") |
| 87 | ->args({"db","sql","errmsg"}); |
| 88 | addExtern<DAS_BIND_FUN(sqlite3_exec_cb)>(*this,lib,"sqlite3_exec", |
| 89 | SideEffects::worstDefault, "sqlite3_exec_cb") |
| 90 | ->args({"db","sql","errmsg","block","context","at"}); |
| 91 | addExtern<DAS_BIND_FUN(sqlite3_bind_blob_)>(*this,lib,"sqlite3_bind_blob", |
| 92 | SideEffects::worstDefault, "sqlite3_bind_blob_") |
| 93 | ->args({"stmt","sqlite3_bind_text_","data","size"}); |
| 94 | addExtern<DAS_BIND_FUN(sqlite3_bind_text_)>(*this,lib,"sqlite3_bind_text", |
| 95 | SideEffects::worstDefault, "sqlite3_bind_text_") |
| 96 | ->args({"stmt","index","data"}); |
| 97 | addExtern<DAS_BIND_FUN(sqlite3_prepare_v2_no_tail)>(*this,lib,"sqlite3_prepare_v2_no_tail", |
| 98 | SideEffects::worstDefault, "sqlite3_prepare_v2_no_tail") |
| 99 | ->args({"db","sql","stmt"}); |
| 100 | addExtern<DAS_BIND_FUN(sqlite3_open_v2_no_vfs)>(*this,lib,"sqlite3_open_v2_no_vfs", |
| 101 | SideEffects::worstDefault, "sqlite3_open_v2_no_vfs") |
| 102 | ->args({"filename","ppDb","flags"}); |
| 103 | addExtern<DAS_BIND_FUN(sqlite3_register_function)>(*this,lib,"sqlite3_register_function", |
| 104 | SideEffects::worstDefault, "sqlite3_register_function") |
| 105 | ->args({"db","name","fn","nArgs", |
| 106 | "tag0","tag1","tag2","tag3", |
| 107 | "retTag","deterministic","directonly","context","at"}); |
| 108 | addExtern<DAS_BIND_FUN(sqlite3_backup_run)>(*this,lib,"sqlite3_backup_run", |
| 109 | SideEffects::worstDefault, "sqlite3_backup_run") |
| 110 | ->args({"src","dst"}); |
| 111 | |
| 112 | for ( auto & pfn : this->functions.each() ) { |
| 113 | // ok, lets fix up everything returning uint8? into returning string# and make it unsafe operation |
| 114 | if ( pfn->result->isPointer() && pfn->result->firstType && |
| 115 | pfn->result->firstType->baseType==Type::tUInt8 && pfn->result->firstType->dim.size()==0 ) { |
| 116 | pfn->result = new TypeDecl(Type::tString); |
| 117 | pfn->result->constant = true; |
| 118 | pfn->result->temporary = true; |
| 119 | pfn->unsafeOperation = true; |
| 120 | } |
| 121 | // fixup module functions, so that there is a string cast |
| 122 | bool anyString = false; |
| 123 | for ( auto & arg : pfn->arguments ) { |
| 124 | if ( arg->type->isString() && !arg->type->ref ) { |
| 125 | anyString = true; |
| 126 | } |
| 127 | } |
| 128 | if ( anyString ) { |
| 129 | pfn->needStringCast = true; |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | ModuleAotType Module_dasSQLITE::aotRequire ( TextWriter & tw ) const { |
| 135 | tw << "#include \"../modules/dasSQLITE/src/aot_sqlite.h\"\n"; |