Skip to content

Commit c869920

Browse files
parijatgargsparkprime
authored andcommitted
Support for jpathdir in python bindings (#584)
1 parent 2e9ac53 commit c869920

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

python/_jsonnet.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ static int handle_native_callbacks(struct JsonnetVm *vm, PyObject *native_callba
448448
static PyObject* evaluate_file(PyObject* self, PyObject* args, PyObject *keywds)
449449
{
450450
const char *filename;
451+
const char *jpathdir = NULL;
451452
char *out;
452453
unsigned max_stack = 500, gc_min_objects = 1000, max_trace = 20;
453454
double gc_growth_trigger = 2;
@@ -458,7 +459,7 @@ static PyObject* evaluate_file(PyObject* self, PyObject* args, PyObject *keywds)
458459
PyObject *native_callbacks = NULL;
459460
struct JsonnetVm *vm;
460461
static char *kwlist[] = {
461-
"filename",
462+
"filename", "jpathdir",
462463
"max_stack", "gc_min_objects", "gc_growth_trigger", "ext_vars",
463464
"ext_codes", "tla_vars", "tla_codes", "max_trace", "import_callback",
464465
"native_callbacks",
@@ -468,8 +469,8 @@ static PyObject* evaluate_file(PyObject* self, PyObject* args, PyObject *keywds)
468469
(void) self;
469470

470471
if (!PyArg_ParseTupleAndKeywords(
471-
args, keywds, "s|IIdOOOOIOO", kwlist,
472-
&filename,
472+
args, keywds, "s|sIIdOOOOIOO", kwlist,
473+
&filename, &jpathdir,
473474
&max_stack, &gc_min_objects, &gc_growth_trigger, &ext_vars,
474475
&ext_codes, &tla_vars, &tla_codes, &max_trace, &import_callback,
475476
&native_callbacks)) {
@@ -481,6 +482,8 @@ static PyObject* evaluate_file(PyObject* self, PyObject* args, PyObject *keywds)
481482
jsonnet_gc_min_objects(vm, gc_min_objects);
482483
jsonnet_max_trace(vm, max_trace);
483484
jsonnet_gc_growth_trigger(vm, gc_growth_trigger);
485+
if (jpathdir != NULL)
486+
jsonnet_jpath_add(vm, jpathdir);
484487
if (!handle_vars(vm, ext_vars, 0, 0)) return NULL;
485488
if (!handle_vars(vm, ext_codes, 1, 0)) return NULL;
486489
if (!handle_vars(vm, tla_vars, 0, 1)) return NULL;
@@ -502,6 +505,7 @@ static PyObject* evaluate_file(PyObject* self, PyObject* args, PyObject *keywds)
502505
static PyObject* evaluate_snippet(PyObject* self, PyObject* args, PyObject *keywds)
503506
{
504507
const char *filename, *src;
508+
const char *jpathdir = NULL;
505509
char *out;
506510
unsigned max_stack = 500, gc_min_objects = 1000, max_trace = 20;
507511
double gc_growth_trigger = 2;
@@ -512,7 +516,7 @@ static PyObject* evaluate_snippet(PyObject* self, PyObject* args, PyObject *keyw
512516
PyObject *native_callbacks = NULL;
513517
struct JsonnetVm *vm;
514518
static char *kwlist[] = {
515-
"filename", "src",
519+
"filename", "src", "jpathdir",
516520
"max_stack", "gc_min_objects", "gc_growth_trigger", "ext_vars",
517521
"ext_codes", "tla_vars", "tla_codes", "max_trace", "import_callback",
518522
"native_callbacks",
@@ -522,8 +526,8 @@ static PyObject* evaluate_snippet(PyObject* self, PyObject* args, PyObject *keyw
522526
(void) self;
523527

524528
if (!PyArg_ParseTupleAndKeywords(
525-
args, keywds, "ss|IIdOOOOIOO", kwlist,
526-
&filename, &src,
529+
args, keywds, "ss|sIIdOOOOIOO", kwlist,
530+
&filename, &src, &jpathdir,
527531
&max_stack, &gc_min_objects, &gc_growth_trigger, &ext_vars,
528532
&ext_codes, &tla_vars, &tla_codes, &max_trace, &import_callback,
529533
&native_callbacks)) {
@@ -535,6 +539,8 @@ static PyObject* evaluate_snippet(PyObject* self, PyObject* args, PyObject *keyw
535539
jsonnet_gc_min_objects(vm, gc_min_objects);
536540
jsonnet_max_trace(vm, max_trace);
537541
jsonnet_gc_growth_trigger(vm, gc_growth_trigger);
542+
if (jpathdir != NULL)
543+
jsonnet_jpath_add(vm, jpathdir);
538544
if (!handle_vars(vm, ext_vars, 0, 0)) return NULL;
539545
if (!handle_vars(vm, ext_codes, 1, 0)) return NULL;
540546
if (!handle_vars(vm, tla_vars, 0, 1)) return NULL;

0 commit comments

Comments
 (0)