Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Fixed search paths for Pd generator #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions generators/c2pdext/templates/pd_external.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,17 @@ static void printHook(HeavyContextInterface *c, const char *receiverName, const
}

static void sendHook(HeavyContextInterface *c, const char *receiverName, unsigned int receiverHash, const HvMessage * m) {
if (!strcmp(receiverName, "#HV_TO_PD")) {
t_outlet *const outlet = ((t_{{struct_name}} *) hv_getUserData(c))->msgOutlet;
if (hv_msg_getNumElements(m) == 1) {
if (hv_msg_isFloat(m, 0)) {
outlet_float(outlet, hv_msg_getFloat(m, 0));
} else if (hv_msg_isBang(m, 0)) {
outlet_bang(outlet);
} else if (hv_msg_isSymbol(m, 0)) {
outlet_symbol(outlet, gensym(hv_msg_getSymbol(m, 0)));
} else return;
} else {
const int argc = (int) hv_msg_getNumElements(m);
t_atom *argv = (t_atom *) alloca(argc*sizeof(t_atom));
for (int i = 0; i < argc; i++) {
if (hv_msg_isFloat(m, i)) {
SETFLOAT(argv+i, hv_msg_getFloat(m, i));
} else if (hv_msg_isSymbol(m, i)) {
SETSYMBOL(argv+i, gensym(hv_msg_getSymbol(m, i)));
} else return;
}
outlet_list(outlet, NULL, argc, argv);
}
t_outlet *const outlet = ((t_clicker_tilde *) hv_getUserData(c))->msgOutlet;
const int argc = (int) hv_msg_getNumElements(m);
t_atom *argv = (t_atom *) alloca(argc*sizeof(t_atom));
for (int i = 0; i < argc; i++) {
if (hv_msg_isFloat(m, i)) {
SETFLOAT(argv+i, hv_msg_getFloat(m, i));
} else if (hv_msg_isSymbol(m, i)) {
SETSYMBOL(argv+i, gensym(hv_msg_getSymbol(m, i)));
} else return;
}
outlet_anything(outlet, gensym(receiverName), argc, argv);
}

static void *{{struct_name}}_new(t_symbol *s, int argc, t_atom *argv) {
Expand Down
10 changes: 5 additions & 5 deletions generators/ir2c/templates/Heavy_NAME.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Heavy_{{name}} : public HeavyContext {
struct Parameter {
{% if externs.parameters.in|length > 0 -%}
struct In {
enum ParameterIn : hv_uint32_t {
enum ParameterIn {
{%- for k,v in externs.parameters.in %}
{{k|upper}} = {{v.hash}}, // {{v.display}}
{%- endfor %}
Expand All @@ -39,7 +39,7 @@ class Heavy_{{name}} : public HeavyContext {

{%- if externs.parameters.out|length > 0 %}
struct Out {
enum ParameterOut : hv_uint32_t {
enum ParameterOut {
{%- for k,v in externs.parameters.out %}
{{k|upper}} = {{v.hash}}, // {{v.display}}
{%- endfor %}
Expand All @@ -53,7 +53,7 @@ class Heavy_{{name}} : public HeavyContext {
struct Event {
{%- if externs.events.in|length > 0 %}
struct In {
enum EventIn : hv_uint32_t {
enum EventIn {
{%- for k,v in externs.events.in %}
{{k|upper}} = {{v.hash}}, // {{v.display}}
{%- endfor %}
Expand All @@ -63,7 +63,7 @@ class Heavy_{{name}} : public HeavyContext {

{%- if externs.events.out|length > 0 %}
struct Out {
enum EventOut : hv_uint32_t {
enum EventOut {
{%- for k,v in externs.events.out %}
{{k|upper}} = {{v.hash}}, // {{v.display}}
{%- endfor %}
Expand All @@ -74,7 +74,7 @@ class Heavy_{{name}} : public HeavyContext {
{%- endif %}

{%- if externs.tables|length > 0 %}
enum Table : hv_uint32_t {
enum Table {
{%- for k,v in externs.tables %}
{{k|upper}} = {{v.hash}}, // {{v.display}}
{%- endfor %}
Expand Down
4 changes: 3 additions & 1 deletion hvcc.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python2.7

# Copyright (C) 2014-2018 Enzien Audio, Ltd.
#
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -335,7 +337,7 @@ def main():
parser.add_argument(
"-p",
"--search_paths",
nargs="+",
action="append",
help="Add a list of directories to search through for abstractions.")
parser.add_argument(
"-n",
Expand Down
11 changes: 7 additions & 4 deletions interpreters/pd2hv/PdParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,19 @@ def __get_pd_line(clazz, pd_path):
else:
concat = (concat + " " + l) if len(concat) > 0 else l

def add_relative_search_directory(self, search_dir):
search_dir = os.path.abspath(os.path.join(
self.__search_paths[0],
search_dir))
def add_absolute_search_directory(self, search_dir):
if os.path.isdir(search_dir):
self.__search_paths.append(search_dir)
return True
else:
return False

def add_relative_search_directory(self, search_dir):
search_dir = os.path.abspath(os.path.join(
self.__search_paths[0],
search_dir))
return self.add_absolute_search_directory(search_dir)

def find_abstraction_path(self, local_dir, abs_name):
""" Finds the full path for an abstraction.
Checks the local directory first, then all declared paths.
Expand Down
5 changes: 5 additions & 0 deletions interpreters/pd2hv/pd2hv.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def compile(clazz, pd_path, hv_dir, search_paths=None, verbose=False, export_arg
tick = time.time()

parser = PdParser() # create parser state

if search_paths is not None:
for p in search_paths:
parser.add_absolute_search_directory(p)

pd_graph = parser.graph_from_file(pd_path)
notices = pd_graph.get_notices()

Expand Down