Skip to content

Commit 494e9d8

Browse files
committed
Finalize
1 parent 5281422 commit 494e9d8

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

tools/gen_filerefmap.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
$locations = [];
1414

15-
final class TLContext
15+
final readonly class TLContext
1616
{
1717
public function __construct(
1818
public readonly TLInterface $tl,
@@ -144,7 +144,7 @@ interface ActionOp extends Op
144144
{
145145
}
146146

147-
final class Noop implements ActionOp
147+
final readonly class Noop implements ActionOp
148148
{
149149
public function __construct(private readonly string $why)
150150
{
@@ -171,7 +171,7 @@ public function build(TLContext $tl): array
171171
}
172172
}
173173

174-
final class CopyMethodCallOp implements ActionOp
174+
final readonly class CopyMethodCallOp implements ActionOp
175175
{
176176
public function __construct(private readonly string $method)
177177
{
@@ -198,7 +198,7 @@ public function build(TLContext $tl): array
198198
}
199199
}
200200

201-
final class ThemeFormatOp implements ExtractorOrLiteralOp
201+
final readonly class ThemeFormatOp implements ExtractorOrLiteralOp
202202
{
203203
public function __construct()
204204
{
@@ -225,7 +225,7 @@ public function build(TLContext $tl): array
225225
}
226226
}
227227

228-
final class ExtractFromHereOp implements SimpleExtractorOp
228+
final readonly class ExtractFromHereOp implements SimpleExtractorOp
229229
{
230230
public function __construct(
231231
/** @var string[] */
@@ -286,7 +286,7 @@ public function build(TLContext $tl): array
286286
}
287287
}
288288

289-
final class ExtractFromMethodCallOp implements SimpleExtractorOp
289+
final readonly class ExtractFromMethodCallOp implements SimpleExtractorOp
290290
{
291291
public function __construct(
292292
/** @var string[] */
@@ -347,7 +347,7 @@ public function build(TLContext $tl): array
347347
}
348348
}
349349

350-
final class ExtractStickerSetFromDocumentAttributesOp implements SimpleExtractorOp
350+
final readonly class ExtractStickerSetFromDocumentAttributesOp implements SimpleExtractorOp
351351
{
352352
public function __construct(
353353
private readonly SimpleExtractorOp $path,
@@ -386,7 +386,7 @@ public function build(TLContext $tl): array
386386
}
387387
}
388388

389-
final class GetInputPeerOp implements ExtractorOrLiteralOp
389+
final readonly class GetInputPeerOp implements ExtractorOrLiteralOp
390390
{
391391
public function __construct(private readonly SimpleExtractorOp $path)
392392
{
@@ -425,7 +425,7 @@ public function build(TLContext $tl): array
425425
];
426426
}
427427
}
428-
final class GetInputUserOp implements ExtractorOrLiteralOp
428+
final readonly class GetInputUserOp implements ExtractorOrLiteralOp
429429
{
430430
public function __construct(private readonly SimpleExtractorOp $path)
431431
{
@@ -470,7 +470,7 @@ public function build(TLContext $tl): array
470470
];
471471
}
472472
}
473-
final class GetInputChannelOp implements ExtractorOrLiteralOp
473+
final readonly class GetInputChannelOp implements ExtractorOrLiteralOp
474474
{
475475
public function __construct(private readonly SimpleExtractorOp $path)
476476
{
@@ -516,7 +516,7 @@ public function build(TLContext $tl): array
516516
}
517517
}
518518

519-
final class ArrayOp implements ExtractorOrLiteralOp
519+
final readonly class ArrayOp implements ExtractorOrLiteralOp
520520
{
521521
/** @var Op[] */
522522
private readonly array $values;
@@ -571,7 +571,7 @@ public function build(TLContext $tl): array
571571
}
572572
}
573573

574-
final class LiteralOp implements ExtractorOrLiteralOp
574+
final readonly class LiteralOp implements ExtractorOrLiteralOp
575575
{
576576
public function __construct(private readonly string $type, private readonly mixed $value)
577577
{
@@ -601,7 +601,7 @@ public function build(TLContext $tl): array
601601
}
602602
}
603603

604-
final class GetMessageOp implements ActionOp
604+
final readonly class GetMessageOp implements ActionOp
605605
{
606606
public function __construct(
607607
private readonly Op $peer,
@@ -644,7 +644,7 @@ public function build(TLContext $tl): array
644644
}
645645
}
646646

647-
final class CallOp implements ActionOp
647+
final readonly class CallOp implements ActionOp
648648
{
649649
/** @param Op[] $args */
650650
public function __construct(
@@ -711,7 +711,7 @@ public function build(TLContext $tl): array
711711
];
712712
}
713713
}
714-
final class ConstructorOp implements ExtractorOrLiteralOp
714+
final readonly class ConstructorOp implements ExtractorOrLiteralOp
715715
{
716716
/** @param Op[] $args */
717717
public function __construct(
@@ -978,6 +978,8 @@ public function build(TLContext $tl): array
978978
'limit' => new LiteralOp('int', 1),
979979
]
980980
);
981+
$locations['messages.getInlineBotResults'][]= new Noop('Inline bot results are ephemeral');
982+
$locations['messages.getPreparedInlineMessage'][]= new Noop('Inline bot results are ephemeral');
981983

982984
$locations['messages.uploadMedia'][]= new Noop('A freshly uploaded media file will obtain a context only once it is sent to a chat');
983985

@@ -999,6 +1001,11 @@ public function build(TLContext $tl): array
9991001
}
10001002

10011003
$recurse = static function (Closure $onStackEnd, string $type, array &$stack, array &$stackTypes) use ($TL, &$recurse): void {
1004+
if ($type === 'Update' || $type === 'Updates') {
1005+
$onStackEnd($stack);
1006+
return;
1007+
}
1008+
10021009
$pos = count($stack);
10031010
$found = false;
10041011
foreach ([...$TL->getConstructors()->by_id, ...$TL->getMethods()->by_id] as $constructor) {
@@ -1086,20 +1093,10 @@ public function build(TLContext $tl): array
10861093
$stack = [$constructor];
10871094
$stackTypes = [$type => true];
10881095
$recurse(
1089-
static function (array $stack) use ($locations): void {
1096+
static function (array $stack) use ($locations, $TL, &$normalizedLocations): void {
10901097
if (end($stack) === 'messages.getWebPagePreview'
1091-
|| end($stack) === 'help.appUpdate'
1092-
|| (
1093-
in_array($stack[0], ['photo', 'document'], true)
1094-
&& ($stack[1] ?? null) === 'game'
1095-
&& in_array(end($stack), [
1096-
'messages.getWebPagePreview',
1097-
'messages.invitedUsers',
1098-
'payments.paymentResult',
1099-
], true)
1100-
) || array_intersect(
1098+
|| array_intersect(
11011099
[
1102-
'updateServiceNotification',
11031100
'updateShortSentMessage',
11041101
'updateShortMessage',
11051102
'updateShortChatMessage',
@@ -1111,19 +1108,20 @@ static function (array $stack) use ($locations): void {
11111108
}
11121109
$slice = [];
11131110
$had = false;
1111+
$top = $stack[0];
11141112
for ($x = count($stack)-1; $x >= 0; $x--) {
11151113
$constructor = $stack[$x];
1116-
$slice[] = $constructor;
11171114
if (isset($locations[$constructor])) {
11181115
foreach ($locations[$constructor] as $op) {
11191116
$normalized = $op->normalize($slice);
11201117
if ($normalized === null) {
11211118
continue;
11221119
}
11231120
$had = true;
1124-
$normalizedLocations[$constructor][] = $normalized;
1121+
$normalizedLocations[$top][] = $normalized;//->build(new TLContext($TL, $constructor));
11251122
}
11261123
}
1124+
$slice[] = $constructor;
11271125
}
11281126
if (!$had) {
11291127
throw new AssertionError("Uncovered path: " . json_encode($stack));
@@ -1134,3 +1132,5 @@ static function (array $stack) use ($locations): void {
11341132
$stackTypes,
11351133
);
11361134
}
1135+
1136+
var_dump($normalizedLocations);

0 commit comments

Comments
 (0)