Imported Debian patch 4.6.2-4~numeezy

This commit is contained in:
Alexandre Ellert
2018-01-31 13:57:05 +02:00
committed by Mario Fetka
parent 8ff3be4216
commit c86f4cfde4
103 changed files with 38064 additions and 0 deletions

View File

@@ -0,0 +1,164 @@
define(["../_base/declare", "./util/QueryResults", "./util/SimpleQueryEngine" /*=====, "./api/Store" =====*/],
function(declare, QueryResults, SimpleQueryEngine /*=====, Store =====*/){
// module:
// dojo/store/Memory
// No base class, but for purposes of documentation, the base class is dojo/store/api/Store
var base = null;
/*===== base = Store; =====*/
return declare("dojo.store.Memory", base, {
// summary:
// This is a basic in-memory object store. It implements dojo/store/api/Store.
constructor: function(options){
// summary:
// Creates a memory object store.
// options: dojo/store/Memory
// This provides any configuration information that will be mixed into the store.
// This should generally include the data property to provide the starting set of data.
for(var i in options){
this[i] = options[i];
}
this.setData(this.data || []);
},
// data: Array
// The array of all the objects in the memory store
data:null,
// idProperty: String
// Indicates the property to use as the identity property. The values of this
// property should be unique.
idProperty: "id",
// index: Object
// An index of data indices into the data array by id
index:null,
// queryEngine: Function
// Defines the query engine to use for querying the data store
queryEngine: SimpleQueryEngine,
get: function(id){
// summary:
// Retrieves an object by its identity
// id: Number
// The identity to use to lookup the object
// returns: Object
// The object in the store that matches the given id.
return this.data[this.index[id]];
},
getIdentity: function(object){
// summary:
// Returns an object's identity
// object: Object
// The object to get the identity from
// returns: Number
return object[this.idProperty];
},
put: function(object, options){
// summary:
// Stores an object
// object: Object
// The object to store.
// options: dojo/store/api/Store.PutDirectives?
// Additional metadata for storing the data. Includes an "id"
// property if a specific id is to be used.
// returns: Number
var data = this.data,
index = this.index,
idProperty = this.idProperty;
var id = object[idProperty] = (options && "id" in options) ? options.id : idProperty in object ? object[idProperty] : Math.random();
if(id in index){
// object exists
if(options && options.overwrite === false){
throw new Error("Object already exists");
}
// replace the entry in data
data[index[id]] = object;
}else{
// add the new object
index[id] = data.push(object) - 1;
}
return id;
},
add: function(object, options){
// summary:
// Creates an object, throws an error if the object already exists
// object: Object
// The object to store.
// options: dojo/store/api/Store.PutDirectives?
// Additional metadata for storing the data. Includes an "id"
// property if a specific id is to be used.
// returns: Number
(options = options || {}).overwrite = false;
// call put with overwrite being false
return this.put(object, options);
},
remove: function(id){
// summary:
// Deletes an object by its identity
// id: Number
// The identity to use to delete the object
// returns: Boolean
// Returns true if an object was removed, falsy (undefined) if no object matched the id
var index = this.index;
var data = this.data;
if(id in index){
data.splice(index[id], 1);
// now we have to reindex
this.setData(data);
return true;
}
},
query: function(query, options){
// summary:
// Queries the store for objects.
// query: Object
// The query to use for retrieving objects from the store.
// options: dojo/store/api/Store.QueryOptions?
// The optional arguments to apply to the resultset.
// returns: dojo/store/api/Store.QueryResults
// The results of the query, extended with iterative methods.
//
// example:
// Given the following store:
//
// | var store = new Memory({
// | data: [
// | {id: 1, name: "one", prime: false },
// | {id: 2, name: "two", even: true, prime: true},
// | {id: 3, name: "three", prime: true},
// | {id: 4, name: "four", even: true, prime: false},
// | {id: 5, name: "five", prime: true}
// | ]
// | });
//
// ...find all items where "prime" is true:
//
// | var results = store.query({ prime: true });
//
// ...or find all items where "even" is true:
//
// | var results = store.query({ even: true });
return QueryResults(this.queryEngine(query, options)(this.data));
},
setData: function(data){
// summary:
// Sets the given data as the source for this store, and indexes it
// data: Object[]
// An array of objects to use as the source of data.
if(data.items){
// just for convenience with the data format IFRS expects
this.idProperty = data.identifier;
data = this.data = data.items;
}else{
this.data = data;
}
this.index = {};
for(var i = 0, l = data.length; i < l; i++){
this.index[data[i][this.idProperty]] = i;
}
}
});
});

View File

@@ -0,0 +1,187 @@
define(["../_base/kernel", "../_base/lang", "../when", "../_base/array" /*=====, "./api/Store" =====*/
], function(kernel, lang, when, array /*=====, Store =====*/){
// module:
// dojo/store/Observable
var Observable = function(/*Store*/ store){
// summary:
// The Observable store wrapper takes a store and sets an observe method on query()
// results that can be used to monitor results for changes.
//
// description:
// Observable wraps an existing store so that notifications can be made when a query
// is performed.
//
// example:
// Create a Memory store that returns an observable query, and then log some
// information about that query.
//
// | var store = Observable(new Memory({
// | data: [
// | {id: 1, name: "one", prime: false},
// | {id: 2, name: "two", even: true, prime: true},
// | {id: 3, name: "three", prime: true},
// | {id: 4, name: "four", even: true, prime: false},
// | {id: 5, name: "five", prime: true}
// | ]
// | }));
// | var changes = [], results = store.query({ prime: true });
// | var observer = results.observe(function(object, previousIndex, newIndex){
// | changes.push({previousIndex:previousIndex, newIndex:newIndex, object:object});
// | });
//
// See the Observable tests for more information.
var undef, queryUpdaters = [], revision = 0;
// a Comet driven store could directly call notify to notify observers when data has
// changed on the backend
// create a new instance
store = lang.delegate(store);
store.notify = function(object, existingId){
revision++;
var updaters = queryUpdaters.slice();
for(var i = 0, l = updaters.length; i < l; i++){
updaters[i](object, existingId);
}
};
var originalQuery = store.query;
store.query = function(query, options){
options = options || {};
var results = originalQuery.apply(this, arguments);
if(results && results.forEach){
var nonPagedOptions = lang.mixin({}, options);
delete nonPagedOptions.start;
delete nonPagedOptions.count;
var queryExecutor = store.queryEngine && store.queryEngine(query, nonPagedOptions);
var queryRevision = revision;
var listeners = [], queryUpdater;
results.observe = function(listener, includeObjectUpdates){
if(listeners.push(listener) == 1){
// first listener was added, create the query checker and updater
queryUpdaters.push(queryUpdater = function(changed, existingId){
when(results, function(resultsArray){
var atEnd = resultsArray.length != options.count;
var i, l, listener;
if(++queryRevision != revision){
throw new Error("Query is out of date, you must observe() the query prior to any data modifications");
}
var removedObject, removedFrom = -1, insertedInto = -1;
if(existingId !== undef){
// remove the old one
for(i = 0, l = resultsArray.length; i < l; i++){
var object = resultsArray[i];
if(store.getIdentity(object) == existingId){
removedObject = object;
removedFrom = i;
if(queryExecutor || !changed){// if it was changed and we don't have a queryExecutor, we shouldn't remove it because updated objects would be eliminated
resultsArray.splice(i, 1);
}
break;
}
}
}
if(queryExecutor){
// add the new one
if(changed &&
// if a matches function exists, use that (probably more efficient)
(queryExecutor.matches ? queryExecutor.matches(changed) : queryExecutor([changed]).length)){
var firstInsertedInto = removedFrom > -1 ?
removedFrom : // put back in the original slot so it doesn't move unless it needs to (relying on a stable sort below)
resultsArray.length;
resultsArray.splice(firstInsertedInto, 0, changed); // add the new item
insertedInto = array.indexOf(queryExecutor(resultsArray), changed); // sort it
// we now need to push the chagne back into the original results array
resultsArray.splice(firstInsertedInto, 1); // remove the inserted item from the previous index
if((options.start && insertedInto == 0) ||
(!atEnd && insertedInto == resultsArray.length)){
// if it is at the end of the page, assume it goes into the prev or next page
insertedInto = -1;
}else{
resultsArray.splice(insertedInto, 0, changed); // and insert into the results array with the correct index
}
}
}else if(changed){
// we don't have a queryEngine, so we can't provide any information
// about where it was inserted or moved to. If it is an update, we leave it's position alone, other we at least indicate a new object
if(existingId !== undef){
// an update, keep the index the same
insertedInto = removedFrom;
}else if(!options.start){
// a new object
insertedInto = store.defaultIndex || 0;
resultsArray.splice(insertedInto, 0, changed);
}
}
if((removedFrom > -1 || insertedInto > -1) &&
(includeObjectUpdates || !queryExecutor || (removedFrom != insertedInto))){
var copyListeners = listeners.slice();
for(i = 0;listener = copyListeners[i]; i++){
listener(changed || removedObject, removedFrom, insertedInto);
}
}
});
});
}
var handle = {};
// TODO: Remove cancel in 2.0.
handle.remove = handle.cancel = function(){
// remove this listener
var index = array.indexOf(listeners, listener);
if(index > -1){ // check to make sure we haven't already called cancel
listeners.splice(index, 1);
if(!listeners.length){
// no more listeners, remove the query updater too
queryUpdaters.splice(array.indexOf(queryUpdaters, queryUpdater), 1);
}
}
};
return handle;
};
}
return results;
};
var inMethod;
function whenFinished(method, action){
var original = store[method];
if(original){
store[method] = function(value){
if(inMethod){
// if one method calls another (like add() calling put()) we don't want two events
return original.apply(this, arguments);
}
inMethod = true;
try{
var results = original.apply(this, arguments);
when(results, function(results){
action((typeof results == "object" && results) || value);
});
return results;
}finally{
inMethod = false;
}
};
}
}
// monitor for updates by listening to these methods
whenFinished("put", function(object){
store.notify(object, store.getIdentity(object));
});
whenFinished("add", function(object){
store.notify(object);
});
whenFinished("remove", function(id){
store.notify(undefined, id);
});
return store;
};
lang.setObject("dojo.store.Observable", Observable);
return Observable;
});

View File

@@ -0,0 +1,63 @@
define(["../../_base/array", "../../_base/lang", "../../when"
], function(array, lang, when){
// module:
// dojo/store/util/QueryResults
var QueryResults = function(results){
// summary:
// A function that wraps the results of a store query with additional
// methods.
// description:
// QueryResults is a basic wrapper that allows for array-like iteration
// over any kind of returned data from a query. While the simplest store
// will return a plain array of data, other stores may return deferreds or
// promises; this wrapper makes sure that *all* results can be treated
// the same.
//
// Additional methods include `forEach`, `filter` and `map`.
// results: Array|dojo/promise/Promise
// The result set as an array, or a promise for an array.
// returns:
// An array-like object that can be used for iterating over.
// example:
// Query a store and iterate over the results.
//
// | store.query({ prime: true }).forEach(function(item){
// | // do something
// | });
if(!results){
return results;
}
// if it is a promise it may be frozen
if(results.then){
results = lang.delegate(results);
}
function addIterativeMethod(method){
if(!results[method]){
results[method] = function(){
var args = arguments;
return when(results, function(results){
Array.prototype.unshift.call(args, results);
return QueryResults(array[method].apply(array, args));
});
};
}
}
addIterativeMethod("forEach");
addIterativeMethod("filter");
addIterativeMethod("map");
if(!results.total){
results.total = when(results, function(results){
return results.length;
});
}
return results; // Object
};
lang.setObject("dojo.store.util.QueryResults", QueryResults);
return QueryResults;
});

View File

@@ -0,0 +1,110 @@
define(["../../_base/array" /*=====, "../api/Store" =====*/], function(arrayUtil /*=====, Store =====*/){
// module:
// dojo/store/util/SimpleQueryEngine
return function(query, options){
// summary:
// Simple query engine that matches using filter functions, named filter
// functions or objects by name-value on a query object hash
//
// description:
// The SimpleQueryEngine provides a way of getting a QueryResults through
// the use of a simple object hash as a filter. The hash will be used to
// match properties on data objects with the corresponding value given. In
// other words, only exact matches will be returned.
//
// This function can be used as a template for more complex query engines;
// for example, an engine can be created that accepts an object hash that
// contains filtering functions, or a string that gets evaluated, etc.
//
// When creating a new dojo.store, simply set the store's queryEngine
// field as a reference to this function.
//
// query: Object
// An object hash with fields that may match fields of items in the store.
// Values in the hash will be compared by normal == operator, but regular expressions
// or any object that provides a test() method are also supported and can be
// used to match strings by more complex expressions
// (and then the regex's or object's test() method will be used to match values).
//
// options: dojo/store/api/Store.QueryOptions?
// An object that contains optional information such as sort, start, and count.
//
// returns: Function
// A function that caches the passed query under the field "matches". See any
// of the "query" methods on dojo.stores.
//
// example:
// Define a store with a reference to this engine, and set up a query method.
//
// | var myStore = function(options){
// | // ...more properties here
// | this.queryEngine = SimpleQueryEngine;
// | // define our query method
// | this.query = function(query, options){
// | return QueryResults(this.queryEngine(query, options)(this.data));
// | };
// | };
// create our matching query function
switch(typeof query){
default:
throw new Error("Can not query with a " + typeof query);
case "object": case "undefined":
var queryObject = query;
query = function(object){
for(var key in queryObject){
var required = queryObject[key];
if(required && required.test){
// an object can provide a test method, which makes it work with regex
if(!required.test(object[key], object)){
return false;
}
}else if(required != object[key]){
return false;
}
}
return true;
};
break;
case "string":
// named query
if(!this[query]){
throw new Error("No filter function " + query + " was found in store");
}
query = this[query];
// fall through
case "function":
// fall through
}
function execute(array){
// execute the whole query, first we filter
var results = arrayUtil.filter(array, query);
// next we sort
var sortSet = options && options.sort;
if(sortSet){
results.sort(typeof sortSet == "function" ? sortSet : function(a, b){
for(var sort, i=0; sort = sortSet[i]; i++){
var aValue = a[sort.attribute];
var bValue = b[sort.attribute];
if (aValue != bValue){
return !!sort.descending == (aValue == null || aValue > bValue) ? -1 : 1;
}
}
return 0;
});
}
// now we paginate
if(options && (options.start || options.count)){
var total = results.length;
results = results.slice(options.start || 0, (options.start || 0) + (options.count || Infinity));
results.total = total;
}
return results;
}
execute.matches = query;
return execute;
};
});