Skip to content

Commit

Permalink
1.9.4.6予定。jsmode と互換の関数群をあらかた実装
Browse files Browse the repository at this point in the history
  • Loading branch information
komiyamma committed Aug 27, 2022
1 parent e768079 commit 8f25bc0
Show file tree
Hide file tree
Showing 30 changed files with 909 additions and 16 deletions.
Binary file modified hmV8.src/Release/hmV8.dll
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.iobj
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.res
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.tlog/CL.write.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.tlog/hmV8.write.1u.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.tlog/link.command.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.tlog/link.write.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/Release/hmV8.tlog/rc.read.1.tlog
Binary file not shown.
24 changes: 24 additions & 0 deletions hmV8.src/hmJS/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <windows.h>

HMODULE hSelfDllModule = NULL;


#pragma unmanaged
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
hSelfDllModule = hModule;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

#pragma managed
1 change: 1 addition & 0 deletions hmV8.src/hmJS/hmJS.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="hidemaruexe_export.cpp" />
<ClCompile Include="hmV8.cpp" />
<ClCompile Include="string_converter.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions hmV8.src/hmJS/hmJS.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<ClCompile Include="hmV8.cpp">
<Filter>本体</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>本体</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="hidemaruexe_export.h">
Expand Down
825 changes: 825 additions & 0 deletions hmV8.src/hmJS/hmJSMode.js

Large diffs are not rendered by default.

48 changes: 34 additions & 14 deletions hmV8.src/hmJS/hmV8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using namespace std;
using namespace System;

extern HMODULE hSelfDllModule;

// 上の手動のBindDllHandleを自動で行う。秀丸8.66以上
// 1回だけ実行すれば良いわけではない。dllが読み込まれている間にもdll値が変わってしまうかもしれないため。(将来の実装では)
Expand All @@ -30,6 +31,24 @@ static bool BindDllHandle() {
return false;
}

bool isExpressionLoaded = false;
static bool InitializeHandle() {
bool ret = BindDllHandle();
if (!isExpressionLoaded && hSelfDllModule) {
HRSRC res = FindResource(hSelfDllModule, TEXT("HMJSMODE"), TEXT("TEXT"));
if (res) {
char* expression = (char*)LoadResource(hSelfDllModule, res);
if (expression) {
String^ mng_expression = gcnew String(expression);
IV8StaticLib::SetJSModeExpression(mng_expression);
isExpressionLoaded = true;
}
}
}
return ret;
}


//------------------------------------------------------------------------------------
MACRO_DLL intHM_t SetDebuggingPort(intHM_t port) {
IV8StaticLib::SetDebuggingPort((IntPtr)port);
Expand Down Expand Up @@ -67,59 +86,59 @@ MACRO_DLL const TCHAR * PopStrVar() {

//------------------------------------------------------------------------------------
MACRO_DLL intHM_t GetNumVar(const TCHAR *sz_var_name) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::GetNumVar(gcnew String(sz_var_name));
}

MACRO_DLL intHM_t SetNumVar(const TCHAR *sz_var_name, intHM_t value) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::SetNumVar(gcnew String(sz_var_name), (IntPtr)value);
}

// 秀丸のキャッシュのため
static wstring strvars;
MACRO_DLL const TCHAR * GetStrVar(const TCHAR *sz_var_name) {
BindDllHandle();
InitializeHandle();

auto var = IV8StaticLib::GetStrVar(gcnew String(sz_var_name));
strvars = String_to_tstring(var->ToString());
return strvars.data();
}

MACRO_DLL intHM_t SetStrVar(const TCHAR *sz_var_name, const TCHAR *value) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::SetStrVar(gcnew String(sz_var_name), gcnew String(value));
}
//------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------
MACRO_DLL intHM_t GetNumItemOfList(const TCHAR *sz_arr_name, const intHM_t index) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::GetNumItemOfList(gcnew String(sz_arr_name), (IntPtr)index);
}

MACRO_DLL intHM_t SetNumItemOfList(const TCHAR *sz_arr_name, const intHM_t index, const intHM_t value) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::SetNumItemOfList(gcnew String(sz_arr_name), (IntPtr)index, (IntPtr)value);
}

// 秀丸のキャッシュのため
static wstring strvarsoflist;
MACRO_DLL const TCHAR * GetStrItemOfList(const TCHAR *sz_arr_name, const intHM_t index) {
BindDllHandle();
InitializeHandle();

auto var = IV8StaticLib::GetStrItemOfList(gcnew String(sz_arr_name), (IntPtr)index);
strvarsoflist = String_to_tstring(var->ToString());
return strvarsoflist.data();
}

MACRO_DLL intHM_t SetStrItemOfList(const TCHAR *sz_arr_name, const intHM_t index, const TCHAR *value) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::SetStrItemOfList(gcnew String(sz_arr_name), (IntPtr)index, gcnew String(value));
}
Expand All @@ -129,13 +148,13 @@ MACRO_DLL intHM_t SetStrItemOfList(const TCHAR *sz_arr_name, const intHM_t index

//------------------------------------------------------------------------------------
MACRO_DLL intHM_t GetNumItemOfDict(const TCHAR *sz_arr_name, const TCHAR *key) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::GetNumItemOfDict(gcnew String(sz_arr_name), gcnew String(key));
}

MACRO_DLL intHM_t SetNumItemOfDict(const TCHAR *sz_arr_name, const TCHAR *key, const intHM_t value) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::SetNumItemOfDict(gcnew String(sz_arr_name), gcnew String(key), (IntPtr)value);
}
Expand All @@ -144,23 +163,23 @@ MACRO_DLL intHM_t SetNumItemOfDict(const TCHAR *sz_arr_name, const TCHAR *key, c

static wstring strvarsofdict;
MACRO_DLL const TCHAR * GetStrItemOfDict(const TCHAR *sz_arr_name, const TCHAR *key) {
BindDllHandle();
InitializeHandle();

auto var = IV8StaticLib::GetStrItemOfDict(gcnew String(sz_arr_name), gcnew String(key));
strvarsofdict = String_to_tstring(var->ToString());
return strvarsofdict.data();
}

MACRO_DLL intHM_t SetStrItemOfDict(const TCHAR *sz_arr_name, const TCHAR *key, const TCHAR *value) {
BindDllHandle();
InitializeHandle();

return (intHM_t)IV8StaticLib::SetStrItemOfDict(gcnew String(sz_arr_name), gcnew String(key), gcnew String(value));
}
//------------------------------------------------------------------------------------


MACRO_DLL intHM_t DoString(const TCHAR *szexpression) {
BindDllHandle();
InitializeHandle();

// ここはよく間違えるのでここだけチェック。他は秀丸8.66以降ではほとんど利用しないので無視
if (Hidemaru_GetDllFuncCalledType) {
Expand All @@ -179,7 +198,7 @@ MACRO_DLL intHM_t DoString(const TCHAR *szexpression) {
}

MACRO_DLL intHM_t DoFile(const TCHAR *szfilename) {
BindDllHandle();
InitializeHandle();

// ここはよく間違えるのでここだけチェック。他は秀丸8.66以降ではほとんど利用しないので無視
if (Hidemaru_GetDllFuncCalledType) {
Expand All @@ -198,6 +217,7 @@ MACRO_DLL intHM_t DoFile(const TCHAR *szfilename) {
}

MACRO_DLL intHM_t DestroyScope() {
isExpressionLoaded = false;
return (intHM_t)IV8StaticLib::DestroyScope();
}

Expand Down
Binary file modified hmV8.src/hmJS/hmV8.rc
Binary file not shown.
2 changes: 2 additions & 0 deletions hmV8.src/hmJS/hmV8StatlcLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public ref class IV8StaticLib

static IntPtr BindDllHandle(IntPtr dll);

static void SetJSModeExpression(String^ str);

static void SetCodePage(IntPtr cp);

static IntPtr SetTmpVar(Object^ value);
Expand Down
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.iobj
Binary file not shown.
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.res
Binary file not shown.
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.tlog/CL.write.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.tlog/link.command.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.tlog/link.write.1.tlog
Binary file not shown.
Binary file modified hmV8.src/hmJS/x64/Release/hmV8.tlog/rc.read.1.tlog
Binary file not shown.
4 changes: 2 additions & 2 deletions hmV8.src/hmJSStaticLib/ClearScript/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
using System.Runtime.InteropServices;

[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.9.4.5")]
[assembly: AssemblyFileVersion("1.9.4.5")]
[assembly: AssemblyVersion("1.9.4.6")]
[assembly: AssemblyFileVersion("1.9.4.6")]
18 changes: 18 additions & 0 deletions hmV8.src/hmJSStaticLib/ClearScript/hmJSStaticLib/hmV8StaticLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public static IntPtr BindDllHandle(IntPtr dll)
{
return hmV8DynamicLib.BindDllHandle(dll);
}
public static void SetJSModeExpression(String str)
{
hmV8DynamicLib.SetJSModeExpression(str);
}

public static void SetCodePage(IntPtr cp)
{
Expand Down Expand Up @@ -186,6 +190,13 @@ public static IntPtr BindDllHandle(IntPtr dll)
return dll;
}

static bool isJSModeLoaded = false;
static string strJSModeExpression = "";
public static void SetJSModeExpression(String str)
{
strJSModeExpression = str;
}

// dllのloaddllタイプによって、渡されたcmd(=expression)に対して、「dllの番号,」or「」を当てはめる処理
public static String ModifyFuncCallByDllType(String cmd)
{
Expand Down Expand Up @@ -648,6 +659,12 @@ public static IntPtr DoString(String expression, String inAction = "DoString")

try
{
if (!isJSModeLoaded)
{
isJSModeLoaded = true;
engine.Evaluate(strJSModeExpression);
}

// 文字列からソース生成
engine.Evaluate(expression);
return (IntPtr)1;
Expand Down Expand Up @@ -750,6 +767,7 @@ public static IntPtr DestroyScope()

SetCodePage((IntPtr)default_codepage);
iDllBindHandle = 0;
isJSModeLoaded = false;
tmpVar = null;
iDebuggingPort = 0;

Expand Down
Binary file modified hmV8.src/x64/Release/hmV8.dll
Binary file not shown.

0 comments on commit 8f25bc0

Please sign in to comment.