seed r3 - in trunk: . doc examples libseed tests
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r3 - in trunk: . doc examples libseed tests
- Date: Fri, 17 Oct 2008 21:51:25 +0000 (UTC)
Author: racarr
Date: Fri Oct 17 21:51:25 2008
New Revision: 3
URL: http://svn.gnome.org/viewvc/seed?rev=3&view=rev
Log:
Add seed.
Added:
trunk/AUTHORS
trunk/COPYING
trunk/Makefile
trunk/TODO
trunk/doc/
trunk/doc/tutorial.html
trunk/examples/
trunk/examples/calculator.js (contents, props changed)
trunk/examples/clutter-test.js (contents, props changed)
trunk/examples/mini-browser.js (contents, props changed)
trunk/examples/n-oscillator.js (contents, props changed)
trunk/examples/notify-test.js (contents, props changed)
trunk/examples/repl.js (contents, props changed)
trunk/examples/spacewhale.js (contents, props changed)
trunk/examples/vte-test.js (contents, props changed)
trunk/libseed/
trunk/libseed/Makefile
trunk/libseed/seed-builtins.c
trunk/libseed/seed-builtins.h
trunk/libseed/seed-engine.c
trunk/libseed/seed-engine.h
trunk/libseed/seed-private.h
trunk/libseed/seed-signals.c
trunk/libseed/seed-signals.h
trunk/libseed/seed-structs.c
trunk/libseed/seed-structs.h
trunk/libseed/seed-types.c
trunk/libseed/seed-types.h
trunk/libseed/seed-utils.c
trunk/libseed/seed-utils.h
trunk/libseed/seed.h
trunk/main.c
trunk/tests/
trunk/tests/enum.js (contents, props changed)
trunk/tests/include.js (contents, props changed)
trunk/tests/json-constructor.js (contents, props changed)
trunk/tests/print.js (contents, props changed)
trunk/tests/property-benchmark.js (contents, props changed)
trunk/tests/readline.js (contents, props changed)
trunk/tests/run-tests.py (contents, props changed)
trunk/tests/signal.js (contents, props changed)
trunk/tests/value-exception.js (contents, props changed)
Added: trunk/AUTHORS
==============================================================================
--- (empty file)
+++ trunk/AUTHORS Fri Oct 17 21:51:25 2008
@@ -0,0 +1,3 @@
+* Robert Carr <carrr rpi edu>
+* Tim Horton <hortot2 rpi edu>
+* Matt Arsenault <arsenm2 rpi edu>
Added: trunk/COPYING
==============================================================================
--- (empty file)
+++ trunk/COPYING Fri Oct 17 21:51:25 2008
@@ -0,0 +1,675 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, 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
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU 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
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+
Added: trunk/Makefile
==============================================================================
--- (empty file)
+++ trunk/Makefile Fri Oct 17 21:51:25 2008
@@ -0,0 +1,8 @@
+all:
+ gcc libseed/*.c -shared -fPIC -lreadline -g -o libseed/libseed.so `pkg-config --cflags --libs webkit-1.0 gobject-introspection-1.0 glib-2.0`
+ gcc `pkg-config --cflags --libs gstreamer-0.10 glib-2.0 webkit-1.0 gobject-introspection-1.0` *.c -g -o seed -L libseed -lseed -lreadline -lffi
+install:
+ cp libseed/libseed.so /usr/local/lib
+ cp ./seed /usr/local/bin/seed
+test:
+ cd tests ; ./run-tests.py
Added: trunk/TODO
==============================================================================
--- (empty file)
+++ trunk/TODO Fri Oct 17 21:51:25 2008
@@ -0,0 +1 @@
+
Added: trunk/doc/tutorial.html
==============================================================================
--- (empty file)
+++ trunk/doc/tutorial.html Fri Oct 17 21:51:25 2008
@@ -0,0 +1,78 @@
+<html>
+<head>
+ <title>Seed Tutorial : Standalone</title>
+ <style>
+body
+{
+ font-size: 10pt;
+ font-face: "Sans";
+ text-align: justify;
+}
+
+#header
+{
+ text-align: right;
+ font-size: 18pt;
+ width: 100%;
+ border-bottom: 1px solid #aaa;
+
+}
+
+#subheader
+{
+ text-align: right;
+ font-size: 12pt;
+ width: 100%;
+}
+
+div.section
+{
+ font-size: 16pt;
+ font-weight: bold;
+ width: 100%;
+ border-bottom: 1px solid #ccc;
+ margin-bottom: 10px;
+}
+
+p
+{
+ margin-left: 10px;
+}
+
+pre
+{
+ margin-left: 20px;
+ padding-left: 5px;
+ border-left: 1px solid #ddd;
+}
+
+ </style>
+</head>
+<body>
+<div id="header">Seed Tutorial : Standalone</div>
+<div id="subheader">v.0.1</div>
+<div class="section">Introduction</div>
+<p>Seed, first and foremost, provides an easily embeddable Javascript engine to developers looking for a straightforward way to create extensible applications. It also provides bindings between <a href="#">GObject</a> and the <a href="#">WebKit</a> Javascript engine, giving new developers access to the power of the GNOME stack from a familiar and simple language, and allowing rapid prototyping of applications for hardened GNOME developers.</p>
+<p>This tutorial begins with a few brief examples, and then dives right in, following the development of a simple Seed program, from beginning to end. By the end of the tutorial, you'll have your very own minimalist audio player, as well as a summary knowledge of the use of Seed to build Gtk+ applications.</p>
+<div class="section">Beginning Seed</div>
+<p>It makes sense to start our exploration with a program you're probably quite familiar with:</p>
+<pre>
+#!/usr/local/bin/seed
+
+Seed.print("Hello, world!");
+</pre>
+<p>If you were to make this script executable (<code>chmod +x hello.js</code>), and run it, you'd hopefully see the following, just as expected (if you don't, for some reason, make sure you have the latest version of Seed installed, then <a href="#">email us</a>):</p>
+<pre>
+Hello, world!
+</pre>
+<p>Make sure that you include the header (<code>#!/usr/local/seed</code>) at the top of every Seed program you write; I'm only going to include it when listing a whole file, from now on. This is what tells the shell that it should run the program using <code>seed</code>, and that <code>seed</code> is installed to <code>/usr/local/bin</code> (you'll recognize this if you've used another scripting language, such as Python).
+<p>Variables in Javascript are rather interesting, in that they are not given any <em>type</em>, and conversion between different kinds of values is automatic and painless. Thus, the following code is perfectly valid:</p>
+<pre>
+my_name = Seed.readline("Your name? ");
+my_age = 25;
+Seed.print(my_name + " is " + my_age);
+</pre>
+<div class="section">Our Media Player</div>
+<p></p>
+</body>
+</html>
Added: trunk/examples/calculator.js
==============================================================================
--- (empty file)
+++ trunk/examples/calculator.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,151 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Gdk");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("GLib");
+
+Gtk.init(null, null);
+
+var window, label;
+var calc_val = "";
+
+function end_program()
+{
+ Gtk.main_quit();
+}
+
+function update_display()
+{
+ label.set_markup("<span size='30000'>" + calc_val + "</span>");
+
+ if(calc_val == "")
+ {
+ label.set_markup("<span size='30000'>0</span>");
+ }
+}
+
+function clear(button)
+{
+ calc_val = "";
+ update_display();
+}
+
+function backspace(button)
+{
+ calc_val = calc_val.substring(0, calc_val.length - 1);
+ update_display();
+}
+
+function pressed_equals(button)
+{
+ calc_val = calc_val.replace("sin", "Math.sin");
+ calc_val = calc_val.replace("cos", "Math.cos");
+ calc_val = calc_val.replace("tan", "Math.tan");
+ calc_val = eval(calc_val) + "";
+ label.set_markup("<span size='30000'>" + calc_val + "</span>");
+}
+
+function pressed_operator(button)
+{
+ calc_val += button.label;
+ update_display();
+}
+
+function pressed_number(button)
+{
+ calc_val = (((calc_val == 0) ? "" : calc_val) + button.label);
+ update_display();
+}
+
+function swap_sign(button)
+{
+ calc_val = ((calc_val[0] == "-") ? calc_val.substring(1) : "-" + calc_val)
+ update_display();
+}
+
+function random_num()
+{
+ calc_val = Math.floor(Math.random() * 1000) + "";
+ update_display();
+}
+
+function pack_buttons(buttons, vbox)
+{
+ var hbox = new Gtk.HBox();
+
+ hbox.homogeneous = true;
+
+ vbox.pack_start(hbox, true, true, 2);
+
+ for(i = 0; i <= 4; i++)
+ {
+ hbox.pack_start(buttons[i], true, true, 1);
+ }
+}
+
+function create_button(str, func)
+{
+ var btn = new Gtk.Button({"label":str});
+ btn.signal_clicked.connect(func, btn);
+ return btn;
+}
+
+function create_buttons()
+{
+ var vbox = new Gtk.VBox();
+
+ vbox.homogeneous = true;
+
+ pack_buttons([ create_button("(", pressed_number),
+ create_button("â", backspace),
+ create_button("â", random_num),
+ create_button("Clr", clear),
+ create_button("Â", swap_sign)], vbox);
+
+
+ pack_buttons([ create_button(")", pressed_number),
+ create_button("7", pressed_number),
+ create_button("8", pressed_number),
+ create_button("9", pressed_number),
+ create_button("/", pressed_operator)], vbox);
+
+ pack_buttons([ create_button("sin(", pressed_number),
+ create_button("4", pressed_number),
+ create_button("5", pressed_number),
+ create_button("6", pressed_number),
+ create_button("*", pressed_operator)], vbox);
+
+ pack_buttons([ create_button("cos(", pressed_number),
+ create_button("1", pressed_number),
+ create_button("2", pressed_number),
+ create_button("3", pressed_number),
+ create_button("-", pressed_operator)], vbox);
+
+ pack_buttons([ create_button("tan(", pressed_number),
+ create_button("0", pressed_number),
+ create_button(".", pressed_number),
+ create_button("=", pressed_equals),
+ create_button("+", pressed_operator)], vbox);
+
+ return vbox;
+}
+
+var window = new Gtk.Window({"title": "Calculator", "resizable": false});
+
+window.resize(250, 250);
+window.signal_hide.connect(end_program);
+window.opacity = 0.95;
+
+var label = new Gtk.Label({"label": ""});
+label.set_alignment(1,0);
+update_display();
+
+var mainvbox = new Gtk.VBox();
+mainvbox.pack_start(label, false, true, 1);
+mainvbox.pack_start(new Gtk.HSeparator(), false, true, 5);
+mainvbox.pack_start(create_buttons(), true, true, 2);
+
+window.add(mainvbox);
+window.show_all();
+Gtk.main();
+
Added: trunk/examples/clutter-test.js
==============================================================================
--- (empty file)
+++ trunk/examples/clutter-test.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,13 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Clutter");
+
+Clutter.init(null, null);
+var stage = new Clutter.Stage();
+var rectangle = new Clutter.Label({"text":"Never gonna give you up, never..."});
+var template = new Clutter.EffectTemplate();
+rectangle.width = 100;
+rectangle.height = 100;
+stage.add_actor(rectangle);
+stage.show_all();
+Clutter.main();
Added: trunk/examples/mini-browser.js
==============================================================================
--- (empty file)
+++ trunk/examples/mini-browser.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,136 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Gtk");
+Seed.import_namespace("WebKit");
+
+function quit()
+{
+ Gtk.main_quit();
+}
+
+function forward(button)
+{
+ this.go_forward();
+}
+
+function back(button)
+{
+ this.go_back();
+}
+
+function refresh(button)
+{
+ this.reload();
+}
+
+function title_changed(view, title)
+{
+ var tab_title = title.title;
+
+ if(tab_title.length > 25)
+ tab_title = tab_title.slice(0,25) + "...";
+
+ this.label = tab_title;
+}
+
+function browse(url_entry)
+{
+ if (url_entry.text.search("://") < 0)
+ {
+ url_entry.text = "http://" + url_entry.text;
+ }
+
+ this.open(url_entry.text);
+}
+
+function new_tab(browser_view, browser_frame)
+{
+ //create_tab(tabs
+ //Seed.print("Do shit with: " + browser_frame.get_name());
+ return true;
+}
+
+function url_changed(browser_view, browser_frame)
+{
+ this.text = browser_frame.get_uri();
+ return true;
+}
+
+function create_toolbar(browser_view)
+{
+ var toolbar = new Gtk.HBox();
+
+ var back_button = new Gtk.ToolButton();
+ back_button.set_stock_id("gtk-go-back");
+ back_button.signal_clicked.connect(back, browser_view);
+
+ var forward_button = new Gtk.ToolButton();
+ forward_button.set_stock_id("gtk-go-forward");
+ forward_button.signal_clicked.connect(forward, browser_view);
+
+ var refresh_button = new Gtk.ToolButton();
+ refresh_button.set_stock_id("gtk-refresh");
+ refresh_button.signal_clicked.connect(refresh, browser_view);
+
+ toolbar.pack_start(back_button);
+ toolbar.pack_start(forward_button);
+ toolbar.pack_start(refresh_button);
+
+ return toolbar;
+}
+
+function create_tab()
+{
+ var tab = new Gtk.VBox();
+
+ var browser_title = new Gtk.Label({"label":"Untitled"});
+ var browser_view = new WebKit.WebView();
+
+ var url_entry = new Gtk.Entry();
+ url_entry.signal_activate.connect(browse, browser_view);
+
+ browser_view.set_scroll_adjustments(null,null);
+ browser_view.signal_title_changed.connect(title_changed, browser_title);
+ browser_view.signal_load_committed.connect(url_changed, url_entry);
+ browser_view.signal_load_started.connect(new_tab, this);
+ browser_view.open("http://www.google.com/");
+
+ var toolbar = create_toolbar(browser_view);
+ toolbar.pack_start(url_entry, true, true);
+
+ tab.pack_start(toolbar);
+ tab.pack_start(browser_view, true, true);
+
+ this.append_page(tab, browser_title);
+ this.set_tab_reorderable(tab, true);
+}
+
+function create_ui()
+{
+ var vbox = new Gtk.VBox();
+ var tabs = new Gtk.Notebook();
+ tabs.create_tab = create_tab;
+
+ tabs.create_tab();
+ tabs.create_tab();
+ vbox.pack_start(tabs, true, true);
+
+ return vbox;
+}
+
+function browser_init()
+{
+ Gtk.init(null, null);
+ var window = new Gtk.Window();
+ window.signal_hide.connect(quit);
+ window.title = "Browser";
+ window.resize(800,800);
+
+ window.add(create_ui());
+
+ window.show_all();
+ Gtk.main();
+}
+
+browser_init();
+
Added: trunk/examples/n-oscillator.js
==============================================================================
--- (empty file)
+++ trunk/examples/n-oscillator.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,99 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gtk","2.0");
+Seed.import_namespace("Gst","0.10");
+
+Gtk.init(null, null);
+
+function oscillator(freq)
+{
+ this.vbox = new Gtk.VBox();
+ this.hbox = new Gtk.HBox();
+ this.vscale = new Gtk.VScale();
+ this.volscale = new Gtk.VScale();
+ this.button = new Gtk.Button({"label": "Toggle"});
+
+ this.pipeline = new Gst.Pipeline({"name": "test"});
+ this.audiosrc = Gst.element_factory_make("audiotestsrc", "audio");
+ this.audiosink = Gst.element_factory_make("alsasink", "sink");
+ this.volume = Gst.element_factory_make("volume", "vcontrol");
+ this.audiosrc.freq = freq;
+
+ this.pipeline.add(this.audiosrc);
+ this.pipeline.add(this.audiosink);
+ this.pipeline.add(this.volume);
+ this.audiosrc.link(this.volume);
+ this.volume.link(this.audiosink);
+
+ this.playing = false;
+
+ var adjustment = this.vscale.get_adjustment();
+ adjustment.upper = 3000;
+ adjustment.value = freq;
+
+ var adjustment = this.volscale.get_adjustment();
+ adjustment.upper = 10;
+ adjustment.value = this.volume.volume;
+
+ this.hbox.pack_start(this.vscale, true, true, 10);
+ this.hbox.pack_start(this.volscale, true, true, 10);
+ this.vbox.pack_start(this.hbox, true, true, 10);
+ this.vbox.pack_start(this.button, false, false, 10);
+
+ this.toggle = function(button)
+ {
+ if (this.playing == false)
+ {
+ this.pipeline.set_state(Gst.State.playing);
+ this.playing = true;
+ }
+ else
+ {
+ this.pipeline.set_state(Gst.State.paused);
+ this.playing = false;
+ }
+ }
+ this.update_freq = function(range)
+ {
+ this.audiosrc.freq = range.get_value();
+ }
+ this.update_vol = function(range)
+ {
+ this.volume.volume = range.get_value();
+ }
+ this.button.signal_clicked.connect(this.toggle, this);
+ this.vscale.signal_value_changed.connect(this.update_freq, this);
+ this.volscale.signal_value_changed.connect(this.update_vol, this);
+}
+
+function end_program()
+{
+ Gtk.main_quit();
+}
+
+var window = new Gtk.Window();
+var button = new Gtk.Button({"label": "Add Oscillator"});
+
+window.signal_hide.connect(end_program);
+window.resize(600,300);
+var hbox = new Gtk.HBox();
+
+var os1 = new oscillator(500);
+var os2 = new oscillator(700);
+
+function add_oscillator(button)
+{
+ var os = new oscillator(300);
+ this.pack_start(os.vbox, true, true, 10);
+ os.vbox.show_all();
+}
+button.signal_clicked.connect(add_oscillator, hbox);
+
+window.add(hbox);
+hbox.pack_start(button, true, true, 10);
+hbox.pack_start(os1.vbox, true, true, 10);
+hbox.pack_start(os2.vbox, true, true, 10);
+window.show_all();
+
+
+Gtk.main();
+
Added: trunk/examples/notify-test.js
==============================================================================
--- (empty file)
+++ trunk/examples/notify-test.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,9 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Notify");
+Notify.init("Seed Test!");
+var notification = new Notify.Notification(
+ {"summary" : "I am testling libnotify",
+ "body" : "And it seems to be working!"});
+notification.set_timeout(1000);
+notification.show(null);
Added: trunk/examples/repl.js
==============================================================================
--- (empty file)
+++ trunk/examples/repl.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,13 @@
+#!/usr/local/bin/seed
+
+while(1)
+{
+ try
+ {
+ Seed.print(eval(Seed.readline("> ")));
+ }
+ catch(e)
+ {
+ Seed.print(e.name + " " + e.message);
+ }
+}
Added: trunk/examples/spacewhale.js
==============================================================================
--- (empty file)
+++ trunk/examples/spacewhale.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,119 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gdk");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("WebKit");
+
+function title_changed(view, title)
+{
+ this.title = "SpaceWhale - " + title.title;
+}
+
+function key_pressed(view, key_event)
+{
+ a = key_event.type;
+ if (a == Gdk.EventType.key_press)
+ Seed.print("Win!\n");
+}
+
+function update_progress(view, progress)
+{
+ this.update(progress/100);
+}
+
+function forward(entry)
+{
+ this.go_forward();
+}
+
+function back(entry)
+{
+ this.go_back();
+}
+
+function browse(entry)
+{
+ if (entry.text.search("://") < 0)
+ {
+ entry.text = "http://" + entry.text;
+ }
+
+ this.open(entry.text);
+}
+
+function zoom_in(button)
+{
+ this.zoom_in();
+}
+
+function zoom_out(button)
+{
+ this.zoom_out();
+}
+
+function refresh(button)
+{
+ this.reload();
+}
+
+function quit()
+{
+ Gtk.main_quit();
+}
+
+Gtk.init(null, null);
+window = new Gtk.Window();
+window.signal_hide.connect(quit);
+window.title = "SpaceWhale"
+vbox = new Gtk.VBox();
+hbox = new Gtk.HBox();
+
+back_button = new Gtk.ToolButton();
+forward_button = new Gtk.ToolButton();
+zoom_in_button = new Gtk.ToolButton();
+zoom_out_button = new Gtk.ToolButton();
+refresh_button = new Gtk.ToolButton();
+
+back_button.set_stock_id("gtk-go-back");
+forward_button.set_stock_id("gtk-go-forward");
+zoom_in_button.set_stock_id("gtk-zoom-in");
+zoom_out_button.set_stock_id("gtk-zoom-out");
+refresh_button.set_stock_id("gtk-refresh");
+
+
+
+view = new WebKit.WebView();
+view.open("http://www.reddit.com/");
+view.full_content_zoom = true;
+entry = new Gtk.Entry();
+bar = new Gtk.ProgressBar();
+bar.text = "SpaceWhale";
+view.signal_load_progress_changed.connect(update_progress, bar);
+view.signal_key_press_event.connect(key_pressed);
+view.set_scroll_adjustments(null,null);
+
+
+
+entry.signal_activate.connect(browse, view);
+forward_button.signal_clicked.connect(forward, view);
+back_button.signal_clicked.connect(back, view);
+zoom_in_button.signal_clicked.connect(zoom_in, view);
+zoom_out_button.signal_clicked.connect(zoom_out, view);
+refresh_button.signal_clicked.connect(refresh, view);
+view.signal_title_changed.connect(title_changed, window);
+
+hbox.pack_start(back_button);
+hbox.pack_start(forward_button);
+hbox.pack_start(entry, true, true);
+hbox.pack_start(zoom_in_button);
+hbox.pack_start(zoom_out_button);
+hbox.pack_start(refresh_button);
+
+vbox.pack_start(hbox, false, true);
+vbox.pack_start(view, true, true);
+vbox.pack_start(bar);
+
+window.resize(800,900);
+
+window.add(vbox);
+window.show_all();
+Gtk.main();
Added: trunk/examples/vte-test.js
==============================================================================
--- (empty file)
+++ trunk/examples/vte-test.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,30 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gtk","2.0");
+Seed.import_namespace("Vte");
+
+Gtk.init(null, null);
+
+function childquit(terminal)
+{
+ Gtk.main_quit();
+}
+
+function updatetitle(terminal)
+{
+ this.set_title(terminal.get_window_title());
+}
+
+
+var window = new Gtk.Window();
+
+var vte = new Vte.Terminal();
+vte.fork_command("/bin/bash");
+vte.signal_child_exited.connect(childquit);
+vte.signal_window_title_changed.connect(updatetitle, window);
+
+window.add(vte);
+
+window.show_all();
+
+Gtk.main();
+
Added: trunk/libseed/Makefile
==============================================================================
--- (empty file)
+++ trunk/libseed/Makefile Fri Oct 17 21:51:25 2008
@@ -0,0 +1,5 @@
+all:
+ gcc *.c -shared -fPIC -lreadline -g -o libseed.so `pkg-config --cflags --libs webkit-1.0 gobject-introspection-1.0 glib-2.0`
+ cp libseed.so ..
+install:
+ cp libseed.so /usr/local/lib
Added: trunk/libseed/seed-builtins.c
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-builtins.c Fri Oct 17 21:51:25 2008
@@ -0,0 +1,126 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-builtins.c
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "seed-private.h"
+#include <readline/readline.h>
+#include <string.h>
+
+JSValueRef
+seed_include(JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
+{
+ const gchar * import_file;
+ gchar * buffer, * walk;
+ GValue gval = {0};
+
+ seed_gvalue_from_seed_value((SeedValue)arguments[0], G_TYPE_STRING, &gval);
+ g_assert(G_VALUE_HOLDS_STRING(&gval));
+
+ import_file = g_value_get_string(&gval);
+
+ g_file_get_contents(import_file, &buffer, 0, 0);
+
+ if(!buffer)
+ {
+ //gchar * mes = g_strdup_printf("File not found: %s.\n", import_file);
+ //seed_make_exception(exception, "FileNotFound", mes);
+ //g_free(mes);
+ return 0; // TODO: raise exception?
+ }
+
+ walk = buffer;
+
+ if(*walk == '#')
+ {
+ while(*walk != '\n')
+ walk++;
+ walk++;
+ }
+
+ walk = strdup(walk);
+ g_free(buffer);
+
+ JSEvaluateScript(ctx, JSStringCreateWithUTF8CString(walk), NULL, JSStringCreateWithUTF8CString(import_file), 0, NULL);
+
+ return 0;
+}
+
+JSValueRef
+seed_print(JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
+{
+ // TODO: careful!
+ gchar * buf = seed_value_to_string(arguments[0]);
+ printf("%s\n", buf, 0);
+ free(buf);
+
+ return 0;
+}
+
+JSValueRef
+seed_readline(JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
+{
+ // TODO: Should add an interface to rl_bind_key
+ // Perhaps Seed.readline_bind('a', function)
+ // Then automagically do function stuff and make it happen!
+
+ JSStringRef jsstr = 0;
+ JSValueRef valstr = 0;
+ gchar * str = 0;
+ gchar * buf = seed_value_to_string(arguments[0]);
+
+ str = readline(buf);
+ if(str && *str)
+ {
+ add_history(str);
+ valstr = seed_locale_string_to_seed_value(str);
+ free(str);
+ }
+
+ free(buf);
+
+ if(valstr == 0)
+ valstr = JSValueMakeNull(eng->context);
+
+ return valstr;
+}
+
+void seed_init_builtins()
+{
+ JSObjectRef obj = (JSObjectRef)seed_value_get_property(eng->global, "Seed");
+
+ seed_create_function("include", &seed_include, obj);
+ seed_create_function("print", &seed_print, obj);
+ seed_create_function("readline", &seed_readline, obj);
+}
+
Added: trunk/libseed/seed-builtins.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-builtins.h Fri Oct 17 21:51:25 2008
@@ -0,0 +1,55 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-builtins.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _SEED_BUILTINS_H_
+#define _SEED_BUILTINS_H_
+
+#include "seed-private.h"
+
+// TODO: someday, maybe, move import_namespace here!
+
+JSValueRef
+seed_include(JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception);
+
+JSValueRef
+seed_print(JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception);
+
+JSValueRef
+seed_readline(JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception);
+
+void seed_init_builtins();
+
+#endif
+
Added: trunk/libseed/seed-engine.c
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-engine.c Fri Oct 17 21:51:25 2008
@@ -0,0 +1,897 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-engine.c
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "seed-private.h"
+
+#include <string.h>
+
+GQuark qname = 0;
+GQuark qprototype = 0;
+
+JSClassRef gobject_signal_class;
+
+GParamSpec ** global_prop_cache;
+
+static void seed_make_exception(JSValueRef * exception,
+ gchar * name, gchar * message)
+{
+ JSStringRef js_name = 0;
+ JSStringRef js_message = 0;
+ JSValueRef js_name_ref = 0, js_message_ref = 0;
+ JSObjectRef exception_obj;
+
+ if (name)
+ {
+ js_name = JSStringCreateWithUTF8CString(name);
+ js_name_ref = JSValueMakeString(eng->context, js_name);
+ }
+ if (message)
+ {
+ js_message = JSStringCreateWithUTF8CString(message);
+ js_message_ref = JSValueMakeString(eng->context, js_message);
+ }
+
+ exception_obj = JSObjectMake(eng->context, 0, NULL);
+ seed_value_set_property(exception_obj, "message", js_message_ref);
+ seed_value_set_property(exception_obj, "name", js_name_ref);
+
+ *exception = exception_obj;
+
+ JSStringRelease(js_name);
+ JSStringRelease(js_message);
+}
+
+static JSObjectRef
+seed_gobject_constructor_invoked (JSContextRef ctx,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
+{
+ GType type;
+ GParameter *params;
+ GObjectClass *oclass;
+ GObject * gobject;
+ // Do we free GParamSpecs...? It's not clear.
+ GParamSpec * param_spec;
+ gchar * prop_name;
+ int i, nparams = 0, length;
+ GValue gval = {0};
+ JSObjectRef ret;
+ JSPropertyNameArrayRef jsprops = 0;
+ JSStringRef jsprop_name;
+ JSValueRef jsprop_value;
+
+ type = (GType)JSObjectGetPrivate(constructor);
+ if (!type)
+ return 0;
+ oclass = g_type_class_ref (type);
+
+ g_assert(argumentCount <= 1);
+
+ if(argumentCount == 1)
+ {
+ jsprops = JSObjectCopyPropertyNames(eng->context,
+ (JSObjectRef)arguments[0]);
+ nparams = JSPropertyNameArrayGetCount(jsprops);
+ }
+ i = 0;
+
+ params = g_new0(GParameter, nparams + 1);
+
+ // TODO: make sure we don't die if we get passed something other than an object
+
+ while(i < nparams)
+ {
+ jsprop_name = JSPropertyNameArrayGetNameAtIndex(jsprops, i);
+
+ length = JSStringGetMaximumUTF8CStringSize(jsprop_name);
+ prop_name = malloc(length * sizeof(gchar));
+ JSStringGetUTF8CString(jsprop_name, prop_name, length);
+
+ param_spec = g_object_class_find_property (oclass, prop_name);
+ if (param_spec == NULL)
+ g_error("Constructor called "
+ "with invalid property \n");
+
+ // TODO: exception handling
+ jsprop_value = JSObjectGetProperty(eng->context,
+ (JSObjectRef)arguments[0],
+ jsprop_name,
+ NULL);
+
+ if (!seed_gvalue_from_seed_value(
+ jsprop_value,
+ G_PARAM_SPEC_VALUE_TYPE(param_spec),
+ ¶ms[i].value))
+ {
+ g_free(prop_name);
+ g_free(params);
+ return 0;
+ }
+ params[i].name = prop_name;
+
+ ++i;
+ }
+
+ if (jsprops)
+ JSPropertyNameArrayRelease(jsprops);
+
+ gobject = g_object_newv(type, nparams, params);
+
+ if (!gobject)
+ return 0;
+ g_value_init(&gval, G_TYPE_OBJECT);
+ g_value_set_object(&gval, gobject);
+
+ ret = (JSObjectRef)seed_value_from_gvalue(&gval);
+
+ g_value_unset(&gval);
+ g_object_unref(gobject);
+ g_type_class_unref(oclass);
+
+ g_free(params);
+
+ return ret;
+}
+
+static JSValueRef
+seed_gobject_method_invoked (JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ GIBaseInfo * info;
+ GObject * object;
+ gboolean instance_method = TRUE;
+ GArgument retval;
+ GValue gval = {0};
+ GArgument *in_args;
+ GArgument *out_args;
+ int n_args, n_in_args, n_out_args, i;
+ GIArgInfo * arg_info;
+ GITypeInfo * type_info;
+ GIDirection dir;
+ JSValueRef retval_ref;
+ GError * error = 0;
+
+ info = JSObjectGetPrivate(function);
+ if (!
+ seed_gvalue_from_seed_value((SeedValue)this_object,
+ G_TYPE_OBJECT,
+ &gval))
+ instance_method = FALSE;
+
+ if (instance_method)
+ object = g_value_get_object(&gval);
+
+ n_args = g_callable_info_get_n_args((GICallableInfo *) info);
+
+
+ in_args = g_new0(GArgument, n_args+1);
+ out_args = g_new0(GArgument, n_args+1);
+ n_in_args = n_out_args = 0;
+
+ if(instance_method)
+ in_args[n_in_args++].v_pointer = object;
+ for (i = 0;(i < (n_args)); i++)
+ {
+ arg_info = g_callable_info_get_arg((GICallableInfo *) info,
+ i);
+ dir = g_arg_info_get_direction(arg_info);
+ type_info = g_arg_info_get_type(arg_info);
+ if (i+1 > argumentCount)
+ {
+ in_args[n_in_args++].v_pointer = 0;
+ }
+ else if (dir == GI_DIRECTION_IN || dir == GI_DIRECTION_INOUT)
+ {
+
+ if(!seed_gi_make_argument(arguments[i],
+ type_info,
+ &in_args[n_in_args++]))
+ {
+ g_error("Unable to make argument %d for"
+ " function: %s. \n",
+ i+1, g_base_info_get_name(
+ (GIBaseInfo*)info));
+ }
+ if (dir == GI_DIRECTION_INOUT)
+ n_out_args++;
+
+
+
+ }
+ else
+ {
+ g_error("GI_DIRECTION_IN argument: %d"
+ ". In function %s \n",
+ g_base_info_get_name(
+ (GIBaseInfo *) info));
+ }
+
+ g_base_info_unref((GIBaseInfo *) type_info);
+ g_base_info_unref((GIBaseInfo *) arg_info);
+ }
+ if (g_function_info_invoke((GIFunctionInfo*)info,
+ in_args,
+ n_in_args,
+ out_args,
+ n_out_args,
+ &retval,
+ &error))
+ {
+ type_info =
+ g_callable_info_get_return_type((GICallableInfo *)
+ info);
+ if (g_type_info_get_tag(type_info) == GI_TYPE_TAG_VOID)
+ retval_ref = 0;
+ else
+ retval_ref =
+ seed_gi_argument_make_js(&retval, type_info);
+ g_base_info_unref((GIBaseInfo*)type_info);
+ }
+ else
+ {
+ g_error("Error invoking function, %s. %s \n",
+ g_base_info_get_name((GIBaseInfo *) info),
+ error->message);
+ }
+
+ g_free(in_args);
+ g_free(out_args);
+ if (instance_method)
+ g_value_unset(&gval);
+ return retval_ref;
+}
+
+static void seed_gobject_define_property_from_function_info(GIFunctionInfo *info, JSObjectRef object)
+{
+ GIFunctionInfoFlags flags;
+ int n_args, i;
+ GIArgInfo *arg_info;
+ GITypeInfo *type_info;
+ GIDirection dir;
+ SeedValue method_ref;
+ const gchar * symbol_name;
+
+ //if (g_base_info_is_deprecated ((GIBaseInfo *) info))
+ // g_printf("Not defining deprecated symbol: %s \n",
+ // g_base_info_get_name((GIBaseInfo *)info));
+
+ flags = g_function_info_get_flags (info);
+
+ if ((flags & GI_FUNCTION_IS_CONSTRUCTOR) ||
+ (flags & GI_FUNCTION_IS_GETTER) ||
+ (flags & GI_FUNCTION_IS_SETTER))
+ {
+ return;
+ }
+
+ n_args = g_callable_info_get_n_args((GICallableInfo *) info);
+ for (i = 0; i < n_args; i++)
+ {
+ arg_info = g_callable_info_get_arg((GICallableInfo *) info, i);
+ dir = g_arg_info_get_direction(arg_info);
+ if (dir == GI_DIRECTION_OUT)//||
+ // dir == GI_DIRECTION_INOUT)
+ return;
+ type_info = g_arg_info_get_type(arg_info);
+
+
+ if (!seed_gi_supports_type(type_info))
+ g_base_info_unref((GIBaseInfo *)type_info);
+
+ }
+
+ method_ref = JSObjectMake(eng->context, gobject_method_class, info);
+ // This is not clear to me.
+ // JSValueProtect(eng->context, (JSValueRef)method_ref);
+ seed_value_set_property(object,
+ g_base_info_get_name((GIBaseInfo *) info),
+ method_ref);
+
+}
+
+
+static void seed_gobject_add_methods_for_interfaces(GIObjectInfo * oinfo, JSObjectRef object)
+{
+ GIInterfaceInfo * interface;
+ gint n_interfaces, i;
+
+ n_interfaces = g_object_info_get_n_interfaces(oinfo);
+
+ for (i = 0; i < n_interfaces; i++)
+ {
+ GIFunctionInfo * function;
+ gint n_functions, k;
+ interface = g_object_info_get_interface(oinfo, i);
+
+ n_functions = g_interface_info_get_n_methods(interface);
+ for (k = 0; k < n_functions; k++)
+ {
+ function = g_interface_info_get_method(interface, k);
+ seed_gobject_define_property_from_function_info
+ (function, object);
+ }
+ // g_base_info_unref((GIBaseInfo*)interface);
+ }
+}
+
+static void seed_gobject_add_methods_for_type(GIObjectInfo * oinfo, JSObjectRef object)
+{
+ int n_methods;
+ int i, j;
+ GIFunctionInfo * info;
+
+ n_methods = g_object_info_get_n_methods(oinfo);
+
+ for (i = 0; i < n_methods; i++)
+ {
+ info = g_object_info_get_method(oinfo, i);
+ seed_gobject_define_property_from_function_info(info, object);
+ }
+}
+
+JSClassRef
+seed_gobject_get_class_for_gtype(GType type)
+{
+ JSClassDefinition def;
+ GType parent;
+ JSClassRef ref;
+ JSClassRef parent_class;
+ GIBaseInfo * info;
+ JSObjectRef prototype_obj;
+ JSObjectRef parent_prototype;
+
+ if ((ref = g_type_get_qdata (type, qname)) != NULL)
+ {
+ return ref;
+ }
+
+ info = g_irepository_find_by_gtype(g_irepository_get_default(),
+ type);
+
+
+
+ if (!info || !(g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
+ return 0;
+
+ memset(&def, 0, sizeof(JSClassDefinition));
+
+
+ def.className = g_type_name(type);
+ if (parent = g_type_parent(type))
+ parent_class = seed_gobject_get_class_for_gtype(parent);
+ def.parentClass = parent_class;
+ def.attributes = kJSClassAttributeNoAutomaticPrototype;
+
+ prototype_obj = JSObjectMake(eng->context, 0, 0);
+ if (parent)
+ {
+ parent_prototype = seed_gobject_get_prototype_for_gtype(parent);
+ if (parent_prototype)
+ JSObjectSetPrototype(eng->context,
+ prototype_obj, parent_prototype);
+ }
+ seed_gobject_add_methods_for_type((GIObjectInfo *)info, prototype_obj);
+ seed_gobject_add_methods_for_interfaces((GIObjectInfo *) info,
+ prototype_obj);
+
+ ref = JSClassCreate(&def);
+ JSClassRetain(ref);
+
+ JSValueProtect(eng->context, prototype_obj);
+
+ g_type_set_qdata(type, qname, ref);
+ g_type_set_qdata(type, qprototype, prototype_obj);
+
+
+
+ return ref;
+}
+
+JSObjectRef seed_gobject_get_prototype_for_gtype(GType type)
+{
+
+ return g_type_get_qdata(type, qprototype);
+}
+
+static void seed_gobject_finalize(JSObjectRef object)
+{
+ GValue gval = {0};
+ GObject * gobject;
+ GIBaseInfo * base;
+
+ seed_gvalue_from_seed_value((SeedValue) object,
+ G_TYPE_OBJECT, &gval);
+ /* Something would have to go very wrong here */
+ if (!G_VALUE_HOLDS_OBJECT(&gval))
+ return;
+ gobject = g_value_get_object(&gval);
+ if (!gobject)
+ return;
+
+ g_value_unset(&gval);
+ g_object_unref(gobject);
+}
+
+static void seed_gobject_initialize(JSContextRef ctx,
+ JSObjectRef object)
+{
+ GValue gval = {0};
+ GObject * gobject;
+ GIBaseInfo * base;
+
+ seed_gvalue_from_seed_value((SeedValue) object,
+ G_TYPE_OBJECT, &gval);
+ /* Something would have to go very wrong here */
+ if (!G_VALUE_HOLDS_OBJECT(&gval))
+ return;
+ gobject = g_value_get_object(&gval);
+ if (!gobject)
+ return;
+
+ base = g_irepository_find_by_gtype(g_irepository_get_default(),
+ G_OBJECT_TYPE(gobject));
+ if (!base)
+ {
+ g_warning("No GIBaseInfo for: %s \n",
+ G_OBJECT_TYPE_NAME(gobject));
+ return;
+ }
+
+ seed_add_signals_to_object(object, gobject);
+
+ g_assert(g_base_info_get_type(base) == GI_INFO_TYPE_OBJECT);
+
+ g_value_unset(&gval);
+}
+
+static JSValueRef seed_gobject_get_property(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef property_name,
+ JSValueRef * exception)
+{
+ GParamSpec * spec;
+ GObject * b;
+ GValue gval = {0};
+ char * cproperty_name;
+ int length;
+ SeedValue ret;
+ int i, len;
+ GType parent;
+
+ if (!seed_gvalue_from_seed_value((SeedValue)object,
+ G_TYPE_OBJECT, &gval))
+ return 0;
+
+ b = g_value_get_object(&gval);
+
+ length = JSStringGetMaximumUTF8CStringSize(property_name);
+ cproperty_name = malloc(length * sizeof(gchar));
+ JSStringGetUTF8CString(property_name, cproperty_name, length);
+
+
+ spec = g_object_class_find_property(G_OBJECT_GET_CLASS(b),
+ cproperty_name);
+
+ if (!spec)
+ {
+ len = strlen(cproperty_name);
+ for (i = 0; i < len-1; i++)
+ {
+ if (cproperty_name[i] == '_')
+ cproperty_name[i]='-';
+ }
+ spec = g_object_class_find_property(G_OBJECT_GET_CLASS(b),
+ cproperty_name);
+ g_free(cproperty_name);
+ return 0;
+ }
+
+
+
+ g_value_unset(&gval);
+ g_value_init(&gval, spec->value_type);
+ g_object_get_property(b, cproperty_name, &gval);
+ ret = seed_value_from_gvalue(&gval);
+ g_value_unset(&gval);
+
+ g_free(cproperty_name);
+ return (JSValueRef) ret;
+}
+
+static bool seed_gobject_set_property(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef property_name,
+ JSValueRef value,
+ JSValueRef * exception)
+{
+ GParamSpec * spec = 0;
+ GObject * obj;
+ GValue gval = {0};
+ gchar * cproperty_name;
+ int length;
+
+ if (JSValueIsNull(eng->context, value))
+ return 0;
+
+ seed_gvalue_from_seed_value((SeedValue) object, G_TYPE_OBJECT, &gval);
+
+ /* Should probably free here. I lolled */
+ if (!G_VALUE_HOLDS_OBJECT(&gval))
+ return FALSE;
+
+
+ obj = g_value_get_object(&gval);
+ if (!obj || !G_IS_OBJECT(obj))
+ return FALSE;
+
+
+ length = JSStringGetMaximumUTF8CStringSize(property_name);
+ cproperty_name = malloc(length * sizeof(gchar));
+ JSStringGetUTF8CString(property_name, cproperty_name, length);
+
+ spec = g_object_class_find_property(G_OBJECT_GET_CLASS(obj),
+ cproperty_name);
+
+ if (!spec)
+ {
+ int i, len;
+ len = strlen(cproperty_name);
+ for (i = 0; i < len; i++)
+ {
+ if (cproperty_name[i] == '_')
+ cproperty_name[i]='-';
+ }
+ spec = g_object_class_find_property(G_OBJECT_GET_CLASS(obj),
+ cproperty_name);
+ if (!spec)
+ {
+ //gchar * mes = g_strdup_printf("No such property: %s on object of type %s \n",
+ // cproperty_name, g_type_name(G_OBJECT_TYPE(obj)));
+ // seed_make_exception(exception, "InvalidProperty", mes);
+ //g_free(mes);
+ g_free(cproperty_name);
+ return 0;
+ }
+ }
+
+ g_value_unset(&gval);
+
+ if (!(seed_gvalue_from_seed_value(value, spec->value_type, &gval) &&
+ g_type_is_a(G_VALUE_TYPE(&gval), spec->value_type)))
+ {
+ gchar * mes = g_strdup_printf("Not able to set property %s on object of type %s."
+ " Expected type: %s. \n", cproperty_name,
+ g_type_name(G_OBJECT_TYPE(obj)),
+ g_type_name(spec->value_type));
+ seed_make_exception(exception, "InvalidPropertyValue", mes);
+ g_free(mes);
+ g_free(cproperty_name);
+ return 0;
+ }
+
+ g_object_set_property(obj, cproperty_name, &gval);
+ g_free(cproperty_name);
+
+ return TRUE;
+}
+
+static JSValueRef
+seed_gi_import_namespace(JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
+{
+ GIBaseInfo * info;
+ const gchar * namespace;
+ const gchar * version = 0;
+ JSObjectRef namespace_ref;
+ int n,i;
+
+ namespace = seed_value_to_locale_string(arguments[0]);
+ if (argumentCount == 2)
+ {
+ version = seed_value_to_locale_string(arguments[1]);
+ }
+
+ if(!g_irepository_require (g_irepository_get_default (), namespace,
+ version, 0, NULL))
+ g_error("No namespace: %s \n", namespace);
+
+ n = g_irepository_get_n_infos(g_irepository_get_default(),
+ namespace);
+
+ namespace_ref = JSObjectMake(eng->context,
+ NULL, NULL);
+ JSValueProtect(eng->context, namespace_ref);
+ seed_value_set_property(eng->global, namespace, namespace_ref);
+
+ for (i = 0; i < n; i++)
+ {
+ info = g_irepository_get_info(g_irepository_get_default(),
+ namespace, i);
+ if (info &&
+ (g_base_info_get_type(info) == GI_INFO_TYPE_FUNCTION))
+ {
+ seed_gobject_define_property_from_function_info(
+ (GIFunctionInfo *) info, namespace_ref);
+ }
+ else if (info &&
+ (g_base_info_get_type(info) == GI_INFO_TYPE_ENUM))
+ {
+ int num_vals =
+ g_enum_info_get_n_values((GIEnumInfo *) info);
+ int j;
+ JSObjectRef enum_class = JSObjectMake(eng->context,
+ 0,0);
+ JSValueProtect(eng->context, (JSValueRef) enum_class);
+ seed_value_set_property(namespace_ref,
+ g_base_info_get_name(info),
+ enum_class);
+
+
+ for (j = 0; j < num_vals; j++)
+ {
+ GIValueInfo * val =
+ g_enum_info_get_value((GIEnumInfo *)
+ info, j);
+ gint value = g_value_info_get_value(val);
+ gchar * name = g_strdup(
+ g_base_info_get_name(
+ (GIBaseInfo *) val));
+ int name_len = strlen(name);
+ int j;
+ JSValueRef value_ref;
+
+ value_ref = JSValueMakeNumber
+ (eng->context, value);
+ JSValueProtect
+ (eng->context, (JSValueRef)value_ref);
+
+ for (j = 0; j < name_len; j++)
+ {
+ if (name[j]=='-')
+ name[j]='_';
+ }
+
+ seed_value_set_property(
+ enum_class,
+ name,
+ value_ref);
+
+
+
+
+ g_free(name);
+
+ }
+ }
+ else if (info &&
+ (g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
+ {
+ GType type;
+ JSClassRef class_ref;
+
+ type = g_registered_type_info_get_g_type(
+ (GIRegisteredTypeInfo *) info);
+
+ if (type != 0)
+ {
+ JSObjectRef constructor_ref;
+ class_ref =
+ seed_gobject_get_class_for_gtype(type);
+
+ constructor_ref =
+ JSObjectMake(eng->context,
+ gobject_constructor_class,
+ (gpointer)type);
+ seed_value_set_property(namespace_ref,
+ g_base_info_get_name(
+ info),
+ constructor_ref);
+ JSValueProtect(eng->context,
+ (JSValueRef)constructor_ref);
+ }
+
+ }
+ }
+
+ g_free((gchar *)namespace);
+
+ return 0;
+}
+
+JSClassDefinition gobject_def[] = {
+ 0, /* Version, always 0 */
+ kJSClassAttributeNoAutomaticPrototype, /* JSClassAttributes */
+ "gobject", /* Class Name */
+ NULL, /* Parent Class */
+ NULL, /* Static Values */
+ NULL, /* Static Functions */
+ seed_gobject_initialize, /* Initialize */
+ seed_gobject_finalize, /* Finalize */
+ NULL, /* Has Property */
+ seed_gobject_get_property, /* Get Property */
+ seed_gobject_set_property, /* Set Property */
+ NULL, /* Delete Property */
+ NULL, /* Get Property Names */
+ NULL, /* Call As Function */
+ NULL, /* Call As Constructor */
+ NULL, /* Has Instance */
+ NULL /* Convert To Type */
+};
+
+JSClassDefinition gobject_method_def[] = {
+ 0, /* Version, always 0 */
+ 0,
+ "gobject_method", /* Class Name */
+ NULL, /* Parent Class */
+ NULL, /* Static Values */
+ NULL, /* Static Functions */
+ NULL,
+ NULL, /* Finalize */
+ NULL, /* Has Property */
+ NULL, /* Get Property */
+ NULL, /* Set Property */
+ NULL, /* Delete Property */
+ NULL, /* Get Property Names */
+ seed_gobject_method_invoked, /* Call As Function */
+ NULL, /* Call As Constructor */
+ NULL, /* Has Instance */
+ NULL /* Convert To Type */
+};
+
+JSClassDefinition gobject_constructor_def[] = {
+ 0, /* Version, always 0 */
+ 0,
+ "gobject_constructor", /* Class Name */
+ NULL, /* Parent Class */
+ NULL, /* Static Values */
+ NULL, /* Static Functions */
+ NULL,
+ NULL, /* Finalize */
+ NULL, /* Has Property */
+ NULL, /* Get Property */
+ NULL, /* Set Property */
+ NULL, /* Delete Property */
+ NULL, /* Get Property Names */
+ NULL, /* Call As Function */
+ seed_gobject_constructor_invoked, /* Call As Constructor */
+ NULL, /* Has Instance */
+ NULL /* Convert To Type */
+};
+
+JSValueRef seed_locale_string_to_seed_value(char * str)
+{
+ // TODO: lots of these functions, and all in their own file!
+ JSStringRef jsstr = JSStringCreateWithUTF8CString(str);
+ JSValueRef valstr = JSValueMakeString(eng->context, jsstr);
+ JSStringRelease(jsstr);
+
+ return valstr;
+}
+
+void seed_create_function(char * name, gpointer func, JSObjectRef obj)
+{
+ JSObjectRef oref;
+
+ oref = JSObjectMakeFunctionWithCallback(eng->context, NULL, func);
+ JSValueProtect(eng->context, oref);
+ seed_value_set_property(obj, name, oref);
+}
+
+gboolean seed_init(int * argc, char *** argv)
+{
+ JSObjectRef import_namespace_ref, seed_obj_ref;
+
+ g_type_init ();
+
+ qname = g_quark_from_static_string("js-type");
+ qprototype = g_quark_from_static_string("js-prototype");
+
+ eng = (SeedEngine *)malloc(sizeof(SeedEngine));
+
+ eng->context = JSGlobalContextCreateInGroup(NULL,NULL);
+ eng->global = JSContextGetGlobalObject(eng->context);
+ gobject_class = JSClassCreate(gobject_def);
+ JSClassRetain(gobject_class);
+ gobject_method_class = JSClassCreate(gobject_method_def);
+ JSClassRetain(gobject_method_class);
+ gobject_constructor_class = JSClassCreate(gobject_constructor_def);
+ JSClassRetain(gobject_constructor_class);
+ gobject_signal_class = JSClassCreate(seed_get_signal_class());
+ JSClassRetain(gobject_signal_class);
+
+ g_type_set_qdata(G_TYPE_OBJECT, qname, gobject_class);
+
+ seed_obj_ref = JSObjectMake(eng->context, NULL, NULL);
+ seed_value_set_property(eng->global, "Seed", seed_obj_ref);
+ JSValueProtect(eng->context, seed_obj_ref);
+
+ seed_create_function("import_namespace", &seed_gi_import_namespace, seed_obj_ref);
+ seed_init_builtins();
+
+ return TRUE;
+
+}
+
+SeedScript * seed_make_script(const gchar * js, const gchar * source_url,
+ int line_number)
+{
+ SeedScript * ret = g_new0(SeedScript, 1);
+
+ ret->script = JSStringCreateWithUTF8CString(js);
+ JSCheckScriptSyntax(eng->context, ret->script,
+ 0, 0, &ret->exception);
+
+ if (source_url)
+ {
+ ret->source_url = JSStringCreateWithUTF8CString(source_url);
+ }
+ ret->line_number = line_number;
+
+ return ret;
+}
+
+JSValueRef seed_evaluate(SeedScript * js, JSObjectRef this)
+{
+ JSValueRef ret;
+
+ js->exception = 0;
+ ret = JSEvaluateScript(eng->context,
+ js->script, this, js->source_url,
+ js->line_number, &js->exception);
+
+ return ret;
+}
+
+SeedValue seed_script_exception(SeedScript *s)
+{
+ return s->exception;
+}
+
+gchar * seed_exception_get_name(JSValueRef e)
+{
+ SeedValue name;
+ g_assert((e));
+ if (!JSValueIsObject(eng->context, e))
+ return 0;
+
+ name = seed_value_get_property(e, "name");
+ return seed_value_to_locale_string(name);
+}
+
+gchar * seed_exception_get_message(JSValueRef e)
+{
+ SeedValue name;
+ g_assert((e));
+ if (!JSValueIsObject(eng->context, e))
+ return 0;
+
+ name = seed_value_get_property(e, "message");
+ return seed_value_to_locale_string(name);
+}
Added: trunk/libseed/seed-engine.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-engine.h Fri Oct 17 21:51:25 2008
@@ -0,0 +1,45 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-engine.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _SEED_ENGINE_H
+#define _SEED_ENGINE_H
+
+#include "seed-private.h"
+
+extern JSClassRef gobject_class;
+extern JSClassRef gobject_method_class;
+extern JSClassRef gobject_constructor_class;
+extern SeedEngine * eng;
+
+typedef struct _SeedScript
+{
+ JSStringRef script;
+ JSValueRef exception;
+
+ JSStringRef source_url;
+ int line_number;
+} SeedScript;
+
+JSObjectRef seed_gobject_get_prototype_for_gtype(GType type);
+JSClassRef seed_gobject_get_class_for_gtype(GType type);
+
+JSValueRef seed_locale_string_to_seed_value(char * str);
+
+#endif
Added: trunk/libseed/seed-private.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-private.h Fri Oct 17 21:51:25 2008
@@ -0,0 +1,47 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-private.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _SEED_PRIVATE_H
+#define _SEED_PRIVATE_H
+
+#include <JavaScriptCore/JavaScript.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <girepository.h>
+
+typedef struct _SeedEngine SeedEngine;
+typedef JSValueRef SeedValue;
+
+struct _SeedEngine
+{
+ JSGlobalContextRef context;
+ JSObjectRef global;
+};
+
+#include "seed-engine.h"
+#include "seed-types.h"
+#include "seed-signals.h"
+#include "seed-builtins.h"
+#include "seed-utils.h"
+#include "seed-structs.h"
+
+#endif
Added: trunk/libseed/seed-signals.c
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-signals.c Fri Oct 17 21:51:25 2008
@@ -0,0 +1,224 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-signals.c
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <string.h>
+
+#include "seed-private.h"
+
+typedef struct _signal_privates{
+ guint signal_id;
+ GObject * object;
+} signal_privates;
+
+typedef struct _SeedClosure {
+ GClosure closure;
+ JSObjectRef function;
+ JSObjectRef object;
+ JSObjectRef this;
+} SeedClosure;
+
+
+static void seed_add_signal_to_object(JSObjectRef object_ref,
+ GObject * obj,
+ GSignalQuery * signal)
+{
+ int k;
+ JSObjectRef signal_ref;
+ signal_privates * priv =
+ malloc(sizeof(signal_privates));
+ gchar * my_signal_name =
+ g_strdup(signal->signal_name);
+ gchar * modified_signal_name;
+
+ g_assert(signal);
+
+ for (k = 0; k < strlen(my_signal_name); k++)
+ {
+ if (my_signal_name[k]=='-')
+ my_signal_name[k]='_';
+ }
+
+
+ signal_ref = JSObjectMake(eng->context,
+ gobject_signal_class,
+ priv);
+
+ priv->signal_id = signal->signal_id;
+ priv->object = obj;
+
+ modified_signal_name =
+ g_strconcat("signal_",
+ my_signal_name, 0);
+
+ seed_value_set_property(object_ref,
+ modified_signal_name,
+ signal_ref);
+ g_free(my_signal_name);
+ g_free(modified_signal_name);
+}
+
+static void seed_add_signals_for_type(JSObjectRef object_ref,
+ GObject * obj,
+ GType type)
+{
+ guint n, i;
+ guint *signal_ids;
+ GSignalQuery query;
+ signal_ids = g_signal_list_ids(type, &n);
+ for (i = 0; i < n; i++)
+ {
+ g_signal_query(
+ signal_ids[i], &query);
+ if (query.signal_id != 0)
+ {
+ seed_add_signal_to_object(object_ref,
+ obj,
+ &query);
+ }
+ }
+ g_free(signal_ids);
+}
+
+void
+seed_add_signals_to_object(JSObjectRef object_ref, GObject *obj)
+{
+ GType type;
+ GType * interfaces;
+ guint n,i;
+
+ g_assert(obj);
+
+ type = G_OBJECT_TYPE(obj);
+ while (type != 0)
+ {
+ seed_add_signals_for_type(object_ref, obj, type);
+
+ interfaces = g_type_interfaces(type, &n);
+ for (i = 0; i < n; i++)
+ seed_add_signals_for_type(object_ref, obj, interfaces[i]);
+
+ type = g_type_parent(type);
+
+ g_free(interfaces);
+ }
+}
+
+static void
+seed_signal_marshal_func (GClosure * closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshall_data)
+{
+ SeedClosure *seed_closure = (SeedClosure *)closure;
+ JSValueRef * args;
+ int i;
+
+ args = g_new0(JSValueRef, n_param_values);
+
+ for (i = 0; i < n_param_values; i++)
+ {
+ args[i] = seed_value_from_gvalue((GValue *)¶m_values[i]);
+ if (!args[i])
+ g_error("Error in signal marshal. "
+ "Unable to convert argument of type: %s \n",
+ g_type_name(param_values[i].g_type));
+
+ }
+
+ JSObjectCallAsFunction(eng->context, seed_closure->function,
+ seed_closure->this,
+ n_param_values, args, 0);
+ g_free(args);
+}
+
+static JSValueRef
+seed_gobject_signal_connect (JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef * exception)
+{
+ JSObjectRef object;
+ signal_privates * privates;
+ GClosure * closure;
+
+ privates = (signal_privates *)JSObjectGetPrivate(thisObject);
+ if (!privates)
+ g_error("Signal constructed with invalid parameters"
+ "in namespace import \n");
+
+ g_assert((argumentCount <= 2));
+
+ closure = g_closure_new_simple (sizeof(SeedClosure), 0);
+ g_closure_set_marshal(closure, seed_signal_marshal_func);
+ //Losing a ref here. Fix please.
+ //g_closure_add_finalize_notifier(closure, NULL, NULL);
+ ((SeedClosure *) closure)->function = (JSObjectRef)arguments[0];
+ ((SeedClosure *)closure)->object =
+ g_object_get_data(privates->object, "js-ref");
+ if (argumentCount == 2)
+ ((SeedClosure *)closure)->this = (JSObjectRef)arguments[1];
+ else
+ ((SeedClosure *)closure)->this = 0;
+
+
+ g_signal_connect_closure_by_id (privates->object,
+ privates->signal_id,
+ 0,
+ closure,
+ FALSE);
+ return 0;
+}
+
+JSStaticFunction signal_static_functions[] =
+{{ "connect",seed_gobject_signal_connect,0},
+ { 0, 0, 0}};
+
+JSClassDefinition gobject_signal_def[] = {
+ 0, /* Version, always 0 */
+ kJSClassAttributeNoAutomaticPrototype,
+ "gobject_signal", /* Class Name */
+ NULL, /* Parent Class */
+ NULL, /* Static Values */
+ signal_static_functions, /* Static Functions */
+ NULL,
+ NULL, /* Finalize */
+ NULL, /* Has Property */
+ NULL, /* Get Property */
+ NULL, /* Set Property */
+ NULL, /* Delete Property */
+ NULL, /* Get Property Names */
+ NULL, /* Call As Function */
+ NULL, /* Call As Constructor */
+ NULL, /* Has Instance */
+ NULL /* Convert To Type */
+};
+
+JSClassDefinition * seed_get_signal_class(void)
+{
+ return gobject_signal_def;
+}
+
+
+
+
Added: trunk/libseed/seed-signals.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-signals.h Fri Oct 17 21:51:25 2008
@@ -0,0 +1,30 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-signals.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _SEED_SIGNALS_H
+#define _SEED_SIGNALS_H
+
+#include "seed-private.h"
+
+void seed_add_signals_to_object(JSObjectRef object_ref, GObject *obj);
+JSClassDefinition * seed_get_signal_class(void);
+extern JSClassRef gobject_signal_class;
+
+#endif
Added: trunk/libseed/seed-structs.c
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-structs.c Fri Oct 17 21:51:25 2008
@@ -0,0 +1,223 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-structs.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "seed-private.h"
+
+JSClassRef seed_struct_class = 0;
+
+typedef struct _SeedStructPrivates
+{
+ gpointer object;
+ GIBaseInfo * info;
+} SeedStructPrivates;
+
+static void seed_struct_finalize(JSObjectRef younion)
+{
+ g_free(JSObjectGetPrivate(younion));
+}
+
+static JSValueRef seed_struct_get_property(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef property_name,
+ JSValueRef * exception)
+{
+ SeedStructPrivates * priv;
+ GIBaseInfo * info;
+ GIFieldInfo * field = 0;
+ GITypeInfo * prop_type;
+ GIInfoType obj_type;
+ GType prop_gtype;
+ gint num_fields = 0, i, length, offset = 0;
+ gchar * cproperty_name;
+ GValue gval = {0};
+ JSValueRef ret;
+
+ priv = (SeedStructPrivates*)JSObjectGetPrivate(object);
+ info = (GIBaseInfo *)priv->info;
+
+ obj_type = g_base_info_get_type(info);
+
+ length = JSStringGetMaximumUTF8CStringSize(property_name);
+ cproperty_name = malloc(length * sizeof(gchar));
+ JSStringGetUTF8CString(property_name, cproperty_name, length);
+
+ if (obj_type == GI_INFO_TYPE_UNION)
+ num_fields = g_union_info_get_n_fields((GIUnionInfo *)info);
+ else if (obj_type == GI_INFO_TYPE_STRUCT)
+ num_fields = g_struct_info_get_n_fields((GIStructInfo *)info);
+ for (i = 0; i < num_fields; i++)
+ {
+ if (obj_type == GI_INFO_TYPE_UNION)
+ field = g_union_info_get_field((GIUnionInfo *)info, i);
+ else if (obj_type == GI_INFO_TYPE_STRUCT)
+ field = g_struct_info_get_field((GIStructInfo*)info, i);
+ offset += g_field_info_get_size(field);
+
+ if (!strcmp(g_base_info_get_name((GIBaseInfo*)field),
+ cproperty_name))
+ break;
+ else
+ field = 0;
+ }
+ if (!field)
+ return 0;
+
+ prop_type = g_field_info_get_type(field);
+ prop_gtype = seed_gi_type_to_gtype(prop_type,
+ g_type_info_get_tag(prop_type));
+
+ if (prop_gtype)
+ g_value_init(&gval, prop_gtype);
+ switch (g_type_info_get_tag(prop_type))
+ {
+ case GI_TYPE_TAG_VOID:
+ return 0;
+ case GI_TYPE_TAG_BOOLEAN:
+ g_value_set_boolean(&gval,*(gboolean *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_INT8:
+ g_value_set_char(&gval,*(char *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_UINT8:
+ g_value_set_uchar(&gval,*(guchar *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_INT16:
+ g_value_set_int(&gval,*(short *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_UINT16:
+ g_value_set_uint(&gval,*(ushort *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_INT32:
+ g_value_set_int(&gval,*(gint32 *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_UINT32:
+ g_value_set_uint(&gval,*(guint32 *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_LONG:
+ case GI_TYPE_TAG_INT64:
+ g_value_set_long(&gval,*(glong *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_ULONG:
+ case GI_TYPE_TAG_UINT64:
+ g_value_set_ulong(&gval,*(gulong *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_INT:
+ g_value_set_int(&gval,*(gint *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_UINT:
+ g_value_set_uint(&gval,*(guint *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_SSIZE:
+ g_value_set_int(&gval,*(gint *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_SIZE:
+ g_value_set_int(&gval,*(gint *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_FLOAT:
+ g_value_set_float(&gval,*(gfloat *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_DOUBLE:
+ g_value_set_double(&gval,*(gdouble *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_UTF8:
+ g_value_set_string(&gval,(gchar *)(priv->object + offset));
+ break;
+ case GI_TYPE_TAG_INTERFACE:
+ {
+ GIBaseInfo *interface;
+ GIInfoType interface_type;
+ GType required_gtype;
+ GObject * gobject;
+
+ interface = g_type_info_get_interface(prop_type);
+ interface_type = g_base_info_get_type(interface);
+
+
+ if (interface_type == GI_INFO_TYPE_OBJECT)
+ {
+ g_value_set_object(&gval,
+ *(gpointer *)(priv->object + offset));
+ break;
+ }
+ else if (interface_type == GI_INFO_TYPE_ENUM)
+ {
+ g_value_set_long(&gval,
+ *(glong *)(priv->object + offset));
+ break;
+ }
+ else if ((interface_type == GI_INFO_TYPE_STRUCT) ||
+ (interface_type == GI_INFO_TYPE_UNION))
+ {
+ return seed_make_struct(((gpointer *)
+ (priv->object +offset)),
+ g_type_info_get_interface(prop_type));
+ }
+ }
+
+ default:
+ return FALSE;
+
+ }
+ ret = seed_value_from_gvalue(&gval);
+
+ g_value_unset(&gval);
+ g_free(cproperty_name);
+ return ret;
+}
+
+
+JSClassDefinition gobject_struct_def[] = {
+ 0, /* Version, always 0 */
+ 0,
+ "gobject_union", /* Class Name */
+ NULL, /* Parent Class */
+ NULL, /* Static Values */
+ NULL, /* Static Functions */
+ NULL,
+ seed_struct_finalize, /* Finalize */
+ NULL, /* Has Property */
+ seed_struct_get_property, /* Get Property */
+ NULL, /* Set Property */
+ NULL, /* Delete Property */
+ NULL, /* Get Property Names */
+ NULL, /* Call As Function */
+ NULL, /* Call As Constructor */
+ NULL, /* Has Instance */
+ NULL /* Convert To Type */
+};
+
+JSObjectRef seed_make_union(gpointer younion, GIBaseInfo * info)
+{
+ SeedStructPrivates * privates;
+ if (!seed_struct_class)
+ seed_struct_class = JSClassCreate(gobject_struct_def);
+
+ privates = g_new0(SeedStructPrivates, 1);
+
+ privates->object = younion;
+ privates->info = info;
+
+ return JSObjectMake(eng->context, seed_struct_class, privates);
+}
+
+JSObjectRef seed_make_struct(gpointer strukt, GIBaseInfo * info)
+{
+ seed_make_union(strukt, info);
+}
Added: trunk/libseed/seed-structs.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-structs.h Fri Oct 17 21:51:25 2008
@@ -0,0 +1,26 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-struct.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SEED_STRUCT_H
+#define _SEED_STRUCT_H
+
+JSObjectRef seed_make_union(gpointer younion, GIBaseInfo * info);
+JSObjectRef seed_make_struct(gpointer strukt, GIBaseInfo * info);
+
+#endif
Added: trunk/libseed/seed-types.c
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-types.c Fri Oct 17 21:51:25 2008
@@ -0,0 +1,812 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-types.c
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "seed-private.h"
+
+JSClassRef gobject_class;
+JSClassRef gobject_method_class;
+JSClassRef gobject_constructor_class;
+SeedEngine * eng;
+
+static void seed_protect_object(SeedValue val)
+{
+ JSValueProtect(eng->context, val);
+}
+
+static void seed_unprotect_object(SeedValue val)
+{
+ JSValueUnprotect(eng->context, val);
+}
+
+static gboolean seed_value_is_gobject(SeedValue value)
+{
+ gboolean ret;
+
+ if (!JSValueIsObject(eng->context, value) ||
+ JSValueIsNull(eng->context, value))
+ return FALSE;
+
+
+ return JSValueIsObjectOfClass(eng->context, value, gobject_class);
+}
+
+static GObject * seed_value_to_gobject(SeedValue value)
+{
+ GObject * gobject;
+
+ if (!JSValueIsObject(eng->context, value) ||
+ JSValueIsNull(eng->context, value))
+ return NULL;
+
+ if(JSValueIsObjectOfClass(eng->context, value, gobject_class))
+ gobject = (GObject*)JSObjectGetPrivate((JSObjectRef)value);
+ else
+ gobject = NULL;
+
+ return gobject;
+}
+
+static SeedValue seed_wrap_object(GObject * object)
+{
+ SeedValue user_data;
+ SeedValue js_ref;
+ JSClassRef class;
+ GType type;
+ JSValueRef prototype;
+
+
+ type = G_OBJECT_TYPE(object);
+
+ user_data = (SeedValue)g_object_get_data(object,
+ "js-ref");
+
+ if (user_data)
+ return user_data;
+
+ class = seed_gobject_get_class_for_gtype(type);
+
+
+ while (!class && (type=g_type_parent(type)))
+ {
+ class = seed_gobject_get_class_for_gtype(type);
+ }
+
+
+ prototype = seed_gobject_get_prototype_for_gtype(type);
+ js_ref = JSObjectMake(eng->context, class, object);
+ JSObjectSetPrototype(eng->context, (JSObjectRef)js_ref, prototype);
+
+ // Is this going to work? g_free seems wrong, don't we need some
+ // variety of finalize. This is a pointer declared on the stack anyway.
+ // What is happening. You had &js_ref, after this ramblign comment
+ // I am changing it to js_ref, and protecting/unprotecting it.
+ object = g_object_ref(object);
+ //g_object_set_data_full(object, "js-ref", (gpointer)js_ref,
+ // (GDestroyNotify) seed_unprotect_object);
+ /* I think we avoid the need for this
+ g_object_add_toggle_ref(object,
+ object_toggle_notify_cb,
+ 0); */
+
+ return js_ref;
+
+
+
+
+}
+
+/* Should update to try and use glib type conversion */
+gchar * seed_value_to_locale_string (SeedValue val)
+{
+ JSStringRef jsstr;
+ gint length;
+ gchar * ret;
+
+ g_return_if_fail(val);
+
+ if (!JSValueIsString(eng->context, val))
+ return 0;
+
+
+ jsstr = JSValueToStringCopy(eng->context, val, NULL);
+
+ length = JSStringGetMaximumUTF8CStringSize(jsstr);
+ ret = malloc(length * sizeof(gchar));
+
+ JSStringGetUTF8CString(jsstr, ret, length);
+
+ JSStringRelease(jsstr);
+
+ return ret;
+}
+
+GType seed_gi_type_to_gtype(GITypeInfo *type_info, GITypeTag tag)
+{
+ switch(tag)
+ {
+ case GI_TYPE_TAG_VOID:
+ return G_TYPE_NONE;
+ case GI_TYPE_TAG_BOOLEAN:
+ return G_TYPE_BOOLEAN;
+ case GI_TYPE_TAG_INT8:
+ return G_TYPE_CHAR;
+ case GI_TYPE_TAG_UINT8:
+ return G_TYPE_UCHAR;
+ case GI_TYPE_TAG_INT16:
+ return G_TYPE_INT;
+ case GI_TYPE_TAG_UINT16:
+ return G_TYPE_UINT;
+ case GI_TYPE_TAG_INT32:
+ return G_TYPE_INT;
+ case GI_TYPE_TAG_UINT32:
+ return G_TYPE_UINT;
+ case GI_TYPE_TAG_INT64:
+ return G_TYPE_INT64;
+ case GI_TYPE_TAG_UINT64:
+ return G_TYPE_UINT64;
+ case GI_TYPE_TAG_INT:
+ return G_TYPE_INT;
+ case GI_TYPE_TAG_UINT:
+ return G_TYPE_UINT;
+ case GI_TYPE_TAG_LONG:
+ return G_TYPE_LONG;
+ case GI_TYPE_TAG_ULONG:
+ return G_TYPE_ULONG;
+ case GI_TYPE_TAG_SSIZE:
+ return G_TYPE_INT;
+ case GI_TYPE_TAG_SIZE:
+ return G_TYPE_INT;
+ case GI_TYPE_TAG_FLOAT:
+ return G_TYPE_FLOAT;
+ case GI_TYPE_TAG_DOUBLE:
+ return G_TYPE_DOUBLE;
+ case GI_TYPE_TAG_UTF8:
+ case GI_TYPE_TAG_FILENAME:
+ return G_TYPE_STRING;
+ case GI_TYPE_TAG_ARRAY:
+ case GI_TYPE_TAG_GLIST:
+ case GI_TYPE_TAG_GSLIST:
+ case GI_TYPE_TAG_GHASH:
+ case GI_TYPE_TAG_ERROR:
+ return G_TYPE_INVALID;
+ case GI_TYPE_TAG_INTERFACE:
+ {
+ GIBaseInfo *interface;
+ GIInfoType interface_type;
+
+ interface = g_type_info_get_interface(type_info);
+ interface_type = g_base_info_get_type(interface);
+ if (interface_type == GI_INFO_TYPE_OBJECT)
+ return G_TYPE_OBJECT;
+ else if (interface_type == GI_INFO_TYPE_ENUM)
+ return G_TYPE_LONG;
+ }
+ }
+ return 0;
+}
+
+
+gboolean seed_gi_make_argument(SeedValue value,
+ GITypeInfo *type_info,
+ GArgument * arg)
+{
+ GValue gval = {0};
+ GITypeTag gi_tag = g_type_info_get_tag(type_info);
+ GType gtag = seed_gi_type_to_gtype(type_info,
+ gi_tag);
+
+ if (!value || JSValueIsNull(eng->context, value))
+ {
+ arg->v_pointer = 0;
+ return 1;
+ }
+
+ seed_gvalue_from_seed_value(value,
+ gtag,
+ &gval);
+
+ switch(gi_tag)
+ {
+ case GI_TYPE_TAG_VOID:
+ break;
+ case GI_TYPE_TAG_BOOLEAN:
+ arg->v_boolean = g_value_get_boolean(&gval);
+ break;
+ case GI_TYPE_TAG_INT8:
+ arg->v_int8 = g_value_get_char(&gval);
+ break;
+ case GI_TYPE_TAG_UINT8:
+ arg->v_uint8 = g_value_get_uchar(&gval);
+ break;
+ case GI_TYPE_TAG_INT16:
+ arg->v_int16 = g_value_get_int(&gval);
+ break;
+ case GI_TYPE_TAG_UINT16:
+ arg->v_uint16 = g_value_get_uint(&gval);
+ break;
+ case GI_TYPE_TAG_INT32:
+ arg->v_int32 = g_value_get_int(&gval);
+ break;
+ case GI_TYPE_TAG_UINT32:
+ arg->v_uint32 = g_value_get_uint(&gval);
+ break;
+ case GI_TYPE_TAG_LONG:
+ case GI_TYPE_TAG_INT64:
+ arg->v_int64 = (gint64)g_value_get_long(&gval);
+ break;
+ case GI_TYPE_TAG_ULONG:
+ case GI_TYPE_TAG_UINT64:
+ arg->v_uint64 = (guint64)g_value_get_ulong(&gval);
+ break;
+ case GI_TYPE_TAG_INT:
+ arg->v_int = g_value_get_int(&gval);
+ break;
+ case GI_TYPE_TAG_UINT:
+ arg->v_uint = g_value_get_uint(&gval);
+ break;
+ case GI_TYPE_TAG_SSIZE:
+ arg->v_int = g_value_get_int(&gval);
+ break;
+ case GI_TYPE_TAG_SIZE:
+ arg->v_int = g_value_get_int(&gval);
+ break;
+ case GI_TYPE_TAG_FLOAT:
+ arg->v_float = g_value_get_float(&gval);
+ break;
+ case GI_TYPE_TAG_DOUBLE:
+ arg->v_double = g_value_get_double(&gval);
+ break;
+ case GI_TYPE_TAG_UTF8:
+ arg->v_string = g_strdup(g_value_get_string(&gval));
+ break;
+ case GI_TYPE_TAG_INTERFACE:
+ {
+ GIBaseInfo *interface;
+ GIInfoType interface_type;
+ GType required_gtype;
+ GObject * gobject;
+
+ interface = g_type_info_get_interface(type_info);
+ interface_type = g_base_info_get_type(interface);
+
+ arg->v_pointer = NULL;
+
+ if (interface_type == GI_INFO_TYPE_OBJECT)
+ {
+ if (!G_VALUE_HOLDS_OBJECT(&gval))
+ {
+ return FALSE;
+ }
+ gobject = g_value_get_object(&gval);
+ required_gtype =
+ g_registered_type_info_get_g_type(
+ (GIRegisteredTypeInfo *) interface);
+ if (!g_type_is_a(G_OBJECT_TYPE (gobject),
+ required_gtype))
+ {
+ return FALSE;
+ }
+
+ arg->v_pointer = g_object_ref(gobject);
+ break;
+ }
+ else if (interface_type == GI_INFO_TYPE_ENUM)
+ {
+ arg->v_long = JSValueToNumber(eng->context,
+ value, NULL);
+ break;
+ }
+ }
+
+ default:
+ return FALSE;
+
+
+
+
+ }
+ return TRUE;
+
+}
+
+JSValueRef seed_gi_argument_make_js(GArgument * arg, GITypeInfo *type_info)
+{
+ GValue gval = {0};
+ GITypeTag gi_tag = g_type_info_get_tag(type_info);
+ GType gtag = seed_gi_type_to_gtype(type_info, gi_tag);
+ SeedValue ret;
+
+ g_value_init(&gval, gtag);
+ switch (gi_tag)
+ {
+ case GI_TYPE_TAG_VOID:
+ return 0;
+ case GI_TYPE_TAG_BOOLEAN:
+ g_value_set_boolean(&gval,arg->v_boolean );
+ break;
+ case GI_TYPE_TAG_INT8:
+ g_value_set_char(&gval,arg->v_int8 );
+ break;
+ case GI_TYPE_TAG_UINT8:
+ g_value_set_uchar(&gval,arg->v_uint8 );
+ break;
+ case GI_TYPE_TAG_INT16:
+ g_value_set_int(&gval,arg->v_int16 );
+ break;
+ case GI_TYPE_TAG_UINT16:
+ g_value_set_uint(&gval,arg->v_uint16 );
+ break;
+ case GI_TYPE_TAG_INT32:
+ g_value_set_int(&gval,arg->v_int32 );
+ break;
+ case GI_TYPE_TAG_UINT32:
+ g_value_set_uint(&gval,arg->v_uint32 );
+ break;
+ case GI_TYPE_TAG_LONG:
+ case GI_TYPE_TAG_INT64:
+ g_value_set_long(&gval,arg->v_int64);
+ break;
+ case GI_TYPE_TAG_ULONG:
+ case GI_TYPE_TAG_UINT64:
+ g_value_set_ulong(&gval,arg->v_uint64);
+ break;
+ case GI_TYPE_TAG_INT:
+ g_value_set_int(&gval,arg->v_int );
+ break;
+ case GI_TYPE_TAG_UINT:
+ g_value_set_uint(&gval,arg->v_uint );
+ break;
+ case GI_TYPE_TAG_SSIZE:
+ g_value_set_int(&gval,arg->v_int );
+ break;
+ case GI_TYPE_TAG_SIZE:
+ g_value_set_int(&gval,arg->v_int );
+ break;
+ case GI_TYPE_TAG_FLOAT:
+ g_value_set_float(&gval,arg->v_float );
+ break;
+ case GI_TYPE_TAG_DOUBLE:
+ g_value_set_double(&gval,arg->v_double );
+ break;
+ case GI_TYPE_TAG_UTF8:
+ g_value_set_string(&gval,arg->v_string);
+ break;
+ case GI_TYPE_TAG_INTERFACE:
+ {
+ GIBaseInfo *interface;
+ GIInfoType interface_type;
+ GType required_gtype;
+ GObject * gobject;
+
+ interface = g_type_info_get_interface(type_info);
+ interface_type = g_base_info_get_type(interface);
+
+
+ if (interface_type == GI_INFO_TYPE_OBJECT)
+ {
+ g_value_set_object(&gval, arg->v_pointer);
+ break;
+ }
+ else if (interface_type == GI_INFO_TYPE_ENUM)
+ {
+ g_value_set_long(&gval, arg->v_double);
+ return 0;
+ }
+ else
+ {
+ printf("OH NO! \n");
+ }
+ }
+
+ default:
+ return FALSE;
+
+ }
+ ret = seed_value_from_gvalue(&gval);
+ g_value_unset(&gval);
+ return ret;
+}
+
+gboolean seed_gi_supports_type(GITypeInfo * type_info)
+{
+ GITypeTag type_tag;
+
+ type_tag = g_type_info_get_tag(type_info);
+
+ switch (type_tag)
+ {
+ case GI_TYPE_TAG_VOID:
+ case GI_TYPE_TAG_BOOLEAN:
+ case GI_TYPE_TAG_INT8:
+ case GI_TYPE_TAG_UINT8:
+ case GI_TYPE_TAG_INT16:
+ case GI_TYPE_TAG_UINT16:
+ case GI_TYPE_TAG_INT32:
+ case GI_TYPE_TAG_UINT32:
+ case GI_TYPE_TAG_INT64:
+ case GI_TYPE_TAG_UINT64:
+ case GI_TYPE_TAG_INT:
+ case GI_TYPE_TAG_UINT:
+ case GI_TYPE_TAG_LONG:
+ case GI_TYPE_TAG_ULONG:
+ case GI_TYPE_TAG_SSIZE:
+ case GI_TYPE_TAG_SIZE:
+ case GI_TYPE_TAG_FLOAT:
+ case GI_TYPE_TAG_DOUBLE:
+ case GI_TYPE_TAG_UTF8:
+ return TRUE;
+
+ case GI_TYPE_TAG_FILENAME:
+ case GI_TYPE_TAG_ARRAY:
+ case GI_TYPE_TAG_GLIST:
+ case GI_TYPE_TAG_GSLIST:
+ case GI_TYPE_TAG_GHASH:
+ case GI_TYPE_TAG_ERROR:
+ return FALSE;
+
+ case GI_TYPE_TAG_INTERFACE:
+ {
+ return TRUE;
+ }
+
+
+ }
+}
+
+SeedValue seed_value_from_gvalue(GValue * gval)
+{
+ if(!G_IS_VALUE(gval))
+ {
+ return false;
+ }
+
+ SeedValue val;
+
+ switch(G_VALUE_TYPE(gval))
+ {
+ case G_TYPE_BOOLEAN:
+ {
+ return JSValueMakeBoolean(eng->context,
+ g_value_get_boolean(gval));
+ }
+ case G_TYPE_CHAR:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_char(gval));
+ }
+ case G_TYPE_UCHAR:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_uchar(gval));
+ }
+ case G_TYPE_INT:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_int(gval));
+ }
+ case G_TYPE_UINT:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_uint(gval));
+ }
+ case G_TYPE_LONG:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_long(gval));
+ }
+ case G_TYPE_ULONG:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_ulong(gval));
+ }
+ case G_TYPE_INT64:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_int64(gval));
+ }
+ case G_TYPE_UINT64:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_uint64(gval));
+ }
+ case G_TYPE_FLOAT:
+ {
+ return JSValueMakeNumber(eng->context, g_value_get_float(gval));
+ }
+ case G_TYPE_DOUBLE:
+ {
+ return JSValueMakeNumber(eng->context,
+ g_value_get_double(gval));
+ }
+ case G_TYPE_STRING:
+ {
+ JSValueRef str = JSValueMakeString(eng->context,
+ JSStringCreateWithUTF8CString(
+ g_value_get_string(gval)));
+ return JSValueToObject(eng->context,str,0);
+ }
+ }
+
+ if(g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_ENUM))
+ return JSValueMakeNumber(eng->context,
+ (double)gval->data[0].v_long);
+ else if(g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_ENUM))
+ return JSValueMakeNumber(eng->context,
+ (double)gval->data[0].v_ulong);
+ else if(g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_OBJECT))
+ {
+ GObject * gobject;
+
+
+ gobject = (GObject*)g_value_get_object(gval);
+ if(gobject == NULL)
+ val = JSValueMakeNull(eng->context);
+ else
+ val = seed_wrap_object(gobject);
+
+
+ g_object_unref(gobject);
+
+ return val;
+ }
+ else
+ {
+ GIBaseInfo * info;
+ GIInfoType type;
+
+ info = g_irepository_find_by_gtype(0, G_VALUE_TYPE(gval));
+ type = g_base_info_get_type(info);
+
+ if (type == GI_INFO_TYPE_UNION)
+ {
+ return seed_make_union(g_value_peek_pointer(gval),
+ info);
+ }
+ else if (type == GI_INFO_TYPE_STRUCT)
+ {
+ return seed_make_struct(g_value_peek_pointer(gval),
+ info);
+ }
+
+ }
+
+ return NULL;
+}
+
+gboolean seed_gvalue_from_seed_value(SeedValue val,
+ GType type,
+ GValue * ret)
+
+{
+ gint32 cv;
+
+ switch(type)
+ {
+ case G_TYPE_BOOLEAN:
+ {
+ /* This is fail. Need to call
+ seed_gvalue_from_seed_value with no type, and then
+ try gobject cast. */
+ if(!JSValueIsBoolean(eng->context, val))
+ goto bad_type;
+
+ g_value_init(ret, G_TYPE_BOOLEAN);
+ g_value_set_boolean(ret, JSValueToBoolean(eng->context, val));
+ return TRUE;
+ }
+ case G_TYPE_INT:
+ case G_TYPE_UINT:
+ {
+ if(!JSValueIsNumber(eng->context, val))
+ goto bad_type;
+
+ g_value_init(ret, type);
+ if (type == G_TYPE_INT)
+ g_value_set_int(ret,
+ JSValueToNumber(eng->context, val, NULL));
+ else
+ g_value_set_uint(ret,
+ JSValueToNumber(eng->context, val, NULL));
+ return TRUE;
+ }
+ case G_TYPE_CHAR:
+ {
+ if(!JSValueIsNumber(eng->context, val))
+ goto bad_type;
+
+ cv = JSValueToNumber(eng->context, val, NULL);
+ if(cv < G_MININT8 || cv > G_MAXINT8)
+ goto bad_type;
+
+ g_value_init(ret, G_TYPE_INT);
+ g_value_set_char(ret, cv);
+ return TRUE;
+ }
+ case G_TYPE_UCHAR:
+ {
+ if(!JSValueIsNumber(eng->context, val))
+ goto bad_type;
+
+ cv = JSValueToNumber(eng->context, val, NULL);
+ if(cv < 0 || cv > G_MAXUINT8)
+ goto bad_type;
+
+ g_value_init(ret, G_TYPE_INT);
+ g_value_set_uchar(ret, cv);
+ return TRUE;
+ }
+ case G_TYPE_LONG:
+ case G_TYPE_ULONG:
+ case G_TYPE_INT64:
+ case G_TYPE_UINT64:
+ case G_TYPE_FLOAT:
+ case G_TYPE_DOUBLE:
+ {
+ if(!JSValueIsNumber(eng->context, val))
+ goto bad_type;
+
+ g_value_init(ret, type);
+ switch(type)
+ {
+ case G_TYPE_LONG:
+ g_value_set_long(ret,
+ JSValueToNumber(eng->context,
+ val, NULL));
+ break;
+ case G_TYPE_ULONG:
+ g_value_set_ulong(ret,
+ JSValueToNumber(eng->context,
+ val, NULL));
+ break;
+ case G_TYPE_INT64:
+ g_value_set_int64(ret,
+ JSValueToNumber(eng->context,
+ val, NULL));
+ break;
+ case G_TYPE_UINT64:
+ g_value_set_uint64(ret,
+ JSValueToNumber(eng->context,
+ val, NULL));
+ break;
+ case G_TYPE_FLOAT:
+ g_value_set_float(ret,
+ JSValueToNumber(eng->context,
+ val, NULL));
+ break;
+ case G_TYPE_DOUBLE:
+ g_value_set_double(ret,
+ JSValueToNumber(eng->context,
+ val, NULL));
+ break;
+ }
+ return TRUE;
+ }
+ case G_TYPE_STRING:
+ {
+ gchar * cval = seed_value_to_string(val);
+
+ g_value_init(ret, G_TYPE_STRING);
+ g_value_take_string(ret, cval);
+
+ return TRUE;
+ }
+ default:
+ {
+ switch(JSValueGetType(eng->context, val))
+ {
+ case kJSTypeBoolean:
+ {
+ g_value_init(ret, G_TYPE_BOOLEAN);
+ g_value_set_boolean(ret,
+ JSValueToBoolean(eng->context,
+ val));
+ return TRUE;
+ }
+ case kJSTypeNumber:
+ {
+ g_value_init(ret, G_TYPE_DOUBLE);
+ g_value_set_double(ret,
+ JSValueToNumber(eng->context,
+ val, NULL));
+ return TRUE;
+ }
+ case kJSTypeString:
+ {
+ gchar * cv = seed_value_to_locale_string(val);
+
+ g_value_init(ret, G_TYPE_STRING);
+ g_value_take_string(ret, cv);
+ return TRUE;
+ }
+ }
+ break;
+ }
+ }
+
+ if(g_type_is_a(type, G_TYPE_ENUM) && JSValueIsNumber(eng->context, val))
+ {
+ if(!JSValueIsNumber(eng->context, val))
+ goto bad_type;
+
+ g_value_init(ret, type);
+ /* What? */
+ ret->data[0].v_long = JSValueToNumber(eng->context, val, NULL);
+ return TRUE;
+ }
+ else if(g_type_is_a(type, G_TYPE_FLAGS)
+ && JSValueIsNumber(eng->context, val))
+ {
+ if(!JSValueIsNumber(eng->context, val))
+ goto bad_type;
+
+ g_value_init(ret, type);
+ ret->data[0].v_long = JSValueToNumber(eng->context, val, NULL);
+ return TRUE;
+ }
+ else if(g_type_is_a(type, G_TYPE_OBJECT)
+ && (JSValueIsNull(eng->context, val)
+ || seed_value_is_gobject(val)))
+ {
+ GObject * o = seed_value_to_gobject(val);
+
+ if(o == NULL || g_type_is_a(G_OBJECT_TYPE(o), type))
+ {
+ g_value_init(ret, G_TYPE_OBJECT);
+ g_value_set_object(ret, o);
+ return TRUE;
+ }
+
+ g_object_unref(o);
+ }
+
+bad_type:
+ return 0;
+}
+
+SeedValue seed_value_get_property(SeedValue val,
+ const char * name)
+{
+
+ JSStringRef jname = JSStringCreateWithUTF8CString(name);
+ JSValueRef ret = JSObjectGetProperty(eng->context,
+ (JSObjectRef)val,
+ jname, NULL);
+
+ JSStringRelease(jname);
+
+ return ret;
+}
+
+gboolean seed_value_set_property(JSObjectRef object,
+ const char * name,
+ JSValueRef value)
+{
+ JSStringRef jname = JSStringCreateWithUTF8CString(name);
+
+ if (value)
+ {
+ JSObjectSetProperty(eng->context, (JSObjectRef)object,
+ jname, value, 0, 0);
+ }
+
+ JSStringRelease(jname);
+
+ return TRUE;
+}
Added: trunk/libseed/seed-types.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-types.h Fri Oct 17 21:51:25 2008
@@ -0,0 +1,44 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-types.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _SEED_TYPES_H
+#define _SEED_TYPES_H
+
+#include "seed-private.h"
+
+gchar * seed_value_to_locale_string(SeedValue val);
+SeedValue seed_value_from_gvalue(GValue * gval);
+SeedValue seed_value_get_property(SeedValue val,
+ const char * name);
+
+gboolean seed_value_set_property(JSObjectRef object,
+ const char * name, JSValueRef value);
+gboolean seed_gvalue_from_seed_value(SeedValue val,
+ GType type,
+ GValue * gval);
+gboolean seed_gi_supports_type(GITypeInfo * type_info);
+gboolean seed_gi_make_argument(SeedValue value, GITypeInfo *type_info,
+ GArgument * arg);
+JSValueRef seed_gi_argument_make_js(GArgument * arg, GITypeInfo *type_info);
+
+GType seed_gi_type_to_gtype(GITypeInfo *type_info, GITypeTag tag);
+
+#endif
+
Added: trunk/libseed/seed-utils.c
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-utils.c Fri Oct 17 21:51:25 2008
@@ -0,0 +1,58 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-utils.c
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "seed-private.h"
+
+#include <string.h>
+
+gchar * seed_value_to_string(JSValueRef obj)
+{
+ // TODO: there's /definitely/ still a way to crash this (pass it a JSStringRef)
+
+ JSValueRef func, str;
+ gchar * buf;
+
+ if(obj == NULL)
+ return NULL;
+
+ if(JSValueIsBoolean(eng->context, obj) || JSValueIsNumber(eng->context, obj))
+ {
+ buf = malloc(1000 * sizeof(gchar));
+
+ snprintf(buf, 1000, "%f", JSValueToNumber(eng->context, obj, NULL));
+ }
+ else if(JSValueIsNull(eng->context, obj) || JSValueIsUndefined(eng->context, obj))
+ {
+ buf = strdup("[null]");
+ }
+ else if(JSValueIsString(eng->context, obj))
+ {
+ buf = seed_value_to_locale_string(obj);
+ }
+ else
+ {
+ func = seed_value_get_property(obj, "toString");
+ str = JSObjectCallAsFunction(eng->context, (JSObjectRef)func, (JSObjectRef)obj, 0, NULL, NULL);
+ // TODO: exceptions!!
+ buf = seed_value_to_locale_string(str);
+ }
+
+ return buf;
+}
Added: trunk/libseed/seed-utils.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-utils.h Fri Oct 17 21:51:25 2008
@@ -0,0 +1,27 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed-utils.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _SEED_UTILS_H_
+#define _SEED_UTILS_H_
+
+gchar * seed_value_to_string(SeedValue obj);
+
+#endif
+
Added: trunk/libseed/seed.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed.h Fri Oct 17 21:51:25 2008
@@ -0,0 +1,50 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * seed.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _SEED_H
+#define _SEED_H
+
+typedef gpointer SeedValue;
+typedef gpointer SeedObject;
+typedef gpointer SeedClass;
+typedef gpointer SeedException;
+typedef gpointer SeedFunction;
+
+typedef struct _SeedScript SeedScript;
+
+/* seed-engine.c */
+gboolean seed_init(int * argc, char *** argv);
+
+SeedScript * seed_make_script(const gchar *s, const gchar * source_url,
+ int line_number);
+SeedException seed_script_exception(SeedScript *s);
+SeedException seed_make_exception(gchar * name, gchar * message);
+gchar * seed_exception_get_name(SeedException e);
+gchar * seed_exception_get_message(SeedException e);
+
+SeedValue seed_evaluate(SeedScript *s, SeedObject this);
+
+gchar * seed_value_to_string(SeedValue obj);
+
+/* seed-util.c */
+
+
+
+#endif
Added: trunk/main.c
==============================================================================
--- (empty file)
+++ trunk/main.c Fri Oct 17 21:51:25 2008
@@ -0,0 +1,78 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * main.c
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <glib.h>
+#include <glib-object.h>
+#include "libseed/seed.h"
+#include "readline/readline.h"
+#include <stdlib.h>
+
+void seed_exec(int argc, char ** argv)
+{
+ SeedScript * script;
+ SeedException e;
+ gchar * buffer;
+
+ g_assert((argc==2));
+
+ g_file_get_contents(argv[1],
+ &buffer, 0, 0);
+
+ if (*buffer == '#')
+ {
+ while (*buffer != '\n')
+ buffer++;
+ buffer++;
+ }
+ script = seed_make_script(buffer, argv[1], 0);
+ if (e =seed_script_exception(script))
+ g_critical("%s. %s",
+ seed_exception_get_name(e),
+ seed_exception_get_message(e));
+ seed_evaluate(script, 0);
+ if (e = seed_script_exception(script))
+ g_critical("%s. %s",
+ seed_exception_get_name(e),
+ seed_exception_get_message(e));
+
+ g_free(script);
+}
+
+int main(int argc, char ** argv)
+{
+ // TODO: GStreamer doesn't like to be initialized late. I don't remember
+ // how to fix this right now.
+
+ // Apparently our name for glib logging gets set in g*_init. can we set
+ // that ourselves so that when we do on-the-fly init, we don't lose that?
+ gst_init(&argc, &argv);
+ seed_init(&argc, &argv);
+
+ if (!g_irepository_require(g_irepository_get_default(),
+ "GObject", 0, 0))
+ g_critical("Unable to import GObject repository");
+
+ if(argc == 2)
+ seed_exec(argc, argv);
+ else
+ printf("Usage: %s file.js\n", argv[0]);
+
+ return 0;
+}
Added: trunk/tests/enum.js
==============================================================================
--- (empty file)
+++ trunk/tests/enum.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,9 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:4.000000
+// STDERR:
+
+Seed.import_namespace("Gst");
+Seed.print(Gst.State.playing);
+
Added: trunk/tests/include.js
==============================================================================
--- (empty file)
+++ trunk/tests/include.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,7 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:Hello, world!
+// STDERR:
+
+Seed.include("print.js");
Added: trunk/tests/json-constructor.js
==============================================================================
--- (empty file)
+++ trunk/tests/json-constructor.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,16 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:JSON Win!
+// STDERR:
+
+Seed.import_namespace("Gdk");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("GLib");
+
+Gtk.init(null, null);
+window = new Gtk.Window({"title":"JSON Win!"});
+window.show_all();
+
+Seed.print(window.title);
+
Added: trunk/tests/print.js
==============================================================================
--- (empty file)
+++ trunk/tests/print.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,7 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:Hello, world!
+// STDERR:
+
+Seed.print("Hello, world!");
Added: trunk/tests/property-benchmark.js
==============================================================================
--- (empty file)
+++ trunk/tests/property-benchmark.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,17 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:
+// STDERR:
+
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+
+window = new Gtk.Window();
+window.title="HI";
+window.name="HI";
+for (i = 0; i < 100000; i++)
+{
+ a = window.title;
+ b = window.name;
+}
Added: trunk/tests/readline.js
==============================================================================
--- (empty file)
+++ trunk/tests/readline.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,7 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:2+2
+// STDOUT:4.000000
+// STDERR:
+
+Seed.print(eval(Seed.readline("")));
Added: trunk/tests/run-tests.py
==============================================================================
--- (empty file)
+++ trunk/tests/run-tests.py Fri Oct 17 21:51:25 2008
@@ -0,0 +1,77 @@
+#!/usr/bin/python
+
+#######################
+# Kram Test Framework #
+# Seed Unit Tests #
+#######################
+
+# So! Ideas...
+# We obviously need not just 'pass' tests, but also 'fail' tests, and to make
+# sure that they throw the correct exceptions. Something a bit more flexible
+# than a Bash script that just checks to make sure all the .jses exit properly.
+
+# I'm thinking of a comment directly after the shebang in the tests that gives
+# expected output (on one line) and expected exit value... scripts get run
+# by Python, which checks the comment and the exit value, runs the tests,
+# and records run information (rev #, uname, test times, etc.) in an
+# easily-emailed format (and append to a log file, for safekeeping).
+
+# Test script could also have an option to perform timing/memory-use tests,
+# automatically running numerous times and averaging, etc... (find a way around
+# launching overhead... reimplement main.c here?), and recording to a running
+# log so we can keep track of performance/mem-use regressions, etc...
+
+# TODO: test return value
+
+import os
+import re
+import sys
+
+passed = []
+failed = []
+
+for f in os.listdir("."):
+ if f.endswith(".js"):
+ rfile = open(f, "r")
+ test_code = rfile.readlines()
+ test_in = test_code[2].replace("// STDIN:","").rstrip().replace("\\n","\n");
+ test_out = test_code[3].replace("// STDOUT:","").rstrip().replace("\\n","\n");
+ test_err = test_code[4].replace("// STDERR:","").rstrip().replace("\\n","\n");
+
+ (n,out,err) = os.popen3("./" + f)
+
+ if(test_in != ""):
+ n.write(test_in + "\004")
+ n.close()
+
+ run_out = "".join(out.readlines()).rstrip()
+ run_err = "".join(err.readlines()).rstrip()
+
+ if not re.match(test_out,run_out):
+ failed.append([f,test_out,run_out,0])
+ sys.stdout.write("x")
+ elif not re.match(test_err,run_err):
+ failed.append([f,test_err,run_err,1])
+ sys.stdout.write("x")
+ else:
+ passed.append([f,test_out,run_out])
+ sys.stdout.write(".")
+ sys.stdout.flush()
+print
+
+revnof = os.popen("bzr revno");
+revno = "".join(revnof.readlines()).rstrip()
+
+print "libseed test run (rev. %s):" % revno
+print "%d tests passed; %d tests failed.\n" % (len(passed), len(failed))
+for fail in failed:
+ print "-------------FAILED TEST---------------"
+ print "Name: %s" % fail[0]
+ if fail[3]:
+ print " Expected Error:\t" + fail[1]
+ print " Actual Error:\t" + fail[2]
+ else:
+ print " Expected Output:\t" + fail[1]
+ print " Actual Output:\t" + fail[2]
+if len(failed):
+ print "---------------------------------------"
Added: trunk/tests/signal.js
==============================================================================
--- (empty file)
+++ trunk/tests/signal.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,18 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:Window mapped.
+// STDERR:
+
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+
+function mapped(window)
+{
+ Seed.print("Window mapped.");
+}
+
+w = new Gtk.Window();
+w.signal_map.connect(mapped);
+
+w.show_all();
Added: trunk/tests/value-exception.js
==============================================================================
--- (empty file)
+++ trunk/tests/value-exception.js Fri Oct 17 21:51:25 2008
@@ -0,0 +1,11 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:
+// STDERR:\n\*\* \(seed:[0-9]*\): CRITICAL \*\*: InvalidPropertyValue. Not able to set property opacity on object of type GtkWindow. Expected type: gdouble.
+
+Seed.import_namespace("GLib");
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+window = new Gtk.Window();
+window.opacity = "Hello World!";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]