Skip to content

Commit

Permalink
Fix for minimization in Cappuccino.
Browse files Browse the repository at this point in the history
[#9 state:resolved]

Reviewed by ross.
  • Loading branch information
Francisco Ryan Tolmasky I committed Nov 4, 2008
1 parent 54d48e9 commit 6cff27c
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 115 deletions.
16 changes: 3 additions & 13 deletions AppKit/AppKit.steam
Expand Up @@ -35,23 +35,13 @@
<key>Name</key>
<string>Debug</string>
<key>Flags</key>
<string>-DDEBUG</string>
<key>Settings</key>
<dict>
<key>PREPROCESS</key>
<true/>
</dict>
<string>-DDEBUG -g</string>
</dict>
<dict>
<key>Name</key>
<string>Release</string>
<key>Settings</key>
<dict>
<key>PREPROCESS</key>
<true/>
<key>PREINTERPRET</key>
<true/>
</dict>
<key>Flags</key>
<string>-O</string>
</dict>
</array>
</dict>
Expand Down
5 changes: 5 additions & 0 deletions AppKit/Platform/DOM/CPDOMWindowBridge.j
Expand Up @@ -35,6 +35,11 @@ CPSharedDOMWindowBridge = nil;

var ExcludedDOMElements = [];

// Define up here so compressor knows about em.
var CPDOMWindowGetFrame,
CPDOMEventGetClickCount,
CPDOMEventStop;

@implementation CPDOMWindowBridge : CPObject
{
CPArray _orderedWindows;
Expand Down
18 changes: 4 additions & 14 deletions Foundation/Foundation.steam
Expand Up @@ -16,24 +16,14 @@
<dict>
<key>Name</key>
<string>Debug</string>
<key>Settings</key>
<dict>
<key>PREPROCESS</key>
<true/>
<key>FLAGS</key>
<string>-DDEBUG</string>
</dict>
<key>Flags</key>
<string>-DDEBUG -g</string>
</dict>
<dict>
<key>Name</key>
<string>Release</string>
<key>Settings</key>
<dict>
<key>PREPROCESS</key>
<true/>
<key>PREINTERPRET</key>
<true/>
</dict>
<key>Flags</key>
<string>-O</string>
</dict>
</array>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Objective-J/evaluate.js
Expand Up @@ -202,7 +202,7 @@ function fragment_evaluate_file(aFragment)

// Grab the file's fragments if it has them, or preprocess it if not.
if (!aFile.fragments)
aFile.fragments = objj_preprocess(aFile.contents, aFile.bundle, aFile);
aFile.fragments = objj_preprocess(aFile.contents, aFile.bundle, aFile, OBJJ_PREPROCESSOR_DEBUG_SYMBOLS);

var fragments = aFile.fragments,
count = fragments.length,
Expand Down
18 changes: 12 additions & 6 deletions Objective-J/preprocess.js
Expand Up @@ -20,13 +20,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

function objj_preprocess(/*String*/ aString, /*objj_bundle*/ aBundle, /*objj_file*/ aSourceFile)
OBJJ_PREPROCESSOR_DEBUG_SYMBOLS = 1 << 0;

function objj_preprocess(/*String*/ aString, /*objj_bundle*/ aBundle, /*objj_file*/ aSourceFile, /*unsigned*/ flags)
{
try
{
OBJJ_CURRENT_BUNDLE = aBundle;

return new objj_preprocessor(aString, aSourceFile).fragments();
return new objj_preprocessor(aString, aSourceFile, flags).fragments();
}
catch (anException)
{
Expand Down Expand Up @@ -133,7 +135,7 @@ objj_stringBuffer.prototype.isEmpty = function()
return (this.atoms.length === 0);
}

var objj_preprocessor = function(aString, aSourceFile)
var objj_preprocessor = function(aString, aSourceFile, flags)
{
this._currentClass = "";
this._currentSuperClass = "";
Expand All @@ -142,6 +144,7 @@ var objj_preprocessor = function(aString, aSourceFile)
this._fragments = [];
this._preprocessed = new objj_stringBuffer();
this._tokens = new objj_lexer(aString);
this._flags = flags;

this.preprocess(this._tokens, this._preprocessed);
this.fragment();
Expand Down Expand Up @@ -736,8 +739,11 @@ objj_preprocessor.prototype.method = function(tokens)

CONCAT(buffer, "new objj_method(sel_getUid(\"");
CONCAT(buffer, selector);
CONCAT(buffer, "\"), function ");
CONCAT(buffer, "$" + this._currentClass + "__" + selector.replace(/:/g, "_"));
CONCAT(buffer, "\"), function");

if (this._flags & OBJJ_PREPROCESSOR_DEBUG_SYMBOLS)
CONCAT(buffer, " $" + this._currentClass + "__" + selector.replace(/:/g, "_"));

CONCAT(buffer, "(self, _cmd");

for(; index < count; ++index)
Expand Down Expand Up @@ -811,7 +817,7 @@ objj_preprocessor.prototype.preprocess = function(tokens, /*objj_stringBuffer*/

// Skip everything until the next open curly brace.
while((token = tokens.next()) && token != TOKEN_OPEN_BRACE)
CONCAT(bfufer, token);
CONCAT(buffer, token);

// Place the open curly brace as well, and the function name
CONCAT(buffer, token + "\n \"__FIREBUG_FNAME__" + functionName + "\".length;\n");
Expand Down
36 changes: 0 additions & 36 deletions Objective-J/static.js
Expand Up @@ -9,42 +9,6 @@ var STATIC_MAGIC_NUMBER = "@STATIC",

var STATIC_EXTENSION = "sj";

function objj_preprocess_file(aFilePath, fileContents, checkSyntax)
{
// Preprocess contents into fragments.
var fragments = objj_preprocess(fileContents, { path:"/x" }, { path:aFilePath}),
index = 0,
count = fragments.length,
preprocessed = MARKER_PATH + ';' + aFilePath.length() + ';' + aFilePath;

// Writer preprocessed fragments out.
for (; index < count; ++index)
{
var fragment = fragments[index];

if (IS_FILE(fragment))
preprocessed += (IS_LOCAL(fragment) ? MARKER_IMPORT_LOCAL : MARKER_IMPORT_STD) + ';' + GET_PATH(fragment).length + ';' + GET_PATH(fragment);
else
{
if (checkSyntax)
{
try
{
new Function(GET_CODE(fragment));
}
catch (e)
{
e.fragment = fragment;
throw e;
}
}
preprocessed += MARKER_CODE + ';' + GET_CODE(fragment).length + ';' + GET_CODE(fragment);
}
}

return preprocessed;
}

function objj_decompile(aString, bundle)
{
var stream = new objj_markedStream(aString);
Expand Down
2 changes: 2 additions & 0 deletions Tools/objjc/build.xml
Expand Up @@ -51,6 +51,8 @@

<copy file = "${Build.objjc}/objjc.class" tofile = "${Build.Cappuccino.Tools.Lib}/objjc.class" />

<copy file = "shrinksafe.jar" tofile = "${Build.Cappuccino.Tools.Lib}/shrinksafe.jar" />

</target>

</project>

0 comments on commit 6cff27c

Please sign in to comment.