Skip to content

Commit

Permalink
Fix php libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Sep 6, 2024
1 parent 3f81642 commit a503a7e
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 91 deletions.
15 changes: 0 additions & 15 deletions lib/python/ast/Match.php

This file was deleted.

15 changes: 0 additions & 15 deletions lib/python/ast/Return.php

This file was deleted.

15 changes: 0 additions & 15 deletions lib/python/ast/Try.php

This file was deleted.

15 changes: 0 additions & 15 deletions lib/python/ast/While.php

This file was deleted.

15 changes: 0 additions & 15 deletions lib/python/ast/Yield.php

This file was deleted.

4 changes: 2 additions & 2 deletions lib/python/ast/List.php → lib/python/ast/_And.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

/**
*/
class List
class _And
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->List();
$this->_self = \PyCore::import('ast')->_And();
}

}
4 changes: 2 additions & 2 deletions lib/python/ast/Global.php → lib/python/ast/_Break.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

/**
*/
class Global
class _Break
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->Global();
$this->_self = \PyCore::import('ast')->_Break();
}

}
4 changes: 2 additions & 2 deletions lib/python/ast/Continue.php → lib/python/ast/_Continue.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

/**
*/
class Continue
class _Continue
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->Continue();
$this->_self = \PyCore::import('ast')->_Continue();
}

}
4 changes: 2 additions & 2 deletions lib/python/ast/If.php → lib/python/ast/_For.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

/**
*/
class If
class _For
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->If();
$this->_self = \PyCore::import('ast')->_For();
}

}
15 changes: 15 additions & 0 deletions lib/python/ast/_Global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace python\ast;

/**
*/
class _Global
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->_Global();
}

}
4 changes: 2 additions & 2 deletions lib/python/ast/And.php → lib/python/ast/_If.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

/**
*/
class And
class _If
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->And();
$this->_self = \PyCore::import('ast')->_If();
}

}
4 changes: 2 additions & 2 deletions lib/python/ast/Break.php → lib/python/ast/_List.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

/**
*/
class Break
class _List
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->Break();
$this->_self = \PyCore::import('ast')->_List();
}

}
15 changes: 15 additions & 0 deletions lib/python/ast/_Match.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace python\ast;

/**
*/
class _Match
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->_Match();
}

}
4 changes: 2 additions & 2 deletions lib/python/ast/Or.php → lib/python/ast/_Or.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

/**
*/
class Or
class _Or
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->Or();
$this->_self = \PyCore::import('ast')->_Or();
}

}
15 changes: 15 additions & 0 deletions lib/python/ast/_Return.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace python\ast;

/**
*/
class _Return
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->_Return();
}

}
4 changes: 2 additions & 2 deletions lib/python/ast/For.php → lib/python/ast/_Try.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

/**
*/
class For
class _Try
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->For();
$this->_self = \PyCore::import('ast')->_Try();
}

}
15 changes: 15 additions & 0 deletions lib/python/ast/_While.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace python\ast;

/**
*/
class _While
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->_While();
}

}
15 changes: 15 additions & 0 deletions lib/python/ast/_Yield.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace python\ast;

/**
*/
class _Yield
{
private $_self;

public function __construct()
{
$this->_self = \PyCore::import('ast')->_Yield();
}

}
19 changes: 19 additions & 0 deletions tools/src/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ class Tool
'__sizeof__',
];

protected const KEYWORDS = [
'and',
'break',
'continue',
'for',
'global',
'if',
'list',
'match',
'or',
'return',
'try',
'while',
'yield',
];

static function render($tplFile, $outFile, $vars, $prefix = ''): void
{
extract($vars);
Expand Down Expand Up @@ -65,6 +81,9 @@ static function valueToRepr($v, $python = false): ?string

public static function parseClass($module_name, $class_name, $class): void
{
if (in_array(strtolower($class_name), self::KEYWORDS)) {
$class_name = '_' . $class_name;
}
$methods = [];
$properties = [];
$constructor = ['call' => '', 'args' => ''];
Expand Down

0 comments on commit a503a7e

Please sign in to comment.