Skip to content

Commit 28f35d1

Browse files
authored
🤖 Merge PR DefinitelyTyped#72699 update some v8 changes, add contributions from MBBM by @twhiston
1 parent a41de94 commit 28f35d1

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

‎types/maxmsp/index.d.ts‎

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ declare var max: Max;
1515
declare var maxclass: string;
1616
declare var messagename: string;
1717
declare var patcher: Patcher;
18-
declare function error(...messages: any[]): void;
19-
declare function cpost(...message: any[]): void;
20-
declare function post(...message: any[]): void;
18+
19+
// See https://cycling74.com/forums/any-plans-to-update-support-for-recent-versions-of-js#reply-67264ffa39a940001350f9ab
20+
declare function maxclasswrap(external_name: string, javascript_class_name: string): void;
21+
declare function error(message?: any): void;
22+
declare function error(...messages: any): void;
23+
declare function cpost(args?: any): void;
24+
declare function cpost(...args: any): void;
25+
declare function post(args?: any): void;
26+
declare function post(...args: any): void;
2127
/**
2228
* Sends a message to the named Max object.
2329
* A named Max object is an object associated with a global symbol (not an object with a patcher-specific name).
@@ -1269,6 +1275,12 @@ declare class Maxobj {
12691275
*/
12701276
understands(message: string): boolean;
12711277

1278+
/**
1279+
* Returns an Array value containing the current value(s) of the (UI) object.
1280+
* A single value would be returned by "...()[0]"
1281+
*/
1282+
getvalueof(): any;
1283+
12721284
/**
12731285
* Returns an Array value containing the names of available attributes for the object.
12741286
*/
@@ -1277,12 +1289,19 @@ declare class Maxobj {
12771289
/**
12781290
* Returns the value of the attribute specified by attribute_name. Lists are returned as JS Array objects.
12791291
*/
1280-
getattr(attribute_name: string): unknown;
1292+
getattr(attrname: string): number | number[] | string;
1293+
1294+
/*
1295+
* Gets the value of an attribute's attribute
1296+
* V8 ONLY!
1297+
*/
1298+
getattrattr(attrname: string, attrAttrName: string): number | number[] | string;
12811299

12821300
/**
12831301
* Sets the value of the attribute specified by attribute_name.
1302+
* C'74 docs say value is number | number[] | string but it definitely isn't and can take variadic inputs
12841303
*/
1285-
setattr(attribute_name: string, anything: unknown): void;
1304+
setattr(attrname: string, ...value: any[]): void;
12861305

12871306
/**
12881307
* Returns an Array value containing the names of available attributes for the object's box.
@@ -1442,8 +1461,21 @@ declare class Patcher {
14421461

14431462
/**
14441463
* Returns the value of the attribute specified by attribute_name. Lists are returned as JS Array objects.
1464+
* C74 docs say that this is a string[] but that is definitely incorrect!
14451465
*/
1446-
getattr(attribute_name: string): unknown;
1466+
getattr(attrname: string): number | number[] | string;
1467+
1468+
1469+
/**
1470+
* Get the value of a specified patcher attribute's attribute
1471+
* V8 ONLY!
1472+
*/
1473+
getattrattr(attrname: string, attrAttrName: string): number | number[] | string;
1474+
1475+
/**
1476+
* Sets the value of the attribute specified by attribute_name.
1477+
*/
1478+
setattr(attrname: string, ...value: any[]): void;
14471479

14481480
/**
14491481
* Sends message to the patcher followed by any additional arguments (..anything) provided.
@@ -1622,7 +1654,7 @@ declare class Task {
16221654
* Repeat a task function. The optional number argument specifies the number of repetitions. If the argument is not present or is negative, the task repeats until it is cancelled. The optional
16231655
* initialdelay argument sets the delay in milliseconds until the first iteration. See documentation for an example.
16241656
*/
1625-
repeat(times: number): void;
1657+
repeat(n?: number, initialdelay?: number): void;
16261658

16271659
/**
16281660
* Run the task once, right now. Equivalent to calling the task function with its arguments.
@@ -1818,7 +1850,7 @@ declare function refresh(): void;
18181850
* https://docs.cycling74.com/max8/vignettes/jsmgraphics
18191851
*/
18201852
declare class MGraphics {
1821-
constructor();
1853+
constructor(width: number, height: number);
18221854

18231855
/**
18241856
* When autosketch is set to 1, the drawing commands will immediately be drawn without waiting a drawing execution command. While this is convenient, it is less flexible than working with

‎types/maxmsp/maxmsp-tests.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ inspector = 1;
66
outlets = 2;
77
autowatch = 1;
88
jsarguments.push(1, 2, 3);
9+
maxclasswrap("MyExternal", "CoolStuff");
910
error("This is a test error.\n");
1011
error("This is a", "multiple string", "error\n");
1112
cpost("This is cpost.\n");
@@ -404,7 +405,7 @@ post(fieldName);
404405
const value = mySQLResult.value(0, 0);
405406
post(value);
406407

407-
const myMGraphics = new MGraphics();
408+
const myMGraphics = new MGraphics(23, 23);
408409

409410
myMGraphics.autosketch = 1;
410411
myMGraphics.relative_coords = 1;

0 commit comments

Comments
 (0)