Expose enough of the AbstractState API in order to generate phase envelopes - works!; closes #819

This commit is contained in:
Ian Bell
2015-12-19 18:36:12 -07:00
parent 3c821e0637
commit fcf641ee64
2 changed files with 48 additions and 0 deletions

View File

@@ -767,3 +767,47 @@ TEST_CASE("Check AbstractState","[AbstractState]")
}
#endif
/// *********************************************************************************
/// *********************************************************************************
/// EMSCRIPTEN (for javascript)
/// *********************************************************************************
/// *********************************************************************************
#ifdef EMSCRIPTEN
#include <emscripten/bind.h>
using namespace emscripten;
CoolProp::AbstractState * factory(const std::string &backend, const std::string &fluid_names)
{
return CoolProp::AbstractState::factory(backend, strsplit(fluid_names, '&'));
}
// Binding code
EMSCRIPTEN_BINDINGS(abstract_state_bindings) {
register_vector<double>("VectorDouble");
register_vector<std::string>("VectorString");
//value_object<CoolProp::PhaseEnvelopeData>("CoolProp::PhaseEnvelopeData")
// // Use X macros to auto-generate the variables;
// // each will look something like: .field("T", &CoolProp::PhaseEnvelopeData::T);
// #define X(name) .field("name", &CoolProp::PhaseEnvelopeData::name)
// PHASE_ENVELOPE_VECTORS
// #undef X
// ;
function("factory", &factory, allow_raw_pointers());
class_<CoolProp::AbstractState>("AbstractState")
.function("gas_constant", &CoolProp::AbstractState::gas_constant)
.function("update", &CoolProp::AbstractState::update)
.function("set_mole_fractions", &CoolProp::AbstractState::set_mole_fractions_double)
.function("build_phase_envelope", &CoolProp::AbstractState::build_phase_envelope)
.function("get_phase_envelope_data", &CoolProp::AbstractState::get_phase_envelope_data);
}
#endif