Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit ea7a007985362dd41ab2da027dec0422374eb422 @tomlokhorst committed Apr 15, 2011
@@ -0,0 +1,9 @@
+# Vim swap file
+*.swp
+
+# Visual studio files
+[Oo]bj
+[Bb]in
+*.user
+*.suo
+
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{d294906b-de5d-43cb-b88f-8799f2096730}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>Coffee</RootNamespace>
+ <AssemblyName>Coffee</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <Name>Coffee</Name>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>x86</PlatformTarget>
+ <DocumentationFile>bin\Debug\Coffee.XML</DocumentationFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <Tailcalls>true</Tailcalls>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>x86</PlatformTarget>
+ <DocumentationFile>bin\Release\Coffee.XML</DocumentationFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="mscorlib" />
+ <Reference Include="FSharp.Core" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Numerics" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.fs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\CoffeeSharp\CoffeeSharp.csproj">
+ <Name>CoffeeSharp</Name>
+ <Project>{b269febd-f9ce-4c90-b26c-c2c42f3be375}</Project>
+ <Private>True</Private>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
+ <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,6 @@
+open CoffeeSharp
+
+let cse = new CoffeeScriptEngine()
+
+let main =
+ cse.Eval "console.log 'Hello, World!'"
@@ -0,0 +1,42 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoffeeSharp", "CoffeeSharp\CoffeeSharp.csproj", "{B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Coffee", "Coffee\Coffee.fsproj", "{D294906B-DE5D-43CB-B88F-8799F2096730}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}.Release|x86.ActiveCfg = Release|Any CPU
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|x86.ActiveCfg = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Debug|x86.Build.0 = Debug|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|Any CPU.ActiveCfg = Release|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|Mixed Platforms.Build.0 = Release|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|x86.ActiveCfg = Release|x86
+ {D294906B-DE5D-43CB-B88F-8799F2096730}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,64 @@
+using Jurassic;
+using Jurassic.Library;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+
+namespace CoffeeSharp
+{
+ public class CoffeeScriptEngine
+ {
+ private ScriptEngine scriptEngine;
+
+ public CoffeeScriptEngine()
+ {
+ this.scriptEngine = new ScriptEngine();
+ scriptEngine.Execute(Resources.CoffeeScriptSource);
+ scriptEngine.Execute("coffeeScriptEval = CoffeeScript.eval;");
+ scriptEngine.Execute("coffeeScriptNodes = CoffeeScript.nodes;");
+ scriptEngine.Execute("coffeeScriptTokens = CoffeeScript.tokens;");
+ scriptEngine.Execute("coffeeScriptCompile = CoffeeScript.compile;");
+ }
+
+ public void Eval(string code, bool globals = false)
+ {
+ var options = new JsObject(scriptEngine);
+ options["globals"] = globals;
+
+ scriptEngine.SetGlobalValue("console", new Jurassic.Library.FirebugConsole(scriptEngine));
+ scriptEngine.CallGlobalFunction("coffeeScriptEval", code, options);
+ scriptEngine.Evaluate("delete console");
+ }
+
+ public string Nodes(string source)
+ {
+ return scriptEngine.CallGlobalFunction("coffeeScriptNodes", source).ToString();
+ }
+
+ public IEnumerable<Tuple<String, object>> Tokens(string code, bool rewrite = true)
+ {
+ var options = new JsObject(scriptEngine);
+ options["rewrite"] = rewrite;
+
+ var ts = (ArrayInstance)scriptEngine.CallGlobalFunction("coffeeScriptTokens", code, options);
+
+ foreach (var v in ts.ElementValues.Cast<ArrayInstance>())
+ yield return Tuple.Create((string)v[0], v[1]);
+ }
+
+ public string Compile(string code, bool bare = false)
+ {
+ var options = new JsObject(scriptEngine);
+ options["bare"] = bare;
+
+ return scriptEngine.CallGlobalFunction<string>("coffeeScriptCompile", code, options);
+ }
+
+ private class JsObject : ObjectInstance
+ {
+ public JsObject(ScriptEngine se) : base(se) { }
+ }
+ }
+}
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{B269FEBD-F9CE-4C90-B26C-C2C42F3BE375}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>CoffeeSharp</RootNamespace>
+ <AssemblyName>CoffeeSharp</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Jurassic">
+ <HintPath>..\Lib\Jurassic.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CoffeeScriptEngine.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CoffeeSharp")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CoffeeSharp")]
+[assembly: AssemblyCopyright("Copyright © 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("99d5bb9d-2d42-4c8b-b1ff-d8e2727226e1")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.1.0")]
+[assembly: AssemblyFileVersion("1.0.1.0")]

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit ea7a007

Please sign in to comment.