-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop binding refs into args array for fb_intercept with inout handlers
Summary: They already return the arguments array back out as an `inout` parameter. Reviewed By: jano Differential Revision: D14999692 fbshipit-source-id: 01bf885731d343e24d75958db022d6a6f04e48e7
- Loading branch information
Showing
5 changed files
with
130 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?hh | ||
|
||
function handler1($name, $target, inout $args, $ctx, inout $done) { | ||
$done = true; | ||
$args[0] = 'handler1'; | ||
} | ||
|
||
class W { | ||
static function handler2($name, $target, inout $args, $ctx, inout $done) { | ||
$done = true; | ||
$args[0] = 'handler2'; | ||
} | ||
|
||
function handler3($name, $target, inout $args, $ctx, inout $done) { | ||
$done = true; | ||
$args[0] = 'handler3'; | ||
} | ||
|
||
function make_closure() { | ||
return ($name, $target, inout $args, $ctx, inout $done) ==> { | ||
spl_object_hash($this); | ||
$done = true; | ||
$args[0] = 'handler4'; | ||
}; | ||
} | ||
|
||
static function make_static_closure() { | ||
return ($name, $target, inout $args, $ctx, inout $done) ==> { | ||
$done = true; | ||
$args[0] = 'handler5'; | ||
}; | ||
} | ||
} | ||
|
||
function foo(&$x) { echo "fail!\n"; } | ||
function bar(&$x) { echo "fail!\n"; } | ||
function fiz(&$x) { echo "fail!\n"; } | ||
function buz(&$x) { echo "fail!\n"; } | ||
function biz(&$x) { echo "fail!\n"; } | ||
function far(&$x) { echo "fail!\n"; } | ||
|
||
<<__EntryPoint>> | ||
function main() { | ||
$handler6 = ($name, $target, inout $args, $ctx, inout $done) ==> { | ||
$done = true; | ||
$args[0] = 'handler6'; | ||
}; | ||
fb_intercept('foo', 'handler1'); | ||
fb_intercept('bar', 'W::handler2'); | ||
fb_intercept('fiz', [new W, 'handler3']); | ||
fb_intercept('buz', (new W)->make_closure()); | ||
fb_intercept('biz', W::make_static_closure()); | ||
fb_intercept('far', $handler6); | ||
|
||
$x = 'fail'; foo(&$x); echo "foo: $x\n"; | ||
$x = 'fail'; bar(&$x); echo "bar: $x\n"; | ||
$x = 'fail'; fiz(&$x); echo "fiz: $x\n"; | ||
$x = 'fail'; buz(&$x); echo "buz: $x\n"; | ||
$x = 'fail'; biz(&$x); echo "biz: $x\n"; | ||
$x = 'fail'; far(&$x); echo "far: $x\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
foo: handler1 | ||
bar: handler2 | ||
fiz: handler3 | ||
buz: handler4 | ||
biz: handler5 | ||
far: handler6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-vJitEnableRenameFunction=1 |