Skip to content

Commit ea3a6e8

Browse files
committed
Исправлена прокси-библиотека NativeApi для 32-битной архитектуры
1 parent 6c6fd14 commit ea3a6e8

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/OneScript.StandardLibrary/NativeApi/NativeApiKernel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public static IntPtr LoadLibrary(string filename)
3131

3232
public static IntPtr GetProcAddress(IntPtr module, string procName)
3333
{
34-
return IsLinux ? LinuxProc(module, procName) : WindowsProc(module, procName);
34+
var pointer = IsLinux ? LinuxProc(module, procName) : WindowsProc(module, procName);
35+
return pointer != IntPtr.Zero
36+
? pointer
37+
: throw new ApplicationException($"Function pointer for {procName} not obtained.");
3538
}
3639

3740
public static bool FreeLibrary(IntPtr module)

src/OneScript.StandardLibrary/NativeApi/NativeApiLibrary.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public NativeApiLibrary(string filepath, string identifier, ITypeManager typeMan
3939
_tempfile = Path.GetTempFileName();
4040
NativeApiPackage.Extract(stream, _tempfile);
4141
Module = NativeApiKernel.LoadLibrary(_tempfile);
42+
if (Module == IntPtr.Zero)
43+
{
44+
File.Delete(_tempfile);
45+
}
4246
}
4347
else
4448
Module = NativeApiKernel.LoadLibrary(filepath);

src/ScriptEngine.NativeApi/NativeApiProxy.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ DllExport int32_t GetNParams(ProxyComponent* proxy, int32_t lMethodNum)
326326
return (int32_t)proxy->Component().GetNParams(lMethodNum);
327327
}
328328

329-
DllExport bool ADDIN_API HasParamDefValue(ProxyComponent* proxy, int32_t lMethodNum, int32_t lParamNum)
329+
DllExport bool HasParamDefValue(ProxyComponent* proxy, int32_t lMethodNum, int32_t lParamNum)
330330
{
331331
CHECK_PROXY(false);
332332
tVariant variant = { 0 };
@@ -335,7 +335,7 @@ DllExport bool ADDIN_API HasParamDefValue(ProxyComponent* proxy, int32_t lMethod
335335
return result;
336336
}
337337

338-
DllExport bool ADDIN_API GetParamDefValue(ProxyComponent* proxy, int32_t lMethodNum, int32_t lParamNum, VariantFuncRespond respond)
338+
DllExport bool GetParamDefValue(ProxyComponent* proxy, int32_t lMethodNum, int32_t lParamNum, VariantFuncRespond respond)
339339
{
340340
CHECK_PROXY(false);
341341
tVariant variant = { 0 };
@@ -351,15 +351,15 @@ DllExport bool HasRetVal(ProxyComponent* proxy, int32_t lMethodNum)
351351
return proxy->Component().HasRetVal(lMethodNum);
352352
}
353353

354-
DllExport bool ADDIN_API CallAsProc(ProxyComponent* proxy, int32_t lMethodNum, tVariant* paParams)
354+
DllExport bool CallAsProc(ProxyComponent* proxy, int32_t lMethodNum, tVariant* paParams)
355355
{
356356
CHECK_PROXY(false);
357357
auto lSizeArray = GetNParams(proxy, lMethodNum);
358358
bool ok = proxy->Component().CallAsProc(lMethodNum, paParams, lSizeArray);
359359
return ok;
360360
}
361361

362-
DllExport bool ADDIN_API CallAsFunc(ProxyComponent* proxy, int32_t lMethodNum, tVariant* paParams, VariantFuncRespond respond)
362+
DllExport bool CallAsFunc(ProxyComponent* proxy, int32_t lMethodNum, tVariant* paParams, VariantFuncRespond respond)
363363
{
364364
CHECK_PROXY(false);
365365
tVariant variant = { 0 };

tests/native-api.os

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
ВсеТесты = Новый Массив;
1414

15+
// TODO: сделать прогон этого теста еще и на 32-битной архитектуре, см. ошибку #1531
1516
ВсеТесты.Добавить("ТестДолжен_ПроверитьПодключениеВнешнейКомпонентыZIP");
1617
ВсеТесты.Добавить("ТестДолжен_ПроверитьПодключениеВнешнейКомпонентыDLL");
1718
ВсеТесты.Добавить("ТестДолжен_ПроверитьСвойстваВнешнейКомпоненты");
@@ -125,7 +126,7 @@
125126

126127
юТест.ПроверитьРавенство(Строка(ТипЗнч(ВнешняяКомпонента)), Строка(Тип(ИмяВнешнейКомпоненты)));
127128

128-
КонецПроцедуры
129+
КонецПроцедуры
129130

130131
Процедура ТестДолжен_ПроверитьПодключениеВнешнейКомпонентыDLL() Экспорт
131132

0 commit comments

Comments
 (0)