fix for a last-minute Fx 4 API change. this at least gets the translator infrastructure working, but the API change may result in a good amount of translator breakage as well.
This commit is contained in:
parent
623e2dd150
commit
0a91608268
3 changed files with 57 additions and 16 deletions
|
@ -64,13 +64,11 @@ Zotero.Translate.SandboxManager.prototype = {
|
||||||
*/
|
*/
|
||||||
"importObject":function(object, passAsFirstArgument, attachTo) {
|
"importObject":function(object, passAsFirstArgument, attachTo) {
|
||||||
if(!attachTo) attachTo = this.sandbox.Zotero;
|
if(!attachTo) attachTo = this.sandbox.Zotero;
|
||||||
for(var key in (object.__exposedProps__ ? object.__exposedProps__ : object)) {
|
var newExposedProps = false;
|
||||||
let localKey;
|
if(!object.__exposedProps__) newExposedProps = {};
|
||||||
if(object.__exposedProps__) {
|
for(var key in (newExposedProps ? object : object.__exposedProps__)) {
|
||||||
localKey = object.__exposedProps__[key];
|
let localKey = key;
|
||||||
} else {
|
if(newExposedProps) newExposedProps[localKey] = "r";
|
||||||
localKey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
// magical XPCSafeJSObjectWrappers for sandbox
|
// magical XPCSafeJSObjectWrappers for sandbox
|
||||||
if(typeof object[localKey] === "function" || typeof object[localKey] === "object") {
|
if(typeof object[localKey] === "function" || typeof object[localKey] === "object") {
|
||||||
|
@ -90,9 +88,15 @@ Zotero.Translate.SandboxManager.prototype = {
|
||||||
this.importObject(object[localKey], passAsFirstArgument ? passAsFirstArgument : null, attachTo[localKey]);
|
this.importObject(object[localKey], passAsFirstArgument ? passAsFirstArgument : null, attachTo[localKey]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object[localKey] = object[localKey];
|
attachTo[localKey] = object[localKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(newExposedProps) {
|
||||||
|
attachTo.__exposedProps__ = newExposedProps;
|
||||||
|
} else {
|
||||||
|
attachTo.__exposedProps__ = object.__exposedProps__;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +247,12 @@ Zotero.Translate.IO.Read = function(file, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Translate.IO.Read.prototype = {
|
Zotero.Translate.IO.Read.prototype = {
|
||||||
"__exposedProps__":["_getXML", "RDF", "read", "setCharacterSet"],
|
"__exposedProps__":{
|
||||||
|
"_getXML":"r",
|
||||||
|
"RDF":"r",
|
||||||
|
"read":"r",
|
||||||
|
"setCharacterSet":"r"
|
||||||
|
},
|
||||||
|
|
||||||
"_seekToStart":function() {
|
"_seekToStart":function() {
|
||||||
this._rawStream.QueryInterface(Components.interfaces.nsISeekableStream)
|
this._rawStream.QueryInterface(Components.interfaces.nsISeekableStream)
|
||||||
|
@ -351,7 +360,11 @@ Zotero.Translate.IO.Write = function(file, mode, charset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Translate.IO.Write.prototype = {
|
Zotero.Translate.IO.Write.prototype = {
|
||||||
"__exposedProps__":["RDF", "write", "setCharacterSet"],
|
"__exposedProps__":{
|
||||||
|
"RDF":"r",
|
||||||
|
"write":"r",
|
||||||
|
"setCharacterSet":"r"
|
||||||
|
},
|
||||||
|
|
||||||
"_initRDF":function() {
|
"_initRDF":function() {
|
||||||
Zotero.debug("Translate: Initializing RDF data store");
|
Zotero.debug("Translate: Initializing RDF data store");
|
||||||
|
|
|
@ -150,6 +150,16 @@ Zotero.Translate.Sandbox = {
|
||||||
// for security reasons, safeTranslator wraps the translator object.
|
// for security reasons, safeTranslator wraps the translator object.
|
||||||
// note that setLocation() is not allowed
|
// note that setLocation() is not allowed
|
||||||
var safeTranslator = new Object();
|
var safeTranslator = new Object();
|
||||||
|
safeTranslator.__exposedProps__ = {
|
||||||
|
"setSearch":"r",
|
||||||
|
"setDocument":"r",
|
||||||
|
"setHandler":"r",
|
||||||
|
"setString":"r",
|
||||||
|
"setTranslator":"r",
|
||||||
|
"getTranslators":"r",
|
||||||
|
"translate":"r",
|
||||||
|
"getTranslatorObject":"r"
|
||||||
|
};
|
||||||
safeTranslator.setSearch = function(arg) {
|
safeTranslator.setSearch = function(arg) {
|
||||||
if(Zotero.isFx4) arg = JSON.parse(JSON.stringify(arg));
|
if(Zotero.isFx4) arg = JSON.parse(JSON.stringify(arg));
|
||||||
return translation.setSearch(arg);
|
return translation.setSearch(arg);
|
||||||
|
@ -1379,7 +1389,13 @@ Zotero.Translate.IO.String = function(string, uri, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Translate.IO.String.prototype = {
|
Zotero.Translate.IO.String.prototype = {
|
||||||
"__exposedProps__":["RDF", "read", "write", "setCharacterSet", "_getXML"],
|
"__exposedProps__":{
|
||||||
|
"RDF":"r",
|
||||||
|
"read":"r",
|
||||||
|
"write":"r",
|
||||||
|
"setCharacterSet":"r",
|
||||||
|
"_getXML":"r"
|
||||||
|
},
|
||||||
|
|
||||||
"_initRDF":function() {
|
"_initRDF":function() {
|
||||||
Zotero.debug("Translate: Initializing RDF data store");
|
Zotero.debug("Translate: Initializing RDF data store");
|
||||||
|
@ -1488,9 +1504,21 @@ Zotero.Translate.IO._RDFSandbox = function(dataStore) {
|
||||||
|
|
||||||
Zotero.Translate.IO._RDFSandbox.prototype = {
|
Zotero.Translate.IO._RDFSandbox.prototype = {
|
||||||
"_containerCounts":[],
|
"_containerCounts":[],
|
||||||
"__exposedProps__":["addStatement", "newResource", "newContainer", "addContainerElement",
|
"__exposedProps__":{
|
||||||
"getContainerElements", "addNamespace", "getAllResources", "getResourceURI", "getArcsIn",
|
"addStatement":"r",
|
||||||
"getArcsOut", "getSources", "getTargets", "getStatementsMatching"],
|
"newResource":"r",
|
||||||
|
"newContainer":"r",
|
||||||
|
"addContainerElement":"r",
|
||||||
|
"getContainerElements":"r",
|
||||||
|
"addNamespace":"r",
|
||||||
|
"getAllResources":"r",
|
||||||
|
"getResourceURI":"r",
|
||||||
|
"getArcsIn":"r",
|
||||||
|
"getArcsOut":"r",
|
||||||
|
"getSources":"r",
|
||||||
|
"getTargets":"r",
|
||||||
|
"getStatementsMatching":"r"
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a resource as a Zotero.RDF.AJAW.RDFSymbol, rather than a string
|
* Gets a resource as a Zotero.RDF.AJAW.RDFSymbol, rather than a string
|
||||||
|
|
|
@ -906,10 +906,10 @@ Zotero.Utilities.Translate.prototype._convertURL = function(url) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Utilities.Translate.prototype.__exposedProps__ = [];
|
Zotero.Utilities.Translate.prototype.__exposedProps__ = {};
|
||||||
for(var j in Zotero.Utilities.Translate.prototype) {
|
for(var j in Zotero.Utilities.Translate.prototype) {
|
||||||
if(typeof Zotero.Utilities.Translate.prototype[j] === "function" && j[0] !== "_" && j != "Translate") {
|
if(typeof Zotero.Utilities.Translate.prototype[j] === "function" && j[0] !== "_" && j != "Translate") {
|
||||||
Zotero.Utilities.Translate.prototype.__exposedProps__.push(j);
|
Zotero.Utilities.Translate.prototype.__exposedProps__[j] = "r";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue