From 87d724fc8a82b50c341b89318289d8c0ebc5292c Mon Sep 17 00:00:00 2001 From: Jens Ayton Date: Sat, 2 Aug 2008 19:19:01 +0000 Subject: [PATCH] Fix for bug in prefix script adding player compatibility aliases to all objects. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1716 127b21dd-08f5-0310-b4b7-95ae10353056 --- Oolite.xcodeproj/project.pbxproj | 12 +- Resources/Config/equipment.plist | 2 + Resources/Scripts/oolite-global-prefix.js | 220 +++++++++++----------- src/Cocoa/debug-exports-64.exp | 4 + src/Cocoa/debug-exports.exp | 5 + src/Core/Entities/PlayerEntity.m | 2 +- src/Core/OOFastArithmetic.m | 10 +- src/Core/Scripting/OOJSSpecialFunctions.m | 9 + src/Core/Scripting/OOJavaScriptEngine.m | 30 +++ 9 files changed, 174 insertions(+), 120 deletions(-) diff --git a/Oolite.xcodeproj/project.pbxproj b/Oolite.xcodeproj/project.pbxproj index 4bbfc4b6..7ceced0f 100644 --- a/Oolite.xcodeproj/project.pbxproj +++ b/Oolite.xcodeproj/project.pbxproj @@ -1030,7 +1030,7 @@ 083325DC09DDBCDE00F5B8E4 /* OOColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOColor.m; sourceTree = ""; }; 083DB4D30A70E51E00B419B2 /* OOBrain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOBrain.h; sourceTree = ""; }; 083DB4D40A70E51E00B419B2 /* OOBrain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOBrain.m; sourceTree = ""; }; - 0865432206B8447D000CA0AB /* Oolite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Oolite.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0865432206B8447D000CA0AB /* OoliteDev.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OoliteDev.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0878FD2F086EF845004CB752 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 1A020E0A0D020AFB00C3F51E /* changedScriptHandlers.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = changedScriptHandlers.plist; sourceTree = ""; }; @@ -1707,7 +1707,7 @@ 19C28FACFE9D520D11CA2CBB /* Products */ = { isa = PBXGroup; children = ( - 0865432206B8447D000CA0AB /* Oolite.app */, + 0865432206B8447D000CA0AB /* OoliteDev.app */, 1A71E6F30BCE340C00CD5C13 /* libpng.a */, ); name = Products; @@ -2943,7 +2943,7 @@ name = Oolite; productInstallPath = "$(HOME)/Applications"; productName = Oolite; - productReference = 0865432206B8447D000CA0AB /* Oolite.app */; + productReference = 0865432206B8447D000CA0AB /* OoliteDev.app */; productType = "com.apple.product-type.application"; }; 1A71E6F20BCE340C00CD5C13 /* libpng-custom */ = { @@ -3575,7 +3575,10 @@ MACOSX_DEPLOYMENT_TARGET = 10.3; MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; MACOSX_DEPLOYMENT_TARGET_ppc = 10.3; - OTHER_CFLAGS = "-DLOADSAVEGUI"; + OTHER_CFLAGS = ( + "-DLOADSAVEGUI", + "-fstack-protector-all", + ); SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; }; name = "Debug GCC 4.2/Leopard"; @@ -3638,7 +3641,6 @@ "MACOSX_DEPLOYMENT_TARGET[arch=ppc64]" = 10.5; "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5; OGGVORBISROOT = "$(SRCROOT)/deps/Cocoa-deps/Ogg\\ Vorbis"; - OTHER_CFLAGS = "-DLOADSAVEGUIXX"; OTHER_LDFLAGS = $OTHER_LINKER_FLAGS_32; "OTHER_LDFLAGS[arch=ppc64]" = $OTHER_LINKER_FLAGS_64; "OTHER_LDFLAGS[arch=x86_64]" = $OTHER_LINKER_FLAGS_64; diff --git a/Resources/Config/equipment.plist b/Resources/Config/equipment.plist index a62ccd12..6a894730 100644 --- a/Resources/Config/equipment.plist +++ b/Resources/Config/equipment.plist @@ -159,6 +159,8 @@ portable_between_ships + available_to_all + diff --git a/Resources/Scripts/oolite-global-prefix.js b/Resources/Scripts/oolite-global-prefix.js index 32b91207..342c57e4 100644 --- a/Resources/Scripts/oolite-global-prefix.js +++ b/Resources/Scripts/oolite-global-prefix.js @@ -129,41 +129,41 @@ this.defineCompatibilityWriteOnly = function (constructorName, oldName, funcName } // Define a compatibility getter for a property that's moved to another property. -// Example: to map player.docked to player.ship.docked, this.defineCompatibilitySubGetter("Player", "ship", "docked") -this.defineCompatibilitySubGetter = function (constructorName, subName, propName) +// Example: to map player.docked to player.ship.docked, this.defineCompatibilitySubGetter("player", "ship", "docked") +this.defineCompatibilitySubGetter = function (singletonName, subName, propName) { let getter = function () { - special.jsWarning(constructorName + "." + propName + " is deprecated, use " + constructorName + "." + subName + "." + propName + " instead."); + special.jsWarning(singletonName + "." + propName + " is deprecated, use " + singletonName + "." + subName + "." + propName + " instead."); return this[subName][propName]; } - global[constructorName].__proto__.__defineGetter__(propName, getter); + global[singletonName].__defineGetter__(propName, getter); } // Define a compatibility setter for a property that's moved to another property. -this.defineCompatibilitySubSetter = function (constructorName, subName, propName) +this.defineCompatibilitySubSetter = function (singletonName, subName, propName) { let setter = function (value) { - special.jsWarning(constructorName + "." + propName + " is deprecated, use " + constructorName + "." + subName + "." + propName + " instead."); + special.jsWarning(singletonName + "." + propName + " is deprecated, use " + singletonName + "." + subName + "." + propName + " instead."); this[subName][propName] = value; } - global[constructorName].__proto__.__defineSetter__(propName, setter); + global[singletonName].__defineSetter__(propName, setter); } // Define a compatibility getter and setter for a property that's moved to another property. -this.defineCompatibilitySubGetterAndSetter = function (constructorName, subName, propName) +this.defineCompatibilitySubGetterAndSetter = function (singletonName, subName, propName) { - this.defineCompatibilitySubGetter(constructorName, subName, propName); - this.defineCompatibilitySubSetter(constructorName, subName, propName); + this.defineCompatibilitySubGetter(singletonName, subName, propName); + this.defineCompatibilitySubSetter(singletonName, subName, propName); } // Like defineCompatibilitySubGetter() et al, for methods. -this.defineCompatibilitySubMethod = function (constructorName, subName, methodName) +this.defineCompatibilitySubMethod = function (singletonName, subName, methodName) { - global[constructorName][methodName] = function () + global[singletonName][methodName] = function () { - special.jsWarning(constructorName + "." + methodName + "() is deprecated, use " + constructorName + "." + subName + "." + methodName + "() instead."); + special.jsWarning(singletonName + "." + methodName + "() is deprecated, use " + singletonName + "." + subName + "." + methodName + "() instead."); let sub = this[subName]; return sub[methodName].apply(sub, arguments); } @@ -201,102 +201,102 @@ system.setSunNova = function(delay) this.defineCompatibilityGetter("Ship", "maxCargo", "cargoCapacity"); // Lots of Player properties, including inherited ones, moved to playerShip -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "fuelLeakRate"); -this.defineCompatibilitySubGetter("Player", "ship", "docked"); -this.defineCompatibilitySubGetter("Player", "ship", "dockedStation"); -this.defineCompatibilitySubGetter("Player", "ship", "specialCargo"); -this.defineCompatibilitySubGetter("Player", "ship", "galacticHyperspaceBehaviour"); -this.defineCompatibilitySubGetter("Player", "ship", "galacticHyperspaceFixedCoords"); -this.defineCompatibilitySubMethod("Player", "ship", "awardEquipment"); -this.defineCompatibilitySubMethod("Player", "ship", "removeEquipment"); -this.defineCompatibilitySubMethod("Player", "ship", "hasEquipment"); -this.defineCompatibilitySubMethod("Player", "ship", "equipmentStatus"); -this.defineCompatibilitySubMethod("Player", "ship", "setEquipmentStatus"); -this.defineCompatibilitySubMethod("Player", "ship", "launch"); -this.defineCompatibilitySubMethod("Player", "ship", "awardCargo"); -this.defineCompatibilitySubMethod("Player", "ship", "canAwardCargo"); -this.defineCompatibilitySubMethod("Player", "ship", "removeAllCargo"); -this.defineCompatibilitySubMethod("Player", "ship", "useSpecialCargo"); -this.defineCompatibilitySubMethod("Player", "ship", "setGalacticHyperspaceBehaviour"); -this.defineCompatibilitySubMethod("Player", "ship", "setGalacticHyperspaceFixedCoords"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "fuelLeakRate"); +this.defineCompatibilitySubGetter("player", "ship", "docked"); +this.defineCompatibilitySubGetter("player", "ship", "dockedStation"); +this.defineCompatibilitySubGetter("player", "ship", "specialCargo"); +this.defineCompatibilitySubGetter("player", "ship", "galacticHyperspaceBehaviour"); +this.defineCompatibilitySubGetter("player", "ship", "galacticHyperspaceFixedCoords"); +this.defineCompatibilitySubMethod("player", "ship", "awardEquipment"); +this.defineCompatibilitySubMethod("player", "ship", "removeEquipment"); +this.defineCompatibilitySubMethod("player", "ship", "hasEquipment"); +this.defineCompatibilitySubMethod("player", "ship", "equipmentStatus"); +this.defineCompatibilitySubMethod("player", "ship", "setEquipmentStatus"); +this.defineCompatibilitySubMethod("player", "ship", "launch"); +this.defineCompatibilitySubMethod("player", "ship", "awardCargo"); +this.defineCompatibilitySubMethod("player", "ship", "canAwardCargo"); +this.defineCompatibilitySubMethod("player", "ship", "removeAllCargo"); +this.defineCompatibilitySubMethod("player", "ship", "useSpecialCargo"); +this.defineCompatibilitySubMethod("player", "ship", "setGalacticHyperspaceBehaviour"); +this.defineCompatibilitySubMethod("player", "ship", "setGalacticHyperspaceFixedCoords"); -this.defineCompatibilitySubGetter("Player", "ship", "AI"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "AIState"); -this.defineCompatibilitySubGetter("Player", "ship", "beaconCode"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "bounty"); -this.defineCompatibilitySubGetter("Player", "ship", "entityPersonality"); -this.defineCompatibilitySubGetter("Player", "ship", "escorts"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "fuel"); -this.defineCompatibilitySubGetter("Player", "ship", "groupID"); -this.defineCompatibilitySubGetter("Player", "ship", "hasHostileTarget"); -this.defineCompatibilitySubGetter("Player", "ship", "hasSuspendedAI"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "heatInsulation"); -this.defineCompatibilitySubGetter("Player", "ship", "isBeacon"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "isCloaked"); -this.defineCompatibilitySubGetter("Player", "ship", "isFrangible"); -this.defineCompatibilitySubGetter("Player", "ship", "isJamming"); -this.defineCompatibilitySubGetter("Player", "ship", "isPirate"); -this.defineCompatibilitySubGetter("Player", "ship", "isPirateVictim"); -this.defineCompatibilitySubGetter("Player", "ship", "isPlayer"); -this.defineCompatibilitySubGetter("Player", "ship", "isPolice"); -this.defineCompatibilitySubGetter("Player", "ship", "isThargoid"); -this.defineCompatibilitySubGetter("Player", "ship", "isTrader"); -this.defineCompatibilitySubGetter("Player", "ship", "cargoSpaceUsed"); -this.defineCompatibilitySubGetter("Player", "ship", "cargoCapacity"); -this.defineCompatibilitySubGetter("Player", "ship", "availableCargoSpace"); -this.defineCompatibilitySubGetter("Player", "ship", "maxSpeed"); -this.defineCompatibilitySubGetter("Player", "ship", "potentialCollider"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "primaryRole"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "reportAIMessages"); -this.defineCompatibilitySubGetter("Player", "ship", "roleProbabilities"); -this.defineCompatibilitySubGetter("Player", "ship", "roles"); -this.defineCompatibilitySubGetter("Player", "ship", "scannerRange"); -this.defineCompatibilitySubGetter("Player", "ship", "scriptInfo"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "shipDescription"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "shipDisplayName"); -this.defineCompatibilitySubGetter("Player", "ship", "speed"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "desiredSpeed"); -this.defineCompatibilitySubGetter("Player", "ship", "subEntities"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "target"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "temperature"); -this.defineCompatibilitySubGetter("Player", "ship", "weaponRange"); -this.defineCompatibilitySubGetter("Player", "ship", "withinStationAegis"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "trackCloseContacts"); -this.defineCompatibilitySubGetter("Player", "ship", "passengerCount"); -this.defineCompatibilitySubGetter("Player", "ship", "passengerCapacity"); -this.defineCompatibilitySubMethod("Player", "ship", "setScript"); -this.defineCompatibilitySubMethod("Player", "ship", "setAI"); -this.defineCompatibilitySubMethod("Player", "ship", "switchAI"); -this.defineCompatibilitySubMethod("Player", "ship", "exitAI"); -this.defineCompatibilitySubMethod("Player", "ship", "reactToAIMessage"); -this.defineCompatibilitySubMethod("Player", "ship", "deployEscorts"); -this.defineCompatibilitySubMethod("Player", "ship", "dockEscorts"); -this.defineCompatibilitySubMethod("Player", "ship", "hasRole"); -this.defineCompatibilitySubMethod("Player", "ship", "ejectItem"); -this.defineCompatibilitySubMethod("Player", "ship", "ejectSpecificItem"); -this.defineCompatibilitySubMethod("Player", "ship", "dumpCargo"); -this.defineCompatibilitySubMethod("Player", "ship", "runLegacyScriptActions"); -this.defineCompatibilitySubMethod("Player", "ship", "spawn"); -this.defineCompatibilitySubMethod("Player", "ship", "explode"); +this.defineCompatibilitySubGetter("player", "ship", "AI"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "AIState"); +this.defineCompatibilitySubGetter("player", "ship", "beaconCode"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "bounty"); +this.defineCompatibilitySubGetter("player", "ship", "entityPersonality"); +this.defineCompatibilitySubGetter("player", "ship", "escorts"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "fuel"); +this.defineCompatibilitySubGetter("player", "ship", "groupID"); +this.defineCompatibilitySubGetter("player", "ship", "hasHostileTarget"); +this.defineCompatibilitySubGetter("player", "ship", "hasSuspendedAI"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "heatInsulation"); +this.defineCompatibilitySubGetter("player", "ship", "isBeacon"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "isCloaked"); +this.defineCompatibilitySubGetter("player", "ship", "isFrangible"); +this.defineCompatibilitySubGetter("player", "ship", "isJamming"); +this.defineCompatibilitySubGetter("player", "ship", "isPirate"); +this.defineCompatibilitySubGetter("player", "ship", "isPirateVictim"); +this.defineCompatibilitySubGetter("player", "ship", "isPlayer"); +this.defineCompatibilitySubGetter("player", "ship", "isPolice"); +this.defineCompatibilitySubGetter("player", "ship", "isThargoid"); +this.defineCompatibilitySubGetter("player", "ship", "isTrader"); +this.defineCompatibilitySubGetter("player", "ship", "cargoSpaceUsed"); +this.defineCompatibilitySubGetter("player", "ship", "cargoCapacity"); +this.defineCompatibilitySubGetter("player", "ship", "availableCargoSpace"); +this.defineCompatibilitySubGetter("player", "ship", "maxSpeed"); +this.defineCompatibilitySubGetter("player", "ship", "potentialCollider"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "primaryRole"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "reportAIMessages"); +this.defineCompatibilitySubGetter("player", "ship", "roleProbabilities"); +this.defineCompatibilitySubGetter("player", "ship", "roles"); +this.defineCompatibilitySubGetter("player", "ship", "scannerRange"); +this.defineCompatibilitySubGetter("player", "ship", "scriptInfo"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "shipDescription"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "shipDisplayName"); +this.defineCompatibilitySubGetter("player", "ship", "speed"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "desiredSpeed"); +this.defineCompatibilitySubGetter("player", "ship", "subEntities"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "target"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "temperature"); +this.defineCompatibilitySubGetter("player", "ship", "weaponRange"); +this.defineCompatibilitySubGetter("player", "ship", "withinStationAegis"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "trackCloseContacts"); +this.defineCompatibilitySubGetter("player", "ship", "passengerCount"); +this.defineCompatibilitySubGetter("player", "ship", "passengerCapacity"); +this.defineCompatibilitySubMethod("player", "ship", "setScript"); +this.defineCompatibilitySubMethod("player", "ship", "setAI"); +this.defineCompatibilitySubMethod("player", "ship", "switchAI"); +this.defineCompatibilitySubMethod("player", "ship", "exitAI"); +this.defineCompatibilitySubMethod("player", "ship", "reactToAIMessage"); +this.defineCompatibilitySubMethod("player", "ship", "deployEscorts"); +this.defineCompatibilitySubMethod("player", "ship", "dockEscorts"); +this.defineCompatibilitySubMethod("player", "ship", "hasRole"); +this.defineCompatibilitySubMethod("player", "ship", "ejectItem"); +this.defineCompatibilitySubMethod("player", "ship", "ejectSpecificItem"); +this.defineCompatibilitySubMethod("player", "ship", "dumpCargo"); +this.defineCompatibilitySubMethod("player", "ship", "runLegacyScriptActions"); +this.defineCompatibilitySubMethod("player", "ship", "spawn"); +this.defineCompatibilitySubMethod("player", "ship", "explode"); -this.defineCompatibilitySubGetter("Player", "ship", "ID"); -this.defineCompatibilitySubGetter("Player", "ship", "position"); -this.defineCompatibilitySubGetter("Player", "ship", "orientation"); -this.defineCompatibilitySubGetter("Player", "ship", "heading"); -this.defineCompatibilitySubGetter("Player", "ship", "status"); -this.defineCompatibilitySubGetter("Player", "ship", "scanClass"); -this.defineCompatibilitySubGetter("Player", "ship", "mass"); -this.defineCompatibilitySubGetter("Player", "ship", "owner"); -this.defineCompatibilitySubGetterAndSetter("Player", "ship", "energy"); -this.defineCompatibilitySubGetter("Player", "ship", "maxEnergy"); -this.defineCompatibilitySubGetter("Player", "ship", "isValid"); -this.defineCompatibilitySubGetter("Player", "ship", "isShip"); -this.defineCompatibilitySubGetter("Player", "ship", "isStation"); -this.defineCompatibilitySubGetter("Player", "ship", "isSubEntity"); -this.defineCompatibilitySubGetter("Player", "ship", "isPlayer"); -this.defineCompatibilitySubGetter("Player", "ship", "isPlanet"); -this.defineCompatibilitySubGetter("Player", "ship", "isSun"); -this.defineCompatibilitySubGetter("Player", "ship", "distanceTravelled"); -this.defineCompatibilitySubGetter("Player", "ship", "spawnTime"); -this.defineCompatibilitySubMethod("Player", "ship", "setPosition"); -this.defineCompatibilitySubMethod("Player", "ship", "setOrientation"); +this.defineCompatibilitySubGetter("player", "ship", "ID"); +this.defineCompatibilitySubGetter("player", "ship", "position"); +this.defineCompatibilitySubGetter("player", "ship", "orientation"); +this.defineCompatibilitySubGetter("player", "ship", "heading"); +this.defineCompatibilitySubGetter("player", "ship", "status"); +this.defineCompatibilitySubGetter("player", "ship", "scanClass"); +this.defineCompatibilitySubGetter("player", "ship", "mass"); +this.defineCompatibilitySubGetter("player", "ship", "owner"); +this.defineCompatibilitySubGetterAndSetter("player", "ship", "energy"); +this.defineCompatibilitySubGetter("player", "ship", "maxEnergy"); +this.defineCompatibilitySubGetter("player", "ship", "isValid"); +this.defineCompatibilitySubGetter("player", "ship", "isShip"); +this.defineCompatibilitySubGetter("player", "ship", "isStation"); +this.defineCompatibilitySubGetter("player", "ship", "isSubEntity"); +this.defineCompatibilitySubGetter("player", "ship", "isPlayer"); +this.defineCompatibilitySubGetter("player", "ship", "isPlanet"); +this.defineCompatibilitySubGetter("player", "ship", "isSun"); +this.defineCompatibilitySubGetter("player", "ship", "distanceTravelled"); +this.defineCompatibilitySubGetter("player", "ship", "spawnTime"); +this.defineCompatibilitySubMethod("player", "ship", "setPosition"); +this.defineCompatibilitySubMethod("player", "ship", "setOrientation"); diff --git a/src/Cocoa/debug-exports-64.exp b/src/Cocoa/debug-exports-64.exp index 98ab4264..75aa9859 100644 --- a/src/Cocoa/debug-exports-64.exp +++ b/src/Cocoa/debug-exports-64.exp @@ -62,3 +62,7 @@ _QuaternionDescription _VectorDescription _BehaviourToString +# Debug value formatter support +_JSValueToStrDbg +_JSObjectToStrDbg +_JSValueTypeDbg diff --git a/src/Cocoa/debug-exports.exp b/src/Cocoa/debug-exports.exp index 03a60fe0..bfef6470 100644 --- a/src/Cocoa/debug-exports.exp +++ b/src/Cocoa/debug-exports.exp @@ -76,3 +76,8 @@ _do_seqnos_mach_notify_dead_name _do_seqnos_mach_notify_no_senders _do_seqnos_mach_notify_port_deleted _do_seqnos_mach_notify_send_once + +# Debug value formatter support +_JSValueToStrDbg +_JSObjectToStrDbg +_JSValueTypeDbg diff --git a/src/Core/Entities/PlayerEntity.m b/src/Core/Entities/PlayerEntity.m index b4b9f845..29503b54 100644 --- a/src/Core/Entities/PlayerEntity.m +++ b/src/Core/Entities/PlayerEntity.m @@ -4715,7 +4715,7 @@ static int last_outfitting_index; if (min_techlevel == 99) { // check mission variables for the existence of a revised tech level (given when item is awarded) - NSString* mission_eq_tl_key = [NSString stringWithFormat:@"mission_TL_FOR_%@", eq_key]; + NSString* mission_eq_tl_key = [@"mission_TL_FOR_" stringByAppendingString:eq_key]; min_techlevel = [mission_variables unsignedIntForKey:mission_eq_tl_key defaultValue:min_techlevel]; } diff --git a/src/Core/OOFastArithmetic.m b/src/Core/OOFastArithmetic.m index aa1c4b99..afd815af 100644 --- a/src/Core/OOFastArithmetic.m +++ b/src/Core/OOFastArithmetic.m @@ -71,12 +71,12 @@ asm float OOInvSqrtf(float x) frsqrte f1,f1 /* get recip sqrt estimate (does no harm if input is NaN */ beq cr1, not_a_number /* branch if original value was not a number */ fmul f2,f2,f9 /* begin Goldschmidt */ - fmuls f3,f1,f1 /* saves one clock without effecting accuracy */ + fmuls f3,f1,f1 /* single-precision saves one clock without affecting accuracy */ fmul f4,f2,f3 - fnmsubs f3,f2,f3,f7 /* saves one clock without effecting accuracy */ + fnmsubs f3,f2,f3,f7 /* single-precision saves one clock without affecting accuracy */ fmul f5,f3,f3 fmul f1,f3,f1 - fnmsubs f3,f4,f5,f7 /* saves one clock without effecting accuracy */ + fnmsubs f3,f4,f5,f7 /* single-precision saves one clock without affecting accuracy */ fmul f4,f4,f5 fmul f1,f3,f1 fmul f5,f3,f3 @@ -93,6 +93,7 @@ neg_number_or_zero: lis r6, 0x8000 /* negative */ lfs f2,8(r1) /* load 1.0F into fpu reg 2 */ beq its_zero /* branch if zero */ + /* This bit sets FPU status bits for negative number case, and isn't strictly needed for Oolite. */ cmpl 0,r5,r6 /* test for negative zero */ beq its_zero /* branch if zero */ @@ -107,7 +108,8 @@ neg_number_or_zero: lfs f6,0(r1) /* load new fpu status */ lfs f1,4(r1) /* load aNaN to be returned */ mtfsf 0xff,f6 /* update fpu status to new value */ - its_zero: + +its_zero: fmuls f1,f1,f2 /* multiply by 1.0 to set appropriate status bits */ addi r1,r1,12 /* clean up stack */ blr /* return */ diff --git a/src/Core/Scripting/OOJSSpecialFunctions.m b/src/Core/Scripting/OOJSSpecialFunctions.m index d4ecc1ac..4778c62e 100644 --- a/src/Core/Scripting/OOJSSpecialFunctions.m +++ b/src/Core/Scripting/OOJSSpecialFunctions.m @@ -29,12 +29,14 @@ MA 02110-1301, USA. static JSObject *sSpecialFunctionsObject; +static JSBool SpecialToString(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult); static JSBool SpecialJsWarning(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult); static JSFunctionSpec sSpecialFunctionsMethods[] = { // JS name Function min args + { "toString", SpecialToString, 0 }, { "jsWarning", SpecialJsWarning, 1 }, { 0 } }; @@ -61,6 +63,13 @@ OOJSValue *JSSpecialFunctionsObjectWrapper(JSContext *context) } +static JSBool SpecialToString(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) +{ + *outResult = STRING_TO_JSVAL(JS_NewStringCopyZ(context, "[object OoliteSpecialFunctions]")); + return YES; +} + + static JSBool SpecialJsWarning(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { OOSetJSWarningOrErrorStackSkip(1); diff --git a/src/Core/Scripting/OOJavaScriptEngine.m b/src/Core/Scripting/OOJavaScriptEngine.m index a4a45850..3cf864b0 100644 --- a/src/Core/Scripting/OOJavaScriptEngine.m +++ b/src/Core/Scripting/OOJavaScriptEngine.m @@ -1076,6 +1076,36 @@ static BOOL JSNewNSDictionaryValue(JSContext *context, NSDictionary *dictionary, @end +#ifndef NDEBUG + +// For use in debugger +const char *JSValueToStrDbg(jsval val) +{ + return [JSValToNSString(NULL, val) UTF8String]; +} + + +const char *JSObjectToStrDbg(JSObject *obj) +{ + return [JSValToNSString(NULL, OBJECT_TO_JSVAL(obj)) UTF8String]; +} + + +const char *JSValueTypeDbg(jsval val) +{ + if (JSVAL_IS_INT(val)) return "integer"; + if (JSVAL_IS_DOUBLE(val)) return "double"; + if (JSVAL_IS_STRING(val)) return "string"; + if (JSVAL_IS_BOOLEAN(val)) return "boolean"; + if (JSVAL_IS_NULL(val)) return "null"; + if (JSVAL_IS_VOID(val)) return "void"; + if (JSVAL_IS_OBJECT(val)) return JS_GetClass(JSVAL_TO_OBJECT(val))->name; + return "unknown"; +} + +#endif + + @implementation NSArray (OOJavaScriptConversion) - (jsval)javaScriptValueInContext:(JSContext *)context