Skip to content

Commit

Permalink
added handling of boolean properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rssh committed Feb 27, 2012
1 parent eeabccf commit 09cd3d3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local.version=1.3.4
local.version=1.3.5
termware.version=2.3.3
termwarephp.version=1.1.1
javachecker.version=2.5.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ public PhpJaoFacts(Facade facade) throws TermWareException

public boolean isGetterString(String name)
{
return name.startsWith("get");
return (name.startsWith("get") &&
name.length() > 3 &&
Character.isUpperCase(name.charAt(3))
)
||
(name.startsWith("is") &&
name.length() > 2 &&
Character.isUpperCase(name.charAt(2))
)
;
}

public boolean getNameFromGetterString(TransformationContext ctx, String s, Term x) throws TermWareException
Expand All @@ -43,6 +52,13 @@ public boolean getNameFromGetterString(TransformationContext ctx, String s, Term
char ch = Character.toLowerCase(withoutGet.charAt(0));
retval = ""+ch+withoutGetX;
}
} else if (s.startsWith("is")) {
String withoutIs = s.substring(2);
if (s.length()>2) {
String withoutIsX = withoutIs.substring(1);
char ch = Character.toLowerCase(withoutIs.charAt(0));
retval = ""+ch+withoutIsX;
}
}
ctx.getCurrentSubstitution().put(x, TermUtils.createString(retval));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class AntCallTest {
@Test
public void testT1() throws Exception
{
doAntCall("testdata/t1","generate-php");
doAntCall("testdata/t1","test-generated");
Assert.assertTrue(checkOutputFile("testdata/t1/phpoutput.log"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@
</phpjao:generate>
</target>

<target name="test-generated" depends="generate-php">
<exec executable="php" output="phpoutput.log" >
<arg value="-c" />
<arg value="php.ini" />
<arg value="php/test.php" />
</exec>
</target>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public function __construct(){

$this->phpClass = 'E1';

$this->typesOfFields = array('name' => 'java.lang.String', 'value' => 'java.lang.String');
$this->typesOfFields = array('name' => 'java.lang.String', 'value' => 'java.lang.String', 'truth' => 'java.lang.Boolean');

}

Expand All @@ -30,6 +30,8 @@ public function getPHPJAOClassDescription(){

public $value;

public $truth;

}
E1::$phpjaoClassDescription = new E1PHPJAOClassDescription();
PHPJAO::registerType('ua.gradsoft.t1.E1', E1::$phpjaoClassDescription);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
require_once('generated.php');
$x = new E1();
//var_dump($x);
if (!$x->truth) {
$x->truth = true;
}
//var_dump($x);
if ($x->truth) {
echo 'OK';
} else {
echo 'ERR: !$x->truth';
}
?>

0 comments on commit 09cd3d3

Please sign in to comment.