Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9814ac6

Browse files
author
Andrew Zenin
committed
Some php7+ compat steps
1 parent 007b970 commit 9814ac6

File tree

10 files changed

+3685
-430
lines changed

10 files changed

+3685
-430
lines changed

‎Source/AutomaticConversion.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fatal: Перетворення перервано.

‎Source/DelphiFunctions.pas

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface
1717
uses
1818
SysUtils, Classes,
1919
Controls,
20-
ZendTypes, ZendAPI, PHPTypes, PHPAPI, Dialogs, typinfo,
20+
{$IFDEF PHP7} hzend_types, {$ELSE}ZendTypes,{$ENDIF} ZendAPI, PHPTypes, PHPAPI, Dialogs, typinfo,
2121
Forms, stdctrls;
2222

2323
{$ifdef fpc}
@@ -29,14 +29,17 @@ interface
2929
author_class_entry : Tzend_class_entry;
3030
delphi_object_entry : TZend_class_entry;
3131

32-
object_functions : array[0..2] of zend_function_entry;
33-
author_functions : array[0..2] of zend_function_entry;
32+
object_functions : {$IFDEF PHP7}HashTable{$ELSE}array[0..2] of zend_function_entry{$ENDIF};
33+
author_functions : {$IFDEF PHP7}HashTable{$ELSE}array[0..2] of zend_function_entry{$ENDIF};
3434

3535
DelphiObject : pzend_class_entry;
3636
ce : pzend_class_entry;
37-
38-
{$IFDEF PHP5}
39-
DelphiObjectHandlers : zend_object_handlers;
37+
{$IFDEF PHP7}
38+
DelphiObjectHandlers : _zend_object_handlers;
39+
{$ELSE}
40+
{$IFDEF PHP5}
41+
DelphiObjectHandlers : zend_object_handlers;
42+
{$ENDIF}
4043
{$ENDIF}
4144

4245

@@ -597,7 +600,7 @@ function delphi_call_method(method : zend_pchar; ht : integer; return_value : pz
597600

598601
end;
599602

600-
function delphi_get_method(_object : pzval; method_name : zend_pchar; method_len : integer; TSRMLS_DC : pointer) : PzendFunction; cdecl;
603+
function delphi_get_method(_object : pzval; method_name : zend_pchar; method_len : integer; TSRMLS_DC : pointer) : {$IFDEF PHP7}P_zend_function{$ELSE}PzendFunction{$ENDIF}; cdecl;
601604

602605
begin
603606

@@ -688,6 +691,9 @@ procedure register_delphi_component(ht : integer; return_value : pzval; this_ptr
688691
procedure RegisterInternalClasses(p : pointer);
689692

690693
begin
694+
{$IFDEF PHP7}
695+
object_functions
696+
{$ELSE}
691697
object_functions[0].fname := 'delphi_classname';
692698
object_functions[0].handler := @delphi_object_classname;
693699

@@ -698,13 +704,13 @@ procedure RegisterInternalClasses(p : pointer);
698704
object_functions[2].handler := nil;
699705

700706
INIT_CLASS_ENTRY(delphi_object_entry, 'delphi_class' , @object_functions);
701-
707+
{$ENDIF}
702708
{$IFDEF PHP4}
703709
Delphi_Object_Entry.handle_property_get := @_delphi_get_property_wrapper;
704710
Delphi_Object_Entry.handle_property_set := @delphi_set_property_handler;
705711
Delphi_Object_Entry.handle_function_call := @delphi_call_function;
706712
{$ELSE}
707-
Move(zend_get_std_object_handlers()^, DelphiObjectHandlers, sizeof(zend_object_handlers));
713+
Move(zend_get_std_object_handlers()^, DelphiObjectHandlers, sizeof({$IFDEF PHP7}_zend_object_handlers{$ELSE}zend_object_handlers{$ENDIF}));
708714
DelphiObjectHandlers.read_property := @delphi_get_property_handler;
709715
DelphiObjecthandlers.write_property := @delphi_set_property_handler;
710716
DelphiObjectHandlers.call_method := @delphi_call_method;

‎Source/PHP.INC

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ If you are using PHP version 5.1.0 or higher please add $DEFINE PHP510
1919
If you are using PHP version 5.1.1 or higher please add $DEFINE PHP511
2020
If you are using PHP version 5.1.2 or higher please add $DEFINE PHP512
2121
If you are using PHP version 5.2.0 or higher please add $DEFINE PHP520
22-
IF you are using PHP version 5.3.0 or highre please add $DEFINE PHP530
23-
IF you are using PHP version 5.4.0 or highre please add $DEFINE PHP540
24-
IF you are using PHP version 5.5.0 or highre please add $DEFINE PHP550
25-
IF you are using PHP version 5.6.0 or highre please add $DEFINE PHP560
22+
IF you are using PHP version 5.3.0 or higher please add $DEFINE PHP530
23+
IF you are using PHP version 5.4.0 or higher please add $DEFINE PHP540
24+
IF you are using PHP version 5.5.0 or higher please add $DEFINE PHP550
25+
IF you are using PHP version 5.6.0 or higher please add $DEFINE PHP560
26+
IF you are using PHP cersion 7.0.0 or higher please add $DEFINE PHP700
2627
If you are using PHP compiled via:
2728
id, define compiler_id
2829
VC9 COMPILER_VC9
@@ -57,14 +58,17 @@ backward compatibility between PHP versions.
5758
{$DEFINE PHP540}
5859
{$DEFINE PHP550}
5960
{$DEFINE PHP560}
60-
6161
{$IFDEF PHP530}
6262
{$DEFINE ZEND_WIN32}
6363
{$DEFINE PHP_COMPILER_ID}
6464
{$ENDIF}
65+
{..$DEFINE soulengine_build}
66+
{..$DEFINE PHP7}
67+
{..$DEFINE P_CUT}
6568
{$IFDEF PHP7}
6669
{$DEFINE COMPILER_VC14}
6770
{$DEFINE PHP560}
71+
{$DEFINE PHP700}
6872
{$ENDIF}
6973
{$IFDEF PHP560}
7074
{$DEFINE PHP530}

‎Source/PHPAPI.pas

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ interface
2929
Windows
3030
{$ENDIF},
3131

32-
ZendTypes, PHPTypes, zendAPI,
32+
ZendTypes,
33+
{$IFDEF PHP7} hzend_types,{$ENDIF}
34+
PHPTypes, zendAPI,
3335

3436

3537
{$IFDEF VERSION6}Variants{$ENDIF}{WinSock};
@@ -127,7 +129,7 @@ interface
127129

128130

129131
function GetSymbolsTable : PHashTable;
130-
function GetTrackHash(Name : zend_ustr) : PHashTable;
132+
function GetTrackHash(Name : zend_ustr) : {$IFDEF PHP7}Pzend_array{$ELSE}PHashTable{$ENDIF};
131133
function GetSAPIGlobals : Psapi_globals_struct; overload;
132134
function GetSAPIGlobals(TSRMLS_DC : pointer) : Psapi_globals_struct; overload;
133135
//procedure phperror(Error : zend_pchar);
@@ -174,9 +176,9 @@ function GetSAPIGlobals(TSRMLS_DC : pointer) : Psapi_globals_struct; overload;
174176

175177

176178

177-
179+
{$IFNDEF P_CUT}
178180
php_log_err: procedure (err_msg : zend_pchar; TSRMLS_DC : pointer); cdecl;
179-
181+
{$ENDIF}
180182
php_html_puts: procedure (str : zend_pchar; str_len : integer; TSRMLS_DC : pointer); cdecl;
181183

182184
_php_error_log: function (opt_err : integer; msg : zend_pchar; opt: zend_pchar; headers: zend_pchar; TSRMLS_DC : pointer) : integer; cdecl;
@@ -357,10 +359,10 @@ function GetSymbolsTable : PHashTable;
357359

358360
{$ENDIF}
359361

360-
function GetTrackHash(Name : zend_ustr) : PHashTable;
362+
function GetTrackHash(Name : zend_ustr) : {$IFDEF PHP7}Pzend_array{$ELSE}PHashTable{$ENDIF};
361363
var
362364
data : ^ppzval;
363-
arr : PHashTable;
365+
arr : {$IFDEF PHP7}Pzend_array{$ELSE}PHashTable{$ENDIF};
364366
ret : integer;
365367
begin
366368
Result := nil;
@@ -375,7 +377,7 @@ function GetTrackHash(Name : zend_ustr) : PHashTable;
375377
ret := zend_hash_find(arr, zend_pchar(Name), Length(Name)+1, Data);
376378
if ret = SUCCESS then
377379
begin
378-
Result := data^^^.value.ht;
380+
Result := {$IFDEF PHP7}data^^^.value.arr{$ELSE}data^^^.value.ht{$ENDIF};
379381
end;
380382
end;
381383
end;
@@ -427,7 +429,7 @@ function GetSAPIGlobals(TSRMLS_DC : pointer) : Psapi_globals_struct;
427429

428430
function zval2variant(value : zval) : variant;
429431
begin
430-
case Value._type of
432+
case {$IFDEF PHP7}Value.u1.v._type{$ELSE}Value._type{$ENDIF} of
431433
IS_NULL : Result := NULL;
432434
IS_LONG : Result := Value.value.lval;
433435
IS_DOUBLE : Result := Value.value.dval;
@@ -756,9 +758,9 @@ function LoadPHP(const DllFileName: zend_ustr = PHPWin) : boolean;
756758
php_body_write := GetProcAddress(PHPLib, 'php_body_write');
757759

758760
php_header_write := GetProcAddress(PHPLib, 'php_header_write');
759-
761+
{$IFNDEF P_CUT}
760762
php_log_err := GetProcAddress(PHPLib, 'php_log_err');
761-
763+
{$ENDIF}
762764
php_html_puts := GetProcAddress(PHPLib, 'php_html_puts');
763765

764766
_php_error_log := GetProcAddress(PHPLib, '_php_error_log');
@@ -845,7 +847,9 @@ procedure CheckPHPErrors;
845847
if @php_register_variable_safe = nil then raise EPHP4DelphiException.Create('php_register_variable_safe');
846848
if @php_register_variable_ex = nil then raise EPHP4DelphiException.Create('php_register_variable_ex');
847849
if @php_strip_tags = nil then raise EPHP4DelphiException.Create('php_strip_tags');
850+
{$IFNDEF P_CUT}
848851
if @php_log_err = nil then raise EPHP4DelphiException.Create('php_log_err');
852+
{$ENDIF}
849853
if @php_html_puts = nil then raise EPHP4DelphiException.Create('php_html_puts');
850854
if @_php_error_log = nil then raise EPHP4DelphiException.Create('_php_error_log');
851855
if @php_print_credits = nil then raise EPHP4DelphiException.Create('php_print_credits');

‎Source/PHPFunctions.pas

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ interface
2222
Windows, SysUtils, Classes,
2323
{$IFDEF PHP_UNICE}WideStrUtils, {$ENDIF}
2424
{$IFDEF VERSION6} Variants,
25-
{$ENDIF} ZendTypes, PHPTypes, ZendAPI, PHPAPI ;
25+
{$ENDIF}
26+
{$IFDEF PHP7} hzend_types, {$ENDIF}
27+
ZendTypes, PHPTypes, ZendAPI, PHPAPI ;
2628

2729
type
2830
TParamType = (tpString, tpInteger, tpFloat, tpBoolean, tpArray, tpUnknown);
@@ -175,7 +177,7 @@ function IsParamTypeCorrect(AParamType : TParamType; z : Pzval) : boolean;
175177
var
176178
ZType : integer;
177179
begin
178-
ZType := Z^._type;
180+
ZType := {$IFDEF PHP7}Z^.u1.v._type{$ELSE} Z^._type{$ENDIF};
179181
case AParamType Of
180182
tpString : Result := (ztype in [IS_STRING, IS_NULL]);
181183
tpInteger : Result := (ztype in [IS_LONG, IS_BOOL, IS_NULL, IS_RESOURCE]);
@@ -389,30 +391,16 @@ procedure TFunctionParams.SetItem(Index: Integer; Value: TFunctionParam);
389391
procedure TFunctionParams.SetItemName(Item: TCollectionItem);
390392
var
391393
I, J: Integer;
392-
ItemName: string;
393394
CurItem: TFunctionParam;
394395
begin
395396
J := 1;
396-
while True do
397+
CurItem := ParamByName('Param1');
398+
while (CurItem <> nil) and (CurItem <> Item) do
397399
begin
398-
ItemName := Format('Param%d', [J]);
399-
I := 0;
400-
while I < Count do
401-
begin
402-
CurItem := Items[I] as TFunctionParam;
403-
if (CurItem <> Item) and (CompareText(CurItem.Name, ItemName) = 0) then
404-
begin
405-
Inc(J);
406-
Break;
407-
end;
408-
Inc(I);
409-
end;
410-
if I >= Count then
411-
begin
412-
(Item as TFunctionParam).Name := ItemName;
413-
Break;
414-
end;
400+
inc(J);
401+
CurItem := ParamByName('Param' + inttostr(J));
415402
end;
403+
(Item as TFunctionParam).Name := 'Param' + inttostr(J);
416404
end;
417405

418406
function TFunctionParams.Values(AName: string): Variant;
@@ -522,7 +510,7 @@ function TZendVariable.GetAsBoolean: boolean;
522510
Exit;
523511
end;
524512

525-
caseFValue^._type of
513+
case{$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} of
526514
IS_STRING :
527515
begin
528516
if SameText(GetAsString, 'True') then
@@ -545,7 +533,7 @@ function TZendVariable.GetAsDate: TDateTime;
545533
Exit;
546534
end;
547535

548-
caseFValue^._type of
536+
case{$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} of
549537
IS_STRING : Result := StrToDate(GetAsString);
550538
IS_DOUBLE : Result := FValue^.value.dval;
551539
else
@@ -561,7 +549,7 @@ function TZendVariable.GetAsDateTime: TDateTime;
561549
Exit;
562550
end;
563551

564-
case FValue^._type of
552+
case {$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} of
565553
IS_STRING : Result := StrToDateTime(GetAsString);
566554
IS_DOUBLE : Result := FValue^.value.dval;
567555
else
@@ -585,7 +573,7 @@ function TZendVariable.GetAsFloat: double;
585573
Exit;
586574
end;
587575

588-
case FValue^._type of
576+
case {$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} of
589577
IS_STRING : Result := StrToFloatDef(GetAsString,0.0);
590578
IS_DOUBLE : Result := FValue^.value.dval;
591579
else
@@ -601,7 +589,7 @@ function TZendVariable.GetAsInteger: integer;
601589
Exit;
602590
end;
603591

604-
case FValue^._type of
592+
case {$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} of
605593
IS_STRING : result := StrToIntDef(GetAsString, 0);
606594
IS_DOUBLE : result := Round(FValue^.value.dval);
607595
IS_NULL : result := 0;
@@ -621,7 +609,7 @@ function TZendVariable.GetAsString: zend_ustr;
621609
Exit;
622610
end;
623611

624-
case FValue^._type of
612+
case {$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} of
625613
IS_STRING : begin
626614
try
627615
SetLength(Result, FValue^.value.str.len);
@@ -654,7 +642,7 @@ function TZendVariable.GetAsTime: TDateTime;
654642
Exit;
655643
end;
656644

657-
case FValue^._type of
645+
case {$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} of
658646
IS_STRING : Result := StrToTime(GetAsString);
659647
IS_DOUBLE : Result := FValue^.value.dval;
660648
else
@@ -681,7 +669,7 @@ function TZendVariable.GetDataType: integer;
681669
Exit;
682670
end;
683671

684-
Result := FValue^._type;
672+
Result := {$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF};
685673
end;
686674

687675
function TZendVariable.GetIsNull: boolean;
@@ -691,7 +679,7 @@ function TZendVariable.GetIsNull: boolean;
691679
Result := true;
692680
Exit;
693681
end;
694-
Result := FValue^._type = IS_NULL;
682+
Result := {$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} = IS_NULL;
695683
end;
696684

697685
function TZendVariable.GetTypeName: string;
@@ -702,7 +690,7 @@ function TZendVariable.GetTypeName: string;
702690
Exit;
703691
end;
704692

705-
case FValue^._type of
693+
case {$IFDEF PHP7}FValue^.u1.v._type{$ELSE} FValue^._type{$ENDIF} of
706694
IS_NULL: result := 'null';
707695
IS_LONG: result := 'integer';
708696
IS_DOUBLE: result := 'double';

‎Source/PHPTypes.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
interface
1717

1818
uses
19-
{$IFNDEF FPC} Windows{$ELSE} LCLType{$ENDIF}, ZENDTypes;
19+
{$IFNDEF FPC} Windows{$ELSE} LCLType{$ENDIF}, {$IFDEF PHP7}hzend_types,{$ENDIF}ZENDTypes;
2020

2121
{$IFDEF PHP4}
2222
const
@@ -240,7 +240,7 @@ interface
240240
sapi_started : zend_bool;
241241
{$IFDEF PHP510}
242242
global_request_time : longint;
243-
known_post_content_types : THashTable;
243+
known_post_content_types : {$IFDEF PHP7}HashTable{$ELSE}THashTable{$ENDIF};
244244
{$ENDIF}
245245
{$ENDIF}
246246
end;
@@ -387,7 +387,7 @@ interface
387387
arg_separator : arg_separators;
388388
gpc_order : zend_pchar;
389389
variables_order : zend_pchar;
390-
rfc1867_protected_variables : THashTable;
390+
rfc1867_protected_variables : {$IFDEF PHP7}HashTable{$ELSE}THashTable{$ENDIF};
391391
connection_status : Smallint;
392392
ignore_user_abort : Smallint;
393393
header_is_being_sent : Byte;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /