mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-05-20 11:31:28 +08:00
...
This commit is contained in:
@@ -9,6 +9,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lib", "Lib\Lib.vcxproj", "{
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "W02_InvokingCppClasses", "W02_InvokingCppClasses\W02_InvokingCppClasses.vcxproj", "{ABA9D015-844F-427C-B4A8-9DE69A2A56B2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "W03_InheritingCppInterfaces", "W03_InheritingCppInterfaces\W03_InheritingCppInterfaces.vcxproj", "{E53A8108-D14F-453D-969E-D00E2668396C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -41,6 +43,14 @@ Global
|
||||
{ABA9D015-844F-427C-B4A8-9DE69A2A56B2}.Release|x64.Build.0 = Release|x64
|
||||
{ABA9D015-844F-427C-B4A8-9DE69A2A56B2}.Release|x86.ActiveCfg = Release|Win32
|
||||
{ABA9D015-844F-427C-B4A8-9DE69A2A56B2}.Release|x86.Build.0 = Release|Win32
|
||||
{E53A8108-D14F-453D-969E-D00E2668396C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E53A8108-D14F-453D-969E-D00E2668396C}.Debug|x64.Build.0 = Debug|x64
|
||||
{E53A8108-D14F-453D-969E-D00E2668396C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E53A8108-D14F-453D-969E-D00E2668396C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E53A8108-D14F-453D-969E-D00E2668396C}.Release|x64.ActiveCfg = Release|x64
|
||||
{E53A8108-D14F-453D-969E-D00E2668396C}.Release|x64.Build.0 = Release|x64
|
||||
{E53A8108-D14F-453D-969E-D00E2668396C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{E53A8108-D14F-453D-969E-D00E2668396C}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -20,6 +20,12 @@ namespace myapi
|
||||
return Console::Read();
|
||||
}
|
||||
|
||||
static WString Get(const WString& message)
|
||||
{
|
||||
Console::Write(message);
|
||||
return Console::Read();
|
||||
}
|
||||
|
||||
static void Print(const WString& text)
|
||||
{
|
||||
Console::WriteLine(text);
|
||||
@@ -44,7 +50,8 @@ namespace vl
|
||||
#define _ ,
|
||||
|
||||
BEGIN_CLASS_MEMBER(App)
|
||||
CLASS_MEMBER_STATIC_METHOD(Get, NO_PARAMETER)
|
||||
CLASS_MEMBER_STATIC_METHOD_OVERLOAD(Get, NO_PARAMETER, WString(*)())
|
||||
CLASS_MEMBER_STATIC_METHOD_OVERLOAD(Get, { L"message" }, WString(*)(const WString&))
|
||||
CLASS_MEMBER_STATIC_METHOD(Print, { L"text" })
|
||||
END_CLASS_MEMBER(App)
|
||||
|
||||
@@ -73,7 +80,8 @@ using myapi::*;
|
||||
|
||||
func main(): void
|
||||
{
|
||||
App::Print("Hello, world!");
|
||||
var name = App::Get("Please enter your name:");
|
||||
App::Print($"Hello, $(name)!");
|
||||
}
|
||||
|
||||
)Workflow";
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
#include <VlppWorkflowCompiler.h>
|
||||
|
||||
using namespace vl;
|
||||
using namespace vl::console;
|
||||
using namespace vl::collections;
|
||||
using namespace vl::parsing;
|
||||
using namespace vl::reflection;
|
||||
using namespace vl::reflection::description;
|
||||
using namespace vl::workflow;
|
||||
using namespace vl::workflow::emitter;
|
||||
using namespace vl::workflow::runtime;
|
||||
|
||||
namespace myapi
|
||||
{
|
||||
class App : public Object, public Description<Console>
|
||||
{
|
||||
public:
|
||||
static WString Get()
|
||||
{
|
||||
return Console::Read();
|
||||
}
|
||||
|
||||
static WString Get(const WString& message)
|
||||
{
|
||||
Console::Write(message);
|
||||
return Console::Read();
|
||||
}
|
||||
|
||||
static void Print(const WString& text)
|
||||
{
|
||||
Console::WriteLine(text);
|
||||
}
|
||||
};
|
||||
|
||||
class IScripting : public virtual IDescriptable, public Description<IScripting>
|
||||
{
|
||||
public:
|
||||
virtual void Execute(const WString& name) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#define MYAPI_TYPELIST(F)\
|
||||
F(myapi::App)\
|
||||
F(myapi::IScripting)\
|
||||
|
||||
namespace vl
|
||||
{
|
||||
namespace reflection
|
||||
{
|
||||
namespace description
|
||||
{
|
||||
MYAPI_TYPELIST(DECL_TYPE_INFO)
|
||||
MYAPI_TYPELIST(IMPL_CPP_TYPE_INFO)
|
||||
|
||||
using namespace myapi;
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4250)
|
||||
BEGIN_INTERFACE_PROXY_SHAREDPTR(IScripting)
|
||||
void Execute(const WString& name)override
|
||||
{
|
||||
INVOKE_INTERFACE_PROXY(Execute, name);
|
||||
}
|
||||
END_INTERFACE_PROXY(IScripting)
|
||||
#pragma warning(pop)
|
||||
|
||||
#define _ ,
|
||||
|
||||
BEGIN_CLASS_MEMBER(App)
|
||||
CLASS_MEMBER_STATIC_METHOD_OVERLOAD(Get, NO_PARAMETER, WString(*)())
|
||||
CLASS_MEMBER_STATIC_METHOD_OVERLOAD(Get, { L"message" }, WString(*)(const WString&))
|
||||
CLASS_MEMBER_STATIC_METHOD(Print, { L"text" })
|
||||
END_CLASS_MEMBER(App)
|
||||
|
||||
BEGIN_INTERFACE_MEMBER(IScripting)
|
||||
CLASS_MEMBER_METHOD(Execute, { L"name" })
|
||||
END_INTERFACE_MEMBER(IScripting)
|
||||
|
||||
#undef _
|
||||
class MyApiTypeLoader : public Object, public ITypeLoader
|
||||
{
|
||||
public:
|
||||
void Load(ITypeManager* manager)
|
||||
{
|
||||
MYAPI_TYPELIST(ADD_TYPE_INFO)
|
||||
}
|
||||
|
||||
void Unload(ITypeManager* manager)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t ScriptCode[] = LR"Workflow(
|
||||
|
||||
module sampleModule;
|
||||
|
||||
using myapi::*;
|
||||
|
||||
func main(): IScripting^
|
||||
{
|
||||
return new IScripting^
|
||||
{
|
||||
override func Execute(name: string): void
|
||||
{
|
||||
App::Print($"Hello, $(name)!");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
)Workflow";
|
||||
|
||||
int main()
|
||||
{
|
||||
// start reflection
|
||||
LoadPredefinedTypes();
|
||||
WfLoadLibraryTypes();
|
||||
GetGlobalTypeManager()->AddTypeLoader(new MyApiTypeLoader);
|
||||
GetGlobalTypeManager()->Load();
|
||||
|
||||
{
|
||||
// prepare Workflow script code
|
||||
List<WString> codes;
|
||||
codes.Add(WString(ScriptCode, false));
|
||||
|
||||
// compile code and get assemblies
|
||||
List<Ptr<ParsingError>> errors;
|
||||
auto table = WfLoadTable();
|
||||
auto assembly = Compile(table, codes, errors);
|
||||
CHECK_ERROR(assembly && errors.Count() == 0, L"Please check the 'errors' variable.");
|
||||
|
||||
// initialize the assembly
|
||||
auto globalContext = MakePtr<WfRuntimeGlobalContext>(assembly);
|
||||
auto initializeFunction = LoadFunction<void()>(globalContext, L"<initialize>");
|
||||
initializeFunction();
|
||||
|
||||
// call main
|
||||
auto mainFunction = LoadFunction<Ptr<myapi::IScripting>()>(globalContext, L"main");
|
||||
mainFunction()->Execute(L"Gaclib");
|
||||
}
|
||||
|
||||
// stop reflection
|
||||
DestroyGlobalTypeManager();
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{E53A8108-D14F-453D-969E-D00E2668396C}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>W03InheritingCppInterfaces</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(ProjectDir)..\..\..\Import;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(ProjectDir)..\..\..\Import;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(ProjectDir)..\..\..\Import;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(ProjectDir)..\..\..\Import;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Lib\Lib.vcxproj">
|
||||
<Project>{6d6fe50e-fd92-46f1-8897-3045e14be02b}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user