--- /dev/null
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+\f
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
--- /dev/null
+TARGET = libliveml.a
+LDFLAGS = -shared
+OBJS = src/*.o
+LIBS = -ltinyxml
+
+all: $(TARGET) example
+
+$(TARGET):
+ cd src; make
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+example:
+ cd test; make
+clean:
+ -rm $(TARGET)
+ cd src; make clean
+ cd test; make clean
--- /dev/null
+=============================
+ LiveMLについて
+=============================
+XMLで画面の制御を手軽に扱うためのライブラリです。
+ゲームなどに組み込んで利用することを想定しています。
+
+プログラム側で画面のレイアウトや演出などを行うことは、
+それだけで大変な作業だと思います。
+そのため、大概の場合はスクリプト言語などを組み込んで制御するか、
+簡易言語を自作するかのどちらかを選択すると思います。
+スクリプトはアニメーションなどの演出などを行うのには適していませんし、
+自作するとなるとそれだけで多くの時間を割くことになります。
+画面の制御を行うためのライブラリは、
+私の調べた限りでは理想的なものはありませんでした。
+
+LiveMLは、画面制御を手軽に扱えるよう設計されています。
+ABAさんが数年前に作成されたもので、
+BulletMLという弾幕をXMLで記述できるものがありました。
+これはとても簡単に弾幕を作成できるよう設計されていて、
+私はBulletMLを参考にLiveMLを設計しています。
+
+また、LiveMLは独自にタグを増やすことができるため、
+利用方法に合わせてカスタマイズして使用することが可能となっています。
+(BulletMLも再現可能かもしれません、あまり意味はないと思いますが^^;)
+
+=============================
+ 注意
+=============================
+このプログラムは現在開発中のため、
+利用できるレベルまで達していません。
+利用する際には自己責任でお願いします。
+
+=============================
+ 依存ライブラリ
+=============================
+tinyxml
+
+=============================
+ ビルド手順
+=============================
+make コマンドを叩くと、ライブラリとテストプログラムが生成されます。
--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual C++ Express 2010\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LiveML", "LiveML\LiveML.vcxproj", "{06B7D52E-730E-4821-A405-27CC430F2D4F}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Win32 = Debug|Win32\r
+ Release|Win32 = Release|Win32\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {06B7D52E-730E-4821-A405-27CC430F2D4F}.Debug|Win32.ActiveCfg = Debug|Win32\r
+ {06B7D52E-730E-4821-A405-27CC430F2D4F}.Debug|Win32.Build.0 = Debug|Win32\r
+ {06B7D52E-730E-4821-A405-27CC430F2D4F}.Release|Win32.ActiveCfg = Release|Win32\r
+ {06B7D52E-730E-4821-A405-27CC430F2D4F}.Release|Win32.Build.0 = Release|Win32\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <ItemGroup>\r
+ <Filter Include="source">\r
+ <UniqueIdentifier>{5c6f7eed-8301-4873-be35-893e1489603f}</UniqueIdentifier>\r
+ </Filter>\r
+ <Filter Include="header">\r
+ <UniqueIdentifier>{63d263b0-75ee-4e31-a9a6-3e9ba1e2787b}</UniqueIdentifier>\r
+ </Filter>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClInclude Include="..\src\directormlparser.h">\r
+ <Filter>header</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\src\directormlrunner.h">\r
+ <Filter>header</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\src\xmlparser.h">\r
+ <Filter>header</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\src\list.h">\r
+ <Filter>header</Filter>\r
+ </ClInclude>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClCompile Include="..\src\directormlparser.cpp">\r
+ <Filter>source</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\src\directormlrunner.cpp">\r
+ <Filter>source</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\src\xmlparser.cpp">\r
+ <Filter>source</Filter>\r
+ </ClCompile>\r
+ </ItemGroup>\r
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <ItemGroup Label="ProjectConfigurations">\r
+ <ProjectConfiguration Include="Debug|Win32">\r
+ <Configuration>Debug</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
+ <ProjectConfiguration Include="Release|Win32">\r
+ <Configuration>Release</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
+ </ItemGroup>\r
+ <PropertyGroup Label="Globals">\r
+ <ProjectGuid>{06B7D52E-730E-4821-A405-27CC430F2D4F}</ProjectGuid>\r
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\r
+ <Keyword>ManagedCProj</Keyword>\r
+ <RootNamespace>libdirectorml</RootNamespace>\r
+ </PropertyGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+ <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+ <UseDebugLibraries>true</UseDebugLibraries>\r
+ <CLRSupport>false</CLRSupport>\r
+ <CharacterSet>Unicode</CharacterSet>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+ <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+ <UseDebugLibraries>false</UseDebugLibraries>\r
+ <CLRSupport>true</CLRSupport>\r
+ <CharacterSet>Unicode</CharacterSet>\r
+ </PropertyGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+ <ImportGroup Label="ExtensionSettings">\r
+ </ImportGroup>\r
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ </ImportGroup>\r
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ </ImportGroup>\r
+ <PropertyGroup Label="UserMacros" />\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <LinkIncremental>false</LinkIncremental>\r
+ <TargetName>directorml</TargetName>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <LinkIncremental>false</LinkIncremental>\r
+ </PropertyGroup>\r
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <ClCompile>\r
+ <Optimization>Disabled</Optimization>\r
+ <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
+ <WarningLevel>Level3</WarningLevel>\r
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r
+ <CompileAsManaged>\r
+ </CompileAsManaged>\r
+ </ClCompile>\r
+ <Link>\r
+ <GenerateDebugInformation>true</GenerateDebugInformation>\r
+ <AdditionalDependencies>tinyxmld.lib</AdditionalDependencies>\r
+ <IgnoreSpecificDefaultLibraries>\r
+ </IgnoreSpecificDefaultLibraries>\r
+ <SubSystem>NotSet</SubSystem>\r
+ <ImportLibrary>\r
+ </ImportLibrary>\r
+ </Link>\r
+ </ItemDefinitionGroup>\r
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <ClCompile>\r
+ <WarningLevel>Level3</WarningLevel>\r
+ <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <PrecompiledHeader>Use</PrecompiledHeader>\r
+ </ClCompile>\r
+ <Link>\r
+ <GenerateDebugInformation>true</GenerateDebugInformation>\r
+ <AdditionalDependencies>\r
+ </AdditionalDependencies>\r
+ </Link>\r
+ </ItemDefinitionGroup>\r
+ <ItemGroup>\r
+ <Reference Include="System" />\r
+ <Reference Include="System.Data" />\r
+ <Reference Include="System.Xml" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClCompile Include="..\..\src\directormlparser.cpp" />\r
+ <ClCompile Include="..\..\src\directormlrunner.cpp" />\r
+ <ClCompile Include="..\..\src\xmlparser.cpp" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClInclude Include="..\..\src\directormlparser.h" />\r
+ <ClInclude Include="..\..\src\directormlrunner.h" />\r
+ <ClInclude Include="..\..\src\list.h" />\r
+ <ClInclude Include="..\..\src\xmlparser.h" />\r
+ </ItemGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+ <ImportGroup Label="ExtensionTargets">\r
+ </ImportGroup>\r
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+</Project>
\ No newline at end of file
--- /dev/null
+OBJS = xmlparser.o livemlparser.o livemlrunner.o calcu.o stack.o fixed_float.o
+CC = cc
+CFLAGS = -O -DDEBUG
+INCLUDES = -I/usr/include -I/usr/include/apr-1.0 -I./src
+
+all: $(OBJS)
+
+clean:
+ -rm $(OBJS)
+
+.cpp.o:
+ $(CC) $(CFLAGS) $(INCLUDES) -c $<
+
+livemlparser.h: xmlparser.h
+livemlparser.o: livemlparser.h
+xmlparser.o: xmlparser.h
--- /dev/null
+/**
+ * bool_list - boolean list.
+ *
+ * MIT License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/c-utils/
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copiGes or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIAGBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#ifndef __BOOL_LIST_H__
+#define __BOOL_LIST_H__
+
+#include <vector>
+
+class bool_list
+{
+ vector<unsigned char> pool;
+ size_t bitPeerElement()
+ {
+ return sizeof(unsigned char) * 8;
+ }
+public:
+ bool operator[](size_t index)
+ {
+ return is(index);
+ }
+ bool is(size_t index)
+ {
+ size_t bit = bitPeerElement();
+ size_t el = index / bit;
+ if (pool.size() < el + 1) return false;
+ return (pool[el] & (1 << (index % bit))) > 0;
+ }
+ void on(size_t index)
+ {
+ size_t bit = bitPeerElement();
+ size_t el = index / bit;
+ if (pool.size() < el + 1) return;
+ pool[el] |= 1 << (index % bit);
+ }
+ void off(size_t index)
+ {
+ size_t bit = bitPeerElement();
+ size_t el = index / bit;
+ if (pool.size() < el + 1) return;
+ pool[el] &= ~(1 << (index % bit));
+ }
+ void clear(void) { pool.clear(); }
+ void resize(size_t index)
+ {
+ size_t bit = bitPeerElement();
+ pool.resize(index / bit + (index % bit > 0));
+ }
+};
+
+#endif
--- /dev/null
+/**
+ * calcu - original calculation.
+ *
+ * MIT License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/c-utils/
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copiGes or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIAGBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#include "calcu.h"
+#include <malloc.h>
+
+enum
+{
+ CALCU_VARIABLE = 'v',
+ CALCU_NUMERIC = 'n',
+ CALCU_EOC = '\0'
+};
+
+fixed_float calcu_decode(const char *data, fixed_float (*func)(calcu_variable))
+{
+ fixed_float v1;
+ fixed_float v2;
+ stack_data stack;
+
+ stack_init(&stack, sizeof(fixed_float));
+ stack_resize(&stack, 5);
+
+ while (*data != CALCU_EOC)
+ {
+ switch (*data++)
+ {
+ case CALCU_VARIABLE:
+ v1 = func(*(calcu_variable*)data);
+ stack_push(&stack, &v1);
+ data += sizeof(calcu_variable);
+ break;
+ case CALCU_NUMERIC:
+ stack_push(&stack, (void*)data);
+ data += sizeof(fixed_float);
+ break;
+ case '+':
+ stack_pop(&stack, &v2);
+ stack_pop(&stack, &v1);
+ v1 += v2;
+ stack_push(&stack, &v1);
+ break;
+ case '-':
+ stack_pop(&stack, &v2);
+ stack_pop(&stack, &v1);
+ v1 -= v2;
+ stack_push(&stack, &v1);
+ break;
+ case '%':
+ stack_pop(&stack, &v2);
+ stack_pop(&stack, &v1);
+ v1 %= v2;
+ stack_push(&stack, &v1);
+ break;
+ case '*':
+ stack_pop(&stack, &v2);
+ stack_pop(&stack, &v1);
+ v1 = fixed_float_multi(v1, v2);
+ stack_push(&stack, &v1);
+ break;
+ case '/':
+ stack_pop(&stack, &v2);
+ stack_pop(&stack, &v1);
+ v1 = fixed_float_div(v1, v2);
+ stack_push(&stack, &v1);
+ break;
+ }
+ }
+
+ stack_pop(&stack, &v1);
+ stack_free(&stack);
+
+ return v1;
+}
+
+inline int operator_priority(char op)
+{
+ int priority = 0;
+ switch (op)
+ {
+ case '/': priority++;
+ case '*': priority++;
+ case '%': priority++;
+ case '+': priority++;
+ case '-': priority++;
+ case '\0': priority++;
+ }
+
+ return priority;
+}
+
+typedef struct
+{
+ int priority;
+ char operator;
+} calcu_operator;
+
+char* calcu_encode(char* text, calcu_variable (*func)(const char*))
+{
+ char *output = malloc(100);
+ char *current = output;
+ int plus_priority = 0;
+ stack_data stack_optr;
+ calcu_operator operator;
+
+ stack_init(&stack_optr, sizeof(calcu_operator));
+ stack_resize(&stack_optr, 10);
+
+ while (1)
+ {
+ /* operator */
+ int priority = operator_priority(*text);
+ if (priority)
+ {
+ priority += plus_priority;
+ while (!stack_pop(&stack_optr, &operator))
+ {
+ if (priority > operator.priority)
+ {
+ stack_push(&stack_optr, &operator);
+ break;
+ }
+ /* output */
+ *current = operator.operator;
+ current++;
+ }
+ if (*text == '\0') break;
+ operator.operator = *text++;
+ operator.priority = priority;
+ stack_push(&stack_optr, &operator);
+ }
+
+ /* numeric */
+ if (*text >= '0' && *text <= '9')
+ {
+ fixed_float *v = (fixed_float*)(current + 1);
+ int float_point = 0;
+ int iv = 0;
+ float fv = 0;
+
+ while (*text >= '0' && *text <= '9' || *text == '.')
+ {
+ char num;
+ if (*text == '.')
+ {
+ float_point = 10;
+ text++;
+ continue;
+ }
+
+ num = *text++ - '0';
+ if (float_point)
+ {
+ fv += (float)num / float_point;
+ float_point *= 10;
+ }
+ else
+ {
+ if (iv) iv *= 10;
+ iv += num;
+ }
+ }
+ /* output */
+ *current = CALCU_NUMERIC;
+ *v = int_to_fixed_float(iv);
+ if (fv) *v += float_to_fixed_float(fv);
+
+ current += 1 + sizeof(fixed_float);
+ continue;
+ }
+
+ /* variable */
+ if (*text == '$')
+ {
+ calcu_variable *v = (calcu_variable*)(current + 1);
+ char *name = ++text;
+ char save;
+ while (
+ (*text >= 'a' && *text <= 'z') ||
+ (*text >= 'A' && *text <= 'Z') ||
+ *text == '_') text++;
+ save = *text;
+ *text = '\0';
+ /* output */
+ *current = CALCU_VARIABLE;
+ *v = func((const char*)name);
+ *text = save;
+ current += 1 + sizeof(calcu_variable);
+ continue;
+ }
+
+ switch (*text++)
+ {
+ case '(':
+ plus_priority += 10;
+ break;
+ case ')':
+ plus_priority -= 10;
+ break;
+ }
+ }
+
+ stack_free(&stack_optr);
+ *current = CALCU_EOC;
+
+ return output;
+}
+
+int calcu_data_size(const char *data)
+{
+ int size = 0;
+
+ while (*data != CALCU_EOC)
+ {
+ size++;
+ switch (*data++)
+ {
+ case CALCU_VARIABLE:
+ size += sizeof(calcu_variable);
+ break;
+ case CALCU_NUMERIC:
+ size += sizeof(fixed_float);
+ break;
+ }
+ }
+
+ return ++size;
+}
--- /dev/null
+/**
+ * calcu - original calculation.
+ *
+ * MIT License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/c-utils/
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#ifndef __CALCU_H__
+#define __CALCU_H__
+
+#include "stack.h"
+#include "fixed_float.h"
+
+typedef unsigned short calcu_variable;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+fixed_float calcu_decode(const char*, fixed_float (*)(calcu_variable));
+char* calcu_encode(char*, calcu_variable (*)(const char*));
+int calcu_data_size(const char*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/**
+ * fixed_float - fixed-point number.
+ *
+ * MIT License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/c-utils/
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copiGes or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIAGBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#include "fixed_float.h"
+
+#define DECIMAL_POINT_HALF (1 << (DECIMAL_POINT - 1))
+
+fixed_float int_to_fixed_float(int x)
+{
+ if (x == 0) return 0;
+ return (fixed_float)(x << DECIMAL_POINT);
+}
+
+fixed_float float_to_fixed_float(float x)
+{
+ if (x == 0) return 0;
+ return (fixed_float)((double)x * (1 << DECIMAL_POINT));
+}
+
+int fixed_float_to_int(fixed_float x)
+{
+ if (x == 0) return 0;
+ return (int)(x >> DECIMAL_POINT);
+}
+
+float fixed_float_to_float(fixed_float x)
+{
+ if (x == 0) return 0;
+ return (float)((double)x / (1 << DECIMAL_POINT));
+}
+
+fixed_float fixed_float_multi(fixed_float x, fixed_float y)
+{
+ fixed_float result = x * y;
+
+ result += DECIMAL_POINT_HALF * (result > 0 ? 1 : -1);
+ result >>= DECIMAL_POINT;
+
+ return result;
+}
+
+fixed_float fixed_float_div(fixed_float x, fixed_float y)
+{
+ fixed_float result = (x << DECIMAL_POINT) / y;
+
+ return result;
+}
--- /dev/null
+/**
+ * fixed_float - fixed-point number.
+ *
+ * MIT License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/c-utils/
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copiGes or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIAGBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#ifndef __FIXED_FLOAT_H__
+#define __FIXED_FLOAT_H__
+
+#define DECIMAL_POINT 8
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int fixed_float;
+
+fixed_float int_to_fixed_float(int x);
+fixed_float float_to_fixed_float(float x);
+int fixed_float_to_int(fixed_float x);
+float fixed_float_to_float(fixed_float x);
+fixed_float fixed_float_multi(fixed_float x, fixed_float y);
+fixed_float fixed_float_div(fixed_float x, fixed_float y);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/**
+ * list - The doubly-linked list.
+ *
+ * MIT License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/c-utils/
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#ifndef __LIST_HPP__
+#define __LIST_HPP__
+
+#include <stdlib.h>
+
+template <class T>
+struct list_item
+{
+ T data;
+ list_item<T> *next;
+ list_item<T> *prev;
+};
+
+template <class T>
+class list_allocator
+{
+ size_t _size;
+ list_item<T> *_pool;
+ list_item<T> *_free;
+public:
+ list_allocator(size_t size = 0)
+ {
+ _size = 0;
+ resize(size);
+ clear();
+ }
+
+ ~list_allocator()
+ {
+ resize(0);
+ }
+
+ void clear(void)
+ {
+ _free = _pool;
+ list_item<T> *item = _pool;
+ for (size_t i = 0; i < _size; i++, item++)
+ {
+ if (i)
+ {
+ item->prev = item - 1;
+ item->prev->next = item;
+ }
+ else item->prev = NULL;
+ item->next = NULL;
+ }
+ }
+
+ void resize(size_t size)
+ {
+ if (_size)
+ {
+ free(_pool);
+ }
+ if (size)
+ {
+ _pool = (list_item<T>*)malloc(sizeof(list_item<T>) * size);
+ }
+ else
+ {
+ _pool = _free = NULL;
+ }
+ _size = size;
+ }
+
+ list_item<T>* add(void)
+ {
+ if (_free == NULL) return NULL;
+ list_item<T>* item = _free;
+ _free = _free->next;
+ item->next = NULL;
+ if (_free != NULL) _free->prev = NULL;
+
+ return item;
+ }
+
+ void remove(list_item<T> *li)
+ {
+ if (_free)
+ {
+ _free->prev = li;
+ li->next = _free;
+ }
+ else li->next = NULL;
+ _free = li;
+ _free->prev = NULL;
+ }
+
+ size_t size(void)
+ {
+ return _size;
+ }
+};
+
+template <class T>
+class list
+{
+ bool _free_alloc;
+ list_allocator<T> *_alloc;
+ list_item<T> *_active_front;
+ list_item<T> *_active_back;
+
+public:
+
+ list(size_t size = 0)
+ {
+ _free_alloc = true;
+ _alloc = new list_allocator<T>;
+ resize(size);
+ clear();
+ }
+
+ ~list()
+ {
+ if (_free_alloc) delete _alloc;
+ }
+
+ void allocator(list_allocator<T> *a, bool is_free = false)
+ {
+ if (_free_alloc) delete _alloc;
+ _alloc = a;
+ _free_alloc = is_free;
+ }
+
+ void clear(void)
+ {
+ _alloc->clear();
+ _active_front = NULL;
+ _active_back = NULL;
+ }
+
+ void resize(size_t size)
+ {
+ _alloc->resize(size);
+ clear();
+ }
+
+ void chain_next(list_item<T> *a, list_item<T> *b)
+ {
+ if (a->next == NULL) _active_back = b;
+ else a->next->prev = b;
+ b->next = a->next;
+ b->prev = a;
+ a->next = b;
+ }
+
+ void chain_prev(list_item<T> *a, list_item<T> *b)
+ {
+ if (a->prev == NULL) _active_front = b;
+ else a->prev->next = b;
+ b->prev = a->prev;
+ b->next = a;
+ a->prev = b;
+ }
+
+ T* push_front(void)
+ {
+ list_item<T> *item = _alloc->add();
+ if (!item) return NULL;
+
+ if (_active_front == NULL)
+ {
+ _active_front = item;
+ _active_back = item;
+ }
+ else chain_prev(_active_front, item);
+
+ return (T*)item;
+ }
+
+ T* push_back(void)
+ {
+ list_item<T> *item = _alloc->add();
+ if (!item) return NULL;
+ if (_active_back == NULL)
+ {
+ _active_front = item;
+ _active_back = item;
+ }
+ else chain_next(_active_back, item);
+
+ return (T*)item;
+ }
+
+ void remove(T *i)
+ {
+ list_item<T> *li = (list_item<T>*)i;
+ if (li == _active_front) _active_front = li->next;
+ if (li == _active_back) _active_back = li->prev;
+ if (li->next) li->next->prev = li->prev;
+ if (li->prev) li->prev->next = li->next;
+ _alloc->remove(li);
+ }
+
+ T* front(void)
+ {
+ return (T*)_active_front;
+ }
+
+ T* back(void)
+ {
+ return (T*)_active_back;
+ }
+};
+
+#endif
--- /dev/null
+/**
+ * LiveML - LiveML is screen(graphic) controling library using XML.
+ *
+ * LGPL License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/liveml/
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#include "livemlparser.h"
+
+namespace lmlTag
+{
+ bool liveml(Parameter ¶m, XMLParser &parser)
+ {
+ return true;
+ }
+
+ bool scene(Parameter ¶m, XMLParser &parser)
+ {
+ LiveMLParser &p = (LiveMLParser&)parser;
+ action_type id = p.sceneContainer.addScene();
+ SceneParser *scene = p.sceneContainer.getScene(id);
+ scene->tag = p.getCurrentTag();
+ p.setCurrentScene(scene);
+
+ if (param.has(1))
+ {
+ id = p.sceneContainer.getSceneType(param.getString(1));
+ scene->parent = p.sceneContainer.getScene(id);
+ }
+
+ return true;
+ }
+
+ bool actor(Parameter ¶m, XMLParser &parser)
+ {
+ LiveMLParser &p = (LiveMLParser&)parser;
+ action_type id = p.actorContainer.addActor();
+ ActorParser *actor = p.actorContainer.getActor(id);
+ actor->tag = p.getCurrentTag();
+ p.setCurrentActor(actor);
+
+ if (param.has(1))
+ {
+ id = p.actorContainer.getActorType(param.getString(1));
+ actor->parent = p.actorContainer.getActor(id);
+ }
+
+ return true;
+ }
+
+ bool event(Parameter &root, XMLParser &parser)
+ {
+ LiveMLParser &p = (LiveMLParser&)parser;
+ tag_type type = p.getParentTag()->type;
+ TagAct *ta = NULL;
+ if (type == p.getTagType("scene"))
+ {
+ ta = (TagAct*)p.getCurrentScene();
+ }
+ if (type == p.getTagType("actor"))
+ {
+ ta = (TagAct*)p.getCurrentActor();
+ }
+ if (ta)
+ {
+ ta->addEventTag(p.getCurrentTag());
+ }
+
+ return true;
+ }
+
+ bool action(Parameter ¶m, XMLParser &parser)
+ {
+ LiveMLParser &p = (LiveMLParser&)parser;
+ tag_type type = p.getParentTag()->type;
+ ActionContainer *ac = NULL;
+
+ if (type == p.getTagType("scene"))
+ {
+ ac = &p.getCurrentScene()->actionContainer;
+ }
+ if (type == p.getTagType("actor"))
+ {
+ ac = &p.getCurrentActor()->actionContainer;
+ }
+ if (type == p.getTagType("liveml"))
+ {
+ ac = &p.actionContainer;
+ }
+ if (ac)
+ {
+#ifdef DEBUG
+ printf("added action\n");
+#endif
+ action_type type = ac->addAction();
+ ac->getAction(type)->tag = p.getCurrentTag();
+ return true;
+ }
+
+ return false;
+ }
+
+ bool include(Parameter ¶m, XMLParser &parser)
+ {
+ LiveMLParser &p = (LiveMLParser&)parser;
+ Tag *t = p.getCurrentTag();
+ p.setCurrentTag(NULL);
+ bool result = p.loadFile(param.getString(0));
+ p.setCurrentTag(t);
+
+ return result;
+ }
+}
+
+event_type LiveMLParser::registerEventType(const char *name)
+{
+ event_type type = EVENT_INIT;
+ return type;
+}
+
+LiveMLParser::LiveMLParser(void)
+{
+ RegisterTag *reg = addRegisterTag("liveml");
+ reg->setFunction(lmlTag::liveml);
+
+ // scene
+ reg = addRegisterTag("scene");
+ reg->setFunction(lmlTag::scene);
+ ParameterOption *po = reg->addParameter();
+ po->set(0, PARAM_STRING, "name");
+ po = reg->addParameter();
+ po->set(1, PARAM_STRING, "extend");
+
+ // actor
+ reg = addRegisterTag("actor");
+ reg->setFunction(lmlTag::actor);
+ po = reg->addParameter();
+ po->set(0, PARAM_STRING, "name");
+ po = reg->addParameter();
+ po->set(1, PARAM_STRING, "extend");
+
+ // print
+ reg = addRegisterTag("print");
+ po = reg->addParameter();
+ po->set(0, PARAM_STRING);
+
+ // active
+ reg = addRegisterTag("active");
+ po = reg->addParameter();
+ po->set(0, PARAM_STRING);
+
+ // event
+ reg = addRegisterTag("event");
+ reg->setFunction(lmlTag::event);
+ po = reg->addParameter();
+ po->set(0, PARAM_STRING, "type");
+
+ // action
+ reg = addRegisterTag("action");
+ reg->setFunction(lmlTag::action);
+ po = reg->addParameter();
+ po->set(0, PARAM_STRING, "name");
+
+ // actionRef
+ reg = addRegisterTag("actionRef");
+ po = reg->addParameter();
+ po->set(0, PARAM_STRING);
+
+ // include
+ reg = addRegisterTag("include");
+ reg->setFunction(lmlTag::include);
+ po = reg->addParameter();
+ po->set(0, PARAM_STRING);
+
+ // repeat
+ reg = addRegisterTag("repeat");
+ po = reg->addParameter();
+ po->set(0, PARAM_CLOSE_TAG);
+ po = reg->addParameter();
+ po->set(1, PARAM_NUMERIC, "count");
+
+ // continue
+ reg = addRegisterTag("continue");
+ po = reg->addParameter();
+ po->set(0, PARAM_PARENT_TAG);
+
+ // break
+ reg = addRegisterTag("break");
+ po = reg->addParameter();
+ po->set(0, PARAM_PARENT_TAG);
+
+ // wait
+ reg = addRegisterTag("wait");
+ po = reg->addParameter();
+ po->set(0, PARAM_NUMERIC);
+
+ // val
+ reg = addRegisterTag("val");
+ po = reg->addParameter();
+ po->set(0, PARAM_NUMERIC, "scope");
+ po->addReplaceValue("local", "0");
+ po->addReplaceValue("global", "1");
+ po->addReplaceValue("parent", "2");
+}
--- /dev/null
+/**
+ * LiveML - LiveML is screen(graphic) controling library using XML.
+ *
+ * LGPL License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/directorml/
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#ifndef __LIVEMLPARSER_H__
+#define __LIVEMLPARSER_H__
+
+#include "xmlparser.h"
+
+enum event_type
+{
+ EVENT_INIT,
+ EVENT_RELEASE,
+ EVENT_FOCUS_ON,
+ EVENT_FOCUS_OFF,
+ EVENT_BTN_PUSH,
+ EVENT_BTN_HOLD,
+ EVENT_PTN_FREE,
+ EVENT_NUMBER
+};
+
+class ActionParser
+{
+public:
+ Tag *tag;
+
+ const char* getName(void)
+ {
+ return tag->param.getString(0);
+ }
+};
+
+class ActionContainer
+{
+ vector<ActionParser> _actions;
+
+public:
+
+ action_type getActionType(const char* name)
+ {
+ for (int i = 0; i < _actions.size(); i++)
+ {
+ if (!strcmp(_actions[i].getName(), name)) return i;
+ }
+
+ return -1;
+ }
+
+ ActionParser* getAction(action_type type)
+ {
+ if (type < 0 || type + 1 > _actions.size()) return NULL;
+ return &_actions[type];
+ }
+
+ action_type addAction(void)
+ {
+ _actions.resize(_actions.size() + 1);
+
+ return _actions.size() - 1;
+ }
+};
+
+class TagAct
+{
+ vector<Tag*> _events;
+public:
+ Tag *tag;
+ ActionContainer actionContainer;
+ TagAct *parent;
+
+ TagAct(void)
+ {
+ parent = NULL;
+ }
+ const char* getName(void)
+ {
+ return tag->param.getString(0);
+ }
+ void addEventTag(Tag *t)
+ {
+ _events.push_back(t);
+ }
+ Tag* getEventTag(size_t index)
+ {
+ return _events[index];
+ }
+ size_t countEvent(void)
+ {
+ return _events.size();
+ }
+};
+
+class SceneParser : public TagAct
+{
+};
+
+class ActorParser : public TagAct
+{
+};
+
+class SceneContainer
+{
+ vector<SceneParser> _scenes;
+public:
+
+ action_type getSceneType(const char* name)
+ {
+ for (int i = 0; i < _scenes.size(); i++)
+ {
+ if (!strcmp(_scenes[i].getName(), name)) return i;
+ }
+
+ return -1;
+ }
+
+ SceneParser* getScene(action_type type)
+ {
+ return &_scenes[type];
+ }
+
+ action_type addScene(void)
+ {
+ _scenes.resize(_scenes.size() + 1);
+
+ return _scenes.size() - 1;
+ }
+};
+
+class ActorContainer
+{
+ vector<ActorParser> _actors;
+public:
+
+ action_type getActorType(const char* name)
+ {
+ for (int i = 0; i < _actors.size(); i++)
+ {
+ if (!strcmp(_actors[i].getName(), name)) return i;
+ }
+
+ return -1;
+ }
+
+ ActorParser* getActor(action_type type)
+ {
+ return &_actors[type];
+ }
+
+ action_type addActor(void)
+ {
+ _actors.resize(_actors.size() + 1);
+
+ return _actors.size() - 1;
+ }
+};
+
+class LiveMLParser : public XMLParser
+{
+ SceneParser *_currentScene;
+ ActorParser *_currentActor;
+public:
+ SceneContainer sceneContainer;
+ ActorContainer actorContainer;
+ ActionContainer actionContainer;
+
+ LiveMLParser(void);
+
+ void setCurrentScene(SceneParser* t) { _currentScene = t; }
+ void setCurrentActor(ActorParser* t) { _currentActor = t; }
+ SceneParser* getCurrentScene(void) { return _currentScene; }
+ ActorParser* getCurrentActor(void) { return _currentActor; }
+
+ event_type registerEventType(const char*);
+};
+
+#endif // __LIVEMLPARSER_H__
--- /dev/null
+/*
+ * LiveML - LiveML is screen(graphic) controling library using XML.
+ *
+ * LGPL License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/liveml/
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#include "livemlrunner.h"
+
+namespace lmlCommand
+{
+ bool action_close(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ ActionParser **ap = obj.currentActionList.back();
+ if (param.getTag(0) == (*ap)->tag)
+ {
+ obj.currentActionList.remove(ap);
+ obj.currentTagList.remove(obj.currentTagList.back());
+ }
+ return obj.currentActionList.back() != NULL;
+ }
+ bool print(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ printf(param.getString(0));
+ printf("\n");
+ return true;
+ }
+ bool active(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ runner.addActor(param.getString(0));
+ return true;
+ }
+ bool event(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ return runner.stateEvent(param.getInteger(0));
+ }
+ bool repeat(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ *obj.repeatCounter.push_back() = param.has(1) ? param.getInteger(1) : -1;
+
+ return true;
+ }
+ bool repeat_close(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ unsigned int *counter = obj.repeatCounter.back();
+ if (*counter > 1)
+ {
+ (*counter)--;
+ *obj.currentTagList.back() = param.getTag(0);
+ }
+ else obj.repeatCounter.remove(counter);
+
+ return true;
+ }
+ bool rcontinue(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ Tag **t = obj.currentTagList.back();
+ *t = param.getTag(0)->param.getTag(0);
+ *t = (Tag*)((list_item<Tag>*)*t)->prev;
+ return true;
+ }
+ bool rbreak(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ if (obj.repeatCounter.back() == NULL) return false;
+ (*obj.repeatCounter.back()) = 0;
+ return rcontinue(param, obj, runner);
+ }
+ bool wait(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ if (obj.waitCounter) obj.waitCounter--;
+ else obj.waitCounter = param.getInteger(0);
+
+ return obj.waitCounter == 0;
+ }
+ bool val(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ return true;
+ }
+ bool actionRef(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+#ifdef DEBUG
+ printf("actionRef: %s\n", param.getString(0));
+#endif
+ // local
+ if (!obj.setActionByName(param.getString(0)))
+ {
+ // global
+ action_type type = runner.parser->actionContainer.getActionType(param.getString(0));
+ obj.setAction(runner.parser->actionContainer.getAction(type));
+ }
+
+ return true;
+ }
+ bool focus(Parameter ¶m, LMLObject &obj, LiveMLRunner &runner)
+ {
+ runner.setFocusObject(&obj);
+ return true;
+ }
+}
+
+LiveMLRunner::LiveMLRunner(LiveMLParser *p)
+{
+ parser = p;
+ setMaxActors(1000); // unauthorised
+ _commandFuncs.resize(parser->countRegisteredTags());
+ _currentActor = NULL;
+ _focusObject = NULL;
+ _eventFlag.resize(64);
+
+ _scene.repeatCounter.allocator(&_repeatAllocator);
+ _scene.currentActionList.allocator(&_actionAllocator);
+ _scene.currentTagList.allocator(&_tagAllocator);
+
+ registerCommand("action", NULL, lmlCommand::action_close);
+ registerCommand("print", lmlCommand::print);
+ registerCommand("active", lmlCommand::active);
+ registerCommand("event", lmlCommand::event);
+ registerCommand("repeat", lmlCommand::repeat, lmlCommand::repeat_close);
+ registerCommand("conitnue", lmlCommand::rcontinue);
+ registerCommand("break", lmlCommand::rbreak);
+ registerCommand("wait", lmlCommand::wait);
+ registerCommand("val", lmlCommand::val);
+ registerCommand("actionRef", lmlCommand::actionRef);
+ registerCommand("focus", lmlCommand::focus);
+}
+
+bool LiveMLRunner::registerCommand(
+ const char* name,
+ bool (*func)(Parameter&, LMLObject&, LiveMLRunner&),
+ bool (*closeFunc)(Parameter&, LMLObject&, LiveMLRunner&)
+)
+{
+ tag_type type = parser->getTagType(name);
+ if (type < 0) return false;
+
+ _commandFuncs[type].func = func;
+ _commandFuncs[type].closeFunc = closeFunc;
+
+ return true;
+}
+
+bool LiveMLRunner::runCommand(LMLObject &obj, Tag *tag)
+{
+ Tag **currentTag = obj.currentTagList.back();
+ *currentTag = tag;
+
+ while (tag != NULL)
+ {
+ bool (*func)(Parameter&, LMLObject&, LiveMLRunner&);
+ if (tag->type == CLOSE_TAG)
+ {
+ func = _commandFuncs[tag->param.getTag(0)->type].closeFunc;
+ }
+ else
+ {
+ func = _commandFuncs[tag->type].func;
+ }
+ if (func != NULL)
+ {
+#ifdef DEBUG
+ printf("execute command: %d\n", tag->type);
+#endif
+ bool result = (*func)(tag->param, obj, *this);
+#ifdef DEBUG
+ printf("finish command: %d\n", tag->type);
+#endif
+ if (result == false) return false;
+ }
+ else
+ {
+#ifdef DEBUG
+ printf("not register command: %d\n", tag->type);
+#endif
+ }
+ currentTag = obj.currentTagList.back();
+ tag = *currentTag = (Tag*)((list_item<Tag>*)*currentTag)->next;
+ }
+}
+
+bool LiveMLRunner::runObjectEvent(LMLObject &obj)
+{
+/*
+ Tag *t = *obj.currentTagList.back();
+ for (size_t i = 0; i < obj.parser->countEvent(); i++)
+ {
+ runCommand(obj, obj.parser->getEventTag(i));
+ }
+ *obj.currentTagList.back() = t;
+*/
+ return true;
+}
+
+bool LiveMLRunner::runObjectAction(LMLObject &obj)
+{
+ if (obj.currentActionList.back() == NULL) return false;
+ runCommand(obj, *obj.currentTagList.back());
+
+ return true;
+}
+
+bool LiveMLRunner::runObject(LMLObject &obj)
+{
+ runObjectEvent(obj);
+ runObjectAction(obj);
+
+ return true;
+}
+
+LMLSceneObject* LiveMLRunner::setScene(const char *name)
+{
+ _scene.init();
+ action_type type = parser->sceneContainer.getSceneType(name);
+ _scene.parser = parser->sceneContainer.getScene(type);
+
+ return &_scene;
+}
+
+LMLActorObject* LiveMLRunner::addActor(const char *name)
+{
+#ifdef DEBUG
+ printf("add actor: start\n");
+#endif
+ LMLActorObject *obj = _actorList.push_back();
+ obj->init();
+ action_type type = parser->actorContainer.getActorType(name);
+ obj->parser = parser->actorContainer.getActor(type);
+ obj->currentActionList.allocator(&_actionAllocator);
+ obj->currentTagList.allocator(&_tagAllocator);
+ obj->repeatCounter.allocator(&_repeatAllocator);
+// runner.runObjectEvent(*(LMLObject*)actor);
+// runner.setCurrentActor(actor);
+#ifdef DEBUG
+ printf("add actor: end\n");
+#endif
+
+ return obj;
+}
+
+void LiveMLRunner::run(void)
+{
+ if (_scene.parser)
+ {
+ runObject((LMLObject&)_scene);
+ }
+
+ LMLActorObject *actor = _actorList.front();
+ while (actor)
+ {
+#ifdef DEBUG
+ printf("execute actor: start\n");
+#endif
+ list_item<LMLActorObject> *item = (list_item<LMLActorObject>*)actor;
+ LMLActorObject *actorNext = (LMLActorObject*)item->next;
+ runObject((LMLObject&)*actor);
+ actor = actorNext;
+#ifdef DEBUG
+ printf("execute actor: end\n");
+#endif
+ }
+}
+
+void LiveMLRunner::setMaxActors(size_t size)
+{
+ _actorList.resize(size);
+ _repeatAllocator.resize(size * 5);
+ _repeatAllocator.clear();
+ _actionAllocator.resize(size * 5);
+ _actionAllocator.clear();
+ _tagAllocator.resize(size * 5);
+ _tagAllocator.clear();
+}
--- /dev/null
+/**
+ * LiveML - LiveML is screen(graphic) controling library using XML.
+ *
+ * LGPL License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/liveml/
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#ifndef __LIVEMLRUNNER_H__
+#define __LIVEMLRUNNER_H__
+
+#include "livemlparser.h"
+#include "list.hpp"
+#include "bool_list.hpp"
+
+struct LMLObject
+{
+public:
+ TagAct *parser;
+ list<ActionParser*> currentActionList;
+ list<Tag*> currentTagList;
+ unsigned int waitCounter;
+ list<unsigned int> repeatCounter;
+
+ void init()
+ {
+ parser = NULL;
+ waitCounter = 0;
+ }
+
+ bool setAction(ActionParser *action)
+ {
+ *currentActionList.push_back() = action;
+ if (action == NULL) return false;
+ *currentTagList.push_back() = action->tag;
+
+ return true;
+ }
+ bool setAction(action_type type)
+ {
+ ActionParser *action = parser->actionContainer.getAction(type);
+ if (action == NULL) return false;
+
+ setAction(action);
+ return true;
+ }
+ bool setActionByName(const char *name)
+ {
+ action_type type = parser->actionContainer.getActionType(name);
+ printf("find %s => %d\n", name, type);
+ return setAction(type);
+ }
+};
+
+struct LMLSceneObject : public LMLObject
+{
+};
+
+struct LMLActorObject : public LMLObject
+{
+};
+
+class LiveMLRunner
+{
+ struct FuncPtr
+ {
+ bool (*func)(Parameter&, LMLObject&, LiveMLRunner&);
+ bool (*closeFunc)(Parameter&, LMLObject&, LiveMLRunner&);
+ };
+
+ LMLSceneObject _scene;
+ list<LMLActorObject> _actorList;
+ LMLActorObject *_currentActor;
+ LMLObject *_focusObject;
+ vector<FuncPtr> _commandFuncs;
+ bool_list _eventFlag;
+ list_allocator<ActionParser*> _actionAllocator;
+ list_allocator<Tag*> _tagAllocator;
+ list_allocator<unsigned int> _repeatAllocator;
+
+public:
+ LiveMLParser *parser;
+ bool registerCommand(
+ const char*,
+ bool (*)(Parameter&, LMLObject&, LiveMLRunner&),
+ bool (*)(Parameter&, LMLObject&, LiveMLRunner&) = NULL
+ );
+
+ LiveMLRunner(LiveMLParser*);
+
+ void setMaxActors(size_t);
+ LMLSceneObject* setScene(const char*);
+ LMLActorObject* addActor(const char*);
+
+ LMLActorObject* setCurrentActor(LMLActorObject *obj) { _currentActor = obj; }
+ LMLActorObject* getCurrentActor(void) { return _currentActor; }
+
+ void setFocusObject(LMLObject* obj) { _focusObject = obj; }
+ LMLObject* getFocusObject(void) { return _focusObject; }
+
+ void onEvent(size_t index) { _eventFlag.on(index); }
+ void offEvent(size_t index) { _eventFlag.off(index); }
+ bool stateEvent(size_t index) { return _eventFlag[index]; }
+ bool_list getbool_lists(void) { return _eventFlag; }
+ void setbool_lists(bool_list &f) { _eventFlag = f; }
+
+ bool runCommand(LMLObject&, Tag*);
+ bool runObjectEvent(LMLObject&);
+ bool runObjectAction(LMLObject&);
+ bool runObject(LMLObject&);
+ void run(void);
+};
+
+#endif // __LIVEMLRUNNER_H__
--- /dev/null
+/**
+ * stack - The stack data structure.
+ *
+ * MIT License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/c-utils/
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copiGes or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIAGBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#include "stack.h"
+#include <string.h>
+#include <malloc.h>
+
+void stack_init(stack_data *data, int block_size)
+{
+ data->size = 0;
+ data->block_size = block_size;
+ data->current = NULL;
+ data->pool = NULL;
+}
+
+void stack_free(stack_data *data)
+{
+ if (data->pool != NULL) free(data->pool);
+}
+
+void stack_resize(stack_data *data, int size)
+{
+ char* pool = malloc(data->block_size * size);
+ int used_size = data->current - data->pool;
+ if (data->pool != NULL)
+ {
+ if(used_size) memcpy(pool, data->pool, used_size);
+ free(data->pool);
+ }
+ data->pool = pool;
+ data->current = data->pool + used_size;
+ data->size = data->block_size * size;
+}
+
+char stack_push(stack_data *stack, void *data)
+{
+ if (stack->current - stack->pool >= stack->size) return 1;
+ memcpy(stack->current, data, stack->block_size);
+ stack->current += stack->block_size;
+ return 0;
+}
+
+char stack_pop(stack_data *stack, void *data)
+{
+ if (stack->current == stack->pool) return 1;
+ stack->current -= stack->block_size;
+ memcpy(data, stack->current, stack->block_size);
+ return 0;
+}
--- /dev/null
+/**
+ * stack - The stack data structure.
+ *
+ * MIT License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/c-utils/
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copiGes or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIAGBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#ifndef __STACK_H__
+#define __STACK_H__
+
+typedef struct
+{
+ int size;
+ int block_size;
+ char *pool;
+ char *current;
+} stack_data;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void stack_init(stack_data*, int);
+void stack_free(stack_data*);
+void stack_resize(stack_data*, int);
+char stack_push(stack_data*, void*);
+char stack_pop(stack_data*, void*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/**
+ * LiveML - LiveML is screen(graphic) controling library using XML.
+ *
+ * LGPL License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/liveml/
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#include "xmlparser.h"
+
+XMLParser::XMLParser(void)
+{
+ tagList.resize(1000); // unauthorised
+ setCurrentTag(NULL);
+ setParentTag(NULL);
+}
+
+RegisterTag* XMLParser::addRegisterTag(const char* name)
+{
+ _registerTags.resize(_registerTags.size() + 1);
+ RegisterTag &rt = _registerTags.back();
+ rt.setName(name);
+
+ return &rt;
+}
+
+size_t XMLParser::countRegisteredTags(void)
+{
+ return _registerTags.size();
+}
+
+tag_type XMLParser::getTagType(const char *name)
+{
+ for (tag_type i = 0; i < _registerTags.size(); i++)
+ {
+ if (!strcmp(_registerTags[i]._name.c_str(), name)) return i;
+ }
+
+ return -1;
+}
+
+bool XMLParser::loadText(const char *text)
+{
+ TiXmlDocument doc;
+ doc.Parse(text);
+
+ TiXmlElement *root = doc.RootElement();
+ if (!root) return false;
+
+ return parse(root);
+}
+
+bool XMLParser::loadFile(const char *file)
+{
+ TiXmlDocument doc;
+
+#ifdef DEBUG
+ printf("load file: %s\n", file);
+#endif
+ if (!doc.LoadFile(file))
+ {
+#ifdef DEBUG
+ printf("can't load file: %s\n", file);
+#endif
+ return false;
+ }
+
+ TiXmlElement *root = doc.RootElement();
+ if (!root) return false;
+
+ bool result = parse(root);
+
+#ifdef DEBUG
+ printf("loaded file: %s\n", file);
+#endif
+
+ return result;
+}
+
+bool XMLParser::parse(TiXmlElement *el)
+{
+ tag_type tagType = getTagType(el->Value());
+
+ if (tagType < 0)
+ {
+#ifdef DEBUG
+ printf("undefined tag: %s\n", el->Value());
+#endif
+ return false;
+ }
+
+#ifdef DEBUG
+ printf("start tag: %s\n", el->Value());
+#endif
+ Tag *tag = addTag(tagType);
+ ParameterOption *poCloseTag = NULL;
+
+ // set parameters
+ for (int i = 0; i < _registerTags[tagType]._params.size(); i++)
+ {
+ ParameterOption &po = _registerTags[tagType]._params[i];
+ string &name = po._name;
+ void *value;
+ switch (po._type)
+ {
+ case PARAM_TAG:
+ value = (void*)tag;
+ break;
+ case PARAM_CLOSE_TAG:
+ poCloseTag = &po;
+ value = NULL;
+ break;
+ case PARAM_PARENT_TAG:
+ value = (void*)getParentTag();
+ break;
+ default:
+ if (name == "") value = (void*)el->GetText();
+ else value = (void*)el->Attribute(name.c_str());
+ break;
+ }
+
+ if (value != NULL) tag->param.setByParameterOption(po, value);
+ }
+
+ setCurrentTag(tag);
+ if (_registerTags[tagType]._func != NULL)
+ {
+ bool result = (*_registerTags[tagType]._func)(tag->param, *this);
+ if (result == false) return false;
+ }
+
+ TiXmlElement *cel;
+ for (cel = el->FirstChildElement(); cel; cel = cel->NextSiblingElement())
+ {
+ setParentTag(tag);
+ parse(cel);
+ }
+
+ // close tag
+ if (tag != tagList.back())
+ {
+ Tag *close = tagList.push_back();
+ close->type = CLOSE_TAG;
+ close->param.set(0, tag);
+ if (poCloseTag != NULL) tag->param.setByParameterOption(*poCloseTag, close);
+ }
+
+ return true;
+}
+
+Tag* XMLParser::addTag(tag_type type)
+{
+#ifdef DEBUG
+ printf("add tag\n");
+#endif
+ Tag *tag = tagList.push_back();
+ tag->type = type;
+
+ return tag;
+}
--- /dev/null
+/**
+ * LiveML - LiveML is screen(graphic) controling library using XML.
+ *
+ * LGPL License
+ * Copyright (C) 2010 Nothan
+ * http://github.com/nothan/liveml/
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Nothan
+ * private@nothan.xrea.jp
+ *
+ * Tsuioku Denrai
+ * http://tsuioku-denrai.xrea.jp/
+ */
+
+#ifndef __XMLPARSER_H__
+#define __XMLPARSER_H__
+
+#include <tinyxml.h>
+#include <vector>
+#include "list.hpp"
+#include "calcu.h"
+using namespace std;
+
+enum {
+ CLOSE_TAG = 0xFFFFFFFF,
+};
+
+typedef int tag_type;
+typedef int action_type;
+
+enum param_type {
+ PARAM_STRING,
+ PARAM_NUMERIC,
+ PARAM_TAG,
+ PARAM_CLOSE_TAG,
+ PARAM_PARENT_TAG
+};
+
+class Parameter;
+class XMLParser;
+struct Tag;
+
+class ParameterOption {
+ friend class Parameter;
+ friend class XMLParser;
+
+ struct ReplaceValue {
+ string value;
+ string to;
+ };
+ size_t _index;
+ string _name;
+ param_type _type;
+ vector<ReplaceValue> _replaces;
+public:
+ ~ParameterOption()
+ {
+ }
+ void set(size_t index, param_type type, const char *name = NULL)
+ {
+ if (name != NULL) _name = name;
+ _index = index;
+ _type = type;
+ }
+ void addReplaceValue(const char* value, const char *to)
+ {
+ ReplaceValue rep = {value, to};
+ _replaces.push_back(rep);
+ }
+ const char* getReplaceValue(const char* value)
+ {
+ for (int i = 0; i < _replaces.size(); i++)
+ {
+ if (_replaces[i].value.find(value)) return _replaces[i].to.c_str();
+ }
+ return value;
+ }
+};
+
+class Parameter
+{
+ vector<void*> values;
+public:
+ ~Parameter()
+ {
+ for (size_t i = 0; i < values.size(); i++) free(values[i]);
+ }
+ void unset(size_t index)
+ {
+ if (values[index] == NULL) return;
+ free(values[index]);
+ values[index] = NULL;
+ }
+ bool has(size_t index)
+ {
+ if (values.size() < index + 1) return false;
+ return values[index] != NULL;
+ }
+ const void* get(size_t index)
+ {
+ if (values.size() < index + 1) return NULL;
+ return values[index];
+ }
+ Tag* getTag(size_t index)
+ {
+ return (Tag*)get(index);
+ }
+ float getFloat(size_t index)
+ {
+ return fixed_float_to_float(calcu_decode((const char*)get(index), NULL));
+ }
+ int getInteger(size_t index)
+ {
+ return fixed_float_to_int(calcu_decode((const char*)get(index), NULL));
+ }
+ const char* getString(size_t index)
+ {
+ return (const char*)values[index];
+ }
+ void set(size_t index, void *data)
+ {
+ if (values.size() < index + 1) values.resize(index + 1);
+ else unset(index);
+ values[index] = data;
+ }
+ void setInteger(size_t index, int value)
+ {
+ int *buf = (int*)malloc(sizeof(int));
+ set(index, buf);
+ }
+ void setCalcu(size_t index, const char *str)
+ {
+ set(index, calcu_encode((char*)str, NULL));
+ }
+ void setString(size_t index, const char *str)
+ {
+ size_t size = strlen(str);
+ void *buf = malloc(size + 1);
+ strcpy((char*)buf, (char*)str);
+ set(index, buf);
+ }
+ void setByParameterOption(ParameterOption &po, void *value)
+ {
+ switch (po._type)
+ {
+ case PARAM_STRING:
+ value = (void*)po.getReplaceValue((char*)value);
+ setString(po._index, (char*)value);
+ break;
+ case PARAM_NUMERIC:
+ value = (void*)po.getReplaceValue((char*)value);
+ setCalcu(po._index, (char*)value);
+ break;
+ case PARAM_TAG:
+ case PARAM_CLOSE_TAG:
+ case PARAM_PARENT_TAG:
+ set(po._index, value);
+ break;
+ }
+ }
+ bool cmpHash(size_t index, const char*buf)
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ if (((int*)values[index])[i] != ((int*)buf)[i]) return false;
+ }
+
+ return true;
+ }
+};
+
+struct Tag
+{
+ tag_type type;
+ Parameter param;
+};
+
+class RegisterTag
+{
+ friend class XMLParser;
+ string _name;
+ bool (*_func)(Parameter&, XMLParser&);
+ vector<ParameterOption> _params;
+public:
+ RegisterTag(void) { _func = NULL; }
+ void setName(string name) { _name = name; }
+ ParameterOption* addParameter(void) { _params.resize(_params.size() + 1); return &_params.back(); }
+ void setFunction(bool (*f)(Parameter&, XMLParser&)) { _func = f; }
+};
+
+class XMLParser
+{
+ vector<RegisterTag> _registerTags;
+ Tag* _currentTag;
+ Tag* _parentTag;
+
+public:
+ list<Tag> tagList;
+
+ XMLParser(void);
+ RegisterTag* addRegisterTag(const char *name);
+ size_t countRegisteredTags(void);
+ tag_type getTagType(const char *name);
+ bool loadText(const char *text);
+ bool loadFile(const char *file);
+ virtual bool parse(TiXmlElement *root);
+
+ Tag* addTag(tag_type);
+ void setCurrentTag(Tag *t) { _currentTag = t; }
+ Tag* getCurrentTag(void) { return _currentTag; }
+ void setParentTag(Tag *t) { _parentTag = t; }
+ Tag* getParentTag(void) { return _parentTag; }
+};
+
+#endif // __XMLPARSER_H__
--- /dev/null
+TARGET = test
+LDFLAGS =
+CFLAGS = -I./../src/
+OBJS = test.o
+LIBS = -L./../ -lliveml
+
+all: $(OBJS) $(TARGET)
+
+$(TARGET):
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+
+.cpp.o:
+ $(CC) $(CFLAGS) $(INCLUDES) -c $<
+
+clean:
+ -rm $(TARGET) $(OBJS)
--- /dev/null
+#include "livemlrunner.h"
+#include <unistd.h>
+
+int main(int argc, char *argv[])
+{
+ LiveMLParser parser;
+ parser.loadFile("test.xml");
+
+ LiveMLRunner runner(&parser);
+
+ LMLSceneObject *obj = runner.setScene("scene1");
+ obj->setAction(0);
+
+ while (true)
+ {
+ if (obj->currentActionList.back() == NULL) break;
+ runner.run();
+ sleep(1);
+ }
+
+ return 1;
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<liveml xmlns="http://tsuioku-denrai.xrea.jp/common/liveml">
+ <scene name="scene1">
+ <event type="init">
+ <load name="image1" type="image">path/to</load>
+ </event>
+ <!-- Local Actions -->
+ <action name="1">
+ <repeat count="(3+2)/5+1*5">
+ <actionRef>g1</actionRef>
+ <wait>1</wait>
+ </repeat>
+ </action>
+ <action name="2">
+ <print>action 2</print>
+ <actionRef>g2</actionRef>
+ </action>
+ </scene>
+
+ <!--Global Actions -->
+ <action name="g1">
+ <print>global action 1</print>
+ <actionRef>2</actionRef>
+ </action>
+ <action name="g2">
+ <print>global action 2</print>
+ </action>
+
+ <actor type="spritebox" name="actor1">
+ <event type="init">
+ <image>image1</image>
+ <pos name="x" type="absolute">0</pos>
+ <pos name="y" type="absolute">0</pos>
+ <pos name="z" type="absolute">0</pos>
+ <scale name="x" type="absolute">1</scale>
+ <scale name="y" type="absolute">1</scale>
+ <create type="actor" relation="child" src="render1"></create>
+ <width type="absolute">100</width>
+ <height type="absolute">100</height>
+ </event>
+ <event type="focus-on">
+ </event>
+ <event type="focus-off">
+ </event>
+ <action name="action1">
+ <print>actor1 action1</print>
+ </action>
+ <action name="action2">
+ <repeat count="5">
+ <wait>1</wait>
+ </repeat>
+ </action>
+ </actor>
+
+ <actor type="render" name="render1">
+ <event type="init">
+ <vertex name="x" id="0" type="absolute">0</vertex>
+ <vertex name="y" id="0" type="absolute">0</vertex>
+ <color name="r" type="absolute">255</color>
+ <color name="g" type="absolute">255</color>
+ <color name="b" type="absolute">255</color>
+ </event>
+ <action name="action">
+ <render type="2d" />
+ </action>
+ </actor>
+</liveml>