├── .gitignore ├── LICENSE ├── README.md └── src ├── win10 ├── edge │ ├── cpp │ │ ├── ChakraHost.cpp │ │ ├── ChakraHost.sln │ │ ├── ChakraHost.vcxproj │ │ ├── ChakraHost.vcxproj.filters │ │ ├── Profiler.cpp │ │ ├── Profiler.h │ │ ├── stdafx.cpp │ │ └── stdafx.h │ ├── cs │ │ ├── ChakraHost.csproj │ │ ├── ChakraHost.sln │ │ ├── Hosting │ │ │ ├── JavaScriptBackgroundWorkItemCallback.cs │ │ │ ├── JavaScriptBeforeCollectCallback.cs │ │ │ ├── JavaScriptContext.cs │ │ │ ├── JavaScriptEngineException.cs │ │ │ ├── JavaScriptErrorCode.cs │ │ │ ├── JavaScriptException.cs │ │ │ ├── JavaScriptFatalException.cs │ │ │ ├── JavaScriptMemoryAllocationCallback.cs │ │ │ ├── JavaScriptMemoryEventType.cs │ │ │ ├── JavaScriptNativeFunction.cs │ │ │ ├── JavaScriptObjectFinalizeCallback.cs │ │ │ ├── JavaScriptPropertyId.cs │ │ │ ├── JavaScriptRuntime.cs │ │ │ ├── JavaScriptRuntimeAttributes.cs │ │ │ ├── JavaScriptScriptException.cs │ │ │ ├── JavaScriptSourceContext.cs │ │ │ ├── JavaScriptThreadServiceCallback.cs │ │ │ ├── JavaScriptUsageException.cs │ │ │ ├── JavaScriptValue.cs │ │ │ ├── JavaScriptValueType.cs │ │ │ └── Native.cs │ │ ├── Profiler.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── app.config │ ├── memory │ │ ├── ChakraMemoryProfile.cpp │ │ ├── ChakraMemoryProfile.sln │ │ ├── ChakraMemoryProfile.vcxproj │ │ ├── ChakraMemoryProfile.vcxproj.filters │ │ ├── stdafx.cpp │ │ └── stdafx.h │ └── vb │ │ ├── ChakraHost.sln │ │ ├── ChakraHost.vbproj │ │ ├── Hosting │ │ ├── JavaScriptBackgroundWorkItemCallback.vb │ │ ├── JavaScriptBeforeCollectCallback.vb │ │ ├── JavaScriptContext.vb │ │ ├── JavaScriptEngineException.vb │ │ ├── JavaScriptErrorCode.vb │ │ ├── JavaScriptException.vb │ │ ├── JavaScriptFatalException.vb │ │ ├── JavaScriptMemoryAllocationCallback.vb │ │ ├── JavaScriptMemoryEventType.vb │ │ ├── JavaScriptNativeFunction.vb │ │ ├── JavaScriptObjectFinalizeCallback.vb │ │ ├── JavaScriptPropertyId.vb │ │ ├── JavaScriptRuntime.vb │ │ ├── JavaScriptRuntimeAttributes.vb │ │ ├── JavaScriptScriptException.vb │ │ ├── JavaScriptSourceContext.vb │ │ ├── JavaScriptThreadServiceCallback.vb │ │ ├── JavaScriptUsageException.vb │ │ ├── JavaScriptValue.vb │ │ ├── JavaScriptValueType.vb │ │ └── Native.vb │ │ ├── My Project │ │ └── AssemblyInfo.vb │ │ ├── Profiler.vb │ │ ├── Program.vb │ │ └── app.config └── ie │ ├── cpp │ ├── ChakraHost.cpp │ ├── ChakraHost.sln │ ├── ChakraHost.vcxproj │ ├── ChakraHost.vcxproj.filters │ ├── Profiler.cpp │ ├── Profiler.h │ ├── stdafx.cpp │ └── stdafx.h │ ├── cs │ ├── ChakraHost.csproj │ ├── ChakraHost.sln │ ├── Hosting │ │ ├── JavaScriptBackgroundWorkItemCallback.cs │ │ ├── JavaScriptBeforeCollectCallback.cs │ │ ├── JavaScriptContext.cs │ │ ├── JavaScriptEngineException.cs │ │ ├── JavaScriptErrorCode.cs │ │ ├── JavaScriptException.cs │ │ ├── JavaScriptFatalException.cs │ │ ├── JavaScriptMemoryAllocationCallback.cs │ │ ├── JavaScriptMemoryEventType.cs │ │ ├── JavaScriptNativeFunction.cs │ │ ├── JavaScriptObjectFinalizeCallback.cs │ │ ├── JavaScriptPropertyId.cs │ │ ├── JavaScriptRuntime.cs │ │ ├── JavaScriptRuntimeAttributes.cs │ │ ├── JavaScriptRuntimeVersion.cs │ │ ├── JavaScriptScriptException.cs │ │ ├── JavaScriptSourceContext.cs │ │ ├── JavaScriptThreadServiceCallback.cs │ │ ├── JavaScriptUsageException.cs │ │ ├── JavaScriptValue.cs │ │ ├── JavaScriptValueType.cs │ │ └── Native.cs │ ├── Profiler.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── app.config │ ├── memory │ ├── ChakraMemoryProfile.cpp │ ├── ChakraMemoryProfile.sln │ ├── ChakraMemoryProfile.vcxproj │ ├── ChakraMemoryProfile.vcxproj.filters │ ├── stdafx.cpp │ └── stdafx.h │ └── vb │ ├── ChakraHost.sln │ ├── ChakraHost.vbproj │ ├── Hosting │ ├── JavaScriptBackgroundWorkItemCallback.vb │ ├── JavaScriptBeforeCollectCallback.vb │ ├── JavaScriptContext.vb │ ├── JavaScriptEngineException.vb │ ├── JavaScriptErrorCode.vb │ ├── JavaScriptException.vb │ ├── JavaScriptFatalException.vb │ ├── JavaScriptMemoryAllocationCallback.vb │ ├── JavaScriptMemoryEventType.vb │ ├── JavaScriptNativeFunction.vb │ ├── JavaScriptObjectFinalizeCallback.vb │ ├── JavaScriptPropertyId.vb │ ├── JavaScriptRuntime.vb │ ├── JavaScriptRuntimeAttributes.vb │ ├── JavaScriptRuntimeVersion.vb │ ├── JavaScriptScriptException.vb │ ├── JavaScriptSourceContext.vb │ ├── JavaScriptThreadServiceCallback.vb │ ├── JavaScriptUsageException.vb │ ├── JavaScriptValue.vb │ ├── JavaScriptValueType.vb │ └── Native.vb │ ├── My Project │ └── AssemblyInfo.vb │ ├── Profiler.vb │ ├── Program.vb │ └── app.config └── win8.1 ├── cpp ├── ChakraHost.cpp ├── ChakraHost.sln ├── ChakraHost.vcxproj ├── ChakraHost.vcxproj.filters ├── Profiler.cpp ├── Profiler.h ├── stdafx.cpp └── stdafx.h ├── cs ├── ChakraHost.csproj ├── ChakraHost.sln ├── Hosting │ ├── JavaScriptBackgroundWorkItemCallback.cs │ ├── JavaScriptBeforeCollectCallback.cs │ ├── JavaScriptContext.cs │ ├── JavaScriptEngineException.cs │ ├── JavaScriptErrorCode.cs │ ├── JavaScriptException.cs │ ├── JavaScriptFatalException.cs │ ├── JavaScriptMemoryAllocationCallback.cs │ ├── JavaScriptMemoryEventType.cs │ ├── JavaScriptNativeFunction.cs │ ├── JavaScriptObjectFinalizeCallback.cs │ ├── JavaScriptPropertyId.cs │ ├── JavaScriptRuntime.cs │ ├── JavaScriptRuntimeAttributes.cs │ ├── JavaScriptRuntimeVersion.cs │ ├── JavaScriptScriptException.cs │ ├── JavaScriptSourceContext.cs │ ├── JavaScriptThreadServiceCallback.cs │ ├── JavaScriptUsageException.cs │ ├── JavaScriptValue.cs │ ├── JavaScriptValueType.cs │ └── Native.cs ├── Profiler.cs ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── memory ├── ChakraMemoryProfile.cpp ├── ChakraMemoryProfile.sln ├── ChakraMemoryProfile.vcxproj ├── ChakraMemoryProfile.vcxproj.filters ├── stdafx.cpp └── stdafx.h └── vb ├── ChakraHost.sln ├── ChakraHost.vbproj ├── Hosting ├── JavaScriptBackgroundWorkItemCallback.vb ├── JavaScriptBeforeCollectCallback.vb ├── JavaScriptContext.vb ├── JavaScriptEngineException.vb ├── JavaScriptErrorCode.vb ├── JavaScriptException.vb ├── JavaScriptFatalException.vb ├── JavaScriptMemoryAllocationCallback.vb ├── JavaScriptMemoryEventType.vb ├── JavaScriptNativeFunction.vb ├── JavaScriptObjectFinalizeCallback.vb ├── JavaScriptPropertyId.vb ├── JavaScriptRuntime.vb ├── JavaScriptRuntimeAttributes.vb ├── JavaScriptRuntimeVersion.vb ├── JavaScriptScriptException.vb ├── JavaScriptSourceContext.vb ├── JavaScriptThreadServiceCallback.vb ├── JavaScriptUsageException.vb ├── JavaScriptValue.vb ├── JavaScriptValueType.vb └── Native.vb ├── My Project └── AssemblyInfo.vb ├── Profiler.vb └── Program.vb /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore build products 2 | 3 | *.sdf 4 | *.suo 5 | *.user 6 | *.opensdf 7 | /src/win8.1/cpp/Debug 8 | /src/win8.1/cpp/Release 9 | /src/win8.1/cpp/ipch 10 | /src/win8.1/cs/bin 11 | /src/win8.1/cs/obj 12 | /src/win8.1/vb/bin 13 | /src/win8.1/vb/obj 14 | /src/win8.1/memory/ipch 15 | /src/win8.1/memory/Debug 16 | /src/win8.1/memory/Release 17 | /src/win10/ie/cpp/Debug 18 | /src/win10/ie/cpp/Release 19 | /src/win10/ie/cpp/ipch 20 | /src/win10/ie/cs/bin 21 | /src/win10/ie/cs/obj 22 | /src/win10/ie/vb/bin 23 | /src/win10/ie/vb/obj 24 | /src/win10/ie/memory/ipch 25 | /src/win10/ie/memory/Debug 26 | /src/win10/ie/memory/Release 27 | /src/win10/edge/cpp/Debug 28 | /src/win10/edge/cpp/Release 29 | /src/win10/edge/cpp/ipch 30 | /src/win10/edge/cs/bin 31 | /src/win10/edge/cs/obj 32 | /src/win10/edge/vb/bin 33 | /src/win10/edge/vb/obj 34 | /src/win10/edge/memory/ipch 35 | /src/win10/edge/memory/Debug 36 | /src/win10/edge/memory/Release 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Chakra Sample Hosts 2 | =========== 3 | 4 | This project contains sample hosts for the Chakra JavaScript engine in C++, C#, and VB. 5 | -------------------------------------------------------------------------------- /src/win10/edge/cpp/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20827.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChakraHost", "ChakraHost.vcxproj", "{CC586644-5E57-4523-9DEA-E82F4FE9F91D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Debug|Win32.Build.0 = Debug|Win32 16 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Release|Win32.ActiveCfg = Release|Win32 17 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win10/edge/cpp/ChakraHost.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/win10/edge/cpp/Profiler.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | Profiler::Profiler(void) 10 | { 11 | m_refCount = 1; 12 | } 13 | 14 | Profiler::~Profiler(void) 15 | { 16 | } 17 | 18 | HRESULT Profiler::QueryInterface(REFIID riid, void **ppvObj) 19 | { 20 | if (riid == IID_IUnknown) 21 | { 22 | *ppvObj = (IUnknown *) this; 23 | } 24 | else if (riid == IID_IActiveScriptProfilerCallback) 25 | { 26 | *ppvObj = (IActiveScriptProfilerCallback *) this; 27 | } 28 | else if (riid == IID_IActiveScriptProfilerCallback2) 29 | { 30 | *ppvObj = (IActiveScriptProfilerCallback2 *) this; 31 | } 32 | else 33 | { 34 | *ppvObj = NULL; 35 | return E_NOINTERFACE; 36 | } 37 | 38 | AddRef(); 39 | return NOERROR; 40 | } 41 | 42 | ULONG Profiler::AddRef() 43 | { 44 | return InterlockedIncrement(&m_refCount); 45 | } 46 | 47 | ULONG Profiler::Release() 48 | { 49 | long lw; 50 | 51 | if (0 == (lw = InterlockedDecrement(&m_refCount))) 52 | { 53 | delete this; 54 | } 55 | return lw; 56 | } 57 | 58 | HRESULT Profiler::Initialize(DWORD dwContext) 59 | { 60 | fwprintf(stdout, L"Profiler::Initialize: 0x%lx\n", dwContext); 61 | return S_OK; 62 | } 63 | 64 | HRESULT Profiler::Shutdown(HRESULT hrReason) 65 | { 66 | fwprintf(stdout, L"Profiler::Shutdown: 0x%lx\n", hrReason); 67 | return S_OK; 68 | } 69 | 70 | HRESULT Profiler::ScriptCompiled(PROFILER_TOKEN scriptId, PROFILER_SCRIPT_TYPE type, IUnknown *pIDebugDocumentContext) 71 | { 72 | fwprintf(stdout, L"Profiler::ScriptCompiled: 0x%lx, %u\n", scriptId, type); 73 | return S_OK; 74 | } 75 | 76 | HRESULT Profiler::FunctionCompiled(PROFILER_TOKEN functionId, PROFILER_TOKEN scriptId, const wchar_t *pwszFunctionName, const wchar_t *pwszFunctionNameHint, IUnknown *pIDebugDocumentContext) 77 | { 78 | fwprintf(stdout, L"Profiler::FunctionCompiled: 0x%lx, 0x%lx, %s, %s\n", scriptId, functionId, pwszFunctionName, pwszFunctionNameHint); 79 | return S_OK; 80 | } 81 | 82 | HRESULT Profiler::OnFunctionEnter(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId) 83 | { 84 | fwprintf(stdout, L"Profiler::OnFunctionEnter: 0x%lx, 0x%lx\n", scriptId, functionId); 85 | return S_OK; 86 | } 87 | 88 | HRESULT Profiler::OnFunctionExit(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId) 89 | { 90 | fwprintf(stdout, L"Profiler::OnFunctionExit: 0x%lx, 0x%lx\n", scriptId, functionId); 91 | return S_OK; 92 | } 93 | 94 | HRESULT Profiler::OnFunctionEnterByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type) 95 | { 96 | fwprintf(stdout, L"Profiler::OnFunctionEnterByName: %s, %u\n", pwszFunctionName, type); 97 | return S_OK; 98 | } 99 | 100 | HRESULT Profiler::OnFunctionExitByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type) 101 | { 102 | fwprintf(stdout, L"Profiler::OnFunctionExitByName: %s, %u\n", pwszFunctionName, type); 103 | return S_OK; 104 | } 105 | -------------------------------------------------------------------------------- /src/win10/edge/cpp/Profiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Profiler sealed : public IActiveScriptProfilerCallback2 4 | { 5 | private: 6 | long m_refCount; 7 | 8 | public: 9 | Profiler(void); 10 | ~Profiler(void); 11 | 12 | // IUnknown 13 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObj); 14 | ULONG STDMETHODCALLTYPE AddRef(void); 15 | ULONG STDMETHODCALLTYPE Release(void); 16 | 17 | // IActiveScriptProfilerCallback 18 | HRESULT STDMETHODCALLTYPE Initialize(DWORD dwContext); 19 | HRESULT STDMETHODCALLTYPE Shutdown(HRESULT hrReason); 20 | HRESULT STDMETHODCALLTYPE ScriptCompiled(PROFILER_TOKEN scriptId, PROFILER_SCRIPT_TYPE type, IUnknown *pIDebugDocumentContext); 21 | HRESULT STDMETHODCALLTYPE FunctionCompiled(PROFILER_TOKEN functionId, PROFILER_TOKEN scriptId, const wchar_t *pwszFunctionName, const wchar_t *pwszFunctionNameHint, IUnknown *pIDebugDocumentContext); 22 | HRESULT STDMETHODCALLTYPE OnFunctionEnter(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId); 23 | HRESULT STDMETHODCALLTYPE OnFunctionExit(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId); 24 | 25 | // IActiveScriptProfilerCallback2 26 | HRESULT STDMETHODCALLTYPE OnFunctionEnterByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type); 27 | HRESULT STDMETHODCALLTYPE OnFunctionExitByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type); 28 | }; 29 | -------------------------------------------------------------------------------- /src/win10/edge/cpp/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /src/win10/edge/cpp/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Profiler.h" 7 | 8 | #define IfFailError(v, e) \ 9 | { \ 10 | JsErrorCode error = (v); \ 11 | if (error != JsNoError) \ 12 | { \ 13 | fwprintf(stderr, L"chakrahost: fatal error: %s.\n", (e)); \ 14 | goto error; \ 15 | } \ 16 | } 17 | 18 | #define IfFailRet(v) \ 19 | { \ 20 | JsErrorCode error = (v); \ 21 | if (error != JsNoError) \ 22 | { \ 23 | return error; \ 24 | } \ 25 | } 26 | 27 | #define IfFailThrow(v, e) \ 28 | { \ 29 | JsErrorCode error = (v); \ 30 | if (error != JsNoError) \ 31 | { \ 32 | ThrowException((e)); \ 33 | return JS_INVALID_REFERENCE; \ 34 | } \ 35 | } 36 | 37 | #define IfComFailError(v) \ 38 | { \ 39 | hr = (v); \ 40 | if (FAILED(hr)) \ 41 | { \ 42 | goto error; \ 43 | } \ 44 | } 45 | 46 | #define IfComFailRet(v) \ 47 | { \ 48 | HRESULT hr = (v); \ 49 | if (FAILED(hr)) \ 50 | { \ 51 | return hr; \ 52 | } \ 53 | } 54 | -------------------------------------------------------------------------------- /src/win10/edge/cs/ChakraHost.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D672BC49-C454-4975-BD25-A555B9BDD793} 8 | Exe 9 | Properties 10 | ChakraHost 11 | ChakraHost 12 | v4.6 13 | 512 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 77 | -------------------------------------------------------------------------------- /src/win10/edge/cs/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChakraHost", "ChakraHost.csproj", "{D672BC49-C454-4975-BD25-A555B9BDD793}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptBackgroundWorkItemCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A background work item callback. 7 | /// 8 | /// 9 | /// This is passed to the host's thread service (if provided) to allow the host to 10 | /// invoke the work item callback on the background thread of its choice. 11 | /// 12 | /// Data argument passed to the thread service. 13 | public delegate void JavaScriptBackgroundWorkItemCallback(IntPtr callbackData); 14 | } 15 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptBeforeCollectCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A callback called before collection. 7 | /// 8 | /// The state passed to SetBeforeCollectCallback. 9 | public delegate void JavaScriptBeforeCollectCallback(IntPtr callbackState); 10 | } 11 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptEngineException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An exception that occurred in the workings of the JavaScript engine itself. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptEngineException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptEngineException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptEngineException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptEngineException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An exception returned from the Chakra engine. 8 | /// 9 | [Serializable] 10 | public class JavaScriptException : Exception 11 | { 12 | /// 13 | /// The error code. 14 | /// 15 | private readonly JavaScriptErrorCode code; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The error code returned. 21 | public JavaScriptException(JavaScriptErrorCode code) : 22 | this(code, "A fatal exception has occurred in a JavaScript runtime") 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The error code returned. 30 | /// The error message. 31 | public JavaScriptException(JavaScriptErrorCode code, string message) : 32 | base(message) 33 | { 34 | this.code = code; 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The serialization info. 41 | /// The streaming context. 42 | protected JavaScriptException(SerializationInfo info, StreamingContext context) : 43 | base(info, context) 44 | { 45 | if (info != null) 46 | { 47 | code = (JavaScriptErrorCode) info.GetUInt32("code"); 48 | } 49 | } 50 | 51 | /// 52 | /// Serializes the exception information. 53 | /// 54 | /// The serialization information. 55 | /// The streaming context. 56 | public override void GetObjectData(SerializationInfo info, StreamingContext context) 57 | { 58 | base.GetObjectData(info, context); 59 | info.AddValue("code", (uint)code); 60 | } 61 | 62 | /// 63 | /// Gets the error code. 64 | /// 65 | public JavaScriptErrorCode ErrorCode 66 | { 67 | get { return code; } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptFatalException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// A fatal exception occurred. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptFatalException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptFatalException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptFatalException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptFatalException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptMemoryAllocationCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// User implemented callback routine for memory allocation events 7 | /// 8 | /// The state passed to SetRuntimeMemoryAllocationCallback. 9 | /// The type of type allocation event. 10 | /// The size of the allocation. 11 | /// 12 | /// For the Allocate event, returning true allows the runtime to continue with 13 | /// allocation. Returning false indicates the allocation request is rejected. The return value 14 | /// is ignored for other allocation events. 15 | /// 16 | public delegate bool JavaScriptMemoryAllocationCallback(IntPtr callbackState, JavaScriptMemoryEventType allocationEvent, UIntPtr allocationSize); 17 | } 18 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptMemoryEventType.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | /// 4 | /// Allocation callback event type. 5 | /// 6 | public enum JavaScriptMemoryEventType 7 | { 8 | /// 9 | /// Indicates a request for memory allocation. 10 | /// 11 | Allocate = 0, 12 | 13 | /// 14 | /// Indicates a memory freeing event. 15 | /// 16 | Free = 1, 17 | 18 | /// 19 | /// Indicates a failed allocation event. 20 | /// 21 | Failure = 2 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptNativeFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ChakraHost.Hosting 4 | { 5 | using System.Runtime.InteropServices; 6 | 7 | /// 8 | /// A function callback. 9 | /// 10 | /// 11 | /// A Function object that represents the function being invoked. 12 | /// 13 | /// Indicates whether this is a regular call or a 'new' call. 14 | /// The arguments to the call. 15 | /// The number of arguments. 16 | /// Callback data, if any. 17 | /// The result of the call, if any. 18 | public delegate JavaScriptValue JavaScriptNativeFunction(JavaScriptValue callee, bool isConstructCall, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] JavaScriptValue[] arguments, ushort argumentCount, IntPtr callbackData); 19 | } 20 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptObjectFinalizeCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A finalization callback. 7 | /// 8 | /// 9 | /// The external data that was passed in when creating the object being finalized. 10 | /// 11 | public delegate void JavaScriptObjectFinalizeCallback(IntPtr data); 12 | } 13 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptRuntimeAttributes.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | /// 7 | /// Attributes of a runtime. 8 | /// 9 | [Flags] 10 | public enum JavaScriptRuntimeAttributes 11 | { 12 | /// 13 | /// No special attributes. 14 | /// 15 | None = 0x00000000, 16 | 17 | /// 18 | /// The runtime will not do any work (such as garbage collection) on background threads. 19 | /// 20 | DisableBackgroundWork = 0x00000001, 21 | 22 | /// 23 | /// The runtime should support reliable script interruption. This increases the number of 24 | /// places where the runtime will check for a script interrupt request at the cost of a 25 | /// small amount of runtime performance. 26 | /// 27 | AllowScriptInterrupt = 0x00000002, 28 | 29 | /// 30 | /// Host will call Idle, so enable idle processing. Otherwise, the runtime will manage 31 | /// memory slightly more aggressively. 32 | /// 33 | EnableIdleProcessing = 0x00000004, 34 | 35 | /// 36 | /// Runtime will not generate native code. 37 | /// 38 | DisableNativeCodeGeneration = 0x00000008, 39 | 40 | /// 41 | /// Using Eval or Function constructor will throw an exception. 42 | /// 43 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Eval is a valid function name.")] 44 | DisableEval = 0x00000010, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptScriptException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// A script exception. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptScriptException : JavaScriptException 11 | { 12 | /// 13 | /// The error. 14 | /// 15 | [NonSerialized] 16 | private readonly JavaScriptValue error; 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The error code returned. 22 | /// The JavaScript error object. 23 | public JavaScriptScriptException(JavaScriptErrorCode code, JavaScriptValue error) : 24 | this(code, error, "JavaScript Exception") 25 | { 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The error code returned. 32 | /// The JavaScript error object. 33 | /// The error message. 34 | public JavaScriptScriptException(JavaScriptErrorCode code, JavaScriptValue error, string message) : 35 | base(code, message) 36 | { 37 | this.error = error; 38 | } 39 | 40 | /// 41 | /// Initializes a new instance of the class. 42 | /// 43 | /// The serialization info. 44 | /// The streaming context. 45 | private JavaScriptScriptException(SerializationInfo info, StreamingContext context) : 46 | base(info, context) 47 | { 48 | } 49 | 50 | /// 51 | /// Gets a JavaScript object representing the script error. 52 | /// 53 | public JavaScriptValue Error 54 | { 55 | get 56 | { 57 | return error; 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptThreadServiceCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A thread service callback. 7 | /// 8 | /// 9 | /// The host can specify a background thread service when creating a runtime. If 10 | /// specified, then background work items will be passed to the host using this callback. The 11 | /// host is expected to either begin executing the background work item immediately and return 12 | /// true or return false and the runtime will handle the work item in-thread. 13 | /// 14 | /// The callback for the background work item. 15 | /// The data argument to be passed to the callback. 16 | /// Whether the thread service will execute the callback. 17 | public delegate bool JavaScriptThreadServiceCallback(JavaScriptBackgroundWorkItemCallback callbackFunction, IntPtr callbackData); 18 | } 19 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptUsageException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An API usage exception occurred. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptUsageException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptUsageException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptUsageException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptUsageException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win10/edge/cs/Hosting/JavaScriptValueType.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | /// 4 | /// The JavaScript type of a JavaScriptValue. 5 | /// 6 | public enum JavaScriptValueType 7 | { 8 | /// 9 | /// The value is the undefined value. 10 | /// 11 | Undefined = 0, 12 | 13 | /// 14 | /// The value is the null value. 15 | /// 16 | Null = 1, 17 | 18 | /// 19 | /// The value is a JavaScript number value. 20 | /// 21 | Number = 2, 22 | 23 | /// 24 | /// The value is a JavaScript string value. 25 | /// 26 | String = 3, 27 | 28 | /// 29 | /// The value is a JavaScript Boolean value. 30 | /// 31 | Boolean = 4, 32 | 33 | /// 34 | /// The value is a JavaScript object value. 35 | /// 36 | Object = 5, 37 | 38 | /// 39 | /// The value is a JavaScript function object value. 40 | /// 41 | Function = 6, 42 | 43 | /// 44 | /// The value is a JavaScript error object value. 45 | /// 46 | Error = 7, 47 | 48 | /// 49 | /// The value is a JavaScript array object value. 50 | /// 51 | Array = 8, 52 | } 53 | } -------------------------------------------------------------------------------- /src/win10/edge/cs/Profiler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using ChakraHost.Hosting; 4 | 5 | namespace ChakraHost 6 | { 7 | [Guid("C3C44476-A1CE-403E-AFE2-D53EF618B139")] 8 | internal class Profiler : Native.IActiveScriptProfilerCallback2 9 | { 10 | public void OnFunctionEnterByName(string pwszFunctionName, Native.ProfilerScriptType type) 11 | { 12 | Console.WriteLine("Profiler.OnFunctionEnterByName: {0}, {1}", pwszFunctionName, type); 13 | } 14 | 15 | public void OnFunctionExitByName(string pwszFunctionName, Native.ProfilerScriptType type) 16 | { 17 | Console.WriteLine("Profiler.OnFunctionExitByName: {0}, {1}", pwszFunctionName, type); 18 | } 19 | 20 | public void Initialize(uint dwContext) 21 | { 22 | Console.WriteLine("Profiler.Initialize: {0}", dwContext); 23 | } 24 | 25 | public void Shutdown(uint hrReason) 26 | { 27 | Console.WriteLine("Profiler.Shutdown: {0}", hrReason); 28 | } 29 | 30 | public void ScriptCompiled(int scriptId, Native.ProfilerScriptType type, IntPtr pIDebugDocumentContext) 31 | { 32 | Console.WriteLine("Profiler.ScriptCompiled: {0}, {1}", scriptId, type); 33 | } 34 | 35 | public void FunctionCompiled(int functionId, int scriptId, string pwszFunctionName, string pwszFunctionNameHint, IntPtr pIDebugDocumentContext) 36 | { 37 | Console.WriteLine("Profiler.FunctionCompiled: {0}, {1}, {2}, {3}", functionId, scriptId, pwszFunctionName, pwszFunctionNameHint); 38 | } 39 | 40 | public void OnFunctionEnter(int scriptId, int functionId) 41 | { 42 | Console.WriteLine("Profiler.OnFunctionEnter: {0}, {1}", scriptId, functionId); 43 | } 44 | 45 | public void OnFunctionExit(int scriptId, int functionId) 46 | { 47 | Console.WriteLine("Profiler.OnFunctionExit: {0}, {1}", scriptId, functionId); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/win10/edge/cs/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: ComVisible(false)] 5 | [assembly: AssemblyVersion("1.0.0.0")] 6 | [assembly: AssemblyFileVersion("1.0.0.0")] 7 | [module: DefaultCharSet(CharSet.Unicode)] 8 | -------------------------------------------------------------------------------- /src/win10/edge/cs/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/win10/edge/memory/ChakraMemoryProfile.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChakraMemoryProfile", "ChakraMemoryProfile.vcxproj", "{A3A67D8F-E613-4348-B432-695A0FB3F63F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Debug|Win32.Build.0 = Debug|Win32 16 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Release|Win32.ActiveCfg = Release|Win32 17 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win10/edge/memory/ChakraMemoryProfile.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {A3A67D8F-E613-4348-B432-695A0FB3F63F} 15 | Win32Proj 16 | ChakraMemoryProfile 17 | 10.0.10240.0 18 | 19 | 20 | 21 | DynamicLibrary 22 | true 23 | v140 24 | Unicode 25 | 26 | 27 | DynamicLibrary 28 | false 29 | v140 30 | true 31 | Unicode 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | true 45 | 46 | 47 | false 48 | 49 | 50 | 51 | Use 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_WINDOWS;_USRDLL;CHAKRAMEMORYPROFILE_EXPORTS;%(PreprocessorDefinitions) 55 | 56 | 57 | Windows 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | Use 65 | MaxSpeed 66 | true 67 | true 68 | WIN32;NDEBUG;_WINDOWS;_USRDLL;CHAKRAMEMORYPROFILE_EXPORTS;%(PreprocessorDefinitions) 69 | 70 | 71 | Windows 72 | true 73 | true 74 | true 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Create 84 | Create 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/win10/edge/memory/ChakraMemoryProfile.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/win10/edge/memory/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /src/win10/edge/memory/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | -------------------------------------------------------------------------------- /src/win10/edge/vb/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ChakraHost", "ChakraHost.vbproj", "{04158E78-A589-4E46-AC4A-490E73E2E750}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptBackgroundWorkItemCallback.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' A background work item callback. 4 | ''' 5 | ''' 6 | ''' This is passed to the host's thread service (if provided) to allow the host to 7 | ''' invoke the work item callback on the background thread of its choice. 8 | ''' 9 | ''' Data argument passed to the thread service. 10 | Public Delegate Sub JavaScriptBackgroundWorkItemCallback(callbackData As IntPtr) 11 | End Namespace 12 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptBeforeCollectCallback.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' A callback called before collection. 4 | ''' 5 | ''' The state passed to SetBeforeCollectCallback. 6 | Public Delegate Sub JavaScriptBeforeCollectCallback(callbackState As IntPtr) 7 | End Namespace 8 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptEngineException.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.Serialization 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' An exception that occurred in the workings of the JavaScript engine itself. 6 | ''' 7 | 8 | Public NotInheritable Class JavaScriptEngineException 9 | Inherits JavaScriptException 10 | ''' 11 | ''' Initializes a new instance of the class. 12 | ''' 13 | ''' The error code returned. 14 | Public Sub New(code As JavaScriptErrorCode) 15 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 16 | End Sub 17 | 18 | ''' 19 | ''' Initializes a new instance of the class. 20 | ''' 21 | ''' The error code returned. 22 | ''' The error message. 23 | Public Sub New(code As JavaScriptErrorCode, message As String) 24 | MyBase.New(code, message) 25 | End Sub 26 | 27 | ''' 28 | ''' Initializes a new instance of the class. 29 | ''' 30 | ''' The serialization info. 31 | ''' The streaming context. 32 | Private Sub New(info As SerializationInfo, context As StreamingContext) 33 | MyBase.New(info, context) 34 | End Sub 35 | End Class 36 | End Namespace 37 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptException.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.Serialization 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' An exception returned from the Chakra engine. 6 | ''' 7 | 8 | Public Class JavaScriptException 9 | Inherits Exception 10 | ''' 11 | ''' The error code. 12 | ''' 13 | Private ReadOnly code As JavaScriptErrorCode 14 | 15 | ''' 16 | ''' Initializes a new instance of the class. 17 | ''' 18 | ''' The error code returned. 19 | Public Sub New(code As JavaScriptErrorCode) 20 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 21 | End Sub 22 | 23 | ''' 24 | ''' Initializes a new instance of the class. 25 | ''' 26 | ''' The error code returned. 27 | ''' The error message. 28 | Public Sub New(code As JavaScriptErrorCode, message As String) 29 | MyBase.New(message) 30 | Me.code = code 31 | End Sub 32 | 33 | ''' 34 | ''' Initializes a new instance of the class. 35 | ''' 36 | ''' The serialization info. 37 | ''' The streaming context. 38 | Protected Sub New(info As SerializationInfo, context As StreamingContext) 39 | MyBase.New(info, context) 40 | If info IsNot Nothing Then 41 | code = DirectCast(info.GetUInt32("code"), JavaScriptErrorCode) 42 | End If 43 | End Sub 44 | 45 | ''' 46 | ''' Serializes the exception information. 47 | ''' 48 | ''' The serialization information. 49 | ''' The streaming context. 50 | Public Overrides Sub GetObjectData(info As SerializationInfo, context As StreamingContext) 51 | MyBase.GetObjectData(info, context) 52 | info.AddValue("code", CUInt(code)) 53 | End Sub 54 | 55 | ''' 56 | ''' Gets the error code. 57 | ''' 58 | Public ReadOnly Property ErrorCode() As JavaScriptErrorCode 59 | Get 60 | Return code 61 | End Get 62 | End Property 63 | End Class 64 | End Namespace 65 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptFatalException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' A fatal exception occurred. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptFatalException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' Initializes a new instance of the class. 13 | ''' 14 | ''' The error code returned. 15 | Public Sub New(code As JavaScriptErrorCode) 16 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 17 | End Sub 18 | 19 | ''' 20 | ''' Initializes a new instance of the class. 21 | ''' 22 | ''' The error code returned. 23 | ''' The error message. 24 | Public Sub New(code As JavaScriptErrorCode, message As String) 25 | MyBase.New(code, message) 26 | End Sub 27 | 28 | ''' 29 | ''' Initializes a new instance of the class. 30 | ''' 31 | ''' The serialization info. 32 | ''' The streaming context. 33 | Private Sub New(info As SerializationInfo, context As StreamingContext) 34 | MyBase.New(info, context) 35 | End Sub 36 | End Class 37 | End Namespace 38 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptMemoryAllocationCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' User implemented callback routine for memory allocation events 6 | ''' 7 | ''' The state passed to SetRuntimeMemoryAllocationCallback. 8 | ''' The type of type allocation event. 9 | ''' The size of the allocation. 10 | ''' 11 | ''' For the Allocate event, returning true allows the runtime to continue with 12 | ''' allocation. Returning false indicates the allocation request is rejected. The return value 13 | ''' is ignored for other allocation events. 14 | ''' 15 | Public Delegate Function JavaScriptMemoryAllocationCallback(callbackState As IntPtr, allocationEvent As JavaScriptMemoryEventType, allocationSize As UIntPtr) As Boolean 16 | End Namespace 17 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptMemoryEventType.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' Allocation callback event type. 4 | ''' 5 | Public Enum JavaScriptMemoryEventType 6 | ''' 7 | ''' Indicates a request for memory allocation. 8 | ''' 9 | Allocate = 0 10 | 11 | ''' 12 | ''' Indicates a memory freeing event. 13 | ''' 14 | Free = 1 15 | 16 | ''' 17 | ''' Indicates a failed allocation event. 18 | ''' 19 | Failure = 2 20 | End Enum 21 | End Namespace 22 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptNativeFunction.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.InteropServices 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A function callback. 6 | ''' 7 | ''' 8 | ''' A Function object that represents the function being invoked. 9 | ''' 10 | ''' Indicates whether this is a regular call or a 'new' call. 11 | ''' The arguments to the call. 12 | ''' The number of arguments. 13 | ''' The callback data, if any. 14 | ''' The result of the call, if any. 15 | Public Delegate Function JavaScriptNativeFunction(callee As JavaScriptValue, isConstructCall As Boolean, arguments As JavaScriptValue(), argumentCount As UShort, callbackData As IntPtr) As JavaScriptValue 16 | End Namespace 17 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptObjectFinalizeCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A finalization callback. 6 | ''' 7 | ''' 8 | ''' The external data that was passed in when creating the object being finalized. 9 | ''' 10 | Public Delegate Sub JavaScriptObjectFinalizeCallback(data As IntPtr) 11 | End Namespace 12 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptRuntimeAttributes.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Diagnostics.CodeAnalysis 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' Attributes of a runtime. 7 | ''' 8 | 9 | Public Enum JavaScriptRuntimeAttributes 10 | ''' 11 | ''' No special attributes. 12 | ''' 13 | None = &H0 14 | 15 | ''' 16 | ''' The runtime will not do any work (such as garbage collection) on background threads. 17 | ''' 18 | DisableBackgroundWork = &H1 19 | 20 | ''' 21 | ''' The runtime should support reliable script interruption. This increases the number of 22 | ''' places where the runtime will check for a script interrupt request at the cost of a 23 | ''' small amount of runtime performance. 24 | ''' 25 | AllowScriptInterrupt = &H2 26 | 27 | ''' 28 | ''' Host will call Idle, so enable idle processing. Otherwise, the runtime will manage 29 | ''' memory slightly more aggressively. 30 | ''' 31 | EnableIdleProcessing = &H4 32 | 33 | ''' 34 | ''' Runtime will not generate native code. 35 | ''' 36 | DisableNativeCodeGeneration = &H8 37 | 38 | ''' 39 | ''' Using Eval or Function constructor will throw an exception. 40 | ''' 41 | 42 | DisableEval = &H10 43 | End Enum 44 | End Namespace 45 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptScriptException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' A script exception. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptScriptException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' The error. 13 | ''' 14 | 15 | Private ReadOnly errorObject As JavaScriptValue 16 | 17 | ''' 18 | ''' Initializes a new instance of the class. 19 | ''' 20 | ''' The error code returned. 21 | ''' The JavaScript error object. 22 | Public Sub New(code As JavaScriptErrorCode, errorObject As JavaScriptValue) 23 | Me.New(code, errorObject, "JavaScript Exception") 24 | End Sub 25 | 26 | ''' 27 | ''' Initializes a new instance of the class. 28 | ''' 29 | ''' The error code returned. 30 | ''' The JavaScript error object. 31 | ''' The error message. 32 | Public Sub New(code As JavaScriptErrorCode, errorObject As JavaScriptValue, message As String) 33 | MyBase.New(code, message) 34 | Me.errorObject = errorObject 35 | End Sub 36 | 37 | ''' 38 | ''' Initializes a new instance of the class. 39 | ''' 40 | ''' The serialization info. 41 | ''' The streaming context. 42 | Private Sub New(info As SerializationInfo, context As StreamingContext) 43 | MyBase.New(info, context) 44 | End Sub 45 | 46 | ''' 47 | ''' Gets a JavaScript object representing the script error. 48 | ''' 49 | Public ReadOnly Property JavaScriptError() As JavaScriptValue 50 | Get 51 | Return errorObject 52 | End Get 53 | End Property 54 | End Class 55 | End Namespace 56 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptThreadServiceCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A thread service callback. 6 | ''' 7 | ''' 8 | ''' The host can specify a background thread service when creating a runtime. If 9 | ''' specified, then background work items will be passed to the host using this callback. The 10 | ''' host is expected to either begin executing the background work item immediately and return 11 | ''' true or return false and the runtime will handle the work item in-thread. 12 | ''' 13 | ''' The callback for the background work item. 14 | ''' The data argument to be passed to the callback. 15 | ''' Whether the thread service will execute the callback. 16 | Public Delegate Function JavaScriptThreadServiceCallback(callbackFunction As JavaScriptBackgroundWorkItemCallback, callbackData As IntPtr) As Boolean 17 | End Namespace 18 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptUsageException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' An API usage exception occurred. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptUsageException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' Initializes a new instance of the class. 13 | ''' 14 | ''' The error code returned. 15 | Public Sub New(code As JavaScriptErrorCode) 16 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 17 | End Sub 18 | 19 | ''' 20 | ''' Initializes a new instance of the class. 21 | ''' 22 | ''' The error code returned. 23 | ''' The error message. 24 | Public Sub New(code As JavaScriptErrorCode, message As String) 25 | MyBase.New(code, message) 26 | End Sub 27 | 28 | ''' 29 | ''' Initializes a new instance of the class. 30 | ''' 31 | ''' The serialization info. 32 | ''' The streaming context. 33 | Private Sub New(info As SerializationInfo, context As StreamingContext) 34 | MyBase.New(info, context) 35 | End Sub 36 | End Class 37 | End Namespace 38 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Hosting/JavaScriptValueType.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' The JavaScript type of a JavaScriptValue. 4 | ''' 5 | Public Enum JavaScriptValueType 6 | ''' 7 | ''' The value is the undefined value. 8 | ''' 9 | Undefined = 0 10 | 11 | ''' 12 | ''' The value is the null value. 13 | ''' 14 | Null = 1 15 | 16 | ''' 17 | ''' The value is a JavaScript number value. 18 | ''' 19 | Number = 2 20 | 21 | ''' 22 | ''' The value is a JavaScript string value. 23 | ''' 24 | [String] = 3 25 | 26 | ''' 27 | ''' The value is a JavaScript Boolean value. 28 | ''' 29 | [Boolean] = 4 30 | 31 | ''' 32 | ''' The value is a JavaScript object value. 33 | ''' 34 | [Object] = 5 35 | 36 | ''' 37 | ''' The value is a JavaScript function object value. 38 | ''' 39 | [Function] = 6 40 | 41 | ''' 42 | ''' The value is a JavaScript error object value. 43 | ''' 44 | [Error] = 7 45 | 46 | ''' 47 | ''' The value is a JavaScript array object value. 48 | ''' 49 | Array = 8 50 | End Enum 51 | End Namespace 52 | -------------------------------------------------------------------------------- /src/win10/edge/vb/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System.Reflection 2 | Imports System.Runtime.InteropServices 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/win10/edge/vb/Profiler.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.InteropServices 2 | Imports ChakraHost.Hosting 3 | 4 | 5 | Friend Class Profiler 6 | Implements IActiveScriptProfilerCallback2 7 | 8 | Public Sub OnFunctionEnterByName(pwszFunctionName As String, type As ProfilerScriptType) Implements IActiveScriptProfilerCallback2.OnFunctionEnterByName 9 | Console.WriteLine("Profiler.OnFunctionEnterByName: {0}, {1}", pwszFunctionName, type) 10 | End Sub 11 | 12 | Public Sub OnFunctionExitByName(pwszFunctionName As String, type As ProfilerScriptType) Implements IActiveScriptProfilerCallback2.OnFunctionExitByName 13 | Console.WriteLine("Profiler.OnFunctionExitByName: {0}, {1}", pwszFunctionName, type) 14 | End Sub 15 | 16 | Public Sub Initialize(dwContext As UInteger) Implements IActiveScriptProfilerCallback.Initialize 17 | Console.WriteLine("Profiler.Initialize: {0}", dwContext) 18 | End Sub 19 | 20 | Public Sub Shutdown(hrReason As UInteger) Implements IActiveScriptProfilerCallback.Shutdown 21 | Console.WriteLine("Profiler.Shutdown: {0}", hrReason) 22 | End Sub 23 | 24 | Public Sub ScriptCompiled(scriptId As Integer, type As ProfilerScriptType, pIDebugDocumentContext As IntPtr) Implements IActiveScriptProfilerCallback.ScriptCompiled 25 | Console.WriteLine("Profiler.ScriptCompiled: {0}, {1}", scriptId, type) 26 | End Sub 27 | 28 | Public Sub FunctionCompiled(functionId As Integer, scriptId As Integer, pwszFunctionName As String, pwszFunctionNameHint As String, pIDebugDocumentContext As IntPtr) Implements IActiveScriptProfilerCallback.FunctionCompiled 29 | Console.WriteLine("Profiler.FunctionCompiled: {0}, {1}, {2}, {3}", functionId, scriptId, pwszFunctionName, pwszFunctionNameHint) 30 | End Sub 31 | 32 | Public Sub OnFunctionEnter(scriptId As Integer, functionId As Integer) Implements IActiveScriptProfilerCallback.OnFunctionEnter 33 | Console.WriteLine("Profiler.OnFunctionEnter: {0}, {1}", scriptId, functionId) 34 | End Sub 35 | 36 | Public Sub OnFunctionExit(scriptId As Integer, functionId As Integer) Implements IActiveScriptProfilerCallback.OnFunctionExit 37 | Console.WriteLine("Profiler.OnFunctionExit: {0}, {1}", scriptId, functionId) 38 | End Sub 39 | End Class 40 | -------------------------------------------------------------------------------- /src/win10/edge/vb/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/win10/ie/cpp/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20827.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChakraHost", "ChakraHost.vcxproj", "{CC586644-5E57-4523-9DEA-E82F4FE9F91D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Debug|Win32.Build.0 = Debug|Win32 16 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Release|Win32.ActiveCfg = Release|Win32 17 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win10/ie/cpp/ChakraHost.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D} 15 | Win32Proj 16 | ChakraHost 17 | 10.0.10240.0 18 | 19 | 20 | 21 | Application 22 | true 23 | v140 24 | Unicode 25 | 26 | 27 | Application 28 | false 29 | v140 30 | true 31 | Unicode 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | true 45 | 46 | 47 | false 48 | 49 | 50 | 51 | Use 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 55 | true 56 | 57 | 58 | Console 59 | true 60 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;jsrt.lib;%(AdditionalDependencies) 61 | 62 | 63 | 64 | 65 | Level3 66 | Use 67 | MaxSpeed 68 | true 69 | true 70 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;jsrt.lib;%(AdditionalDependencies) 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Create 90 | Create 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/win10/ie/cpp/ChakraHost.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/win10/ie/cpp/Profiler.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | Profiler::Profiler(void) 10 | { 11 | m_refCount = 1; 12 | } 13 | 14 | Profiler::~Profiler(void) 15 | { 16 | } 17 | 18 | HRESULT Profiler::QueryInterface(REFIID riid, void **ppvObj) 19 | { 20 | if (riid == IID_IUnknown) 21 | { 22 | *ppvObj = (IUnknown *) this; 23 | } 24 | else if (riid == IID_IActiveScriptProfilerCallback) 25 | { 26 | *ppvObj = (IActiveScriptProfilerCallback *) this; 27 | } 28 | else if (riid == IID_IActiveScriptProfilerCallback2) 29 | { 30 | *ppvObj = (IActiveScriptProfilerCallback2 *) this; 31 | } 32 | else 33 | { 34 | *ppvObj = NULL; 35 | return E_NOINTERFACE; 36 | } 37 | 38 | AddRef(); 39 | return NOERROR; 40 | } 41 | 42 | ULONG Profiler::AddRef() 43 | { 44 | return InterlockedIncrement(&m_refCount); 45 | } 46 | 47 | ULONG Profiler::Release() 48 | { 49 | long lw; 50 | 51 | if (0 == (lw = InterlockedDecrement(&m_refCount))) 52 | { 53 | delete this; 54 | } 55 | return lw; 56 | } 57 | 58 | HRESULT Profiler::Initialize(DWORD dwContext) 59 | { 60 | fwprintf(stdout, L"Profiler::Initialize: 0x%lx\n", dwContext); 61 | return S_OK; 62 | } 63 | 64 | HRESULT Profiler::Shutdown(HRESULT hrReason) 65 | { 66 | fwprintf(stdout, L"Profiler::Shutdown: 0x%lx\n", hrReason); 67 | return S_OK; 68 | } 69 | 70 | HRESULT Profiler::ScriptCompiled(PROFILER_TOKEN scriptId, PROFILER_SCRIPT_TYPE type, IUnknown *pIDebugDocumentContext) 71 | { 72 | fwprintf(stdout, L"Profiler::ScriptCompiled: 0x%lx, %u\n", scriptId, type); 73 | return S_OK; 74 | } 75 | 76 | HRESULT Profiler::FunctionCompiled(PROFILER_TOKEN functionId, PROFILER_TOKEN scriptId, const wchar_t *pwszFunctionName, const wchar_t *pwszFunctionNameHint, IUnknown *pIDebugDocumentContext) 77 | { 78 | fwprintf(stdout, L"Profiler::FunctionCompiled: 0x%lx, 0x%lx, %s, %s\n", scriptId, functionId, pwszFunctionName, pwszFunctionNameHint); 79 | return S_OK; 80 | } 81 | 82 | HRESULT Profiler::OnFunctionEnter(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId) 83 | { 84 | fwprintf(stdout, L"Profiler::OnFunctionEnter: 0x%lx, 0x%lx\n", scriptId, functionId); 85 | return S_OK; 86 | } 87 | 88 | HRESULT Profiler::OnFunctionExit(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId) 89 | { 90 | fwprintf(stdout, L"Profiler::OnFunctionExit: 0x%lx, 0x%lx\n", scriptId, functionId); 91 | return S_OK; 92 | } 93 | 94 | HRESULT Profiler::OnFunctionEnterByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type) 95 | { 96 | fwprintf(stdout, L"Profiler::OnFunctionEnterByName: %s, %u\n", pwszFunctionName, type); 97 | return S_OK; 98 | } 99 | 100 | HRESULT Profiler::OnFunctionExitByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type) 101 | { 102 | fwprintf(stdout, L"Profiler::OnFunctionExitByName: %s, %u\n", pwszFunctionName, type); 103 | return S_OK; 104 | } 105 | -------------------------------------------------------------------------------- /src/win10/ie/cpp/Profiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Profiler sealed : public IActiveScriptProfilerCallback2 4 | { 5 | private: 6 | long m_refCount; 7 | 8 | public: 9 | Profiler(void); 10 | ~Profiler(void); 11 | 12 | // IUnknown 13 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObj); 14 | ULONG STDMETHODCALLTYPE AddRef(void); 15 | ULONG STDMETHODCALLTYPE Release(void); 16 | 17 | // IActiveScriptProfilerCallback 18 | HRESULT STDMETHODCALLTYPE Initialize(DWORD dwContext); 19 | HRESULT STDMETHODCALLTYPE Shutdown(HRESULT hrReason); 20 | HRESULT STDMETHODCALLTYPE ScriptCompiled(PROFILER_TOKEN scriptId, PROFILER_SCRIPT_TYPE type, IUnknown *pIDebugDocumentContext); 21 | HRESULT STDMETHODCALLTYPE FunctionCompiled(PROFILER_TOKEN functionId, PROFILER_TOKEN scriptId, const wchar_t *pwszFunctionName, const wchar_t *pwszFunctionNameHint, IUnknown *pIDebugDocumentContext); 22 | HRESULT STDMETHODCALLTYPE OnFunctionEnter(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId); 23 | HRESULT STDMETHODCALLTYPE OnFunctionExit(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId); 24 | 25 | // IActiveScriptProfilerCallback2 26 | HRESULT STDMETHODCALLTYPE OnFunctionEnterByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type); 27 | HRESULT STDMETHODCALLTYPE OnFunctionExitByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type); 28 | }; 29 | -------------------------------------------------------------------------------- /src/win10/ie/cpp/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /src/win10/ie/cpp/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Profiler.h" 7 | 8 | #define IfFailError(v, e) \ 9 | { \ 10 | JsErrorCode error = (v); \ 11 | if (error != JsNoError) \ 12 | { \ 13 | fwprintf(stderr, L"chakrahost: fatal error: %s.\n", (e)); \ 14 | goto error; \ 15 | } \ 16 | } 17 | 18 | #define IfFailRet(v) \ 19 | { \ 20 | JsErrorCode error = (v); \ 21 | if (error != JsNoError) \ 22 | { \ 23 | return error; \ 24 | } \ 25 | } 26 | 27 | #define IfFailThrow(v, e) \ 28 | { \ 29 | JsErrorCode error = (v); \ 30 | if (error != JsNoError) \ 31 | { \ 32 | ThrowException((e)); \ 33 | return JS_INVALID_REFERENCE; \ 34 | } \ 35 | } 36 | 37 | #define IfComFailError(v) \ 38 | { \ 39 | hr = (v); \ 40 | if (FAILED(hr)) \ 41 | { \ 42 | goto error; \ 43 | } \ 44 | } 45 | 46 | #define IfComFailRet(v) \ 47 | { \ 48 | HRESULT hr = (v); \ 49 | if (FAILED(hr)) \ 50 | { \ 51 | return hr; \ 52 | } \ 53 | } 54 | -------------------------------------------------------------------------------- /src/win10/ie/cs/ChakraHost.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D672BC49-C454-4975-BD25-A555B9BDD793} 8 | Exe 9 | Properties 10 | ChakraHost 11 | ChakraHost 12 | v4.6 13 | 512 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 78 | -------------------------------------------------------------------------------- /src/win10/ie/cs/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChakraHost", "ChakraHost.csproj", "{D672BC49-C454-4975-BD25-A555B9BDD793}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptBackgroundWorkItemCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A background work item callback. 7 | /// 8 | /// 9 | /// This is passed to the host's thread service (if provided) to allow the host to 10 | /// invoke the work item callback on the background thread of its choice. 11 | /// 12 | /// Data argument passed to the thread service. 13 | public delegate void JavaScriptBackgroundWorkItemCallback(IntPtr callbackData); 14 | } 15 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptBeforeCollectCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A callback called before collection. 7 | /// 8 | /// The state passed to SetBeforeCollectCallback. 9 | public delegate void JavaScriptBeforeCollectCallback(IntPtr callbackState); 10 | } 11 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptEngineException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An exception that occurred in the workings of the JavaScript engine itself. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptEngineException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptEngineException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptEngineException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptEngineException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An exception returned from the Chakra engine. 8 | /// 9 | [Serializable] 10 | public class JavaScriptException : Exception 11 | { 12 | /// 13 | /// The error code. 14 | /// 15 | private readonly JavaScriptErrorCode code; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The error code returned. 21 | public JavaScriptException(JavaScriptErrorCode code) : 22 | this(code, "A fatal exception has occurred in a JavaScript runtime") 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The error code returned. 30 | /// The error message. 31 | public JavaScriptException(JavaScriptErrorCode code, string message) : 32 | base(message) 33 | { 34 | this.code = code; 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The serialization info. 41 | /// The streaming context. 42 | protected JavaScriptException(SerializationInfo info, StreamingContext context) : 43 | base(info, context) 44 | { 45 | if (info != null) 46 | { 47 | code = (JavaScriptErrorCode) info.GetUInt32("code"); 48 | } 49 | } 50 | 51 | /// 52 | /// Serializes the exception information. 53 | /// 54 | /// The serialization information. 55 | /// The streaming context. 56 | public override void GetObjectData(SerializationInfo info, StreamingContext context) 57 | { 58 | base.GetObjectData(info, context); 59 | info.AddValue("code", (uint)code); 60 | } 61 | 62 | /// 63 | /// Gets the error code. 64 | /// 65 | public JavaScriptErrorCode ErrorCode 66 | { 67 | get { return code; } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptFatalException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// A fatal exception occurred. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptFatalException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptFatalException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptFatalException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptFatalException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptMemoryAllocationCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// User implemented callback routine for memory allocation events 7 | /// 8 | /// The state passed to SetRuntimeMemoryAllocationCallback. 9 | /// The type of type allocation event. 10 | /// The size of the allocation. 11 | /// 12 | /// For the Allocate event, returning true allows the runtime to continue with 13 | /// allocation. Returning false indicates the allocation request is rejected. The return value 14 | /// is ignored for other allocation events. 15 | /// 16 | public delegate bool JavaScriptMemoryAllocationCallback(IntPtr callbackState, JavaScriptMemoryEventType allocationEvent, UIntPtr allocationSize); 17 | } 18 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptMemoryEventType.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | /// 4 | /// Allocation callback event type. 5 | /// 6 | public enum JavaScriptMemoryEventType 7 | { 8 | /// 9 | /// Indicates a request for memory allocation. 10 | /// 11 | Allocate = 0, 12 | 13 | /// 14 | /// Indicates a memory freeing event. 15 | /// 16 | Free = 1, 17 | 18 | /// 19 | /// Indicates a failed allocation event. 20 | /// 21 | Failure = 2 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptNativeFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ChakraHost.Hosting 4 | { 5 | using System.Runtime.InteropServices; 6 | 7 | /// 8 | /// A function callback. 9 | /// 10 | /// 11 | /// A Function object that represents the function being invoked. 12 | /// 13 | /// Indicates whether this is a regular call or a 'new' call. 14 | /// The arguments to the call. 15 | /// The number of arguments. 16 | /// Callback data, if any. 17 | /// The result of the call, if any. 18 | public delegate JavaScriptValue JavaScriptNativeFunction(JavaScriptValue callee, bool isConstructCall, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] JavaScriptValue[] arguments, ushort argumentCount, IntPtr callbackData); 19 | } 20 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptObjectFinalizeCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A finalization callback. 7 | /// 8 | /// 9 | /// The external data that was passed in when creating the object being finalized. 10 | /// 11 | public delegate void JavaScriptObjectFinalizeCallback(IntPtr data); 12 | } 13 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptRuntimeAttributes.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | /// 7 | /// Attributes of a runtime. 8 | /// 9 | [Flags] 10 | public enum JavaScriptRuntimeAttributes 11 | { 12 | /// 13 | /// No special attributes. 14 | /// 15 | None = 0x00000000, 16 | 17 | /// 18 | /// The runtime will not do any work (such as garbage collection) on background threads. 19 | /// 20 | DisableBackgroundWork = 0x00000001, 21 | 22 | /// 23 | /// The runtime should support reliable script interruption. This increases the number of 24 | /// places where the runtime will check for a script interrupt request at the cost of a 25 | /// small amount of runtime performance. 26 | /// 27 | AllowScriptInterrupt = 0x00000002, 28 | 29 | /// 30 | /// Host will call Idle, so enable idle processing. Otherwise, the runtime will manage 31 | /// memory slightly more aggressively. 32 | /// 33 | EnableIdleProcessing = 0x00000004, 34 | 35 | /// 36 | /// Runtime will not generate native code. 37 | /// 38 | DisableNativeCodeGeneration = 0x00000008, 39 | 40 | /// 41 | /// Using Eval or Function constructor will throw an exception. 42 | /// 43 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Eval is a valid function name.")] 44 | DisableEval = 0x00000010, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptRuntimeVersion.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | /// 4 | /// Version of the runtime. 5 | /// 6 | public enum JavaScriptRuntimeVersion 7 | { 8 | /// 9 | /// Create runtime with IE10 version. 10 | /// 11 | Version10 = 0, 12 | 13 | /// 14 | /// Create runtime with IE11 version. 15 | /// 16 | Version11 = 1, 17 | 18 | /// 19 | /// Create runtime with highest version present on the machine at runtime. 20 | /// 21 | VersionEdge = -1, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptScriptException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// A script exception. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptScriptException : JavaScriptException 11 | { 12 | /// 13 | /// The error. 14 | /// 15 | [NonSerialized] 16 | private readonly JavaScriptValue error; 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The error code returned. 22 | /// The JavaScript error object. 23 | public JavaScriptScriptException(JavaScriptErrorCode code, JavaScriptValue error) : 24 | this(code, error, "JavaScript Exception") 25 | { 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The error code returned. 32 | /// The JavaScript error object. 33 | /// The error message. 34 | public JavaScriptScriptException(JavaScriptErrorCode code, JavaScriptValue error, string message) : 35 | base(code, message) 36 | { 37 | this.error = error; 38 | } 39 | 40 | /// 41 | /// Initializes a new instance of the class. 42 | /// 43 | /// The serialization info. 44 | /// The streaming context. 45 | private JavaScriptScriptException(SerializationInfo info, StreamingContext context) : 46 | base(info, context) 47 | { 48 | } 49 | 50 | /// 51 | /// Gets a JavaScript object representing the script error. 52 | /// 53 | public JavaScriptValue Error 54 | { 55 | get 56 | { 57 | return error; 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptThreadServiceCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A thread service callback. 7 | /// 8 | /// 9 | /// The host can specify a background thread service when creating a runtime. If 10 | /// specified, then background work items will be passed to the host using this callback. The 11 | /// host is expected to either begin executing the background work item immediately and return 12 | /// true or return false and the runtime will handle the work item in-thread. 13 | /// 14 | /// The callback for the background work item. 15 | /// The data argument to be passed to the callback. 16 | /// Whether the thread service will execute the callback. 17 | public delegate bool JavaScriptThreadServiceCallback(JavaScriptBackgroundWorkItemCallback callbackFunction, IntPtr callbackData); 18 | } 19 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptUsageException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An API usage exception occurred. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptUsageException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptUsageException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptUsageException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptUsageException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win10/ie/cs/Hosting/JavaScriptValueType.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | /// 4 | /// The JavaScript type of a JavaScriptValue. 5 | /// 6 | public enum JavaScriptValueType 7 | { 8 | /// 9 | /// The value is the undefined value. 10 | /// 11 | Undefined = 0, 12 | 13 | /// 14 | /// The value is the null value. 15 | /// 16 | Null = 1, 17 | 18 | /// 19 | /// The value is a JavaScript number value. 20 | /// 21 | Number = 2, 22 | 23 | /// 24 | /// The value is a JavaScript string value. 25 | /// 26 | String = 3, 27 | 28 | /// 29 | /// The value is a JavaScript Boolean value. 30 | /// 31 | Boolean = 4, 32 | 33 | /// 34 | /// The value is a JavaScript object value. 35 | /// 36 | Object = 5, 37 | 38 | /// 39 | /// The value is a JavaScript function object value. 40 | /// 41 | Function = 6, 42 | 43 | /// 44 | /// The value is a JavaScript error object value. 45 | /// 46 | Error = 7, 47 | 48 | /// 49 | /// The value is a JavaScript array object value. 50 | /// 51 | Array = 8, 52 | } 53 | } -------------------------------------------------------------------------------- /src/win10/ie/cs/Profiler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using ChakraHost.Hosting; 4 | 5 | namespace ChakraHost 6 | { 7 | [Guid("C3C44476-A1CE-403E-AFE2-D53EF618B139")] 8 | internal class Profiler : Native.IActiveScriptProfilerCallback2 9 | { 10 | public void OnFunctionEnterByName(string pwszFunctionName, Native.ProfilerScriptType type) 11 | { 12 | Console.WriteLine("Profiler.OnFunctionEnterByName: {0}, {1}", pwszFunctionName, type); 13 | } 14 | 15 | public void OnFunctionExitByName(string pwszFunctionName, Native.ProfilerScriptType type) 16 | { 17 | Console.WriteLine("Profiler.OnFunctionExitByName: {0}, {1}", pwszFunctionName, type); 18 | } 19 | 20 | public void Initialize(uint dwContext) 21 | { 22 | Console.WriteLine("Profiler.Initialize: {0}", dwContext); 23 | } 24 | 25 | public void Shutdown(uint hrReason) 26 | { 27 | Console.WriteLine("Profiler.Shutdown: {0}", hrReason); 28 | } 29 | 30 | public void ScriptCompiled(int scriptId, Native.ProfilerScriptType type, IntPtr pIDebugDocumentContext) 31 | { 32 | Console.WriteLine("Profiler.ScriptCompiled: {0}, {1}", scriptId, type); 33 | } 34 | 35 | public void FunctionCompiled(int functionId, int scriptId, string pwszFunctionName, string pwszFunctionNameHint, IntPtr pIDebugDocumentContext) 36 | { 37 | Console.WriteLine("Profiler.FunctionCompiled: {0}, {1}, {2}, {3}", functionId, scriptId, pwszFunctionName, pwszFunctionNameHint); 38 | } 39 | 40 | public void OnFunctionEnter(int scriptId, int functionId) 41 | { 42 | Console.WriteLine("Profiler.OnFunctionEnter: {0}, {1}", scriptId, functionId); 43 | } 44 | 45 | public void OnFunctionExit(int scriptId, int functionId) 46 | { 47 | Console.WriteLine("Profiler.OnFunctionExit: {0}, {1}", scriptId, functionId); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/win10/ie/cs/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: ComVisible(false)] 5 | [assembly: AssemblyVersion("1.0.0.0")] 6 | [assembly: AssemblyFileVersion("1.0.0.0")] 7 | [module: DefaultCharSet(CharSet.Unicode)] 8 | -------------------------------------------------------------------------------- /src/win10/ie/cs/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/win10/ie/memory/ChakraMemoryProfile.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChakraMemoryProfile", "ChakraMemoryProfile.vcxproj", "{A3A67D8F-E613-4348-B432-695A0FB3F63F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Debug|Win32.Build.0 = Debug|Win32 16 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Release|Win32.ActiveCfg = Release|Win32 17 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win10/ie/memory/ChakraMemoryProfile.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {A3A67D8F-E613-4348-B432-695A0FB3F63F} 15 | Win32Proj 16 | ChakraMemoryProfile 17 | 10.0.10240.0 18 | 19 | 20 | 21 | DynamicLibrary 22 | true 23 | v140 24 | Unicode 25 | 26 | 27 | DynamicLibrary 28 | false 29 | v140 30 | true 31 | Unicode 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | true 45 | 46 | 47 | false 48 | 49 | 50 | 51 | Use 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_WINDOWS;_USRDLL;CHAKRAMEMORYPROFILE_EXPORTS;%(PreprocessorDefinitions) 55 | 56 | 57 | Windows 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | Use 65 | MaxSpeed 66 | true 67 | true 68 | WIN32;NDEBUG;_WINDOWS;_USRDLL;CHAKRAMEMORYPROFILE_EXPORTS;%(PreprocessorDefinitions) 69 | 70 | 71 | Windows 72 | true 73 | true 74 | true 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Create 84 | Create 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/win10/ie/memory/ChakraMemoryProfile.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/win10/ie/memory/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /src/win10/ie/memory/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | -------------------------------------------------------------------------------- /src/win10/ie/vb/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ChakraHost", "ChakraHost.vbproj", "{04158E78-A589-4E46-AC4A-490E73E2E750}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptBackgroundWorkItemCallback.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' A background work item callback. 4 | ''' 5 | ''' 6 | ''' This is passed to the host's thread service (if provided) to allow the host to 7 | ''' invoke the work item callback on the background thread of its choice. 8 | ''' 9 | ''' Data argument passed to the thread service. 10 | Public Delegate Sub JavaScriptBackgroundWorkItemCallback(callbackData As IntPtr) 11 | End Namespace 12 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptBeforeCollectCallback.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' A callback called before collection. 4 | ''' 5 | ''' The state passed to SetBeforeCollectCallback. 6 | Public Delegate Sub JavaScriptBeforeCollectCallback(callbackState As IntPtr) 7 | End Namespace 8 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptEngineException.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.Serialization 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' An exception that occurred in the workings of the JavaScript engine itself. 6 | ''' 7 | 8 | Public NotInheritable Class JavaScriptEngineException 9 | Inherits JavaScriptException 10 | ''' 11 | ''' Initializes a new instance of the class. 12 | ''' 13 | ''' The error code returned. 14 | Public Sub New(code As JavaScriptErrorCode) 15 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 16 | End Sub 17 | 18 | ''' 19 | ''' Initializes a new instance of the class. 20 | ''' 21 | ''' The error code returned. 22 | ''' The error message. 23 | Public Sub New(code As JavaScriptErrorCode, message As String) 24 | MyBase.New(code, message) 25 | End Sub 26 | 27 | ''' 28 | ''' Initializes a new instance of the class. 29 | ''' 30 | ''' The serialization info. 31 | ''' The streaming context. 32 | Private Sub New(info As SerializationInfo, context As StreamingContext) 33 | MyBase.New(info, context) 34 | End Sub 35 | End Class 36 | End Namespace 37 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptException.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.Serialization 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' An exception returned from the Chakra engine. 6 | ''' 7 | 8 | Public Class JavaScriptException 9 | Inherits Exception 10 | ''' 11 | ''' The error code. 12 | ''' 13 | Private ReadOnly code As JavaScriptErrorCode 14 | 15 | ''' 16 | ''' Initializes a new instance of the class. 17 | ''' 18 | ''' The error code returned. 19 | Public Sub New(code As JavaScriptErrorCode) 20 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 21 | End Sub 22 | 23 | ''' 24 | ''' Initializes a new instance of the class. 25 | ''' 26 | ''' The error code returned. 27 | ''' The error message. 28 | Public Sub New(code As JavaScriptErrorCode, message As String) 29 | MyBase.New(message) 30 | Me.code = code 31 | End Sub 32 | 33 | ''' 34 | ''' Initializes a new instance of the class. 35 | ''' 36 | ''' The serialization info. 37 | ''' The streaming context. 38 | Protected Sub New(info As SerializationInfo, context As StreamingContext) 39 | MyBase.New(info, context) 40 | If info IsNot Nothing Then 41 | code = DirectCast(info.GetUInt32("code"), JavaScriptErrorCode) 42 | End If 43 | End Sub 44 | 45 | ''' 46 | ''' Serializes the exception information. 47 | ''' 48 | ''' The serialization information. 49 | ''' The streaming context. 50 | Public Overrides Sub GetObjectData(info As SerializationInfo, context As StreamingContext) 51 | MyBase.GetObjectData(info, context) 52 | info.AddValue("code", CUInt(code)) 53 | End Sub 54 | 55 | ''' 56 | ''' Gets the error code. 57 | ''' 58 | Public ReadOnly Property ErrorCode() As JavaScriptErrorCode 59 | Get 60 | Return code 61 | End Get 62 | End Property 63 | End Class 64 | End Namespace 65 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptFatalException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' A fatal exception occurred. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptFatalException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' Initializes a new instance of the class. 13 | ''' 14 | ''' The error code returned. 15 | Public Sub New(code As JavaScriptErrorCode) 16 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 17 | End Sub 18 | 19 | ''' 20 | ''' Initializes a new instance of the class. 21 | ''' 22 | ''' The error code returned. 23 | ''' The error message. 24 | Public Sub New(code As JavaScriptErrorCode, message As String) 25 | MyBase.New(code, message) 26 | End Sub 27 | 28 | ''' 29 | ''' Initializes a new instance of the class. 30 | ''' 31 | ''' The serialization info. 32 | ''' The streaming context. 33 | Private Sub New(info As SerializationInfo, context As StreamingContext) 34 | MyBase.New(info, context) 35 | End Sub 36 | End Class 37 | End Namespace 38 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptMemoryAllocationCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' User implemented callback routine for memory allocation events 6 | ''' 7 | ''' The state passed to SetRuntimeMemoryAllocationCallback. 8 | ''' The type of type allocation event. 9 | ''' The size of the allocation. 10 | ''' 11 | ''' For the Allocate event, returning true allows the runtime to continue with 12 | ''' allocation. Returning false indicates the allocation request is rejected. The return value 13 | ''' is ignored for other allocation events. 14 | ''' 15 | Public Delegate Function JavaScriptMemoryAllocationCallback(callbackState As IntPtr, allocationEvent As JavaScriptMemoryEventType, allocationSize As UIntPtr) As Boolean 16 | End Namespace 17 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptMemoryEventType.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' Allocation callback event type. 4 | ''' 5 | Public Enum JavaScriptMemoryEventType 6 | ''' 7 | ''' Indicates a request for memory allocation. 8 | ''' 9 | Allocate = 0 10 | 11 | ''' 12 | ''' Indicates a memory freeing event. 13 | ''' 14 | Free = 1 15 | 16 | ''' 17 | ''' Indicates a failed allocation event. 18 | ''' 19 | Failure = 2 20 | End Enum 21 | End Namespace 22 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptNativeFunction.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.InteropServices 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A function callback. 6 | ''' 7 | ''' 8 | ''' A Function object that represents the function being invoked. 9 | ''' 10 | ''' Indicates whether this is a regular call or a 'new' call. 11 | ''' The arguments to the call. 12 | ''' The number of arguments. 13 | ''' The callback data, if any. 14 | ''' The result of the call, if any. 15 | Public Delegate Function JavaScriptNativeFunction(callee As JavaScriptValue, isConstructCall As Boolean, arguments As JavaScriptValue(), argumentCount As UShort, callbackData As IntPtr) As JavaScriptValue 16 | End Namespace 17 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptObjectFinalizeCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A finalization callback. 6 | ''' 7 | ''' 8 | ''' The external data that was passed in when creating the object being finalized. 9 | ''' 10 | Public Delegate Sub JavaScriptObjectFinalizeCallback(data As IntPtr) 11 | End Namespace 12 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptRuntimeAttributes.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Diagnostics.CodeAnalysis 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' Attributes of a runtime. 7 | ''' 8 | 9 | Public Enum JavaScriptRuntimeAttributes 10 | ''' 11 | ''' No special attributes. 12 | ''' 13 | None = &H0 14 | 15 | ''' 16 | ''' The runtime will not do any work (such as garbage collection) on background threads. 17 | ''' 18 | DisableBackgroundWork = &H1 19 | 20 | ''' 21 | ''' The runtime should support reliable script interruption. This increases the number of 22 | ''' places where the runtime will check for a script interrupt request at the cost of a 23 | ''' small amount of runtime performance. 24 | ''' 25 | AllowScriptInterrupt = &H2 26 | 27 | ''' 28 | ''' Host will call Idle, so enable idle processing. Otherwise, the runtime will manage 29 | ''' memory slightly more aggressively. 30 | ''' 31 | EnableIdleProcessing = &H4 32 | 33 | ''' 34 | ''' Runtime will not generate native code. 35 | ''' 36 | DisableNativeCodeGeneration = &H8 37 | 38 | ''' 39 | ''' Using Eval or Function constructor will throw an exception. 40 | ''' 41 | 42 | DisableEval = &H10 43 | End Enum 44 | End Namespace 45 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptRuntimeVersion.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' Version of the runtime. 4 | ''' 5 | Public Enum JavaScriptRuntimeVersion 6 | ''' 7 | ''' Create runtime with IE10 version. 8 | ''' 9 | Version10 = 0 10 | 11 | ''' 12 | ''' Create runtime with IE11 version. 13 | ''' 14 | Version11 = 1 15 | 16 | ''' 17 | ''' Create runtime with highest version present on the machine at runtime. 18 | ''' 19 | VersionEdge = -1 20 | End Enum 21 | End Namespace 22 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptScriptException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' A script exception. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptScriptException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' The error. 13 | ''' 14 | 15 | Private ReadOnly errorObject As JavaScriptValue 16 | 17 | ''' 18 | ''' Initializes a new instance of the class. 19 | ''' 20 | ''' The error code returned. 21 | ''' The JavaScript error object. 22 | Public Sub New(code As JavaScriptErrorCode, errorObject As JavaScriptValue) 23 | Me.New(code, errorObject, "JavaScript Exception") 24 | End Sub 25 | 26 | ''' 27 | ''' Initializes a new instance of the class. 28 | ''' 29 | ''' The error code returned. 30 | ''' The JavaScript error object. 31 | ''' The error message. 32 | Public Sub New(code As JavaScriptErrorCode, errorObject As JavaScriptValue, message As String) 33 | MyBase.New(code, message) 34 | Me.errorObject = errorObject 35 | End Sub 36 | 37 | ''' 38 | ''' Initializes a new instance of the class. 39 | ''' 40 | ''' The serialization info. 41 | ''' The streaming context. 42 | Private Sub New(info As SerializationInfo, context As StreamingContext) 43 | MyBase.New(info, context) 44 | End Sub 45 | 46 | ''' 47 | ''' Gets a JavaScript object representing the script error. 48 | ''' 49 | Public ReadOnly Property JavaScriptError() As JavaScriptValue 50 | Get 51 | Return errorObject 52 | End Get 53 | End Property 54 | End Class 55 | End Namespace 56 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptThreadServiceCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A thread service callback. 6 | ''' 7 | ''' 8 | ''' The host can specify a background thread service when creating a runtime. If 9 | ''' specified, then background work items will be passed to the host using this callback. The 10 | ''' host is expected to either begin executing the background work item immediately and return 11 | ''' true or return false and the runtime will handle the work item in-thread. 12 | ''' 13 | ''' The callback for the background work item. 14 | ''' The data argument to be passed to the callback. 15 | ''' Whether the thread service will execute the callback. 16 | Public Delegate Function JavaScriptThreadServiceCallback(callbackFunction As JavaScriptBackgroundWorkItemCallback, callbackData As IntPtr) As Boolean 17 | End Namespace 18 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptUsageException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' An API usage exception occurred. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptUsageException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' Initializes a new instance of the class. 13 | ''' 14 | ''' The error code returned. 15 | Public Sub New(code As JavaScriptErrorCode) 16 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 17 | End Sub 18 | 19 | ''' 20 | ''' Initializes a new instance of the class. 21 | ''' 22 | ''' The error code returned. 23 | ''' The error message. 24 | Public Sub New(code As JavaScriptErrorCode, message As String) 25 | MyBase.New(code, message) 26 | End Sub 27 | 28 | ''' 29 | ''' Initializes a new instance of the class. 30 | ''' 31 | ''' The serialization info. 32 | ''' The streaming context. 33 | Private Sub New(info As SerializationInfo, context As StreamingContext) 34 | MyBase.New(info, context) 35 | End Sub 36 | End Class 37 | End Namespace 38 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Hosting/JavaScriptValueType.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' The JavaScript type of a JavaScriptValue. 4 | ''' 5 | Public Enum JavaScriptValueType 6 | ''' 7 | ''' The value is the undefined value. 8 | ''' 9 | Undefined = 0 10 | 11 | ''' 12 | ''' The value is the null value. 13 | ''' 14 | Null = 1 15 | 16 | ''' 17 | ''' The value is a JavaScript number value. 18 | ''' 19 | Number = 2 20 | 21 | ''' 22 | ''' The value is a JavaScript string value. 23 | ''' 24 | [String] = 3 25 | 26 | ''' 27 | ''' The value is a JavaScript Boolean value. 28 | ''' 29 | [Boolean] = 4 30 | 31 | ''' 32 | ''' The value is a JavaScript object value. 33 | ''' 34 | [Object] = 5 35 | 36 | ''' 37 | ''' The value is a JavaScript function object value. 38 | ''' 39 | [Function] = 6 40 | 41 | ''' 42 | ''' The value is a JavaScript error object value. 43 | ''' 44 | [Error] = 7 45 | 46 | ''' 47 | ''' The value is a JavaScript array object value. 48 | ''' 49 | Array = 8 50 | End Enum 51 | End Namespace 52 | -------------------------------------------------------------------------------- /src/win10/ie/vb/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System.Reflection 2 | Imports System.Runtime.InteropServices 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/win10/ie/vb/Profiler.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.InteropServices 2 | Imports ChakraHost.Hosting 3 | 4 | 5 | Friend Class Profiler 6 | Implements IActiveScriptProfilerCallback2 7 | 8 | Public Sub OnFunctionEnterByName(pwszFunctionName As String, type As ProfilerScriptType) Implements IActiveScriptProfilerCallback2.OnFunctionEnterByName 9 | Console.WriteLine("Profiler.OnFunctionEnterByName: {0}, {1}", pwszFunctionName, type) 10 | End Sub 11 | 12 | Public Sub OnFunctionExitByName(pwszFunctionName As String, type As ProfilerScriptType) Implements IActiveScriptProfilerCallback2.OnFunctionExitByName 13 | Console.WriteLine("Profiler.OnFunctionExitByName: {0}, {1}", pwszFunctionName, type) 14 | End Sub 15 | 16 | Public Sub Initialize(dwContext As UInteger) Implements IActiveScriptProfilerCallback.Initialize 17 | Console.WriteLine("Profiler.Initialize: {0}", dwContext) 18 | End Sub 19 | 20 | Public Sub Shutdown(hrReason As UInteger) Implements IActiveScriptProfilerCallback.Shutdown 21 | Console.WriteLine("Profiler.Shutdown: {0}", hrReason) 22 | End Sub 23 | 24 | Public Sub ScriptCompiled(scriptId As Integer, type As ProfilerScriptType, pIDebugDocumentContext As IntPtr) Implements IActiveScriptProfilerCallback.ScriptCompiled 25 | Console.WriteLine("Profiler.ScriptCompiled: {0}, {1}", scriptId, type) 26 | End Sub 27 | 28 | Public Sub FunctionCompiled(functionId As Integer, scriptId As Integer, pwszFunctionName As String, pwszFunctionNameHint As String, pIDebugDocumentContext As IntPtr) Implements IActiveScriptProfilerCallback.FunctionCompiled 29 | Console.WriteLine("Profiler.FunctionCompiled: {0}, {1}, {2}, {3}", functionId, scriptId, pwszFunctionName, pwszFunctionNameHint) 30 | End Sub 31 | 32 | Public Sub OnFunctionEnter(scriptId As Integer, functionId As Integer) Implements IActiveScriptProfilerCallback.OnFunctionEnter 33 | Console.WriteLine("Profiler.OnFunctionEnter: {0}, {1}", scriptId, functionId) 34 | End Sub 35 | 36 | Public Sub OnFunctionExit(scriptId As Integer, functionId As Integer) Implements IActiveScriptProfilerCallback.OnFunctionExit 37 | Console.WriteLine("Profiler.OnFunctionExit: {0}, {1}", scriptId, functionId) 38 | End Sub 39 | End Class 40 | -------------------------------------------------------------------------------- /src/win10/ie/vb/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/win8.1/cpp/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20827.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChakraHost", "ChakraHost.vcxproj", "{CC586644-5E57-4523-9DEA-E82F4FE9F91D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Debug|Win32.Build.0 = Debug|Win32 16 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Release|Win32.ActiveCfg = Release|Win32 17 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win8.1/cpp/ChakraHost.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {CC586644-5E57-4523-9DEA-E82F4FE9F91D} 15 | Win32Proj 16 | ChakraHost 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | Use 51 | Level3 52 | Disabled 53 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 54 | true 55 | 56 | 57 | Console 58 | true 59 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;jsrt.lib;%(AdditionalDependencies) 60 | 61 | 62 | 63 | 64 | Level3 65 | Use 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 70 | true 71 | 72 | 73 | Console 74 | true 75 | true 76 | true 77 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;jsrt.lib;%(AdditionalDependencies) 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | Create 89 | Create 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/win8.1/cpp/ChakraHost.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/win8.1/cpp/Profiler.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | Profiler::Profiler(void) 10 | { 11 | m_refCount = 1; 12 | } 13 | 14 | Profiler::~Profiler(void) 15 | { 16 | } 17 | 18 | HRESULT Profiler::QueryInterface(REFIID riid, void **ppvObj) 19 | { 20 | if (riid == IID_IUnknown) 21 | { 22 | *ppvObj = (IUnknown *) this; 23 | } 24 | else if (riid == IID_IActiveScriptProfilerCallback) 25 | { 26 | *ppvObj = (IActiveScriptProfilerCallback *) this; 27 | } 28 | else if (riid == IID_IActiveScriptProfilerCallback2) 29 | { 30 | *ppvObj = (IActiveScriptProfilerCallback2 *) this; 31 | } 32 | else 33 | { 34 | *ppvObj = NULL; 35 | return E_NOINTERFACE; 36 | } 37 | 38 | AddRef(); 39 | return NOERROR; 40 | } 41 | 42 | ULONG Profiler::AddRef() 43 | { 44 | return InterlockedIncrement(&m_refCount); 45 | } 46 | 47 | ULONG Profiler::Release() 48 | { 49 | long lw; 50 | 51 | if (0 == (lw = InterlockedDecrement(&m_refCount))) 52 | { 53 | delete this; 54 | } 55 | return lw; 56 | } 57 | 58 | HRESULT Profiler::Initialize(DWORD dwContext) 59 | { 60 | fwprintf(stdout, L"Profiler::Initialize: 0x%lx\n", dwContext); 61 | return S_OK; 62 | } 63 | 64 | HRESULT Profiler::Shutdown(HRESULT hrReason) 65 | { 66 | fwprintf(stdout, L"Profiler::Shutdown: 0x%lx\n", hrReason); 67 | return S_OK; 68 | } 69 | 70 | HRESULT Profiler::ScriptCompiled(PROFILER_TOKEN scriptId, PROFILER_SCRIPT_TYPE type, IUnknown *pIDebugDocumentContext) 71 | { 72 | fwprintf(stdout, L"Profiler::ScriptCompiled: 0x%lx, %u\n", scriptId, type); 73 | return S_OK; 74 | } 75 | 76 | HRESULT Profiler::FunctionCompiled(PROFILER_TOKEN functionId, PROFILER_TOKEN scriptId, const wchar_t *pwszFunctionName, const wchar_t *pwszFunctionNameHint, IUnknown *pIDebugDocumentContext) 77 | { 78 | fwprintf(stdout, L"Profiler::FunctionCompiled: 0x%lx, 0x%lx, %s, %s\n", scriptId, functionId, pwszFunctionName, pwszFunctionNameHint); 79 | return S_OK; 80 | } 81 | 82 | HRESULT Profiler::OnFunctionEnter(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId) 83 | { 84 | fwprintf(stdout, L"Profiler::OnFunctionEnter: 0x%lx, 0x%lx\n", scriptId, functionId); 85 | return S_OK; 86 | } 87 | 88 | HRESULT Profiler::OnFunctionExit(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId) 89 | { 90 | fwprintf(stdout, L"Profiler::OnFunctionExit: 0x%lx, 0x%lx\n", scriptId, functionId); 91 | return S_OK; 92 | } 93 | 94 | HRESULT Profiler::OnFunctionEnterByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type) 95 | { 96 | fwprintf(stdout, L"Profiler::OnFunctionEnterByName: %s, %u\n", pwszFunctionName, type); 97 | return S_OK; 98 | } 99 | 100 | HRESULT Profiler::OnFunctionExitByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type) 101 | { 102 | fwprintf(stdout, L"Profiler::OnFunctionExitByName: %s, %u\n", pwszFunctionName, type); 103 | return S_OK; 104 | } 105 | -------------------------------------------------------------------------------- /src/win8.1/cpp/Profiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Profiler sealed : public IActiveScriptProfilerCallback2 4 | { 5 | private: 6 | long m_refCount; 7 | 8 | public: 9 | Profiler(void); 10 | ~Profiler(void); 11 | 12 | // IUnknown 13 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObj); 14 | ULONG STDMETHODCALLTYPE AddRef(void); 15 | ULONG STDMETHODCALLTYPE Release(void); 16 | 17 | // IActiveScriptProfilerCallback 18 | HRESULT STDMETHODCALLTYPE Initialize(DWORD dwContext); 19 | HRESULT STDMETHODCALLTYPE Shutdown(HRESULT hrReason); 20 | HRESULT STDMETHODCALLTYPE ScriptCompiled(PROFILER_TOKEN scriptId, PROFILER_SCRIPT_TYPE type, IUnknown *pIDebugDocumentContext); 21 | HRESULT STDMETHODCALLTYPE FunctionCompiled(PROFILER_TOKEN functionId, PROFILER_TOKEN scriptId, const wchar_t *pwszFunctionName, const wchar_t *pwszFunctionNameHint, IUnknown *pIDebugDocumentContext); 22 | HRESULT STDMETHODCALLTYPE OnFunctionEnter(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId); 23 | HRESULT STDMETHODCALLTYPE OnFunctionExit(PROFILER_TOKEN scriptId, PROFILER_TOKEN functionId); 24 | 25 | // IActiveScriptProfilerCallback2 26 | HRESULT STDMETHODCALLTYPE OnFunctionEnterByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type); 27 | HRESULT STDMETHODCALLTYPE OnFunctionExitByName(const wchar_t *pwszFunctionName, PROFILER_SCRIPT_TYPE type); 28 | }; 29 | -------------------------------------------------------------------------------- /src/win8.1/cpp/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /src/win8.1/cpp/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Profiler.h" 7 | 8 | #define IfFailError(v, e) \ 9 | { \ 10 | JsErrorCode error = (v); \ 11 | if (error != JsNoError) \ 12 | { \ 13 | fwprintf(stderr, L"chakrahost: fatal error: %s.\n", (e)); \ 14 | goto error; \ 15 | } \ 16 | } 17 | 18 | #define IfFailRet(v) \ 19 | { \ 20 | JsErrorCode error = (v); \ 21 | if (error != JsNoError) \ 22 | { \ 23 | return error; \ 24 | } \ 25 | } 26 | 27 | #define IfFailThrow(v, e) \ 28 | { \ 29 | JsErrorCode error = (v); \ 30 | if (error != JsNoError) \ 31 | { \ 32 | ThrowException((e)); \ 33 | return JS_INVALID_REFERENCE; \ 34 | } \ 35 | } 36 | 37 | #define IfComFailError(v) \ 38 | { \ 39 | hr = (v); \ 40 | if (FAILED(hr)) \ 41 | { \ 42 | goto error; \ 43 | } \ 44 | } 45 | 46 | #define IfComFailRet(v) \ 47 | { \ 48 | HRESULT hr = (v); \ 49 | if (FAILED(hr)) \ 50 | { \ 51 | return hr; \ 52 | } \ 53 | } 54 | -------------------------------------------------------------------------------- /src/win8.1/cs/ChakraHost.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D672BC49-C454-4975-BD25-A555B9BDD793} 8 | Exe 9 | Properties 10 | ChakraHost 11 | ChakraHost 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 74 | -------------------------------------------------------------------------------- /src/win8.1/cs/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChakraHost", "ChakraHost.csproj", "{D672BC49-C454-4975-BD25-A555B9BDD793}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {D672BC49-C454-4975-BD25-A555B9BDD793}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptBackgroundWorkItemCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A background work item callback. 7 | /// 8 | /// 9 | /// This is passed to the host's thread service (if provided) to allow the host to 10 | /// invoke the work item callback on the background thread of its choice. 11 | /// 12 | /// Data argument passed to the thread service. 13 | public delegate void JavaScriptBackgroundWorkItemCallback(IntPtr callbackData); 14 | } 15 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptBeforeCollectCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A callback called before collection. 7 | /// 8 | /// The state passed to SetBeforeCollectCallback. 9 | public delegate void JavaScriptBeforeCollectCallback(IntPtr callbackState); 10 | } 11 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptEngineException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An exception that occurred in the workings of the JavaScript engine itself. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptEngineException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptEngineException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptEngineException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptEngineException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An exception returned from the Chakra engine. 8 | /// 9 | [Serializable] 10 | public class JavaScriptException : Exception 11 | { 12 | /// 13 | /// The error code. 14 | /// 15 | private readonly JavaScriptErrorCode code; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The error code returned. 21 | public JavaScriptException(JavaScriptErrorCode code) : 22 | this(code, "A fatal exception has occurred in a JavaScript runtime") 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The error code returned. 30 | /// The error message. 31 | public JavaScriptException(JavaScriptErrorCode code, string message) : 32 | base(message) 33 | { 34 | this.code = code; 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The serialization info. 41 | /// The streaming context. 42 | protected JavaScriptException(SerializationInfo info, StreamingContext context) : 43 | base(info, context) 44 | { 45 | if (info != null) 46 | { 47 | code = (JavaScriptErrorCode) info.GetUInt32("code"); 48 | } 49 | } 50 | 51 | /// 52 | /// Serializes the exception information. 53 | /// 54 | /// The serialization information. 55 | /// The streaming context. 56 | public override void GetObjectData(SerializationInfo info, StreamingContext context) 57 | { 58 | base.GetObjectData(info, context); 59 | info.AddValue("code", (uint)code); 60 | } 61 | 62 | /// 63 | /// Gets the error code. 64 | /// 65 | public JavaScriptErrorCode ErrorCode 66 | { 67 | get { return code; } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptFatalException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// A fatal exception occurred. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptFatalException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptFatalException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptFatalException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptFatalException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptMemoryAllocationCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// User implemented callback routine for memory allocation events 7 | /// 8 | /// The state passed to SetRuntimeMemoryAllocationCallback. 9 | /// The type of type allocation event. 10 | /// The size of the allocation. 11 | /// 12 | /// For the Allocate event, returning true allows the runtime to continue with 13 | /// allocation. Returning false indicates the allocation request is rejected. The return value 14 | /// is ignored for other allocation events. 15 | /// 16 | public delegate bool JavaScriptMemoryAllocationCallback(IntPtr callbackState, JavaScriptMemoryEventType allocationEvent, UIntPtr allocationSize); 17 | } 18 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptMemoryEventType.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | /// 4 | /// Allocation callback event type. 5 | /// 6 | public enum JavaScriptMemoryEventType 7 | { 8 | /// 9 | /// Indicates a request for memory allocation. 10 | /// 11 | Allocate = 0, 12 | 13 | /// 14 | /// Indicates a memory freeing event. 15 | /// 16 | Free = 1, 17 | 18 | /// 19 | /// Indicates a failed allocation event. 20 | /// 21 | Failure = 2 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptNativeFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ChakraHost.Hosting 4 | { 5 | using System.Runtime.InteropServices; 6 | 7 | /// 8 | /// A function callback. 9 | /// 10 | /// 11 | /// A Function object that represents the function being invoked. 12 | /// 13 | /// Indicates whether this is a regular call or a 'new' call. 14 | /// The arguments to the call. 15 | /// The number of arguments. 16 | /// Callback data, if any. 17 | /// The result of the call, if any. 18 | public delegate JavaScriptValue JavaScriptNativeFunction(JavaScriptValue callee, bool isConstructCall, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] JavaScriptValue[] arguments, ushort argumentCount, IntPtr callbackData); 19 | } 20 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptObjectFinalizeCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A finalization callback. 7 | /// 8 | /// 9 | /// The external data that was passed in when creating the object being finalized. 10 | /// 11 | public delegate void JavaScriptObjectFinalizeCallback(IntPtr data); 12 | } 13 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptRuntimeAttributes.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | /// 7 | /// Attributes of a runtime. 8 | /// 9 | [Flags] 10 | public enum JavaScriptRuntimeAttributes 11 | { 12 | /// 13 | /// No special attributes. 14 | /// 15 | None = 0x00000000, 16 | 17 | /// 18 | /// The runtime will not do any work (such as garbage collection) on background threads. 19 | /// 20 | DisableBackgroundWork = 0x00000001, 21 | 22 | /// 23 | /// The runtime should support reliable script interruption. This increases the number of 24 | /// places where the runtime will check for a script interrupt request at the cost of a 25 | /// small amount of runtime performance. 26 | /// 27 | AllowScriptInterrupt = 0x00000002, 28 | 29 | /// 30 | /// Host will call Idle, so enable idle processing. Otherwise, the runtime will manage 31 | /// memory slightly more aggressively. 32 | /// 33 | EnableIdleProcessing = 0x00000004, 34 | 35 | /// 36 | /// Runtime will not generate native code. 37 | /// 38 | DisableNativeCodeGeneration = 0x00000008, 39 | 40 | /// 41 | /// Using Eval or Function constructor will throw an exception. 42 | /// 43 | [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Eval is a valid function name.")] 44 | DisableEval = 0x00000010, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptRuntimeVersion.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | /// 4 | /// Version of the runtime. 5 | /// 6 | public enum JavaScriptRuntimeVersion 7 | { 8 | /// 9 | /// Create runtime with IE10 version. 10 | /// 11 | Version10 = 0, 12 | 13 | /// 14 | /// Create runtime with IE11 version. 15 | /// 16 | Version11 = 1, 17 | 18 | /// 19 | /// Create runtime with highest version present on the machine at runtime. 20 | /// 21 | VersionEdge = -1, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptScriptException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// A script exception. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptScriptException : JavaScriptException 11 | { 12 | /// 13 | /// The error. 14 | /// 15 | [NonSerialized] 16 | private readonly JavaScriptValue error; 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The error code returned. 22 | /// The JavaScript error object. 23 | public JavaScriptScriptException(JavaScriptErrorCode code, JavaScriptValue error) : 24 | this(code, error, "JavaScript Exception") 25 | { 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The error code returned. 32 | /// The JavaScript error object. 33 | /// The error message. 34 | public JavaScriptScriptException(JavaScriptErrorCode code, JavaScriptValue error, string message) : 35 | base(code, message) 36 | { 37 | this.error = error; 38 | } 39 | 40 | /// 41 | /// Initializes a new instance of the class. 42 | /// 43 | /// The serialization info. 44 | /// The streaming context. 45 | private JavaScriptScriptException(SerializationInfo info, StreamingContext context) : 46 | base(info, context) 47 | { 48 | } 49 | 50 | /// 51 | /// Gets a JavaScript object representing the script error. 52 | /// 53 | public JavaScriptValue Error 54 | { 55 | get 56 | { 57 | return error; 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptThreadServiceCallback.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | 5 | /// 6 | /// A thread service callback. 7 | /// 8 | /// 9 | /// The host can specify a background thread service when creating a runtime. If 10 | /// specified, then background work items will be passed to the host using this callback. The 11 | /// host is expected to either begin executing the background work item immediately and return 12 | /// true or return false and the runtime will handle the work item in-thread. 13 | /// 14 | /// The callback for the background work item. 15 | /// The data argument to be passed to the callback. 16 | /// Whether the thread service will execute the callback. 17 | public delegate bool JavaScriptThreadServiceCallback(JavaScriptBackgroundWorkItemCallback callbackFunction, IntPtr callbackData); 18 | } 19 | -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptUsageException.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | /// 7 | /// An API usage exception occurred. 8 | /// 9 | [Serializable] 10 | public sealed class JavaScriptUsageException : JavaScriptException 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The error code returned. 16 | public JavaScriptUsageException(JavaScriptErrorCode code) : 17 | this(code, "A fatal exception has occurred in a JavaScript runtime") 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class. 23 | /// 24 | /// The error code returned. 25 | /// The error message. 26 | public JavaScriptUsageException(JavaScriptErrorCode code, string message) : 27 | base(code, message) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The serialization info. 35 | /// The streaming context. 36 | private JavaScriptUsageException(SerializationInfo info, StreamingContext context) : 37 | base(info, context) 38 | { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/win8.1/cs/Hosting/JavaScriptValueType.cs: -------------------------------------------------------------------------------- 1 | namespace ChakraHost.Hosting 2 | { 3 | /// 4 | /// The JavaScript type of a JavaScriptValue. 5 | /// 6 | public enum JavaScriptValueType 7 | { 8 | /// 9 | /// The value is the undefined value. 10 | /// 11 | Undefined = 0, 12 | 13 | /// 14 | /// The value is the null value. 15 | /// 16 | Null = 1, 17 | 18 | /// 19 | /// The value is a JavaScript number value. 20 | /// 21 | Number = 2, 22 | 23 | /// 24 | /// The value is a JavaScript string value. 25 | /// 26 | String = 3, 27 | 28 | /// 29 | /// The value is a JavaScript Boolean value. 30 | /// 31 | Boolean = 4, 32 | 33 | /// 34 | /// The value is a JavaScript object value. 35 | /// 36 | Object = 5, 37 | 38 | /// 39 | /// The value is a JavaScript function object value. 40 | /// 41 | Function = 6, 42 | 43 | /// 44 | /// The value is a JavaScript error object value. 45 | /// 46 | Error = 7, 47 | 48 | /// 49 | /// The value is a JavaScript array object value. 50 | /// 51 | Array = 8, 52 | } 53 | } -------------------------------------------------------------------------------- /src/win8.1/cs/Profiler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using ChakraHost.Hosting; 4 | 5 | namespace ChakraHost 6 | { 7 | [Guid("C3C44476-A1CE-403E-AFE2-D53EF618B139")] 8 | internal class Profiler : Native.IActiveScriptProfilerCallback2 9 | { 10 | public void OnFunctionEnterByName(string pwszFunctionName, Native.ProfilerScriptType type) 11 | { 12 | Console.WriteLine("Profiler.OnFunctionEnterByName: {0}, {1}", pwszFunctionName, type); 13 | } 14 | 15 | public void OnFunctionExitByName(string pwszFunctionName, Native.ProfilerScriptType type) 16 | { 17 | Console.WriteLine("Profiler.OnFunctionExitByName: {0}, {1}", pwszFunctionName, type); 18 | } 19 | 20 | public void Initialize(uint dwContext) 21 | { 22 | Console.WriteLine("Profiler.Initialize: {0}", dwContext); 23 | } 24 | 25 | public void Shutdown(uint hrReason) 26 | { 27 | Console.WriteLine("Profiler.Shutdown: {0}", hrReason); 28 | } 29 | 30 | public void ScriptCompiled(int scriptId, Native.ProfilerScriptType type, IntPtr pIDebugDocumentContext) 31 | { 32 | Console.WriteLine("Profiler.ScriptCompiled: {0}, {1}", scriptId, type); 33 | } 34 | 35 | public void FunctionCompiled(int functionId, int scriptId, string pwszFunctionName, string pwszFunctionNameHint, IntPtr pIDebugDocumentContext) 36 | { 37 | Console.WriteLine("Profiler.FunctionCompiled: {0}, {1}, {2}, {3}", functionId, scriptId, pwszFunctionName, pwszFunctionNameHint); 38 | } 39 | 40 | public void OnFunctionEnter(int scriptId, int functionId) 41 | { 42 | Console.WriteLine("Profiler.OnFunctionEnter: {0}, {1}", scriptId, functionId); 43 | } 44 | 45 | public void OnFunctionExit(int scriptId, int functionId) 46 | { 47 | Console.WriteLine("Profiler.OnFunctionExit: {0}, {1}", scriptId, functionId); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/win8.1/cs/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: ComVisible(false)] 5 | [assembly: AssemblyVersion("1.0.0.0")] 6 | [assembly: AssemblyFileVersion("1.0.0.0")] 7 | [module: DefaultCharSet(CharSet.Unicode)] 8 | -------------------------------------------------------------------------------- /src/win8.1/memory/ChakraMemoryProfile.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChakraMemoryProfile", "ChakraMemoryProfile.vcxproj", "{A3A67D8F-E613-4348-B432-695A0FB3F63F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Debug|Win32.Build.0 = Debug|Win32 16 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Release|Win32.ActiveCfg = Release|Win32 17 | {A3A67D8F-E613-4348-B432-695A0FB3F63F}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win8.1/memory/ChakraMemoryProfile.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {A3A67D8F-E613-4348-B432-695A0FB3F63F} 15 | Win32Proj 16 | ChakraMemoryProfile 17 | 18 | 19 | 20 | DynamicLibrary 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | DynamicLibrary 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | Use 51 | Level3 52 | Disabled 53 | WIN32;_DEBUG;_WINDOWS;_USRDLL;CHAKRAMEMORYPROFILE_EXPORTS;%(PreprocessorDefinitions) 54 | 55 | 56 | Windows 57 | true 58 | 59 | 60 | 61 | 62 | Level3 63 | Use 64 | MaxSpeed 65 | true 66 | true 67 | WIN32;NDEBUG;_WINDOWS;_USRDLL;CHAKRAMEMORYPROFILE_EXPORTS;%(PreprocessorDefinitions) 68 | 69 | 70 | Windows 71 | true 72 | true 73 | true 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Create 83 | Create 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/win8.1/memory/ChakraMemoryProfile.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/win8.1/memory/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /src/win8.1/memory/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | -------------------------------------------------------------------------------- /src/win8.1/vb/ChakraHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.20617.1 PREVIEW 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ChakraHost", "ChakraHost.vbproj", "{04158E78-A589-4E46-AC4A-490E73E2E750}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {04158E78-A589-4E46-AC4A-490E73E2E750}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/win8.1/vb/ChakraHost.vbproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {04158E78-A589-4E46-AC4A-490E73E2E750} 8 | Exe 9 | ChakraHost.Program 10 | ChakraHost 11 | ChakraHost 12 | 512 13 | Console 14 | v4.5 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | true 21 | true 22 | bin\Debug\ 23 | ChakraHost.xml 24 | 25 | 26 | 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | false 32 | true 33 | true 34 | bin\Release\ 35 | ChakraHost.xml 36 | 37 | 38 | 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 39 | 40 | 41 | On 42 | 43 | 44 | Binary 45 | 46 | 47 | On 48 | 49 | 50 | On 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 107 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptBackgroundWorkItemCallback.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' A background work item callback. 4 | ''' 5 | ''' 6 | ''' This is passed to the host's thread service (if provided) to allow the host to 7 | ''' invoke the work item callback on the background thread of its choice. 8 | ''' 9 | ''' Data argument passed to the thread service. 10 | Public Delegate Sub JavaScriptBackgroundWorkItemCallback(callbackData As IntPtr) 11 | End Namespace 12 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptBeforeCollectCallback.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' A callback called before collection. 4 | ''' 5 | ''' The state passed to SetBeforeCollectCallback. 6 | Public Delegate Sub JavaScriptBeforeCollectCallback(callbackState As IntPtr) 7 | End Namespace 8 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptEngineException.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.Serialization 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' An exception that occurred in the workings of the JavaScript engine itself. 6 | ''' 7 | 8 | Public NotInheritable Class JavaScriptEngineException 9 | Inherits JavaScriptException 10 | ''' 11 | ''' Initializes a new instance of the class. 12 | ''' 13 | ''' The error code returned. 14 | Public Sub New(code As JavaScriptErrorCode) 15 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 16 | End Sub 17 | 18 | ''' 19 | ''' Initializes a new instance of the class. 20 | ''' 21 | ''' The error code returned. 22 | ''' The error message. 23 | Public Sub New(code As JavaScriptErrorCode, message As String) 24 | MyBase.New(code, message) 25 | End Sub 26 | 27 | ''' 28 | ''' Initializes a new instance of the class. 29 | ''' 30 | ''' The serialization info. 31 | ''' The streaming context. 32 | Private Sub New(info As SerializationInfo, context As StreamingContext) 33 | MyBase.New(info, context) 34 | End Sub 35 | End Class 36 | End Namespace 37 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptException.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.Serialization 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' An exception returned from the Chakra engine. 6 | ''' 7 | 8 | Public Class JavaScriptException 9 | Inherits Exception 10 | ''' 11 | ''' The error code. 12 | ''' 13 | Private ReadOnly code As JavaScriptErrorCode 14 | 15 | ''' 16 | ''' Initializes a new instance of the class. 17 | ''' 18 | ''' The error code returned. 19 | Public Sub New(code As JavaScriptErrorCode) 20 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 21 | End Sub 22 | 23 | ''' 24 | ''' Initializes a new instance of the class. 25 | ''' 26 | ''' The error code returned. 27 | ''' The error message. 28 | Public Sub New(code As JavaScriptErrorCode, message As String) 29 | MyBase.New(message) 30 | Me.code = code 31 | End Sub 32 | 33 | ''' 34 | ''' Initializes a new instance of the class. 35 | ''' 36 | ''' The serialization info. 37 | ''' The streaming context. 38 | Protected Sub New(info As SerializationInfo, context As StreamingContext) 39 | MyBase.New(info, context) 40 | If info IsNot Nothing Then 41 | code = DirectCast(info.GetUInt32("code"), JavaScriptErrorCode) 42 | End If 43 | End Sub 44 | 45 | ''' 46 | ''' Serializes the exception information. 47 | ''' 48 | ''' The serialization information. 49 | ''' The streaming context. 50 | Public Overrides Sub GetObjectData(info As SerializationInfo, context As StreamingContext) 51 | MyBase.GetObjectData(info, context) 52 | info.AddValue("code", CUInt(code)) 53 | End Sub 54 | 55 | ''' 56 | ''' Gets the error code. 57 | ''' 58 | Public ReadOnly Property ErrorCode() As JavaScriptErrorCode 59 | Get 60 | Return code 61 | End Get 62 | End Property 63 | End Class 64 | End Namespace 65 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptFatalException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' A fatal exception occurred. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptFatalException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' Initializes a new instance of the class. 13 | ''' 14 | ''' The error code returned. 15 | Public Sub New(code As JavaScriptErrorCode) 16 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 17 | End Sub 18 | 19 | ''' 20 | ''' Initializes a new instance of the class. 21 | ''' 22 | ''' The error code returned. 23 | ''' The error message. 24 | Public Sub New(code As JavaScriptErrorCode, message As String) 25 | MyBase.New(code, message) 26 | End Sub 27 | 28 | ''' 29 | ''' Initializes a new instance of the class. 30 | ''' 31 | ''' The serialization info. 32 | ''' The streaming context. 33 | Private Sub New(info As SerializationInfo, context As StreamingContext) 34 | MyBase.New(info, context) 35 | End Sub 36 | End Class 37 | End Namespace 38 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptMemoryAllocationCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' User implemented callback routine for memory allocation events 6 | ''' 7 | ''' The state passed to SetRuntimeMemoryAllocationCallback. 8 | ''' The type of type allocation event. 9 | ''' The size of the allocation. 10 | ''' 11 | ''' For the Allocate event, returning true allows the runtime to continue with 12 | ''' allocation. Returning false indicates the allocation request is rejected. The return value 13 | ''' is ignored for other allocation events. 14 | ''' 15 | Public Delegate Function JavaScriptMemoryAllocationCallback(callbackState As IntPtr, allocationEvent As JavaScriptMemoryEventType, allocationSize As UIntPtr) As Boolean 16 | End Namespace 17 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptMemoryEventType.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' Allocation callback event type. 4 | ''' 5 | Public Enum JavaScriptMemoryEventType 6 | ''' 7 | ''' Indicates a request for memory allocation. 8 | ''' 9 | Allocate = 0 10 | 11 | ''' 12 | ''' Indicates a memory freeing event. 13 | ''' 14 | Free = 1 15 | 16 | ''' 17 | ''' Indicates a failed allocation event. 18 | ''' 19 | Failure = 2 20 | End Enum 21 | End Namespace 22 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptNativeFunction.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.InteropServices 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A function callback. 6 | ''' 7 | ''' 8 | ''' A Function object that represents the function being invoked. 9 | ''' 10 | ''' Indicates whether this is a regular call or a 'new' call. 11 | ''' The arguments to the call. 12 | ''' The number of arguments. 13 | ''' The callback data, if any. 14 | ''' The result of the call, if any. 15 | Public Delegate Function JavaScriptNativeFunction(callee As JavaScriptValue, isConstructCall As Boolean, arguments As JavaScriptValue(), argumentCount As UShort, callbackData As IntPtr) As JavaScriptValue 16 | End Namespace 17 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptObjectFinalizeCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A finalization callback. 6 | ''' 7 | ''' 8 | ''' The external data that was passed in when creating the object being finalized. 9 | ''' 10 | Public Delegate Sub JavaScriptObjectFinalizeCallback(data As IntPtr) 11 | End Namespace 12 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptRuntimeAttributes.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Diagnostics.CodeAnalysis 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' Attributes of a runtime. 7 | ''' 8 | 9 | Public Enum JavaScriptRuntimeAttributes 10 | ''' 11 | ''' No special attributes. 12 | ''' 13 | None = &H0 14 | 15 | ''' 16 | ''' The runtime will not do any work (such as garbage collection) on background threads. 17 | ''' 18 | DisableBackgroundWork = &H1 19 | 20 | ''' 21 | ''' The runtime should support reliable script interruption. This increases the number of 22 | ''' places where the runtime will check for a script interrupt request at the cost of a 23 | ''' small amount of runtime performance. 24 | ''' 25 | AllowScriptInterrupt = &H2 26 | 27 | ''' 28 | ''' Host will call Idle, so enable idle processing. Otherwise, the runtime will manage 29 | ''' memory slightly more aggressively. 30 | ''' 31 | EnableIdleProcessing = &H4 32 | 33 | ''' 34 | ''' Runtime will not generate native code. 35 | ''' 36 | DisableNativeCodeGeneration = &H8 37 | 38 | ''' 39 | ''' Using Eval or Function constructor will throw an exception. 40 | ''' 41 | 42 | DisableEval = &H10 43 | End Enum 44 | End Namespace 45 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptRuntimeVersion.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' Version of the runtime. 4 | ''' 5 | Public Enum JavaScriptRuntimeVersion 6 | ''' 7 | ''' Create runtime with IE10 version. 8 | ''' 9 | Version10 = 0 10 | 11 | ''' 12 | ''' Create runtime with IE11 version. 13 | ''' 14 | Version11 = 1 15 | 16 | ''' 17 | ''' Create runtime with highest version present on the machine at runtime. 18 | ''' 19 | VersionEdge = -1 20 | End Enum 21 | End Namespace 22 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptScriptException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' A script exception. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptScriptException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' The error. 13 | ''' 14 | 15 | Private ReadOnly errorObject As JavaScriptValue 16 | 17 | ''' 18 | ''' Initializes a new instance of the class. 19 | ''' 20 | ''' The error code returned. 21 | ''' The JavaScript error object. 22 | Public Sub New(code As JavaScriptErrorCode, errorObject As JavaScriptValue) 23 | Me.New(code, errorObject, "JavaScript Exception") 24 | End Sub 25 | 26 | ''' 27 | ''' Initializes a new instance of the class. 28 | ''' 29 | ''' The error code returned. 30 | ''' The JavaScript error object. 31 | ''' The error message. 32 | Public Sub New(code As JavaScriptErrorCode, errorObject As JavaScriptValue, message As String) 33 | MyBase.New(code, message) 34 | Me.errorObject = errorObject 35 | End Sub 36 | 37 | ''' 38 | ''' Initializes a new instance of the class. 39 | ''' 40 | ''' The serialization info. 41 | ''' The streaming context. 42 | Private Sub New(info As SerializationInfo, context As StreamingContext) 43 | MyBase.New(info, context) 44 | End Sub 45 | 46 | ''' 47 | ''' Gets a JavaScript object representing the script error. 48 | ''' 49 | Public ReadOnly Property JavaScriptError() As JavaScriptValue 50 | Get 51 | Return errorObject 52 | End Get 53 | End Property 54 | End Class 55 | End Namespace 56 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptThreadServiceCallback.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Namespace Hosting 4 | ''' 5 | ''' A thread service callback. 6 | ''' 7 | ''' 8 | ''' The host can specify a background thread service when creating a runtime. If 9 | ''' specified, then background work items will be passed to the host using this callback. The 10 | ''' host is expected to either begin executing the background work item immediately and return 11 | ''' true or return false and the runtime will handle the work item in-thread. 12 | ''' 13 | ''' The callback for the background work item. 14 | ''' The data argument to be passed to the callback. 15 | ''' Whether the thread service will execute the callback. 16 | Public Delegate Function JavaScriptThreadServiceCallback(callbackFunction As JavaScriptBackgroundWorkItemCallback, callbackData As IntPtr) As Boolean 17 | End Namespace 18 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptUsageException.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.Serialization 3 | 4 | Namespace Hosting 5 | ''' 6 | ''' An API usage exception occurred. 7 | ''' 8 | 9 | Public NotInheritable Class JavaScriptUsageException 10 | Inherits JavaScriptException 11 | ''' 12 | ''' Initializes a new instance of the class. 13 | ''' 14 | ''' The error code returned. 15 | Public Sub New(code As JavaScriptErrorCode) 16 | Me.New(code, "A fatal exception has occurred in a JavaScript runtime") 17 | End Sub 18 | 19 | ''' 20 | ''' Initializes a new instance of the class. 21 | ''' 22 | ''' The error code returned. 23 | ''' The error message. 24 | Public Sub New(code As JavaScriptErrorCode, message As String) 25 | MyBase.New(code, message) 26 | End Sub 27 | 28 | ''' 29 | ''' Initializes a new instance of the class. 30 | ''' 31 | ''' The serialization info. 32 | ''' The streaming context. 33 | Private Sub New(info As SerializationInfo, context As StreamingContext) 34 | MyBase.New(info, context) 35 | End Sub 36 | End Class 37 | End Namespace 38 | -------------------------------------------------------------------------------- /src/win8.1/vb/Hosting/JavaScriptValueType.vb: -------------------------------------------------------------------------------- 1 | Namespace Hosting 2 | ''' 3 | ''' The JavaScript type of a JavaScriptValue. 4 | ''' 5 | Public Enum JavaScriptValueType 6 | ''' 7 | ''' The value is the undefined value. 8 | ''' 9 | Undefined = 0 10 | 11 | ''' 12 | ''' The value is the null value. 13 | ''' 14 | Null = 1 15 | 16 | ''' 17 | ''' The value is a JavaScript number value. 18 | ''' 19 | Number = 2 20 | 21 | ''' 22 | ''' The value is a JavaScript string value. 23 | ''' 24 | [String] = 3 25 | 26 | ''' 27 | ''' The value is a JavaScript Boolean value. 28 | ''' 29 | [Boolean] = 4 30 | 31 | ''' 32 | ''' The value is a JavaScript object value. 33 | ''' 34 | [Object] = 5 35 | 36 | ''' 37 | ''' The value is a JavaScript function object value. 38 | ''' 39 | [Function] = 6 40 | 41 | ''' 42 | ''' The value is a JavaScript error object value. 43 | ''' 44 | [Error] = 7 45 | 46 | ''' 47 | ''' The value is a JavaScript array object value. 48 | ''' 49 | Array = 8 50 | End Enum 51 | End Namespace 52 | -------------------------------------------------------------------------------- /src/win8.1/vb/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System.Reflection 2 | Imports System.Runtime.InteropServices 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/win8.1/vb/Profiler.vb: -------------------------------------------------------------------------------- 1 | Imports System.Runtime.InteropServices 2 | Imports ChakraHost.Hosting 3 | 4 | 5 | Friend Class Profiler 6 | Implements IActiveScriptProfilerCallback2 7 | 8 | Public Sub OnFunctionEnterByName(pwszFunctionName As String, type As ProfilerScriptType) Implements IActiveScriptProfilerCallback2.OnFunctionEnterByName 9 | Console.WriteLine("Profiler.OnFunctionEnterByName: {0}, {1}", pwszFunctionName, type) 10 | End Sub 11 | 12 | Public Sub OnFunctionExitByName(pwszFunctionName As String, type As ProfilerScriptType) Implements IActiveScriptProfilerCallback2.OnFunctionExitByName 13 | Console.WriteLine("Profiler.OnFunctionExitByName: {0}, {1}", pwszFunctionName, type) 14 | End Sub 15 | 16 | Public Sub Initialize(dwContext As UInteger) Implements IActiveScriptProfilerCallback.Initialize 17 | Console.WriteLine("Profiler.Initialize: {0}", dwContext) 18 | End Sub 19 | 20 | Public Sub Shutdown(hrReason As UInteger) Implements IActiveScriptProfilerCallback.Shutdown 21 | Console.WriteLine("Profiler.Shutdown: {0}", hrReason) 22 | End Sub 23 | 24 | Public Sub ScriptCompiled(scriptId As Integer, type As ProfilerScriptType, pIDebugDocumentContext As IntPtr) Implements IActiveScriptProfilerCallback.ScriptCompiled 25 | Console.WriteLine("Profiler.ScriptCompiled: {0}, {1}", scriptId, type) 26 | End Sub 27 | 28 | Public Sub FunctionCompiled(functionId As Integer, scriptId As Integer, pwszFunctionName As String, pwszFunctionNameHint As String, pIDebugDocumentContext As IntPtr) Implements IActiveScriptProfilerCallback.FunctionCompiled 29 | Console.WriteLine("Profiler.FunctionCompiled: {0}, {1}, {2}, {3}", functionId, scriptId, pwszFunctionName, pwszFunctionNameHint) 30 | End Sub 31 | 32 | Public Sub OnFunctionEnter(scriptId As Integer, functionId As Integer) Implements IActiveScriptProfilerCallback.OnFunctionEnter 33 | Console.WriteLine("Profiler.OnFunctionEnter: {0}, {1}", scriptId, functionId) 34 | End Sub 35 | 36 | Public Sub OnFunctionExit(scriptId As Integer, functionId As Integer) Implements IActiveScriptProfilerCallback.OnFunctionExit 37 | Console.WriteLine("Profiler.OnFunctionExit: {0}, {1}", scriptId, functionId) 38 | End Sub 39 | End Class 40 | --------------------------------------------------------------------------------