|
From: <da...@us...> - 2003-08-05 23:25:58
|
Update of /cvsroot/binaryphp/binaryphp
In directory sc8-pr-cvs1:/tmp/cvs-serv20410
Modified Files:
convert.php functions.php php_var.cpp testfile.php
tokenflow.php
Log Message:
Partial class support (segfaults\!). Final commit for this branch of the project.
Index: convert.php
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/convert.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** convert.php 5 Aug 2003 01:52:38 -0000 1.22
--- convert.php 5 Aug 2003 23:25:55 -0000 1.23
***************
*** 62,65 ****
--- 62,67 ----
$gen = new Generator($tokenizer);
list($code, $flags) = $gen->Convert();
+ if(DEBUG)
+ $flags .= ' -g';
$lines = explode("\n", $code);
if(DEBUG == true) {
Index: functions.php
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/functions.php,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** functions.php 5 Aug 2003 05:58:00 -0000 1.37
--- functions.php 5 Aug 2003 23:25:55 -0000 1.38
***************
*** 51,61 ****
'socket_write' => array('unistd.h', 'sockets/socket_write.cpp'),
'socket_read' => array(null, 'sockets/socket_read.cpp'),
! 'opendir' => array(array('cstdio', 'dirent.h'), 'dir/opendir.cpp'),
! 'readdir' => array(array('cstdio', 'dirent.h'), 'dir/readdir.cpp'),
! 'closedir' => array(array('cstdio', 'dirent.h'), 'dir/closedir.cpp'),
! 'glClear' => array(array('GL/gl.h', 'GL/glu.h'), null, array('GLU', 'GL')),
'glutWireCube' => array('GL/glut.h', null, array('GLU', 'GL', 'glut')),
'glLightfv' => array(array('GL/gl.h', 'GL/glu.h'), 'glu/glLightfv.cpp'),
! 'glutInit' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutInit.cpp'),
'glutReshapeFunc' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutReshapeFunc.cpp'),
'glutMouseFunc' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutMouseFunc.cpp'),
--- 51,61 ----
'socket_write' => array('unistd.h', 'sockets/socket_write.cpp'),
'socket_read' => array(null, 'sockets/socket_read.cpp'),
! 'opendir' => array(array('cstdio', 'dirent.h'), 'opendir.cpp'),
! 'readdir' => array(array('cstdio', 'dirent.h'), 'readdir.cpp'),
! 'closedir' => array(array('cstdio', 'dirent.h'), 'closedir.cpp'),
! 'glClear' => array(array('GL/gl.h', 'GL/glu.h'), null, array('GLU', 'GL', 'glut')),
'glutWireCube' => array('GL/glut.h', null, array('GLU', 'GL', 'glut')),
'glLightfv' => array(array('GL/gl.h', 'GL/glu.h'), 'glu/glLightfv.cpp'),
! 'glutInit' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutInit.cpp', array('GLU', 'GL', 'glut')),
'glutReshapeFunc' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutReshapeFunc.cpp'),
'glutMouseFunc' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutMouseFunc.cpp'),
***************
*** 63,66 ****
--- 63,67 ----
'glutButtonBoxFunc' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutButtonBoxFunc.cpp'),
'glutKeyboardFunc' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutKeyboardFunc.cpp'),
+ 'glutCreateMenu' => array(array('GL/gl.h', 'GL/glu.h', 'GL/glut.h'), 'glut/glutCreateMenu.cpp'),
null
);
Index: php_var.cpp
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/php_var.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** php_var.cpp 5 Aug 2003 02:23:20 -0000 1.23
--- php_var.cpp 5 Aug 2003 23:25:55 -0000 1.24
***************
*** 24,28 ****
return buf;
}
-
class php_var
{
--- 24,27 ----
***************
*** 37,40 ****
--- 36,40 ----
container = str;
type = PHP_STRING;
+ cout << "Bleh!" << endl;
}
php_var(double i)
***************
*** 396,404 ****
}
}
- void operator/(php_var i)
- {
- if(type == PHP_INT)
- container = doublestring(atof(container.c_str()) / atof(i.container.c_str()));
- }
void operator-(php_var i)
{
--- 396,399 ----
***************
*** 419,422 ****
--- 414,418 ----
int type; // Contains current type.
};
+ template<typename T> inline T * OBJ(php_var obj) { return (reinterpret_cast<T *>(obj.res)); }
ostream &operator<<( ostream &out, const php_var &var )
{
***************
*** 438,441 ****
--- 434,441 ----
{
return (php_var)((int) l - (int) r);
+ }
+ float operator/(php_var &l, php_var &r)
+ {
+ return (float) *l / (float) *r;
}
#define is_identical(var, varb) (((var) == (varb) && (var).type == (varb).type) ? (php_var)true : (php_var)false)
Index: testfile.php
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/testfile.php,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** testfile.php 5 Aug 2003 00:48:38 -0000 1.44
--- testfile.php 5 Aug 2003 23:25:55 -0000 1.45
***************
*** 21,23 ****
}
}
! ?>
--- 21,23 ----
}
}
! ?>
\ No newline at end of file
Index: tokenflow.php
===================================================================
RCS file: /cvsroot/binaryphp/binaryphp/tokenflow.php,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** tokenflow.php 4 Aug 2003 23:46:24 -0000 1.48
--- tokenflow.php 5 Aug 2003 23:25:55 -0000 1.49
***************
*** 85,90 ****
default:
list($parameters[], $z) = $this->parse_statement($tokenizer, $z);
- if($parameters[count($parameters) - 1] == '"\n"')
- $parameters[count($parameters) - 1] = 'endl';
break;
}
--- 85,88 ----
***************
*** 543,546 ****
--- 541,552 ----
if($inconcat == true && $inbrace == false)
$code .= '(string)(const char*)';
+ if(is_array($tokenizer->tokens[$i + 1]) && $tokenizer->tokens[$i + 1][0] == T_OBJECT_OPERATOR)
+ {
+ if(strtolower($data_) == '$this')
+ $code .= 'this.';
+ else
+ $code .= 'OBJ<' . $this->objects[$data_] . '>(_' . substr($data_, 1) . ')->';
+ break;
+ }
if(in_array(substr($data_, 1), $this->scope[$this->curfunction]) || $this->inclass == true)
$code .= '_' . substr($data_, 1);
***************
*** 559,569 ****
if(strtolower($data_) == 'true' || strtolower($data_) == 'false' || strtolower($data_) == 'null')
$code .= '(php_var) ' . strtolower($data_);
- elseif($tokenizer->tokens[$i + 1] != '(')
- $code .= $data_;
elseif(is_array($tokenizer->tokens[$i - 1]) && $tokenizer->tokens[$i - 1][0] == T_NEW)
{
$code .= '(void *) new ' . $data_;
! $this->objects[] = array($tokenizer->tokens[$i - 3][1], $data_);
}
else
{
--- 565,577 ----
if(strtolower($data_) == 'true' || strtolower($data_) == 'false' || strtolower($data_) == 'null')
$code .= '(php_var) ' . strtolower($data_);
elseif(is_array($tokenizer->tokens[$i - 1]) && $tokenizer->tokens[$i - 1][0] == T_NEW)
{
$code .= '(void *) new ' . $data_;
! $this->objects[$tokenizer->tokens[$i - 3][1]] = $data_;
}
+ elseif(is_array($tokenizer->tokens[$i - 1]) && $tokenizer->tokens[$i - 1][0] == T_OBJECT_OPERATOR)
+ $code .= '_' . $data_;
+ elseif($tokenizer->tokens[$i + 1] != '(')
+ $code .= $data_;
else
{
***************
*** 572,578 ****
}
break;
- case T_OBJECT_OPERATOR:
- $code .= '->';
- break;
case '=':
$params[] = $pre . $code . $post;
--- 580,583 ----
***************
*** 587,596 ****
--- 592,610 ----
break;
case T_CONSTANT_ENCAPSED_STRING:
+ if($data_ == '"\n"')
+ {
+ $code .='endl';
+ break;
+ }
if($inconcat == true && $inbrace == false)
$code .= '(string)(const char*)';
+ else
+ $code .= '(php_var)';
$code .= '"' . str_replace('"', '\\"', substr($data_, 1, -1) ). '"';
break;
case T_DNUMBER:
case T_LNUMBER:
+ if(($tokenizer->tokens[$i - 2] == ',' || $tokenizer->tokens[$i - 2] == '(' || $tokenizer->tokens[$i - 2] == '.') && $tokenizer->tokens[$i - 1] == '-')
+ $data_ = '-' . $data_;
if($inconcat == true && $inbrace == false)
$code .= '(string)(const char*)';
***************
*** 658,662 ****
break;
case '-':
! $code .= ' - ';
break;
case '+':
--- 672,677 ----
break;
case '-':
! if($tokenizer->tokens[$i - 1] != ',' && $tokenizer->tokens[$i - 1] != '(' && $tokenizer->tokens[$i - 1] != '.')
! $code .= ' - ';
break;
case '+':
|