1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Michael Hackstein 2013-03-25 12:24:16 +01:00
commit 3978441f4c
4 changed files with 90 additions and 55 deletions

View File

@ -255,22 +255,6 @@ static const TRI_doc_update_policy_e ExtractUpdatePolicy (v8::Arguments const& a
return policy; return policy;
} }
////////////////////////////////////////////////////////////////////////////////
/// @brief return the collection type the object is responsible for
/// - "db" will return TRI_COL_TYPE_DOCUMENT
/// - "edges" will return TRI_COL_TYPE_EDGE
////////////////////////////////////////////////////////////////////////////////
static inline TRI_col_type_e GetVocBaseCollectionType (const v8::Handle<v8::Object>& obj) {
v8::Handle<v8::Value> type = obj->Get(TRI_V8_SYMBOL("_type"));
if (type->IsNumber()) {
return (TRI_col_type_e) TRI_ObjectToInt64(type);
}
return TRI_COL_TYPE_DOCUMENT;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief wraps a C++ into a v8::Object /// @brief wraps a C++ into a v8::Object
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -5434,7 +5418,7 @@ static v8::Handle<v8::Value> MapGetVocBase (v8::Local<v8::String> name,
string key = TRI_ObjectToString(name); string key = TRI_ObjectToString(name);
if (key == "") { if (key == "") {
return scope.Close(v8::ThrowException(TRI_CreateErrorObject(TRI_ERROR_ARANGO_ILLEGAL_NAME, "name must not be empty"))); return scope.Close(v8::Handle<v8::Value>());
} }
if ( key == "toString" if ( key == "toString"
@ -5475,7 +5459,9 @@ static v8::Handle<v8::Value> MapGetVocBase (v8::Local<v8::String> name,
v8::Handle<v8::Value> result = TRI_WrapCollection(collection); v8::Handle<v8::Value> result = TRI_WrapCollection(collection);
holder->Set(name, result); // TODO: when this line is uncommented, the collection names are cached.
// but this causes problems and confusion somewhere else. Need to find the reason!
// holder->Set(name, result);
return scope.Close(result); return scope.Close(result);
} }
@ -5716,10 +5702,7 @@ static v8::Handle<v8::Value> JS_CompletionsVocbase (v8::Arguments const& argv) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_CreateVocbase (v8::Arguments const& argv) { static v8::Handle<v8::Value> JS_CreateVocbase (v8::Arguments const& argv) {
// get the collection type (document/edge) return CreateVocBase(argv, TRI_COL_TYPE_DOCUMENT);
const TRI_col_type_e collectionType = GetVocBaseCollectionType(argv.Holder());
return CreateVocBase(argv, collectionType);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -6403,8 +6386,7 @@ TRI_index_t* TRI_LookupIndexByHandle (const CollectionNameResolver& resolver,
/// @brief wraps a TRI_vocbase_t /// @brief wraps a TRI_vocbase_t
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
v8::Handle<v8::Object> TRI_WrapVocBase (TRI_vocbase_t const* database, v8::Handle<v8::Object> TRI_WrapVocBase (TRI_vocbase_t const* database) {
TRI_col_type_e type) {
v8::HandleScope scope; v8::HandleScope scope;
TRI_v8_global_t* v8g = (TRI_v8_global_t*) v8::Isolate::GetCurrent()->GetData(); TRI_v8_global_t* v8g = (TRI_v8_global_t*) v8::Isolate::GetCurrent()->GetData();
@ -6413,7 +6395,6 @@ v8::Handle<v8::Object> TRI_WrapVocBase (TRI_vocbase_t const* database,
const_cast<TRI_vocbase_t*>(database)); const_cast<TRI_vocbase_t*>(database));
result->Set(TRI_V8_SYMBOL("_path"), v8::String::New(database->_path), v8::ReadOnly); result->Set(TRI_V8_SYMBOL("_path"), v8::String::New(database->_path), v8::ReadOnly);
result->Set(TRI_V8_SYMBOL("_type"), v8::Integer::New((int) type), v8::ReadOnly);
return scope.Close(result); return scope.Close(result);
} }
@ -6757,7 +6738,7 @@ TRI_v8_global_t* TRI_InitV8VocBridge (v8::Handle<v8::Context> context,
// ............................................................................. // .............................................................................
TRI_AddGlobalVariableVocbase(context, "DATABASEPATH", v8::String::New(vocbase->_path)); TRI_AddGlobalVariableVocbase(context, "DATABASEPATH", v8::String::New(vocbase->_path));
TRI_AddGlobalVariableVocbase(context, "db", TRI_WrapVocBase(vocbase, TRI_COL_TYPE_DOCUMENT)); TRI_AddGlobalVariableVocbase(context, "db", TRI_WrapVocBase(vocbase));
// current thread number // current thread number
context->Global()->Set(TRI_V8_SYMBOL("THREAD_NUMBER"), v8::Number::New(threadNumber), v8::ReadOnly); context->Global()->Set(TRI_V8_SYMBOL("THREAD_NUMBER"), v8::Number::New(threadNumber), v8::ReadOnly);

View File

@ -930,7 +930,9 @@ int TRI_BeginTransaction (TRI_transaction_t* const trx,
} }
else { else {
// something is wrong // something is wrong
UpdateTransactionStatus(trx, TRI_TRANSACTION_FAILED); if (nestingLevel == 0) {
UpdateTransactionStatus(trx, TRI_TRANSACTION_FAILED);
}
// free what we have got so far // free what we have got so far
ReleaseCollections(trx, nestingLevel); ReleaseCollections(trx, nestingLevel);

View File

@ -104,7 +104,13 @@ function clear () {
} }
} }
special = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT; try {
// these variables don't exist in the browser context
special = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err2) {
special = false;
}
if (internal.ARANGO_QUIET !== true && ! special) { if (internal.ARANGO_QUIET !== true && ! special) {
if (typeof internal.arango !== "undefined") { if (typeof internal.arango !== "undefined") {
@ -131,22 +137,42 @@ var arango = require("org/arangodb").arango;
/// @brief read rc file /// @brief read rc file
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (! (IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT)) {
(function () {
var fs = require("fs");
var rcf = fs.join(fs.home(), ".arangosh.rc");
if (fs.exists(rcf)) { (function () {
var content = fs.read(rcf); var special;
eval(content);
try {
// these variables are not defined in the browser context
special = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err) {
special = false;
}
if (! special) {
try {
// this will not work from within a browser
var fs = require("fs");
var rcf = fs.join(fs.home(), ".arangosh.rc");
if (fs.exists(rcf)) {
var content = fs.read(rcf);
eval(content);
}
} }
}()); catch (err2) {
} }
}
delete IS_EXECUTE_SCRIPT; try {
delete IS_CHECK_SCRIPT; delete IS_EXECUTE_SCRIPT;
delete IS_UNIT_TESTS; delete IS_CHECK_SCRIPT;
delete IS_JS_LINT; delete IS_UNIT_TESTS;
delete IS_JS_LINT;
}
catch (err3) {
}
}());
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @} /// @}

View File

@ -104,7 +104,13 @@ function clear () {
} }
} }
special = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT; try {
// these variables don't exist in the browser context
special = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err2) {
special = false;
}
if (internal.ARANGO_QUIET !== true && ! special) { if (internal.ARANGO_QUIET !== true && ! special) {
if (typeof internal.arango !== "undefined") { if (typeof internal.arango !== "undefined") {
@ -131,22 +137,42 @@ var arango = require("org/arangodb").arango;
/// @brief read rc file /// @brief read rc file
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (! (IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT)) {
(function () {
var fs = require("fs");
var rcf = fs.join(fs.home(), ".arangosh.rc");
if (fs.exists(rcf)) { (function () {
var content = fs.read(rcf); var special;
eval(content);
try {
// these variables are not defined in the browser context
special = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err) {
special = false;
}
if (! special) {
try {
// this will not work from within a browser
var fs = require("fs");
var rcf = fs.join(fs.home(), ".arangosh.rc");
if (fs.exists(rcf)) {
var content = fs.read(rcf);
eval(content);
}
} }
}()); catch (err2) {
} }
}
delete IS_EXECUTE_SCRIPT; try {
delete IS_CHECK_SCRIPT; delete IS_EXECUTE_SCRIPT;
delete IS_UNIT_TESTS; delete IS_CHECK_SCRIPT;
delete IS_JS_LINT; delete IS_UNIT_TESTS;
delete IS_JS_LINT;
}
catch (err3) {
}
}());
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @} /// @}