Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added coffee-script require in extensions

  • Loading branch information...
commit 475042bb4ef57024ccf0e32095c226116c97d70b 1 parent 4e692e6
Brandon Mason authored
View
19 lib/coffee-script/extensions.js
@@ -1,8 +1,8 @@
(function() {
- var CoffeeScript, appMacros, exists, findParent, join, m, names, normalize, projectRoot, readdirSync, root, rzrRootTest, _i, _len, _ref, _ref2,
+ var CoffeeScript, appMacros, exists, findParent, join, m, names, normalize, projectRoot, readdirSync, root, rzrRootTest, _ref,
__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
- CoffeeScript = require('./coffee-script');
+ CoffeeScript = require('./coffee-script').CoffeeScript;
readdirSync = require('fs').readdirSync;
@@ -34,11 +34,16 @@
appMacros = join(projectRoot(), "macros.coffee");
if (require.resolve(appMacros)) {
- _ref2 = exports.macros;
- for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
- m = _ref2[_i];
- names = m.name;
- }
+ names = (function() {
+ var _i, _len, _ref2, _results;
+ _ref2 = exports.macros;
+ _results = [];
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ m = _ref2[_i];
+ _results.push(m.name);
+ }
+ return _results;
+ })();
if (names != null) {
console.log("found these macros: " + names);
} else {
View
4 lib/coffee-script/lexer.js
@@ -604,7 +604,7 @@
if (macros != null) {
for (_i = 0, _len = macros.length; _i < _len; _i++) {
m = macros[_i];
- COFFEE_KEYWORDS.push(m['name']);
+ COFFEE_KEYWORDS.push(m.name);
}
}
@@ -698,7 +698,7 @@
if (macros != null) {
for (_j = 0, _len2 = macros.length; _j < _len2; _j++) {
m = macros[_j];
- CALLABLE.push(m['name'].toUpperCase);
+ CALLABLE.push(m.tokenName);
}
}
View
2  lib/coffee-script/rewriter.js
@@ -300,7 +300,7 @@
if (macros != null) {
for (_j = 0, _len2 = macros.length; _j < _len2; _j++) {
m = macros[_j];
- IMPLICIT_FUNC.push(m['tokenName']);
+ IMPLICIT_FUNC.push(m.tokenName);
}
}
View
28 src/extensions.coffee
@@ -1,7 +1,8 @@
-CoffeeScript = require './coffee-script'
+{CoffeeScript} = require './coffee-script'
{readdirSync} = require 'fs'
{exists, normalize, join} = require 'path'
+
# ============================================================
# Find root project directory
# ============================================================
@@ -31,31 +32,22 @@ appMacros = join projectRoot(), "macros.coffee" #/config
if require.resolve appMacros
#{macros} = require appMacros
- #exports.macros = macros
- #exports.macros = [
+ #exports.macros.push macros
+ #exports.macros.push [
#{
- #name: 'load'
- #className: 'Load'
- #tokenName: 'LOAD'
+ #name: 'foo'
+ #className: 'Foo'
+ #tokenName: 'FOO'
#classDef: ->
- #class Load extends this.Macro
+ #class Foo extends this.Macro
#compileNode: (o) ->
#code = @args[0].compile o
#path = support.getModulePath(domainRoot(), code)
#"require('#{ path }.js');"
#}
- #macro 'load', (o, args, projectRoot) ->
- #throw SyntaxError 'load takes one argument' unless @args.length == 1
- #{join} = require 'path'
-
- #code = eval args[0].compile(o)
- #domainRoot = join projectRoot, 'domain'
- ##path = getModulePath(domainRoot, code)
-
- #"require('#{ domainRoot }.js');"
- #]
+ #]...
- names = m.name for m in exports.macros
+ names = (m.name for m in exports.macros)
if names?
console.log "found these macros: #{names}"
else
View
4 src/lexer.coffee
@@ -550,7 +550,7 @@ JS_KEYWORDS = [
# CoffeeScript-only keywords.
COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when', 'macro']
if macros?
- COFFEE_KEYWORDS.push m['name'] for m in macros
+ COFFEE_KEYWORDS.push m.name for m in macros
COFFEE_ALIAS_MAP =
and : '&&'
@@ -690,7 +690,7 @@ NOT_SPACED_REGEX = NOT_REGEX.concat ')', '}', 'THIS', 'IDENTIFIER', 'STRING'
# of a function invocation or indexing operation.
CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER', 'MACRO']
if macros?
- CALLABLE.push m['name'].toUpperCase for m in macros
+ CALLABLE.push m.tokenName for m in macros
INDEXABLE = CALLABLE.concat 'NUMBER', 'BOOL'
View
2  src/rewriter.coffee
@@ -292,7 +292,7 @@ EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat EXPRESSION_END
# Tokens that, if followed by an `IMPLICIT_CALL`, indicate a function invocation.
IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS', 'MACRO']
if macros?
- IMPLICIT_FUNC.push m['tokenName'] for m in macros
+ IMPLICIT_FUNC.push m.tokenName for m in macros
# If preceded by an `IMPLICIT_FUNC`, indicates a function invocation.
IMPLICIT_CALL = [
Please sign in to comment.
Something went wrong with that request. Please try again.