Index: TODO =================================================================== diff -u -red9fb67f4304d4e03ce35df1e9cbe10eb5e0e183 -ra08065ac227c3b26514f29392a961f11db121369 --- TODO (.../TODO) (revision ed9fb67f4304d4e03ce35df1e9cbe10eb5e0e183) +++ TODO (.../TODO) (revision a08065ac227c3b26514f29392a961f11db121369) @@ -3064,6 +3064,8 @@ - added tests for object specific "variable" and "attribute + application defined value checker +- library/mongodb: + * updated to current interface in git HEAD TODO: - variable and incremental Index: library/mongodb/mongoAPI.decls =================================================================== diff -u -r40086b195a1a43958f7e99ce6f66a8ab2ae6337c -ra08065ac227c3b26514f29392a961f11db121369 --- library/mongodb/mongoAPI.decls (.../mongoAPI.decls) (revision 40086b195a1a43958f7e99ce6f66a8ab2ae6337c) +++ library/mongodb/mongoAPI.decls (.../mongoAPI.decls) (revision a08065ac227c3b26514f29392a961f11db121369) @@ -8,14 +8,14 @@ cmd "::mongo" } array set ptrConverter { - mongo_connection 1 + mongo 1 gridfs 1 gridfile 1 } cmd close NsfMongoClose { - {-argName "conn" -required 1 -type mongo_connection -withObj 1} + {-argName "conn" -required 1 -type mongo -withObj 1} } cmd connect NsfMongoConnect { {-argName "-replica-set" -required 0 -nrargs 1} @@ -24,13 +24,13 @@ } cmd count NsfMongoCount { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "query" -required 1 -type tclobj} } cmd index NsfMongoIndex { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "attributes" -required 1 -type tclobj} {-argName "-background" -required 0 -nrargs 0} @@ -40,13 +40,13 @@ } cmd insert NsfMongoInsert { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "values" -required 1 -type tclobj} } cmd query NsfMongoQuery { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "query" -required 1 -type tclobj} {-argName "-atts" -required 0 -nrargs 1 -type tclobj} @@ -55,13 +55,13 @@ } cmd remove NsfMongoRemove { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "condition" -required 1 -type tclobj} } cmd update NsfMongoUpdate { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "cond" -required 1 -type tclobj} {-argName "values" -required 1 -type tclobj} @@ -73,7 +73,7 @@ # GridFS # cmd gridfs::open NsfMongoGridFSOpen { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "dbname" -required 1} {-argName "prefix" -required 1} } Index: library/mongodb/mongoAPI.h =================================================================== diff -u -r40086b195a1a43958f7e99ce6f66a8ab2ae6337c -ra08065ac227c3b26514f29392a961f11db121369 --- library/mongodb/mongoAPI.h (.../mongoAPI.h) (revision 40086b195a1a43958f7e99ce6f66a8ab2ae6337c) +++ library/mongodb/mongoAPI.h (.../mongoAPI.h) (revision a08065ac227c3b26514f29392a961f11db121369) @@ -26,11 +26,11 @@ static int NsfMongoRemoveStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfMongoUpdateStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); -static int NsfMongoClose(Tcl_Interp *interp, mongo_connection *connPtr, Tcl_Obj *connObj); +static int NsfMongoClose(Tcl_Interp *interp, mongo *connPtr, Tcl_Obj *connObj); static int NsfMongoConnect(Tcl_Interp *interp, CONST char *withReplica_set, Tcl_Obj *withServer, int withTimeout); -static int NsfMongoCount(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *query); +static int NsfMongoCount(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *query); static int NsfMongoGridFSClose(Tcl_Interp *interp, gridfs *gfsPtr, Tcl_Obj *gfsObj); -static int NsfMongoGridFSOpen(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *dbname, CONST char *prefix); +static int NsfMongoGridFSOpen(Tcl_Interp *interp, mongo *connPtr, CONST char *dbname, CONST char *prefix); static int NsfMongoGridFSRemoveFile(Tcl_Interp *interp, gridfs *gfsPtr, CONST char *filename); static int NsfMongoGridFSStoreFile(Tcl_Interp *interp, gridfs *gfsPtr, CONST char *filename, CONST char *remotename, CONST char *contenttype); static int NsfMongoGridFileClose(Tcl_Interp *interp, gridfile *filePtr, Tcl_Obj *fileObj); @@ -40,11 +40,11 @@ static int NsfMongoGridFileOpen(Tcl_Interp *interp, gridfs *fsPtr, CONST char *filename); static int NsfMongoGridFileRead(Tcl_Interp *interp, gridfile *filePtr, int size); static int NsfMongoGridFileSeek(Tcl_Interp *interp, gridfile *filePtr, int offset); -static int NsfMongoIndex(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *attributes, int withBackground, int withDropdups, int withSparse, int withUnique); -static int NsfMongoInsert(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *values); -static int NsfMongoQuery(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *query, Tcl_Obj *withAtts, int withLimit, int withSkip); -static int NsfMongoRemove(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *condition); -static int NsfMongoUpdate(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *cond, Tcl_Obj *values, int withUpsert, int withAll); +static int NsfMongoIndex(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *attributes, int withBackground, int withDropdups, int withSparse, int withUnique); +static int NsfMongoInsert(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *values); +static int NsfMongoQuery(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *query, Tcl_Obj *withAtts, int withLimit, int withSkip); +static int NsfMongoRemove(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *condition); +static int NsfMongoUpdate(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *cond, Tcl_Obj *values, int withUpsert, int withAll); enum { NsfMongoCloseIdx, @@ -80,7 +80,7 @@ &pc) != TCL_OK) { return TCL_ERROR; } else { - mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; + mongo *connPtr = (mongo *)pc.clientData[0]; assert(pc.status == 0); return NsfMongoClose(interp, connPtr,pc.objv[0]); @@ -120,7 +120,7 @@ &pc) != TCL_OK) { return TCL_ERROR; } else { - mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; + mongo *connPtr = (mongo *)pc.clientData[0]; CONST char *namespace = (CONST char *)pc.clientData[1]; Tcl_Obj *query = (Tcl_Obj *)pc.clientData[2]; @@ -160,7 +160,7 @@ &pc) != TCL_OK) { return TCL_ERROR; } else { - mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; + mongo *connPtr = (mongo *)pc.clientData[0]; CONST char *dbname = (CONST char *)pc.clientData[1]; CONST char *prefix = (CONST char *)pc.clientData[2]; @@ -359,7 +359,7 @@ &pc) != TCL_OK) { return TCL_ERROR; } else { - mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; + mongo *connPtr = (mongo *)pc.clientData[0]; CONST char *namespace = (CONST char *)pc.clientData[1]; Tcl_Obj *attributes = (Tcl_Obj *)pc.clientData[2]; int withBackground = (int )PTR2INT(pc.clientData[3]); @@ -384,7 +384,7 @@ &pc) != TCL_OK) { return TCL_ERROR; } else { - mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; + mongo *connPtr = (mongo *)pc.clientData[0]; CONST char *namespace = (CONST char *)pc.clientData[1]; Tcl_Obj *values = (Tcl_Obj *)pc.clientData[2]; @@ -405,7 +405,7 @@ &pc) != TCL_OK) { return TCL_ERROR; } else { - mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; + mongo *connPtr = (mongo *)pc.clientData[0]; CONST char *namespace = (CONST char *)pc.clientData[1]; Tcl_Obj *query = (Tcl_Obj *)pc.clientData[2]; Tcl_Obj *withAtts = (Tcl_Obj *)pc.clientData[3]; @@ -429,7 +429,7 @@ &pc) != TCL_OK) { return TCL_ERROR; } else { - mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; + mongo *connPtr = (mongo *)pc.clientData[0]; CONST char *namespace = (CONST char *)pc.clientData[1]; Tcl_Obj *condition = (Tcl_Obj *)pc.clientData[2]; @@ -450,7 +450,7 @@ &pc) != TCL_OK) { return TCL_ERROR; } else { - mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; + mongo *connPtr = (mongo *)pc.clientData[0]; CONST char *namespace = (CONST char *)pc.clientData[1]; Tcl_Obj *cond = (Tcl_Obj *)pc.clientData[2]; Tcl_Obj *values = (Tcl_Obj *)pc.clientData[3]; @@ -465,23 +465,23 @@ static Nsf_methodDefinition method_definitions[] = { {"::mongo::close", NsfMongoCloseStub, 1, { - {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}} + {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo",NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::connect", NsfMongoConnectStub, 3, { {"-replica-set", 0, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-server", 0, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-timeout", 0, 1, Nsf_ConvertToInt32, NULL,NULL,"int32",NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::count", NsfMongoCountStub, 3, { - {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}, + {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo",NULL,NULL,NULL,NULL,NULL}, {"namespace", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"query", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::gridfs::close", NsfMongoGridFSCloseStub, 1, { {"gfs", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"gridfs",NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::gridfs::open", NsfMongoGridFSOpenStub, 3, { - {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}, + {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo",NULL,NULL,NULL,NULL,NULL}, {"dbname", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"prefix", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, @@ -520,7 +520,7 @@ {"offset", NSF_ARG_REQUIRED, 1, Nsf_ConvertToInt32, NULL,NULL,"int32",NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::index", NsfMongoIndexStub, 7, { - {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}, + {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo",NULL,NULL,NULL,NULL,NULL}, {"namespace", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"attributes", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-background", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, @@ -529,25 +529,25 @@ {"-unique", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::insert", NsfMongoInsertStub, 3, { - {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}, + {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo",NULL,NULL,NULL,NULL,NULL}, {"namespace", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"values", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::query", NsfMongoQueryStub, 6, { - {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}, + {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo",NULL,NULL,NULL,NULL,NULL}, {"namespace", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"query", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-atts", 0, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-limit", 0, 1, Nsf_ConvertToInt32, NULL,NULL,"int32",NULL,NULL,NULL,NULL,NULL}, {"-skip", 0, 1, Nsf_ConvertToInt32, NULL,NULL,"int32",NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::remove", NsfMongoRemoveStub, 3, { - {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}, + {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo",NULL,NULL,NULL,NULL,NULL}, {"namespace", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"condition", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::update", NsfMongoUpdateStub, 6, { - {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}, + {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo",NULL,NULL,NULL,NULL,NULL}, {"namespace", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"cond", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"values", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, Index: library/mongodb/nsfmongo.c =================================================================== diff -u -rebba70b7b0b296de45cb263fa850913ac8711a27 -ra08065ac227c3b26514f29392a961f11db121369 --- library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision ebba70b7b0b296de45cb263fa850913ac8711a27) +++ library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision a08065ac227c3b26514f29392a961f11db121369) @@ -30,7 +30,7 @@ */ static int gridfsCount = 0; static int gridfileCount = 0; -static int mongo_connectionCount = 0; +static int mongoCount = 0; /*********************************************************************** * The following definitions should not be here, but they are included @@ -249,7 +249,7 @@ *---------------------------------------------------------------------- */ static int -BsonAppend(Tcl_Interp *interp, bson_buffer *bbPtr, char *name, char *tag, Tcl_Obj *value) { +BsonAppend(Tcl_Interp *interp, bson *bbPtr, char *name, char *tag, Tcl_Obj *value) { int result = TCL_OK; bson_type t = BsonTagToType(interp, tag); @@ -376,18 +376,16 @@ static int BsonAppendObjv(Tcl_Interp *interp, bson *bPtr, int objc, Tcl_Obj **objv) { int i; - bson_buffer buf[1]; - bson_buffer_init(buf); + bson_init(bPtr); for (i = 0; i < objc; i += 3) { char *name = ObjStr(objv[i]); char *tag = ObjStr(objv[i+1]); Tcl_Obj *value = objv[i+2]; /*fprintf(stderr, "adding pair '%s' (%s) '%s'\n", name, tag, ObjStr(value));*/ - BsonAppend(interp, buf, name, tag, value); + BsonAppend(interp, bPtr, name, tag, value); } - - bson_from_buffer(bPtr, buf); + bson_finish(bPtr); return TCL_OK; } @@ -461,11 +459,11 @@ /* cmd close NsfMongoClose { - {-argName "conn" -required 1 -type mongo_connection -withObj 1} + {-argName "conn" -required 1 -type mongo -withObj 1} } */ static int -NsfMongoClose(Tcl_Interp *interp, mongo_connection *connPtr, Tcl_Obj *connObj) { +NsfMongoClose(Tcl_Interp *interp, mongo *connPtr, Tcl_Obj *connObj) { if (connPtr) { mongo_destroy(connPtr); @@ -485,7 +483,7 @@ NsfMongoConnect(Tcl_Interp *interp, CONST char *replicaSet, Tcl_Obj *server, int withTimeout) { char channelName[80], *buffer = NULL; int result, port, objc = 0; - mongo_connection *connPtr; + mongo *connPtr; int status; Tcl_Obj **objv; CONST char *host; @@ -497,7 +495,7 @@ } } - connPtr = (mongo_connection *)ckalloc(sizeof(mongo_connection)); + connPtr = (mongo *)ckalloc(sizeof(mongo)); if (objc == 0) { /* @@ -522,7 +520,7 @@ */ int i; - mongo_replset_init_conn( connPtr, replicaSet); + mongo_replset_init( connPtr, replicaSet ); for (i = 0; i < objc; i++) { NsfMongoGetHostPort(ObjStr(objv[i]), &buffer, &host, &port); @@ -563,7 +561,7 @@ /* * setting connection timeout - measured in milliseconds */ - if (mongo_conn_set_timeout(connPtr, withTimeout) != MONGO_OK) { + if (mongo_set_op_timeout(connPtr, withTimeout) != MONGO_OK) { return NsfPrintError(interp, "setting connection timeout failed"); } } @@ -572,21 +570,21 @@ * Make an entry in the symbol table and return entry name it as * result. */ - Nsf_PointerAdd(interp, channelName, "mongo_connection", connPtr); + Nsf_PointerAdd(interp, channelName, "mongo", connPtr); Tcl_SetObjResult(interp, Tcl_NewStringObj(channelName, -1)); return TCL_OK; } /* cmd query NsfMongoCount { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "query" -required 1 -type tclobj} } */ static int -NsfMongoCount(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *queryObj) { +NsfMongoCount(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *queryObj) { int objc, result; Tcl_Obj **objv; char *db, *collection; @@ -625,7 +623,7 @@ /* cmd index NsfMongoIndex { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "attributes" -required 1 -type tclobj} {-argName "-background" -required 0 -nrargs 0} @@ -636,7 +634,7 @@ */ static int NsfMongoIndex(Tcl_Interp *interp, - mongo_connection *connPtr, + mongo *connPtr, CONST char *namespace, Tcl_Obj *attributesObj, int withBackground, @@ -671,34 +669,36 @@ /* cmd insert NsfMongoInsert { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "values" -required 1 -type tclobj} } */ -static int NsfMongoInsert(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *valuesObj) { +static int NsfMongoInsert(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *valuesObj) { int i, objc, result; Tcl_Obj **objv, *resultObj; - bson_buffer buf[1]; + //bson buf[1]; bson b[1]; result = Tcl_ListObjGetElements(interp, valuesObj, &objc, &objv); if (result != TCL_OK || (objc % 3 != 0)) { return NsfPrintError(interp, "%s: must contain a multiple of 3 elements", ObjStr(valuesObj)); } - bson_buffer_init(buf); - bson_append_new_oid(buf, "_id"); + //bson_init(buf); + bson_init(b); + bson_append_new_oid(b, "_id"); for (i = 0; i < objc; i += 3) { char *name = ObjStr(objv[i]); char *tag = ObjStr(objv[i+1]); Tcl_Obj *value = objv[i+2]; /*fprintf(stderr, "adding pair '%s' (%s) '%s'\n", name, tag, ObjStr(value));*/ - BsonAppend(interp, buf, name, tag, value); + BsonAppend(interp, b, name, tag, value); } - bson_from_buffer( b, buf ); + bson_finish(b); + //bson_from_buffer( b, buf ); mongo_insert(connPtr, namespace, b); resultObj = BsonToList(interp, b->data, 0); @@ -711,7 +711,7 @@ /* cmd query NsfMongoQuery { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "query" -required 1 -type tclobj} {-argName "-atts" -required 0 -nrargs 1 -type tclobj} @@ -720,7 +720,7 @@ } */ static int -NsfMongoQuery(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, +NsfMongoQuery(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *queryObj, Tcl_Obj *withAttsObj, int withLimit, int withSkip) { int objc1, objc2, result; @@ -771,13 +771,13 @@ /* cmd remove NsfMongoRemove { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "condition" -required 1 -type tclobj} } */ static int -NsfMongoRemove(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *conditionObj) { +NsfMongoRemove(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *conditionObj) { int objc, result; Tcl_Obj **objv; bson query[1]; @@ -796,7 +796,7 @@ /* cmd insert NsfMongoUpdate { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "namespace" -required 1} {-argName "cond" -required 1 -type tclobj} {-argName "values" -required 1 -type tclobj} @@ -805,7 +805,7 @@ } */ static int -NsfMongoUpdate(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, +NsfMongoUpdate(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *conditionObj, Tcl_Obj *valuesObj, int withUpsert, int withAll) { int objc, result, options = 0; Tcl_Obj **objv; @@ -838,14 +838,14 @@ ***********************************************************************/ /* cmd gridfs::open NsfMongoGridFSOpen { - {-argName "conn" -required 1 -type mongo_connection} + {-argName "conn" -required 1 -type mongo} {-argName "dbname" -required 1} {-argName "prefix" -required 1} } */ static int -NsfMongoGridFSOpen(Tcl_Interp *interp, mongo_connection *connPtr, +NsfMongoGridFSOpen(Tcl_Interp *interp, mongo *connPtr, CONST char *dbname, CONST char *prefix) { char buffer[80]; gridfs *gfsPtr; @@ -889,8 +889,10 @@ CONST char *filename, CONST char *remotename, CONST char *contenttype) { bson b = gridfs_store_file(gridfsPtr, filename, remotename, contenttype); + + /* currently, the result is broken; + Tcl_SetObjResult(interp, BsonToList(interp, b.data, 0));*/ - Tcl_SetObjResult(interp, BsonToList(interp, b.data, 0)); return TCL_OK; } @@ -1079,7 +1081,7 @@ */ Nsf_PointerTypeRegister(interp, "gridfs", &gridfsCount); Nsf_PointerTypeRegister(interp, "gridfile", &gridfileCount); - Nsf_PointerTypeRegister(interp, "mongo_connection", &mongo_connectionCount); + Nsf_PointerTypeRegister(interp, "mongo", &mongoCount); /* create all method commands (will use the namespaces above) */ for (i=0; i < nr_elements(method_definitions)-1; i++) {