Skip to content

Commit 27b2e52

Browse files
committed
Support for documenting arguments for all inputs / distribute modes
1 parent 45af28d commit 27b2e52

File tree

167 files changed

+4885
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+4885
-48
lines changed

Documentation/Max Documentation/Build_Max_Docs.cpp

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ std::string escape_xml(std::string str)
5656
return str;
5757
}
5858

59-
bool write_info(FrameLib_Multistream* frameLibObject, std::string inputName)
59+
bool write_info(FrameLib_Multistream* frameLibObject, std::string inputName, MaxObjectArgsMode argsMode)
6060
{
6161
std::string fileName(__FILE__);
6262
std::string dirPath = dirname(const_cast<char *>(fileName.c_str()));
@@ -81,6 +81,12 @@ bool write_info(FrameLib_Multistream* frameLibObject, std::string inputName)
8181

8282
const FrameLib_Parameters *params = frameLibObject->getParameters();
8383

84+
auto to_lower = [](std::string s)
85+
{
86+
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c){ return std::tolower(c); });
87+
return s;
88+
};
89+
8490
auto write_attribute = [&](const char *name, const char *type, const char *digest, const char *description, const char *label)
8591
{
8692
myfile << tab_2 + "<attribute name='" + name + "' get='1' set='1' type='"+ type + "' size='1'> \n";
@@ -97,13 +103,13 @@ bool write_info(FrameLib_Multistream* frameLibObject, std::string inputName)
97103
myfile << tab_2 + "</attribute> \n";
98104
};
99105

100-
auto write_argument = [&](int idx)
106+
auto write_argument = [&](unsigned long idx)
101107
{
102-
int pIdx = -1;
108+
long pIdx = -1;
103109

104-
for (int i = 0; params && i < params->size(); i++)
110+
for (unsigned long i = 0; params && i < params->size(); i++)
105111
if (params->getArgumentIdx(i) == idx)
106-
pIdx = i;
112+
pIdx = static_cast<long>(i);
107113

108114
if (pIdx == -1)
109115
{
@@ -143,6 +149,39 @@ bool write_info(FrameLib_Multistream* frameLibObject, std::string inputName)
143149
return true;
144150
};
145151

152+
auto write_arguments_all_inputs = [&]()
153+
{
154+
myfile << tab_1 + "<objarglist> \n";
155+
myfile << tab_2 + "<objarg name='default-input' optional='1' type='list'> \n";
156+
myfile << tab_3 + "<digest> \n";
157+
myfile << tab_4 + "The input vector to use for any disconnected inputs \n";
158+
myfile << tab_3 + "</digest> \n";
159+
myfile << tab_3 + "<description> \n";
160+
myfile << tab_4 + "Values typed as arguments will be used as a vector for any inputs that are not connected. Either single values or multi-valued vectors can be entered. The behaviour is similar to that for arguments to standard objects such as +~, *~ or zl.reg. \n";
161+
myfile << tab_3 + "</description> \n";
162+
myfile << tab_2 + "</objarg> \n";
163+
myfile << tab_1 + "</objarglist> \n \n";
164+
};
165+
166+
auto write_arguments_distributed = [&]()
167+
{
168+
myfile << tab_1 + "<objarglist> \n";
169+
170+
for (unsigned long i = 1; i < frameLibObject->getNumIns(); i++)
171+
{
172+
myfile << tab_2 + "<objarg name='default-input' optional='1' type='number'> \n";
173+
myfile << tab_3 + "<digest> \n";
174+
myfile << tab_4 + "The value to use for input " + std::to_string(i + 1) + " if it is disconnected \n";
175+
myfile << tab_3 + "</digest> \n";
176+
myfile << tab_3 + "<description> \n";
177+
myfile << tab_4 + "Sets a single value for " + to_lower(frameLibObject->inputInfo(i)) +" \n";
178+
myfile << tab_3 + "</description> \n";
179+
myfile << tab_2 + "</objarg> \n";
180+
}
181+
182+
myfile << tab_1 + "</objarglist> \n \n";
183+
};
184+
146185
auto write_message = [&](const char *name, const char *digest, const char *description)
147186
{
148187
myfile << tab_2 + "<method name='" + name + "'> \n";
@@ -259,8 +298,21 @@ bool write_info(FrameLib_Multistream* frameLibObject, std::string inputName)
259298

260299
// Arguments //
261300
myfile << tab_1 + "<!--ARGUMENTS-->\n";
262-
for (int i = 0; write_argument(i); i++);
263-
301+
switch (argsMode)
302+
{
303+
case kAsParams:
304+
for (unsigned long i = 0; write_argument(i); i++);
305+
break;
306+
307+
case kAllInputs:
308+
write_arguments_all_inputs();
309+
break;
310+
311+
case kDistribute:
312+
write_arguments_distributed();
313+
break;
314+
}
315+
264316
// Messages //
265317
myfile << tab_1 + "<!--MESSAGES-->\n";
266318
myfile << tab_1 + "<methodlist> \n";
@@ -310,7 +362,7 @@ struct DocumentationGenerator
310362
{
311363
T obj(context, parameters, proxy, 1);
312364

313-
if (!write_info(&obj, FrameLib_ObjectName<T>().name()))
365+
if (!write_info(&obj, FrameLib_ObjectInfo<T>().name(), FrameLib_ObjectInfo<T>().template option<MaxObjectArgsMode, 0>()))
314366
*success = false;
315367
}
316368
};

Documentation/Max Documentation/generate_max_object_list.py

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
docs = Documentation()
66
op = open(docs.max_docs_dir / "Max_Object_List.h", "w+")
77

8-
98
def write_comma(counter: int, ceiling: int) -> None:
109
if counter < ceiling - 1:
1110
op.write(",")
@@ -34,6 +33,8 @@ def name_sanitisation(name: str) -> str:
3433
def main(docs: Documentation):
3534
# Create the Max_Object_list.h and add skeleton
3635
op.write('#include "FrameLib_TypeList.h"\n\n')
36+
op.write("enum MaxObjectArgsMode { kAsParams, kAllInputs, kDistribute };\n\n")
37+
3738
op.write("using FrameLib_DSPList = detail::FrameLib_Typelist<\n\n")
3839

3940
# Directory formation
@@ -47,7 +48,7 @@ def main(docs: Documentation):
4748
if name.stem not in ignored_objects:
4849
source_file_list.append([category, name])
4950

50-
# TODO - lookwithin and reaise this is not okay
51+
# TODO - lookwithin and realise this is not okay
5152
# Recreate full paths to open and parse for type cases
5253
for counter, (category_folder, name) in enumerate(source_file_list):
5354
with open((Path(category_folder) / name), "r") as cpp:
@@ -70,9 +71,9 @@ def main(docs: Documentation):
7071
write_comma(counter, len(source_file_list))
7172

7273
## Demarcate end of this section
73-
op.write("\n\n>;\n\n")
74+
op.write(">;\n\n")
7475

75-
## Start const bit
76+
## Start const char bit
7677
for category_folder, name in source_file_list:
7778
with open(Path(category_folder) / name, "r") as cpp:
7879

@@ -86,7 +87,7 @@ def main(docs: Documentation):
8687
op.write("template<>\n")
8788
if "_Expand" in search_area:
8889
op.write(
89-
"const char* FrameLib_ObjectName<FrameLib_Expand<"
90+
"const char* FrameLib_ObjectInfo<FrameLib_Expand<"
9091
+ fl_object_name
9192
+ '>>::name()\n{ return "'
9293
+ name.stem
@@ -95,7 +96,7 @@ def main(docs: Documentation):
9596

9697
elif "_Expand" not in search_area and "makeClass" in search_area:
9798
op.write(
98-
"const char* FrameLib_ObjectName<FrameLib_Expand<"
99+
"const char* FrameLib_ObjectInfo<FrameLib_Expand<"
99100
+ fl_object_name
100101
+ '>>::name()\n{ return "'
101102
+ name.stem
@@ -104,13 +105,60 @@ def main(docs: Documentation):
104105

105106
elif "_Expand" not in search_area and "makeClass" not in search_area:
106107
op.write(
107-
"const char* FrameLib_ObjectName<"
108+
"const char* FrameLib_ObjectInfo<"
108109
+ fl_object_name
109110
+ '>::name()\n{ return "'
110111
+ name.stem
111112
+ '"; }\n'
112113
)
113114
op.write("\n")
115+
116+
## Start argument type bit
117+
for category_folder, name in source_file_list:
118+
with open(Path(category_folder) / name, "r") as cpp:
119+
120+
source_file = cpp.read().replace("\n", "").replace(" ", "") # flatten it with no spaces whatsoever
121+
search_area = source_file.split('extern"C"intC74_EXPORTmain(void){')[1]
122+
123+
fl_object_name = name_sanitisation(search_area.split("<")[1])
124+
arg_type = "kAsParams"
125+
126+
if "kAllInputs" in source_file:
127+
arg_type = "kAllInputs"
128+
elif "kDistribute" in source_file:
129+
arg_type = "kDistribute"
130+
131+
search_area = search_area.split("<")[0]
132+
# infer type with brutal checking by looking at text in the extern bit (search area)
133+
op.write("template<> template<> \n")
134+
if "_Expand" in search_area:
135+
op.write(
136+
"MaxObjectArgsMode FrameLib_ObjectInfo<FrameLib_Expand<"
137+
+ fl_object_name
138+
+ ">>::option<MaxObjectArgsMode, 0>()\n{ return "
139+
+ arg_type
140+
+ "; }\n"
141+
)
142+
143+
elif "_Expand" not in search_area and "makeClass" in search_area:
144+
op.write(
145+
"MaxObjectArgsMode FrameLib_ObjectInfo<FrameLib_Expand<"
146+
+ fl_object_name
147+
+ ">>::option<MaxObjectArgsMode, 0>()\n{ return "
148+
+ arg_type
149+
+ "; }\n"
150+
)
151+
152+
elif "_Expand" not in search_area and "makeClass" not in search_area:
153+
op.write(
154+
"MaxObjectArgsMode FrameLib_ObjectInfo<"
155+
+ fl_object_name
156+
+ ">::option<MaxObjectArgsMode, 0>()\n{ return "
157+
+ arg_type
158+
+ "; }\n"
159+
)
160+
op.write("\n")
161+
114162
op.close()
115163

116164
if __name__ == "__main__":

FrameLib_Exports/FrameLib_TypeList.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ namespace detail
1818
}
1919

2020
template<typename T>
21-
struct FrameLib_ObjectName
21+
struct FrameLib_ObjectInfo
2222
{
2323
const char *name() { return "unknown"; }
24+
25+
template <typename U, size_t Idx>
26+
static U option()
27+
{
28+
return U();
29+
}
2430
};
2531

2632
using FrameLib_ObjectList = detail::FrameLib_Typelist<

Packaging/Max/FrameLib/docs/refpages/FrameLib Binary/fl.and~.maxref.xml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,42 @@
3434
<metadata name="tag">FrameLib</metadata>
3535
<metadata name="tag">FrameLib Binary</metadata>
3636
</metadatalist>
37-
<objarglist />
37+
<objarglist>
38+
<objarg name="default-input" optional="1" type="list">
39+
<digest>
40+
The input vector to use for any disconnected inputs
41+
</digest>
42+
<description>
43+
Values typed as arguments will be used as a vector for any inputs that are not connected. Either single values or multi-valued vectors can be entered. The behaviour is similar to that for arguments to standard objects such as +~, *~ or zl.reg.
44+
</description>
45+
</objarg>
46+
</objarglist>
47+
<methodlist>
48+
<method name="info">
49+
<digest>
50+
Get Object Info
51+
</digest>
52+
<description>
53+
--detail--
54+
</description>
55+
</method>
56+
<method name="frame">
57+
<digest>
58+
Connect FrameLib objects
59+
</digest>
60+
<description>
61+
Used internally by FrameLib connection routines. User messages have no effect
62+
</description>
63+
</method>
64+
<method name="sync">
65+
<digest>
66+
Synchronise FrameLib audio objects
67+
</digest>
68+
<description>
69+
Used internally by FrameLib connection routines. User messages have no effect
70+
</description>
71+
</method>
72+
</methodlist>
3873
<attributelist>
3974
<attribute name="rt" get="1" set="1" type="int" size="1">
4075
<digest>

Packaging/Max/FrameLib/docs/refpages/FrameLib Binary/fl.atan2~.maxref.xml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,42 @@
3434
<metadata name="tag">FrameLib</metadata>
3535
<metadata name="tag">FrameLib Binary</metadata>
3636
</metadatalist>
37-
<objarglist />
37+
<objarglist>
38+
<objarg name="default-input" optional="1" type="list">
39+
<digest>
40+
The input vector to use for any disconnected inputs
41+
</digest>
42+
<description>
43+
Values typed as arguments will be used as a vector for any inputs that are not connected. Either single values or multi-valued vectors can be entered. The behaviour is similar to that for arguments to standard objects such as +~, *~ or zl.reg.
44+
</description>
45+
</objarg>
46+
</objarglist>
47+
<methodlist>
48+
<method name="info">
49+
<digest>
50+
Get Object Info
51+
</digest>
52+
<description>
53+
--detail--
54+
</description>
55+
</method>
56+
<method name="frame">
57+
<digest>
58+
Connect FrameLib objects
59+
</digest>
60+
<description>
61+
Used internally by FrameLib connection routines. User messages have no effect
62+
</description>
63+
</method>
64+
<method name="sync">
65+
<digest>
66+
Synchronise FrameLib audio objects
67+
</digest>
68+
<description>
69+
Used internally by FrameLib connection routines. User messages have no effect
70+
</description>
71+
</method>
72+
</methodlist>
3873
<attributelist>
3974
<attribute name="rt" get="1" set="1" type="int" size="1">
4075
<digest>

Packaging/Max/FrameLib/docs/refpages/FrameLib Binary/fl.copysign~.maxref.xml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,42 @@
3434
<metadata name="tag">FrameLib</metadata>
3535
<metadata name="tag">FrameLib Binary</metadata>
3636
</metadatalist>
37-
<objarglist />
37+
<objarglist>
38+
<objarg name="default-input" optional="1" type="list">
39+
<digest>
40+
The input vector to use for any disconnected inputs
41+
</digest>
42+
<description>
43+
Values typed as arguments will be used as a vector for any inputs that are not connected. Either single values or multi-valued vectors can be entered. The behaviour is similar to that for arguments to standard objects such as +~, *~ or zl.reg.
44+
</description>
45+
</objarg>
46+
</objarglist>
47+
<methodlist>
48+
<method name="info">
49+
<digest>
50+
Get Object Info
51+
</digest>
52+
<description>
53+
--detail--
54+
</description>
55+
</method>
56+
<method name="frame">
57+
<digest>
58+
Connect FrameLib objects
59+
</digest>
60+
<description>
61+
Used internally by FrameLib connection routines. User messages have no effect
62+
</description>
63+
</method>
64+
<method name="sync">
65+
<digest>
66+
Synchronise FrameLib audio objects
67+
</digest>
68+
<description>
69+
Used internally by FrameLib connection routines. User messages have no effect
70+
</description>
71+
</method>
72+
</methodlist>
3873
<attributelist>
3974
<attribute name="rt" get="1" set="1" type="int" size="1">
4075
<digest>

0 commit comments

Comments
 (0)