{"name": "Books library", "shelfes": [{"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {"books": [{"name": "Alice in wonderlands", "shelf": {}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}}], "name": "python"}]}
А что насчёт соглашений о вызове? У вас тут жесть в виде функции с переменным числом параметров. Есть ли уверенность, что соглашение одинаковое со стороны делфей и C?
По идее должно быть cdelc и со стороны библиотеки, но я бы перепроверил это.
void wsq_returnASSquirrelDoesA(UBERCPPCB cb)
{
if (cb) {
cb(_SC("gfjfgsjk,fghsgjbsnhsrjbtyhsrjktbsrktsnrtjksvrtsdrkjyjsknlrvtuknsrvtuknylsrtuynsrtyunsryuntsynlurtylnusvt\n"));
}
}
void wsq_returnASSquirrelDoesB(UBERCPPCB cb)
{
const wchar_t* data = _SC("gfjfgsjk,fghsgjbsnhsrjbtyhsrjktbsrktsnrtjksvrtsdrkjyjsknlrvtuknsrvtuknylsrtuynsrtyunsryuntsynlurtylnusvt\n");
if (cb) {
cb(data);
}
}
Не понял тут что где не так выглядит, но на всякий случай спрошу - вы всё собираете в одинаковой конфигурации? Нигде случаем нет такого, что одно дебаг, другое - релиз?
Покажите подробно, как вы вызываете эту функцию и как определяете, что получили мусор. Не может быть так что строка куда-то испаряется. Это значит или там её вообще нет (что можно узнать по size), либо всё-таки что-то криво собрано или криво вызывается.
lVM := sq_open(1024);
try
sq_pushroottable(lVM);
sq_setprintfunc(lVM, @VMPrintFunction, @VMErrorFunction);
sqstd_seterrorhandlers(lVM); //теперь sqstdlibaux.cpp будет вызывать VMPrintFunction и VMErrorFunction
sqstd_register_iolib(lVM);
sqstd_register_mathlib(lVM);
sqstd_register_stringlib(lVM);
sqstd_register_systemlib(lVM);
sq_pop(lVM, 1);
sScript := 'print("Hello World!)'; // Ошибка, строка не закончена, нет второго "
sFile := 'buffer.nut';
lRet := sq_compilebuffer(lVM, PSQChar(sScript), Length(sScript) * SizeOf(SQChar), PSQChar(sFile), SQTrue);
ShowMessage(lRet.ToString);
finally
sq_close(lVM);
end;
//где Сишный SQChar*(wchar_t*) это PWideChar паскаля, объявленный под именем PSQChar
SQPRINTFUNCTION = procedure(aVM: HSQUIRRELVM; aString: PSQChar) varargs cdecl;
#define _SC(a) L##a
const SQChar* data = _SC("%s line = (%d) column = (%d) : error %s\n");
if(pf) {
pf(v,data,sSource,line,column,sErr);
}
if(pf) {
pf(v,_SC("%s line = (%d) column = (%d) : error %s\n"),sSource,line,column,sErr);
}
SQUIRREL_API const SQChar *sq_objtostring(const HSQOBJECT *o);
DLL_API const SQChar* wsq_objtostring(const HSQOBJECT *o) {
SQChar* buff;
const SQChar* data = sq_objtostring(o);
const size_t needed = wcslen(data) + 1;
buff = static_cast<SQChar*>(LocalAlloc(LMEM_FIXED, needed));
if (buff)
std::copy_n(data, needed, buff);
return buff;
}
SQUIRREL_API SQBool sq_objtobool(const HSQOBJECT *o);
SQUIRREL_API SQInteger sq_objtointeger(const HSQOBJECT *o);
SQUIRREL_API SQFloat sq_objtofloat(const HSQOBJECT *o);
SQUIRREL_API SQUserPointer sq_objtouserpointer(const HSQOBJECT *o);
SQUIRREL_API SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag);
SQUIRREL_API SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM v, const HSQOBJECT *po);
// Dll2.cpp : Defines the exported functions for the DLL.
//
#include "pch.h"
#include "framework.h"
#include "Dll2.h"
#include <string>
using namespace std;
SQInteger wsq_getversion()
{
return sq_getversion();
}
char* wsq_teststrReturn()
{
char* str1;
static const char* errorMsg = "Path return no points.";
static const size_t needed = std::strlen(errorMsg) + 1;
str1 = static_cast<char*>(LocalAlloc(LMEM_FIXED, needed));
if (str1)
std::copy_n(errorMsg, needed, str1);
return str1;
}
wchar_t* wsq_teststrReturnW()
{
wchar_t* str1;
static const wchar_t* errorMsg = L"Приятное управление памятью...";
static const size_t needed = wcslen(errorMsg) + 1;
str1 = static_cast<wchar_t*>(LocalAlloc(LMEM_FIXED, needed));
if (str1)
std::copy_n(errorMsg, needed, str1);
return str1;
}
/*
Не совсем понимаю, как именно экспортируются функции из squirrel.dll описанные как SQUIRREL_API
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SQUIRREL_API
#define SQUIRREL_API extern
#endif
*/
SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_tostring(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b);
SQUIRREL_API SQRESULT sq_getstringandsize(HSQUIRRELVM v,SQInteger idx,const SQChar **c,SQInteger *size);
SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);
/*
#ifdef DLL2_EXPORTS
#define DLL2_API extern "C" __declspec(dllexport)
#else
#define DLL2_API __declspec(dllimport)
#endif
*/
DLL2_API SQBool __cdecl sq_instanceof(HSQUIRRELVM v);
DLL2_API SQRESULT __cdecl sq_tostring(HSQUIRRELVM v, SQInteger idx);
DLL2_API void __cdecl sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool* b);
DLL2_API SQRESULT __cdecl sq_getstringandsize(HSQUIRRELVM v, SQInteger idx, const SQChar** c, SQInteger* size);
DLL2_API SQRESULT __cdecl sq_getstring(HSQUIRRELVM v, SQInteger idx, const SQChar** c);
Кроме того, эта библиотека есть в Conan Center, может проще поставить оттуда?
. В вашем вопросе никак не отражено, как вы вызывали CMake и с какими параметрами. Ничего не понятно.
А что вы делаете вообще?
echo off
echo Going to dev environment...
set "VSCMD_DEBUG=10"
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 store
echo LOOKING FOR GACUtil.exe....
where regasm.exe
echo LOOKING FOR RegAsm.exe....
where regasm.exe
echo going sleep after any key....
pause
G:\qq>echo off
Going to dev environment...
[DEBUG:vcvarsall.bat] init with arguments 'x86 store'
[DEBUG:vcvarsall.bat] Command line parse completed with values:
[DEBUG:vcvarsall.bat] __VCVARSALL_TARGET_ARCH='x86'
[DEBUG:vcvarsall.bat] __VCVARSALL_HOST_ARCH='x86'
[DEBUG:vcvarsall.bat] __VCVARSALL_WINSDK=''
[DEBUG:vcvarsall.bat] __VCVARSALL_STORE='-app_platform=UWP'
[DEBUG:vcvarsall.bat] __VCVARSALL_HELP=''
[DEBUG:vcvarsall.bat] __VCVARSALL_PARSE_ERROR='0'
[DEBUG:VsDevCmd] Writing pre-initialization environment to C:\Users\Alex\AppData\Local\Temp\dd_vsdevcmd17_preinit_env.log
[DEBUG:core\vsdevcmd_start] initializing with arguments ''
[DEBUG:core\parse_cmd.bat] initializaing with arguments ''
[DEBUG:VsDevCmd.bat] Found version "17.3.5"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.3.5
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[DEBUG:VsDevCmd.bat] calling "core\dotnet.bat"
SET PATH=aaa;bb;ccc;%PATH%
....
num = struct.unpack('b', data[i].to_bytes())[0]
где data = binfile.read()