Skip to content

Commit

Permalink
Merge pull request #240 from WireCell/jsonnet-api-declaration
Browse files Browse the repository at this point in the history
Fix #239 by explicitly declaring Jsonnet API functions used
  • Loading branch information
HaiwangYu committed Aug 24, 2023
2 parents fac1225 + 16bc6ab commit a24a65c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
4 changes: 2 additions & 2 deletions img/src/BlobSetReframer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct FromActivity {
activity[ich->ident()] = act;
}

double qtot=0;
// double qtot=0;

// check each layer of the blob
for (const auto& strip : blob.strips()) {
Expand All @@ -145,7 +145,7 @@ struct FromActivity {
auto strace = std::make_shared<SimpleTrace>(chid, tbin, charge);
traces.push_back(strace);

qtot += act_charge;
// qtot += act_charge;
}
}
return traces;
Expand Down
20 changes: 13 additions & 7 deletions util/inc/WireCellUtil/Persist.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
#define WIRECELL_PERSIST

#include <json/json.h>
//#include "libjsonnet++.h"
//
// Note, you can build WCT against the C-bindings to the Go jsonnet
// library which will provide substantial speed up ver the native C
// implementation. To do this, configure code like:

// WCT can use the C bindings to either the Go or C++ Jsonnet library.
// The Go version is much better optimized and strongly recomended
// over the C++ version though the C++ is default so as to not require
// a dependency on the Go ecosystem. You may tell the WCT build
// system to use the Go version with a command like:
//
// ./wcb configure --with-jsonnet-libs=gojsonnet [...as usual...]
// ./wcb configure --with-jsonnet-libs=gojsonnet [...etc...]
//
// The C bindings to both C++ and Go provide the same C API. Only the
// shared library is required (not headers). The portion of the C API
// used is declared in Persist.cxx and is not exposed to external code
// compiling against WCT.
//
extern "C" {
#include "libjsonnet.h"
struct JsonnetVm;
}
#include <boost/filesystem.hpp>
#include <vector>
Expand Down
7 changes: 5 additions & 2 deletions util/inc/WireCellUtil/custard/custard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ namespace custard {
return sum;
}

class Header
{ /* byte offset */
struct TarHeader {
char name_[100]; /* 0 */
char mode_[8]; /* 100 */
char uid_[8]; /* 108 */
Expand All @@ -114,6 +113,10 @@ namespace custard {
char devminor_[8]; /* 337 */
char prefix_[155]; /* 345 */
char padding_[12]; /* 500 */
};

class Header : private TarHeader
{ /* byte offset */
/* 512 */
public:
Header(std::string filename="", size_t siz=0)
Expand Down
16 changes: 16 additions & 0 deletions util/src/Persist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@
#include <sstream>
#include <fstream>

// see #239 for why this is here.
extern "C" {
struct JsonnetVm;
struct JsonnetVm* jsonnet_make();
char *jsonnet_realloc(struct JsonnetVm *vm, char *buf, size_t sz);
void jsonnet_destroy(struct JsonnetVm* vmRef);
void jsonnet_jpath_add(struct JsonnetVm* vmRef, char* path);
void jsonnet_ext_var(struct JsonnetVm* vmRef, char* key, char* value);
void jsonnet_ext_code(struct JsonnetVm* vmRef, char* key, char* value);
void jsonnet_tla_var(struct JsonnetVm* vmRef, char* key, char* value);
void jsonnet_tla_code(struct JsonnetVm* vmRef, char* key, char* value);
char* jsonnet_evaluate_file(struct JsonnetVm* vmRef, char* filename, int* e);
char* jsonnet_evaluate_snippet(struct JsonnetVm* vmRef, char* filename, char* code, int* e);
}


using spdlog::debug;
using spdlog::error;
using spdlog::info;
Expand Down

0 comments on commit a24a65c

Please sign in to comment.