Skip to content

Commit

Permalink
[MongoDB] Several fixes so we can create a simple BsonDocument and sa…
Browse files Browse the repository at this point in the history
…ve it successfully to the DB
  • Loading branch information
Whiteknight committed Apr 15, 2012
1 parent a09b843 commit 32146e0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
5 changes: 1 addition & 4 deletions Makefile
@@ -1,5 +1,4 @@
all: memcached mysql mongodb
echo "MAKE ALL"

clean: clean_memcached clean_mongodb clean_mysql

Expand All @@ -20,9 +19,7 @@ parrotstore/memcached.pbc: memcached/

## MongoDB

mongodb: mongodb/*.winxed mongodb/pmc/*.pmc mongodb/include/*.h dynext/mongodb_group.so

dynext/mongodb_group.so:
mongodb:
winxed setup.winxed mongodb build

clean_mongodb:
Expand Down
1 change: 1 addition & 0 deletions mongodb/include/ps_mongodb.h
@@ -1,6 +1,7 @@

#define STRING_TO_CSTRING(i, s, c, code) do { \
char * (c) = Parrot_str_to_cstring((i), (s)); \
fprintf(stderr, "Connecting to server '%s'", (c)); \
{ \
code \
} \
Expand Down
2 changes: 1 addition & 1 deletion mongodb/pmc/bsondocument.pmc
Expand Up @@ -57,7 +57,7 @@ pmclass BsonDocument dynpmc auto_attrs {
);
}

METHOD append_finish_object(STRING *name)
METHOD append_finish_object()
{
bson_append_finish_object(GET_BSON(SELF));
}
Expand Down
8 changes: 3 additions & 5 deletions mongodb/pmc/mongodbcontext.pmc
Expand Up @@ -6,7 +6,7 @@ pmclass MongoDbContext dynpmc auto_attrs {
ATTR void *conn;

VTABLE void init() {
mongo * conn = (mongo *)malloc(sizeof(conn));
mongo * conn = (mongo *)malloc(sizeof(mongo));
PARROT_MONGODBCONTEXT(SELF)->conn = conn;
}

Expand All @@ -21,10 +21,8 @@ pmclass MongoDbContext dynpmc auto_attrs {
METHOD connect(STRING * server, INTVAL port)
{
mongo * conn = GET_CONN(SELF);
INTVAL stat;
STRING_TO_CSTRING(INTERP, server, cserver, {
stat = mongo_connect(conn, cserver, port);
});
char * const cserver = Parrot_str_to_cstring(INTERP, server);
INTVAL stat = mongo_connect(conn, cserver, port);
if (stat) {
switch(conn->err) {
case MONGO_CONN_NO_SOCKET:
Expand Down

0 comments on commit 32146e0

Please sign in to comment.