Skip to content

Commit

Permalink
fix pure call_c_function convertion
Browse files Browse the repository at this point in the history
  • Loading branch information
jimthunderbird committed Feb 24, 2015
1 parent 9048c90 commit 62c9056
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/PHPtoCExt/Converter/CFuntionCallConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function convert()
$resultVarName = "";
if ($lineCompsCount == 1) { //this means we just call the c function and do not have a return variable
$cFunctionCallComps = explode(",",$lineComps[0]);
$cFunctionCallComps = explode(",",$lineComps[1]);
foreach($cFunctionCallComps as $idx => $comp) {
$cFunctionCallComps[$idx] = trim(str_replace("$","",$cFunctionCallComps[$idx]));
}
Expand All @@ -50,16 +49,19 @@ public function convert()
}

$cFunctionCallCode = "";
$cFunctionCallCode .= "let $resultVarName = null;\n"; //initialize result var
$cFunctionCallCode .= "\n%{\n";
if (strlen($resultVarName) == 0) {
$cFunctionCallCode .= "\n%{\n";
$cFunctionCallCode .= $cFUnctionName."($cFUnctionInputParamsStr);";
$cFunctionCallCode .= "\n}%\n";
$expectedZephirCode = 'call_c_function('.$firstComp.', '.$secondComp.', '.implode(", ",$cFunctionCallComps).');';
} else {
$cFunctionCallCode .= "let $resultVarName = null;\n"; //initialize result var
$cFunctionCallCode .= "\n%{\n";
$cFunctionCallCode .= "$resultVarName = ".$cFUnctionName."($cFUnctionInputParamsStr);";
$cFunctionCallCode .= "\n}%\n";
$expectedZephirCode = 'let '.$resultVarName.' = call_c_function('.$firstComp.', '.$secondComp.', '.implode(", ",$cFunctionCallComps).');';
}
$cFunctionCallCode .= "\n}%\n";

$expectedZephirCode = 'let '.$resultVarName.' = call_c_function('.$firstComp.', '.$secondComp.', '.implode(", ",$cFunctionCallComps).');';
$this->postSearchAndReplace($expectedZephirCode,$cFunctionCallCode);

//now, inject the c source code to the top of the class
Expand Down

0 comments on commit 62c9056

Please sign in to comment.