mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
initial commit
This commit is contained in:
commit
c2da007f40
1610 changed files with 398047 additions and 0 deletions
47
example/android/AddIntDef.php
Normal file
47
example/android/AddIntDef.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
if ($argc !== 2) {
|
||||
exit();
|
||||
}
|
||||
$file = file_get_contents($argv[1]);
|
||||
|
||||
if (strpos($file, 'androidx.annotation.IntDef') !== false) {
|
||||
exit();
|
||||
}
|
||||
if (strpos($file, 'androidx.annotation.Nullable') === false) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$file = str_replace('import androidx.annotation.Nullable;', 'import java.lang.annotation.Retention;'.PHP_EOL.
|
||||
'import java.lang.annotation.RetentionPolicy;'.PHP_EOL.
|
||||
PHP_EOL.
|
||||
'import androidx.annotation.IntDef;'.PHP_EOL.
|
||||
'import androidx.annotation.Nullable;', $file);
|
||||
|
||||
preg_match_all('/public static class ([A-Za-z0-9]+) extends ([A-Za-z0-9]+)/', $file, $matches, PREG_SET_ORDER);
|
||||
$children = [];
|
||||
foreach ($matches as $val) {
|
||||
if ($val[2] === 'Object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$children[$val[2]][] = PHP_EOL.' '.$val[1].'.CONSTRUCTOR';
|
||||
}
|
||||
|
||||
$file = preg_replace_callback('/public abstract static class ([A-Za-z0-9]+) extends Object [{]/',
|
||||
function ($val) use ($children) {
|
||||
return $val[0].PHP_EOL.' @Retention(RetentionPolicy.SOURCE)'.PHP_EOL.' @IntDef({'.implode(',', $children[$val[1]]).<<<'EOL'
|
||||
|
||||
})
|
||||
public @interface Constructors {}
|
||||
|
||||
/**
|
||||
* @return identifier uniquely determining type of the object.
|
||||
*/
|
||||
@Constructors
|
||||
@Override
|
||||
public abstract int getConstructor();
|
||||
EOL;
|
||||
},
|
||||
$file);
|
||||
|
||||
file_put_contents($argv[1], $file);
|
Loading…
Add table
Add a link
Reference in a new issue