UJMLサンプル108:importとexportの話とstate-machine そろそろまじめに学ばないとわからない(2006/05/05)
既存のソースコードをリファクタリングしていたら、予想外の動作で困り果てる。そろそろまじめに、<partition>や<state-machine>の勉強をしないとはまる。
例えば、main.ujmlがこんな感じで、Hogeという名のステートマシンを使っているとする。このステートマシンから、_link()でnewPart.ujbcという新しい<partition>にリンクしているのだが、ランタイムエラーが発生する。「newPart.ujbcがsHogeのimportに失敗する」というエラーだ。ステートマシン内から_link()してはいけないのだろうか?どうなっているのか知りたい。
----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ujml PUBLIC "-//UIEVOLUTION//DTD UJML 1.5//EN"
"http://www.uievolution.com/dtd/ujml-1.5.dtd" [
]>
<!-- http://uiengineda.blogs.com -->
<ujml>
<application>
<state-machines>
<state-machine name="Hoge">
<state-variables>
<state-var name="sHoge" type="boolean" access="export"/>
</state-variables>
<functions>
<function name="go" type="void" visibility="public">
<script>
_link("test","build/newPart.ujbc");
</script>
</function>
</functions>
</state-machine>
</state-machines>
<script>
Hoge.go();
</script>
</application>
</ujml>
----
----newPart.ujml
<ujml>
<partition>
<state-variables>
<state-var name="sHoge" type="boolean" access="import"/>
</state-variables>
<script>
</script>
</partition>
</ujml>
----
コメント