Skip to content

Commit

Permalink
Modified C++ code so you can pass a CLSID to attach to running xlwing…
Browse files Browse the repository at this point in the history
…s server; updated project to Visual Studio 2015
  • Loading branch information
ericremoreynolds committed Jan 22, 2016
1 parent aa50929 commit 794e2c9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/xlwingsdll/config.cpp
Expand Up @@ -49,7 +49,7 @@ void AddEnvironmentVariables(Config::ValueMap& values)
std::string key = keyEqualsValue.substr(0, equalsPos);
std::string value = keyEqualsValue.substr(equalsPos + 1, keyEqualsValue.length() - equalsPos - 1);

std::transform(key.begin(), key.end(), key.begin(), std::toupper);
strupper(key);

values["Environment:" + key] = value;

Expand Down Expand Up @@ -96,7 +96,10 @@ std::string Config::Preprocess(const std::string& raw)

void Config::SetupAutoConfig(const std::string& commandLine)
{
values["Command"] = Preprocess(commandLine);
if (commandLine[0] == '{')
values["CLSID"] = commandLine;
else
values["Command"] = Preprocess(commandLine);
}

void Config::ParseConfigFile(const std::string& filename)
Expand Down Expand Up @@ -328,6 +331,10 @@ void Config::ActivateRPCServer()
// if the server's not running, try to start it up
if(hr == REGDB_E_CLASSNOTREG)
{
// check if a command is specified in the config
if (!this->HasValue("Command"))
throw formatted_exception() << "No command specified in the configuration, cannot autostart server";

// build the command line with which to start the Python process
std::string workingDir = this->HasValue("WorkingDir") ? this->GetValue("WorkingDir") : "<unspecified>";
std::string pythonCmd = this->GetValue("Command");
Expand Down
6 changes: 4 additions & 2 deletions src/xlwingsdll/utils.h
Expand Up @@ -47,13 +47,15 @@ std::string GetLastErrorMessage();

static inline std::string strlower(std::string& s)
{
std::transform(s.begin(), s.end(), s.begin(), std::tolower);
for (size_t k = 0; k < s.length(); k++)
s[k] = std::tolower(s[k], std::locale());
return s;
}

static inline std::string strupper(std::string& s)
{
std::transform(s.begin(), s.end(), s.begin(), std::toupper);
for (size_t k = 0; k < s.length(); k++)
s[k] = std::toupper(s[k], std::locale());
return s;
}

Expand Down
10 changes: 5 additions & 5 deletions src/xlwingsdll/xlwingsdll.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -28,27 +28,27 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down

0 comments on commit 794e2c9

Please sign in to comment.