Permalink
Browse files

Cleaned up whitespace (spaces only)

No other changes.



git-svn-id: http://luamongo.googlecode.com/svn/trunk@56 17e306f6-9439-11de-a13a-71b910e68cc8
  • Loading branch information...
1 parent 4bc388d commit 668f22369aa65ad41e24da0ad01721dfcb35f160 neomantra committed Oct 27, 2010
Showing with 484 additions and 478 deletions.
  1. +19 −19 common.h
  2. +10 −10 main.cpp
  3. +103 −103 mongo_bsontypes.cpp
  4. +108 −105 mongo_connection.cpp
  5. +8 −4 mongo_cursor.cpp
  6. +29 −29 mongo_gridfile.cpp
  7. +32 −32 mongo_gridfs.cpp
  8. +2 −2 mongo_gridfschunk.cpp
  9. +22 −22 mongo_query.cpp
  10. +134 −135 utils.cpp
  11. +17 −17 utils.h
View
@@ -2,28 +2,28 @@
#define LUAMONGO_CONNECTION "mongo.Connection"
#define LUAMONGO_CURSOR "mongo.Cursor"
#define LUAMONGO_QUERY "mongo.Query"
-#define LUAMONGO_GRIDFS "mongo.GridFS"
-#define LUAMONGO_GRIDFILE "mongo.GridFile"
-#define LUAMONGO_GRIDFSCHUNK "mongo.GridFSChunk"
+#define LUAMONGO_GRIDFS "mongo.GridFS"
+#define LUAMONGO_GRIDFILE "mongo.GridFile"
+#define LUAMONGO_GRIDFSCHUNK "mongo.GridFSChunk"
-#define LUAMONGO_ERR_CONNECTION_FAILED "Connection failed: %s"
-#define LUAMONGO_ERR_GRIDFS_FAILED "GridFS failed: %s"
-#define LUAMONGO_ERR_GRIDFSCHUNK_FAILED "GridFSChunk failed: %s"
-#define LUAMONGO_ERR_QUERY_FAILED "Query failed: %s"
-#define LUAMONGO_ERR_INSERT_FAILED "Insert failed: %s"
-#define LUAMONGO_ERR_CONNECT_FAILED "Connection to %s failed: %s"
-#define LUAMONGO_ERR_COUNT_FAILED "Count failed: %s"
-#define LUAMONGO_ERR_REMOVE_FAILED "Remove failed: %s"
-#define LUAMONGO_ERR_UPDATE_FAILED "Update failed: %s"
-#define LUAMONGO_UNSUPPORTED_BSON_TYPE "Unsupported BSON type `%s'"
-#define LUAMONGO_UNSUPPORTED_LUA_TYPE "Unsupported Lua type `%s'"
-#define LUAMONGO_REQUIRES_JSON_OR_TABLE "JSON string or Lua table required"
-#define LUAMONGO_REQUIRES_QUERY LUAMONGO_QUERY ", JSON string or Lua table required"
-#define LUAMONGO_NOT_IMPLEMENTED "Not implemented: %s.%s"
-#define LUAMONGO_ERR_CALLING "Error calling %s.%s: %s"
+#define LUAMONGO_ERR_CONNECTION_FAILED "Connection failed: %s"
+#define LUAMONGO_ERR_GRIDFS_FAILED "GridFS failed: %s"
+#define LUAMONGO_ERR_GRIDFSCHUNK_FAILED "GridFSChunk failed: %s"
+#define LUAMONGO_ERR_QUERY_FAILED "Query failed: %s"
+#define LUAMONGO_ERR_INSERT_FAILED "Insert failed: %s"
+#define LUAMONGO_ERR_CONNECT_FAILED "Connection to %s failed: %s"
+#define LUAMONGO_ERR_COUNT_FAILED "Count failed: %s"
+#define LUAMONGO_ERR_REMOVE_FAILED "Remove failed: %s"
+#define LUAMONGO_ERR_UPDATE_FAILED "Update failed: %s"
+#define LUAMONGO_UNSUPPORTED_BSON_TYPE "Unsupported BSON type `%s'"
+#define LUAMONGO_UNSUPPORTED_LUA_TYPE "Unsupported Lua type `%s'"
+#define LUAMONGO_REQUIRES_JSON_OR_TABLE "JSON string or Lua table required"
+#define LUAMONGO_REQUIRES_QUERY LUAMONGO_QUERY ", JSON string or Lua table required"
+#define LUAMONGO_NOT_IMPLEMENTED "Not implemented: %s.%s"
+#define LUAMONGO_ERR_CALLING "Error calling %s.%s: %s"
#if defined(MONGO_PRE_1_5)
#define CHUNK Chunk
#else
- #define CHUNK GridFSChunk
+ #define CHUNK GridFSChunk
#endif
View
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2009 Neil Richardson (nrich@iinet.net.au)
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
View
@@ -66,7 +66,7 @@ static int bson_type_ObjectID(lua_State *L) {
static int bson_type_NULL(lua_State *L) {
push_bsontype_table(L, mongo::jstNULL);
// no arg
- return 1;
+ return 1;
}
static int integer_value(lua_State *L) {
@@ -75,12 +75,12 @@ static int integer_value(lua_State *L) {
lua_rawgeti(L, 1, 1);
- if (n > 1) {
- lua_pushinteger(L, luaL_checkint(L, 2));
- lua_rawseti(L, 1, 1);
- returncount = 0;
+ if (n > 1) {
+ lua_pushinteger(L, luaL_checkint(L, 2));
+ lua_rawseti(L, 1, 1);
+ returncount = 0;
} else {
- lua_pushinteger(L, luaL_checkint(L, -1));
+ lua_pushinteger(L, luaL_checkint(L, -1));
}
return returncount;
@@ -92,12 +92,12 @@ static int number_value(lua_State *L) {
lua_rawgeti(L, 1, 1);
- if (n > 1) {
- lua_pushnumber(L, luaL_checknumber(L, 2));
- lua_rawseti(L, 1, 1);
- returncount = 0;
+ if (n > 1) {
+ lua_pushnumber(L, luaL_checknumber(L, 2));
+ lua_rawseti(L, 1, 1);
+ returncount = 0;
} else {
- lua_pushnumber(L, luaL_checknumber(L, -1));
+ lua_pushnumber(L, luaL_checknumber(L, -1));
}
return returncount;
@@ -109,12 +109,12 @@ static int string_value(lua_State *L) {
lua_rawgeti(L, 1, 1);
- if (n > 1) {
- lua_pushstring(L, luaL_checkstring(L, 2));
- lua_rawseti(L, 1, 1);
- returncount = 0;
+ if (n > 1) {
+ lua_pushstring(L, luaL_checkstring(L, 2));
+ lua_rawseti(L, 1, 1);
+ returncount = 0;
} else {
- lua_pushstring(L, luaL_checkstring(L, -1));
+ lua_pushstring(L, luaL_checkstring(L, -1));
}
return returncount;
@@ -134,15 +134,15 @@ static int stringpair_value(lua_State *L) {
lua_rawgeti(L, 1, 1);
lua_rawgeti(L, 1, 2);
- if (n > 1) {
- lua_pushstring(L, luaL_checkstring(L, 2));
- lua_rawseti(L, 1, 1);
- lua_pushstring(L, luaL_checkstring(L, 3));
- lua_rawseti(L, 1, 2);
- returncount = 0;
+ if (n > 1) {
+ lua_pushstring(L, luaL_checkstring(L, 2));
+ lua_rawseti(L, 1, 1);
+ lua_pushstring(L, luaL_checkstring(L, 3));
+ lua_rawseti(L, 1, 2);
+ returncount = 0;
} else {
- lua_pushstring(L, luaL_checkstring(L, -2));
- lua_pushstring(L, luaL_checkstring(L, -2));
+ lua_pushstring(L, luaL_checkstring(L, -2));
+ lua_pushstring(L, luaL_checkstring(L, -2));
}
return returncount;
@@ -210,43 +210,43 @@ void push_bsontype_table(lua_State* L, mongo::BSONType bsontype) {
lua_pushstring(L, "__call");
switch(bsontype) {
- case mongo::NumberInt:
- lua_pushcfunction(L, integer_value);
- break;
- case mongo::Date:
- case mongo::Timestamp:
- lua_pushcfunction(L, number_value);
- break;
- case mongo::Symbol:
- case mongo::jstOID:
- lua_pushcfunction(L, string_value);
- break;
- case mongo::RegEx:
- lua_pushcfunction(L, stringpair_value);
- break;
- case mongo::jstNULL:
- lua_pushcfunction(L, null_value);
- break;
+ case mongo::NumberInt:
+ lua_pushcfunction(L, integer_value);
+ break;
+ case mongo::Date:
+ case mongo::Timestamp:
+ lua_pushcfunction(L, number_value);
+ break;
+ case mongo::Symbol:
+ case mongo::jstOID:
+ lua_pushcfunction(L, string_value);
+ break;
+ case mongo::RegEx:
+ lua_pushcfunction(L, stringpair_value);
+ break;
+ case mongo::jstNULL:
+ lua_pushcfunction(L, null_value);
+ break;
}
lua_settable(L, -3);
lua_pushstring(L, "__tostring");
switch(bsontype) {
- case mongo::NumberInt:
- case mongo::Timestamp:
- case mongo::Symbol:
- case mongo::jstOID:
- lua_pushcfunction(L, generic_tostring);
- break;
- case mongo::Date:
- lua_pushcfunction(L, date_tostring);
- break;
- case mongo::RegEx:
- lua_pushcfunction(L, regex_tostring);
- break;
- case mongo::jstNULL:
- lua_pushcfunction(L, null_tostring);
- break;
+ case mongo::NumberInt:
+ case mongo::Timestamp:
+ case mongo::Symbol:
+ case mongo::jstOID:
+ lua_pushcfunction(L, generic_tostring);
+ break;
+ case mongo::Date:
+ lua_pushcfunction(L, date_tostring);
+ break;
+ case mongo::RegEx:
+ lua_pushcfunction(L, regex_tostring);
+ break;
+ case mongo::jstNULL:
+ lua_pushcfunction(L, null_tostring);
+ break;
}
lua_settable(L, -3);
@@ -258,60 +258,60 @@ void push_bsontype_table(lua_State* L, mongo::BSONType bsontype) {
*/
static int bson_type_name(lua_State *L) {
if (lua_istable(L, 1)) {
- int bsontype_found = luaL_getmetafield(L, 1, "__bsontype");
+ int bsontype_found = luaL_getmetafield(L, 1, "__bsontype");
- if (bsontype_found) {
+ if (bsontype_found) {
int bson_type = lua_tointeger(L, -1);
lua_pop(L, 1);
- lua_pushfstring(L, "%s.%s", LUAMONGO_ROOT, bson_name(bson_type));
- } else {
- lua_pushstring(L, luaL_typename(L, 1));
- }
+ lua_pushfstring(L, "%s.%s", LUAMONGO_ROOT, bson_name(bson_type));
+ } else {
+ lua_pushstring(L, luaL_typename(L, 1));
+ }
} else {
- lua_pushstring(L, luaL_typename(L, 1));
+ lua_pushstring(L, luaL_typename(L, 1));
}
return 1;
}
/*
- * num = mongo.tonumber(obj)
+ * num = mongo.tonumber(obj)
*/
static int bson_tonumber(lua_State *L) {
int base = luaL_optint(L, 2, 10);
if (base == 10) { /* standard conversion */
- luaL_checkany(L, 1);
- if (lua_isnumber(L, 1)) {
- lua_pushnumber(L, lua_tonumber(L, 1));
- return 1;
- } else if (lua_istable(L, 1)) {
- int bsontype_found = luaL_getmetafield(L, 1, "__bsontype");
-
- if (bsontype_found) {
- lua_rawgeti(L, 1, 1);
-
- if (lua_isnumber(L, -1)) {
- lua_pushnumber(L, lua_tonumber(L, -1));
- return 1;
- }
-
- lua_pop(L, 1);
- }
- }
+ luaL_checkany(L, 1);
+ if (lua_isnumber(L, 1)) {
+ lua_pushnumber(L, lua_tonumber(L, 1));
+ return 1;
+ } else if (lua_istable(L, 1)) {
+ int bsontype_found = luaL_getmetafield(L, 1, "__bsontype");
+
+ if (bsontype_found) {
+ lua_rawgeti(L, 1, 1);
+
+ if (lua_isnumber(L, -1)) {
+ lua_pushnumber(L, lua_tonumber(L, -1));
+ return 1;
+ }
+
+ lua_pop(L, 1);
+ }
+ }
} else {
- const char *s1 = luaL_checkstring(L, 1);
- char *s2;
- unsigned long n;
- luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
- n = strtoul(s1, &s2, base);
- if (s1 != s2) { /* at least one valid digit? */
- while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
- if (*s2 == '\0') { /* no invalid trailing characters? */
- lua_pushnumber(L, (lua_Number)n);
- return 1;
- }
- }
+ const char *s1 = luaL_checkstring(L, 1);
+ char *s2;
+ unsigned long n;
+ luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
+ n = strtoul(s1, &s2, base);
+ if (s1 != s2) { /* at least one valid digit? */
+ while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
+ if (*s2 == '\0') { /* no invalid trailing characters? */
+ lua_pushnumber(L, (lua_Number)n);
+ return 1;
+ }
+ }
}
lua_pushnil(L); /* else not a number */
@@ -323,13 +323,13 @@ static int bson_tojson(lua_State *L) {
BSONObj obj;
if (lua_istable(L, 1)) {
- lua_to_bson(L, 1, obj);
+ lua_to_bson(L, 1, obj);
- lua_pushstring(L, obj.toString().c_str());
+ lua_pushstring(L, obj.toString().c_str());
} else {
- lua_pushnil(L);
- lua_pushfstring(L, "Argument is not a table");
- resultcount = 2;
+ lua_pushnil(L);
+ lua_pushfstring(L, "Argument is not a table");
+ resultcount = 2;
}
return resultcount;
@@ -341,7 +341,7 @@ static int bson_fromjson(lua_State *L) {
BSONObj obj;
try {
- bson_to_lua(L, fromjson(json));
+ bson_to_lua(L, fromjson(json));
} catch (std::exception &e) {
lua_pushnil(L);
lua_pushfstring(L, "Error parsing JSON: %s", e.what());
@@ -361,11 +361,11 @@ int mongo_bsontypes_register(lua_State *L) {
{"ObjectId", bson_type_ObjectID},
{"NULL", bson_type_NULL},
- // Utils
+ // Utils
{"type", bson_type_name},
{"tonumber", bson_tonumber},
- {"tojson", bson_tojson},
- {"fromjson", bson_fromjson},
+ {"tojson", bson_tojson},
+ {"fromjson", bson_fromjson},
{NULL, NULL}
};
Oops, something went wrong.

0 comments on commit 668f223

Please sign in to comment.