You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(153) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(48) |
Feb
(46) |
Mar
(12) |
Apr
(4) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
(263) |
Mar
(235) |
Apr
(66) |
May
(42) |
Jun
(270) |
Jul
(65) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Markus R. <rol...@us...> - 2005-12-19 20:09:24
|
Update of /cvsroot/simspark/simspark/spark In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5413 Added Files: .cvsignore AUTHORS COPYING ChangeLog INSTALL Makefile.am NEWS README RELEASE THANKS TODO acinclude.m4 bootstrap configure.ac rel.awk Log Message: --- NEW FILE: .cvsignore --- Makefile Makefile.in aclocal.m4 autom4te.cache config.h config.h.in config.log config.status configure libtool stamp-h1 --- NEW FILE: COPYING --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE 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. 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 convey 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This 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 Library General Public License instead of this License. --- NEW FILE: ChangeLog --- --- NEW FILE: bootstrap --- #! /bin/sh force="" if test "$1" = "--force"; then force="$1"; fi aclocal libtoolize --copy $force aclocal autoheader $force autoconf $force automake --add-missing --copy $force --- NEW FILE: rel.awk --- BEGIN { if( change <= 0 ) exit -1; } /AM_INIT_AUTOMAKE/ { if( $2 ~ /\)$/ ) { ver = substr( $2, 0, length( $2 ) - 1 ); tail=1; } else ver = $2; n = split( ver, ver_array, "." ); while( change > n ) ver_array[ ++n ] = 0; ver_array[ change ]++; while( ++change <= n ) ver_array[ change ] = 0; $2 = ""; for( i = 1; i < n; ++i ) $2 = $2 ver_array[ i ] "."; $2 = $2 ver_array[ n ]; if( tail ) $2 = $2 ")"; } { print $0; } --- NEW FILE: acinclude.m4 --- # RCSS_PATH_RUBY # Substitutes: @RUBY@ ruby command # @RUBY_CPPFLAGS@ additional CPPFLAGS to use to get ruby.h # @RUBY_LDFLAGS@ additional LDFLAGS to use when linking libruby # @RUBY_LDADD@ additional libraries libruby depends on # # original version from the Swig list (major changes by me /oliver) # at http://mailman.cs.uchicago.edu/mailman/listinfo/swig #----------------------------------------------------------------------------- AC_DEFUN([RCSS_PATH_RUBY], [ # --with-ruby=PATH AC_ARG_WITH(ruby, AC_HELP_STRING([--with-ruby=PATH], [path to Ruby interpreter (default is ruby)]), [ruby="$withval"], [ruby="ruby"] ) AC_PATH_PROGS(RUBY,[$ruby ruby],no) # Test ruby interpreter if test $ruby = no; then AC_MSG_ERROR(Could not find Ruby Interpreter. Please use --with-ruby option.) fi # check ruby headers AC_CHECK_HEADER(ruby.h, [RUBY_CPPFLAGS=''], [unset ac_cv_header_ruby_h ruby_tmp=$CPPFLAGS ruby_includedir=`$RUBY -rrbconfig -e "print Config::CONFIG[['archdir']]"` AC_MSG_NOTICE(trying again in $ruby_includedir) RUBY_CPPFLAGS="-I$ruby_includedir" CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS" AC_CHECK_HEADER(ruby.h, [], [AC_MSG_ERROR(check your ruby installation)] ) CPPFLAGS=$ruby_tmp ] ) # set ruby ldflags AC_MSG_CHECKING(ruby library directory) ruby_libdir=`$RUBY -rrbconfig -e "print Config::CONFIG[['archdir']]"` AC_MSG_RESULT($ruby_libdir) RUBY_LDFLAGS="-L$ruby_libdir -lruby" # set ruby additional libraries AC_MSG_CHECKING(libraries ruby depends on) RUBY_LDADD=`$RUBY -rrbconfig -e "print Config::CONFIG[['LIBS']]"` AC_MSG_RESULT($RUBY_LDADD) AC_MSG_CHECKING([for libruby]) rcss_tmp="$LDFLAGS" LDFLAGS="$LDFLAGS $RUBY_LDFLAGS" AC_LINK_IFELSE([int main() { return 0; }], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_MSG_ERROR([libruby cannot be found. If you compile ruby on your own, make sure to configure ruby with '--enable-shared' to create the library.])]) LDFLAGS="$rcss_tmp" # Substitute Makefile Vars. AC_SUBST(RUBY) AC_SUBST(RUBY_CPPFLAGS) AC_SUBST(RUBY_LDFLAGS) AC_SUBST(RUBY_LDADD) ]) # RCSS_PATH_RUBY AC_DEFUN([RCSS_CHECK_RUBY_VERSION], [ AC_MSG_CHECKING([ruby version]) AC_REQUIRE([RCSS_PATH_RUBY]) MAJOR="$1" RUBY_MAJOR=`$RUBY -rrbconfig -e "print Config::CONFIG[['MAJOR']]"` test -z "$1" && MAJOR="$RUBY_MAJOR" MINOR="$2" RUBY_MINOR=`$RUBY -rrbconfig -e "print Config::CONFIG[['MINOR']]"` test -z "$2" && MINOR="$RUBY_MINOR" TEENY="$3" RUBY_TEENY=`$RUBY -rrbconfig -e "print Config::CONFIG[['TEENY']]"` test -z "$3" && TEENY="$RUBY_TEENY" AC_MSG_RESULT($RUBY_MAJOR.$RUBY_MINOR.$RUBY_TEENY) if test \( "$RUBY_MAJOR" -lt "$MAJOR" \) -o \ \( "$RUBY_MAJOR" -eq "$MAJOR" -a "$RUBY_MINOR" -lt "$MINOR" \) -o \ \( "$RUBY_MAJOR" -eq "$MAJOR" -a "$RUBY_MINOR" -eq "$MINOR" -a "$RUBY_TEENY" -lt "$TEENY" \); then AC_MSG_ERROR([Your ruby is too old. Use at least ruby-$MAJOR.$MINOR.$TEENY]) fi ]) # RCSS_CHECK_RUBY_VERSION # RCSS_CHECK_RCSSBASE #----------------------------------------------------------------------------- AC_DEFUN([RCSS_CHECK_RCSSBASE], [ AC_ARG_VAR(RCSSBASE, [location of rcssbase installation]) if test $RCSSBASE; then CPPFLAGS="$CPPFLAGS -I$RCSSBASE/include" LDFLAGS="$LDFLAGS -L$RCSSBASE/lib" fi AC_CHECK_HEADERS([rcssbase/net/udpsocket.hpp],,[ AC_MSG_ERROR([The rcssbase headers (e.g. rcssbase/net/udpsocket.hpp) cannot be found. Please specify the location of the rcssbase installation, by using the RCSSBASE environment variable (e.g. ./configure RCSSBASE=$HOME/rcssbase)])]) AC_MSG_CHECKING([for the rcssnet library]) rcss_tmp="$LDFLAGS" LDFLAGS="$LDFLAGS -lrcssnet" AC_LINK_IFELSE([int main() { return 0; }], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_MSG_ERROR([The rcssnet library (librcssnet.a or librcssnet.so) cannot be found. Please specify the location of the rcssbase installation using the RCSSBASE environment variable (e.g. ./configure RCSSBASE=$HOME/rcssbase)])]) LDFLAGS="$rcss_tmp" ]) # RCSS_CHECK_RCSSBASE # RCSS_CHECK_ODE #----------------------------------------------------------------------------- AC_DEFUN([RCSS_CHECK_ODE], [ AC_ARG_VAR(ODE, [location of ode installation]) if test $ODE; then CPPFLAGS="$CPPFLAGS -I$ODE/include" LDFLAGS="$LDFLAGS -L$ODE/lib" fi AC_CHECK_HEADERS([ode/ode.h],,[ AC_MSG_ERROR([The ode headers (e.g. ode/ode.h) cannot be found. Please specify the location of the ode installation, by using the ODE environment variable (e.g. ./configure ODE=$HOME/ode-0.03)])]) AC_MSG_CHECKING([for the ODE library]) rcss_tmp="$LDFLAGS" LDFLAGS="$LDFLAGS -lode" AC_LINK_IFELSE([int main() { return 0; }], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_MSG_ERROR([The ode library (libode.a or libode.so) cannot be found. Please specify the location of the ode installation using the ODE environment variable (e.g. ./configure ODE=$HOME/ode-0.03)])]) LDFLAGS="$rcss_tmp" ]) # RCSS_CHECK_ODE # RCSS_PATH_FREETYPE # Substitutes: @FREETYPE_CPPFLAGS@ # @FREETYPE_LIBADD@ # #----------------------------------------------------------------------------- AC_DEFUN([RCSS_PATH_FREETYPE], [ # --with-freetype=PATH AC_ARG_WITH(freetype, AC_HELP_STRING([--with-freetype=PATH], [path to freetype-config (default is freetype-config)]), [freetype="$withval"], [freetype="freetype-config"] ) RCSS_KEROSIN_IF_ELSE([ AC_PATH_PROGS(FREETYPE,[$freetype freetype-config],no) if test $FREETYPE = "no"; then RCSS_BUILD_KEROSIN_ERROR([need freetype2 devel library to compile libkerosin]) else rcss_freetype_cppflags=`$FREETYPE --cflags` rcss_freetype_libadd=`$FREETYPE --libtool` AC_MSG_CHECKING([freetype include flags]) AC_MSG_RESULT([$rcss_freetype_cppflags]) AC_SUBST(FREETYPE_CPPFLAGS, [$rcss_freetype_cppflags]) AC_MSG_CHECKING([freetype libtool file]) AC_MSG_RESULT([$rcss_freetype_libadd]) AC_SUBST(FREETYPE_LIBADD, [$rcss_freetype_libadd]) fi ]) ]) # RCSS_PATH_FREETYPE # RCSS_CHECK_GL # if rcss_build_kerosin is (still) set to 'yes', check for the GL # headers and libraries. # Substitutes: @GLDIR@ with the directory where the gl headers can be found #----------------------------------------------------------------------------- AC_DEFUN([RCSS_CHECK_GL], [ RCSS_KEROSIN_IF_ELSE([ # check for OpenGL location and used extensions AC_CHECK_HEADERS([GL/gl.h GL/glut.h],, RCSS_BUILD_KEROSIN_ERROR([not all required OpenGL headers could not be found. Please specify the location of the OpenGL header directory using the CPPFLAGS environment variable])) RCSS_KEROSIN_IF_ELSE([ AC_CHECK_HEADERS([GL/glx.h], AC_SUBST([GLTARGET], [x]), AC_CHECK_HEADERS([GL/wglext.h], AC_SUBST([GLTARGET], [win32]), RCSS_BUILD_KEROSIN_ERROR([could not find X nor MS Windows GL extensions]), [#include <GL/gl.h>]), [#include <GL/gl.h>]) # subst'ing the directory where the prepocessor finds gl.h GLDIR=`echo "#include <GL/gl.h>" | /lib/cpp -M | awk '{ print @S|@2 }'` GLDIR=`dirname "$GLDIR"` AC_SUBST([GLDIR], [$GLDIR]) # checking if linking against libGL succeeds RCSS_KEROSIN_IF_ELSE([ AC_MSG_CHECKING([if linking against libGL succeeds]) rcss_tmp="$LDFLAGS" LDFLAGS="$LDFLAGS -lGL" AC_LINK_IFELSE([#include <GL/gl.h> int main() { glColor3f(0,0,0); }], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) RCSS_BUILD_KEROSIN_ERROR([to build libkerosin, set LDFLAGS so that libGL can be found])]) LDFLAGS="$rcss_tmp" AC_MSG_CHECKING([if linking against libglut succeeds]) LDFLAGS="$LDFLAGS -lGL -lGLU -lglut" AC_LINK_IFELSE([#include <GL/glut.h> int main() { glutMainLoop(); }], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) RCSS_BUILD_KEROSIN_ERROR([to build libkerosin, set LDFLAGS so that libglut or can be found]) ]) LDFLAGS="$rcss_tmp" ]) ]) ]) ]) # RCSS_CHECK_GL # RCSS_CHECK_DEVIL # if rcss_build_kerosin is (still) set to 'yes', check for the DEVIL # headers and libraries. # If DEVIL headers or libraries can not be found, building kerosin will # be disabled. #----------------------------------------------------------------------------- AC_DEFUN([RCSS_CHECK_DEVIL], [ AC_ARG_VAR(DEVIL, [location of DevIL installation]) if test $DEVIL; then CPPFLAGS="$CPPFLAGS -I$DEVIL/include" LDFLAGS="$LDFLAGS -L$DEVIL/lib" fi RCSS_KEROSIN_IF_ELSE([ AC_CHECK_HEADER([IL/il.h],, RCSS_BUILD_KEROSIN_ERROR([DevIL headers not found. Please set CPPFLAGS appropriately or you can specify the location of the DevIL installation using the DEVIL environment variable (e.g. ./configure DEVIL=$HOME/DevIL)])) ]) RCSS_KEROSIN_IF_ELSE([ rcss_tmp="$LDFLAGS" LDFLAGS="$LDFLAGS -lIL" AC_LINK_IFELSE([#include <IL/il.h> #include <stdarg.h> /* _vsnprintf may be undefined (and it is needed by libIL) */ extern "C" int _vsnprintf(char *str, size_t size, const char *format, va_list ap) { return 0;} int main() { ilInit(); return 0; }],, RCSS_BUILD_KEROSIN_ERROR([The DevIL library (libIL.a or libIL.so) cannot be found. Please set LDFLAGS appropriately or you can specify the location of the DevIL installation using the DEVIL environment variable (e.g. ./configure DEVIL=$HOME/DevIL)])) LDFLAGS="$rcss_tmp" ]) ]) # RCSS_CHECK_DEVIL # RCSS_CHECK_SDL # if rcss_build_kerosin is (still) set to 'yes', check for the SDL # headers and libraries. # If SDL headers or libraries can not be found, building kerosin will be # disabled. #----------------------------------------------------------------------------- AC_DEFUN([RCSS_CHECK_SDL], [ AC_ARG_VAR(SDL, [location of SDL installation]) if test $SDL; then CPPFLAGS="$CPPFLAGS -I$SDL/include" LDFLAGS="$LDFLAGS -L$SDL/lib" fi RCSS_KEROSIN_IF_ELSE([ AC_CHECK_HEADER([SDL/SDL.h],, RCSS_BUILD_KEROSIN_ERROR([Simple DirectMedia Layer (SDL) headers not found. Please set CPPFLAGS appropriately or you can specify the location of the SDL installation using the SDL environment variable (e.g. ./configure SDL=$HOME/SDL)])) ]) RCSS_KEROSIN_IF_ELSE([ rcss_tmp="$LDFLAGS" LDFLAGS="$LDFLAGS -lSDL" AC_LINK_IFELSE([#include <SDL/SDL.h> int main() { return SDL_Init(0); }],, RCSS_BUILD_KEROSIN_ERROR([The SDL library (libSDL.a or libSDL.so) cannot be found. Please set LDFLAGS appropriately or you can specify the location of the SDL installation using the SDL environment variable (e.g. ./configure SDL=$HOME/SDL)])) LDFLAGS="$rcss_tmp" ]) ]) # RCSS_CHECK_SDL # RCSS_CHECK_SLANG #----------------------------------------------------------------------------- AC_DEFUN([RCSS_CHECK_SLANG], [ RCSS_KEROSIN_IF_ELSE([ rcss_tmp="$LDFLAGS" LDFLAGS="$LDFLAGS -lslang" AC_LINK_IFELSE([int main() { return 0; }],, RCSS_BUILD_KEROSIN_ERROR([The S-Lang library (libslang.a or libslang.so) cannot be found. Please set LDFLAGS appropriately.])) LDFLAGS="$rcss_tmp" ]) ]) # RCSS_CHECK_SLANG # RCSS_BUILD_SOUNDSYSTEMFMOD # defines a conditional BUILD_SOUNDSYSTEMFMOD if the required header # and library exists. Up to date, there is no version check for the # fmod library. #----------------------------------------------------------------------------- AC_DEFUN([RCSS_BUILD_SOUNDSYSTEMFMOD], [ AC_CHECK_HEADER(fmod/fmod.h, [rcss_soundsystemfmod="true"], [rcss_soundsystemfmod="false" && AC_MSG_WARN([FMOD Sound module will not be built])]) if test $rcss_soundsystemfmod = "true"; then AC_MSG_CHECKING([if linking against libfmod is succeeds]) rcss_tmp="$LDFLAGS" LDFLAGS="$LDFLAGS -lfmod" AC_LINK_IFELSE([#include <fmod/fmod.h> int main() { return FSOUND_GetVolume(0); }], [rcss_soundsystemfmod="true" && AC_MSG_RESULT([yes])], [rcss_soundsystemfmod="false" && AC_MSG_RESULT([no]) && AC_MSG_WARN([there should be a link in one of your libdirs from libfmod.so to libfmod-X.YZ.so. If the link exists, try setting the LDFLAGS environment variable appropriately.])]) LDFLAGS="$rcss_tmp" fi AM_CONDITIONAL(BUILD_SOUNDSYSTEMFMOD, test x$rcss_soundsystemfmod = xtrue) ]) # RCSS_BUILD_SOUNDSYSTEMFMOD # RCSS_BUILD_KEROSIN_INTERNAL # defines preprocessor symbol HAVE_KEROSIN_H if kerosin can be build # set automake conditional BUILD_KEROSIN to true if kerosin can be build #----------------------------------------------------------------------------- AC_DEFUN([RCSS_BUILD_KEROSIN_INTERNAL], [ RCSS_CHECK_GL RCSS_PATH_FREETYPE RCSS_CHECK_SDL RCSS_CHECK_DEVIL RCSS_CHECK_SLANG AC_MSG_CHECKING([if libkerosin will be build]) AC_MSG_RESULT([$rcss_build_kerosin]) RCSS_KEROSIN_IF_ELSE([AC_DEFINE(HAVE_KEROSIN_H, 1, [Define to 1 if using the kerosin header])],[ AC_MSG_ERROR([libkerosin cannot be build without all required libraries.]) AC_MSG_ERROR([the list of libraries required for kerosin can be found in the documentation]) ]) ]) # RCSS_BUILD_KEROSIN_INTERNAL # RCSS_BUILD_KEROSIN # set rcss_build_kerosin to 'yes' #----------------------------------------------------------------------------- AC_DEFUN([RCSS_BUILD_KEROSIN], [ # --enable-kerosin AC_ARG_ENABLE(kerosin, AC_HELP_STRING([--enable-kerosin=@<:@yes|no@:>@], [whether to compile libkerosin (default is no)]), [rcss_build_kerosin="$enableval"], [rcss_build_kerosin=no] ) if test "$rcss_build_kerosin" = yes; then AC_MSG_NOTICE([Checking prerequisites for kerosin...]) AC_PATH_X RCSS_BUILD_KEROSIN_INTERNAL fi AM_CONDITIONAL(BUILD_KEROSIN, test x$rcss_build_kerosin = xyes) if test "$rcss_build_kerosin" = no; then AC_MSG_NOTICE([libkerosin will not be build...]) AC_MSG_NOTICE([...you can enable it using the --enable-kerosin flag]) fi ]) # RCSS_BUILD_KEROSIN # RCSS_BUILD_KEROSIN_ERROR # print a warning and set rcss_build_kerosin to 'no' #----------------------------------------------------------------------------- AC_DEFUN([RCSS_BUILD_KEROSIN_ERROR], [ AC_MSG_WARN($1) rcss_build_kerosin=no ]) # RCSS_BUILD_KEROSIN_ERROR # RCSS_KEROSIN_IF_ELSE # if rcss_build_kerosin is 'yes', execute the if part (first parameter) # if rcss_build_kerosin is unequal to 'yes', execute the else part (2nd) #----------------------------------------------------------------------------- AC_DEFUN([RCSS_KEROSIN_IF_ELSE], [ if test "$rcss_build_kerosin" = yes; then : $1 else : $2 fi ]) # RCSS_KEROSIN_IF_ELSE # AC_LIB_SPADES([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------- # Checks for the spades library AC_DEFUN([AC_LIB_SPADES], [AS_VAR_PUSHDEF([ac_lib_spades], [ac_cv_lib_spades])dnl AC_CACHE_CHECK(whether the spades library is available, ac_cv_lib_spades, [AC_LANG_PUSH(C++) OLD_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -lspades" AC_LINK_IFELSE([@%:@include <spades/enginemain.hpp> int main() { spades::SimulationEngineMain( 0, NULL, NULL ); return 0; }], [AS_VAR_SET(ac_lib_spades, yes)], [AS_VAR_SET(ac_lib_spades, no)]) LDFLAGS="$OLD_LDFLAGS" AC_LANG_POP(C++) ]) AS_IF([test AS_VAR_GET(ac_lib_spades) = yes], [$1], [$2]) AS_VAR_POPDEF([ac_lib_spades])dnl ])# AC_LIB_SPADES # RCSS_LIBRARY_VERSION_INFO # define two variables for the library versions # --------------------------------------------------------- AC_DEFUN([RCSS_LIBRARY_VERSION_INFO], [ $1=$3 AC_SUBST([$1]) $2=`echo $3 | tr : .` AC_SUBST([$2]) ]) # RCSS_LIBRARY_VERSION_INFO # RCSS_BOOST_REGEX([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------- # Checks for the spades library AC_DEFUN([RCSS_BOOST_REGEX], [AS_VAR_PUSHDEF([rcss_boost_regex], [rcss_cv_boost_regex])dnl AC_CACHE_CHECK(if linking against boost_regex succeeds, rcss_cv_boost_regex, [AC_LANG_PUSH(C++) OLD_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -lboost_regex" AC_LINK_IFELSE([int main() { return 0; }], [AS_VAR_SET(rcss_boost_regex, yes)], [AS_VAR_SET(rcss_boost_regex, no)]) LDFLAGS="$OLD_LDFLAGS" AC_LANG_POP(C++) ]) AS_IF([test AS_VAR_GET(rcss_boost_regex) = yes], [$1], [$2]) AS_VAR_POPDEF([rcss_boost_regex])dnl ])# RCSS_BOOST_REGEX --- NEW FILE: configure.ac --- # Process this file with autoconf to produce a configure script. AC_INIT([simspark], 0.1, [sse...@li...]) AC_CONFIG_SRCDIR([salt/salt.h]) AC_CONFIG_HEADER([config.h]) AC_CONFIG_AUX_DIR([config.aux]) AM_INIT_AUTOMAKE([gnu subdir-objects 1.7]) AC_LANG([C++]) AM_ENABLE_SHARED(yes) AM_ENABLE_STATIC(no) ## Here are the version numbers of our libraries. They should be updated (only) ## immediately before a release of the package. See libtool manual for details. RCSS_LIBRARY_VERSION_INFO(salt_version_info,salt_version,'3:0:3') RCSS_LIBRARY_VERSION_INFO(zeitgeist_version_info,zeitgeist_version,'3:1:0') RCSS_LIBRARY_VERSION_INFO(oxygen_version_info,oxygen_version,'3:0:1') RCSS_LIBRARY_VERSION_INFO(kerosin_version_info,kerosin_version,'1:0:0') RCSS_LIBRARY_VERSION_INFO(spark_version_info,spark_version,'0:0:0') RCSS_LIBRARY_VERSION_INFO(rcssmonitor3D_version_info,rcssmonitor3D_version,'2:0:1') RCSS_LIBRARY_VERSION_INFO(rcssnet3D_version_info,rcssnet3D_version,'0:0:0') rcss_prefix=\"$prefix\" test "$rcss_prefix" = \"NONE\" && rcss_prefix=\"$ac_default_prefix\" AC_DEFINE_UNQUOTED(PREFIX, $rcss_prefix, [Define the install prefix. Needed by the libraries to check for ruby scripts.]) # Checks for programs. AC_PROG_CXX AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL AC_PROG_AWK AC_CHECK_PROG([DOXYGEN], [doxygen], [yes], [no]) AC_CHECK_PROG([PDFLATEX], [pdflatex]) AM_CONDITIONAL(DOXYGEN, test x$DOXYGEN = xyes ) AM_CONDITIONAL(COND_PDFLATEX, test x$PDFLATEX != x) AC_CHECK_PROG([HAVE_DOT], [dot], [YES], [NO]) AC_PATH_PROG([PERL], [perl], [perl]) # Checks for libraries. TMP_LIBS=$LIBS AC_CHECK_LIB(dl, dlopen, [AC_SUBST(SALT_LIBADD, [-ldl])], [AC_CHECK_FUNC(dlopen, [], [AC_MSG_ERROR([cannot find required library libdl or dlopen() function.])] )]) LIBS=$TMP_LIBS # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([poll.h]) AC_CHECK_HEADERS([arpa/nameser.h]) AC_CHECK_HEADERS([resolv.h netdb.h]) AC_CHECK_HEADERS([float.h limits.h malloc.h memory.h stdlib.h string.h]) AC_CHECK_HEADER([boost/version.hpp],, AC_MSG_ERROR([boost library not found. Please specify the location of the boost header directory using the CPPFLAGS environment variable])) AC_CHECK_HEADERS([hash_map],, AC_MSG_NOTICE(['hash_map' will be substituted by 'map'. If you need hash_map install stlport])) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T AC_CHECK_TYPES([socklen_t], [], [], [ #include <sys/types.h> #include <sys/socket.h> ]) # Checks for library functions. AC_FUNC_ALLOCA # the FUNC_MEMCMP macro has a bug when used with c++ # (see http://mail.gnu.org/archive/html/autoconf-patches/2003-05/msg00042.html) # the workaround is to switch back to C for the test AC_LANG([C]) AC_FUNC_MEMCMP AC_LANG([C++]) AC_FUNC_SETVBUF_REVERSED AC_FUNC_VPRINTF AC_CONFIG_LIBOBJ_DIR(./utility/libobj/) AC_REPLACE_FUNCS([_vsnprintf]) AC_CHECK_FUNCS([atexit floor gethostname inet_ntoa memset pow socket sqrt strchr strrchr strstr strupr]) AC_SUBST(NET_LIBS) AC_CHECK_LIB(socket, socket, [NET_LIBS="-lsocket"]) AC_CHECK_LIB(nsl, gethostbyname, [NET_LIBS="$NET_LIBS -lnsl"]) AC_CHECK_LIB(posix4, sched_yield, [NET_LIBS="$NET_LIBS -lposix4"]) AC_CHECK_LIB(resolv, hstrerror, [NET_LIBS="$NET_LIBS -lresolv"]) RCSS_BOOST_REGEX([rcss_have_boost_regex=yes],[rcss_have_boost_regex=no]) if test "$rcss_have_boost_regex" = no; then AC_MSG_WARN([the ZIP filesystem plugin cannot be build]) fi AM_CONDITIONAL(HAVE_BOOST_REGEX, test $rcss_have_boost_regex = yes) ## checks for system services # check if we want to build the debug version AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug], [Turn on debugging (default is YES)]), [case "${enableval}" in yes) debug=true && AC_DEFINE(RCSS_DEBUG, 1, [Define to 1 if we are building a debug version]) ;; no) debug=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; esac],[debug=true && AC_DEFINE(RCSS_DEBUG, 1, [Define to 1 if we are building a debug version]) ]) AC_SUBST(debug, [$debug]) AM_CONDITIONAL(DEBUG, test x$debug = xtrue) # This test is required here because of the soccer monitor. # It can be dropped as soon as the monitor uses libkerosin. rcss_build_kerosin=yes RCSS_CHECK_GL if test "$rcss_build_kerosin" = no; then AC_MSG_ERROR([need GL stuff to build monitor]) fi RCSS_BUILD_KEROSIN RCSS_BUILD_SOUNDSYSTEMFMOD RCSS_PATH_RUBY RCSS_CHECK_RUBY_VERSION(1,8,0) RCSS_CHECK_ODE WX_CPPFLAGS="`wx-config --cppflags`" WX_LDFLAGS="`wx-config --libs` `wx-config --gl-libs`" AC_SUBST(WX_CPPFLAGS) AC_SUBST(WX_LDFLAGS) AC_ARG_VAR(SPADES, [prefix of SPADES installation]) AC_ARG_WITH([spades], [AC_HELP_STRING([--with-spades], [whether to support SPADES-SIM (default is yes)])], [rcss_with_spades=$withval], [rcss_with_spades=yes]) if test "$rcss_with_spades" = yes; then if test "$SPADES"; then if test -z "$PATH"; then PATH="$SPADES/bin" else PATH="$PATH:$SPADES/bin" fi if test -z "$LDFLAGS"; then LDFLAGS="-L$SPADES/lib" else LDFLAGS="$LDFLAGS -L$SPADES/lib" fi if test -z "$CPPFLAGS"; then CPPFLAGS="-I$SPADES/include" else CPPFLAGS="$CPPFLAGS -I$SPADES/include" fi fi AC_LIB_SPADES([rcss_build_spades=yes AC_DEFINE([HAVE_SPADES_HEADERS], 1, [Define to 1 if you have the SPADES header files])], [AC_MSG_ERROR([the SPADES library (http://spades-sim.sourceforge.net) cannot be found. Please specify the prefix used when installing SPADES with the SPADES enviroment variable.])]) else rcss_build_spades=no AC_MSG_NOTICE([SpadesServer will not be build]) fi AM_CONDITIONAL(BUILD_SPADES_MODULES, test $rcss_build_spades = yes) # create Makefiles and other configuration files AC_CONFIG_FILES([Makefile \ utility/Makefile \ utility/glextgen/Makefile \ utility/glextgen/glextgen.rb \ utility/libobj/Makefile \ utility/sfsexp/Makefile \ utility/rcssnet/Makefile \ salt/Makefile \ salt/salt-config \ zeitgeist/Makefile \ zeitgeist/zeitgeist-config \ kerosin/Makefile \ kerosin/kerosin-config \ oxygen/Makefile \ oxygen/oxygen-config \ spark/Makefile ], [test -f salt/salt-config && chmod a+x salt/salt-config && \ test -f zeitgeist/zeitgeist-config && chmod a+x zeitgeist/zeitgeist-config && \ test -f oxygen/oxygen-config && chmod a+x oxygen/oxygen-config && \ test -f kerosin/kerosin-config && chmod a+x kerosin/kerosin-config && \ test -f app/simulator/rcsoccersim3D && chmod +x app/simulator/rcsoccersim3D]) AC_OUTPUT --- NEW FILE: Makefile.am --- ### utility subdir has to be made first SUBDIRS = utility salt zeitgeist oxygen kerosin spark pkginclude_HEADERS = \ config.h CLEANFILES = EXTRA_SRC_DISTS = EXTRA_BIN_DISTS = include $(top_srcdir)/config.aux/dist.am UPLOAD_BIN = UPLOAD_SRC = upload-gzip upload-bzip2 upload-zip UPLOAD_TARGETS = \ {gzip=>@PACKAGE@-@VERSION@.tar.gz} \ {bzip2=>@PACKAGE@-@VERSION@.tar.bz2} \ {zip=>@PACKAGE@-@VERSION@.zip} include $(top_srcdir)/config.aux/sf.am include $(top_srcdir)/config.aux/cvs.am --- NEW FILE: README --- --- NEW FILE: THANKS --- (This appears to be a binary file; contents omitted.) --- NEW FILE: INSTALL --- Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. (Caching is disabled by default to prevent problems with accidental use of stale cache files.) If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You only need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not support the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the `--target=TYPE' option to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc will cause the specified gcc to be used as the C compiler (unless it is overridden in the site shell script). `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. --- NEW FILE: AUTHORS --- (This appears to be a binary file; contents omitted.) --- NEW FILE: RELEASE --- --- NEW FILE: NEWS --- --- NEW FILE: TODO --- |
From: Markus R. <rol...@us...> - 2005-12-19 20:07:46
|
Update of /cvsroot/simspark/simspark/spark/kerosin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5237 Modified Files: Makefile.am Log Message: - fixed an -I include path Index: Makefile.am =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile.am 5 Dec 2005 21:38:22 -0000 1.1 --- Makefile.am 19 Dec 2005 20:07:35 -0000 1.2 *************** *** 32,36 **** endif ! AM_CPPFLAGS = -I${top_srcdir}/lib -I$(top_srcdir)/lib/kerosin/sceneserver/helper @FREETYPE_CPPFLAGS@ @RUBY_CPPFLAGS@ ## define include directory local to the pkgincludedir --- 32,36 ---- endif ! AM_CPPFLAGS = -I${top_srcdir} -I$(top_srcdir)/kerosin/sceneserver/helper @FREETYPE_CPPFLAGS@ @RUBY_CPPFLAGS@ ## define include directory local to the pkgincludedir |
From: Markus R. <rol...@us...> - 2005-12-19 19:52:49
|
Update of /cvsroot/simspark/simspark/spark/salt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2594 Added Files: .cvsignore salt-config.in Log Message: --- NEW FILE: salt-config.in --- #! /bin/sh prefix=@prefix@ exec_prefix=@exec_prefix@ usage() { cat <<EOF Usage: salt-config [OPTIONS] [LIBRARIES] Options: [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libdir] [--libs] [--libtool] [--cflags] EOF exit $1 } if test $# -eq 0 ; then usage 1 1>&2 fi while test $# -gt 0 ; do case "$1" in -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac case $1 in --prefix=*) prefix=$optarg local_prefix=yes ;; --prefix) echo_prefix=yes ;; --exec-prefix=*) exec_prefix=$optarg exec_prefix_set=yes local_prefix=yes ;; --exec-prefix) echo_exec_prefix=yes ;; --version) echo @salt_version@ exit 0 ;; --cflags) echo_cflags=yes ;; --libs) echo_libs=yes ;; --libtool) echo_libtool=yes ;; --libdir) echo_libdir=yes ;; *) usage 1 1>&2 ;; esac shift done if test "$local_prefix" = "yes" ; then if test "$exec_prefix_set" != "yes" ; then exec_prefix=$prefix fi fi if test "$echo_prefix" = "yes" ; then echo $prefix fi if test "$echo_exec_prefix" = "yes" ; then echo $exec_prefix fi if test "$echo_cflags" = "yes" ; then cflags="-I@includedir@/rcssserver3d" if test "@includedir@" != "/usr/include" ; then echo $cflags -I@includedir@ else echo $cflags fi fi if test "$echo_libs" = "yes" ; then if test "@debug@" = "true"; then libs="-lsalt_debug @SALT_LIBADD@" else libs="-lsalt @SALT_LIBADD@" fi echo -L@libdir@/rcssserver3d $libs fi if test "$echo_libtool" = "yes" ; then if test "@debug@" = "true"; then convlib="libsalt_debug.la" else convlib="libsalt.la" fi echo @libdir@/rcssserver3d/$convlib fi if test "$echo_libdir" = "yes" ; then echo @libdir@/rcssserver3d fi # EOF --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in salt-config |
From: Markus R. <rol...@us...> - 2005-12-19 19:52:34
|
Update of /cvsroot/simspark/simspark/spark/salt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2557 Modified Files: sharedlibrary.cpp Log Message: - fixed an #include Index: sharedlibrary.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/salt/sharedlibrary.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sharedlibrary.cpp 5 Dec 2005 20:56:00 -0000 1.1 --- sharedlibrary.cpp 19 Dec 2005 19:52:24 -0000 1.2 *************** *** 20,24 **** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! #include "../sharedlibrary.h" #include <dlfcn.h> #include <iostream> --- 20,24 ---- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! #include "sharedlibrary.h" #include <dlfcn.h> #include <iostream> |
From: Markus R. <rol...@us...> - 2005-12-19 19:13:45
|
Update of /cvsroot/simspark/simspark/spark/utility/glextgen/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24814/glextgen/script Added Files: glbackend.rb glextension.rb glextgen.rb glfrontend.rb glmunger.rb Log Message: - added spark utility library --- NEW FILE: glmunger.rb --- # GLMunger # # The munger does some processing on the extension hashes before they go to the # backend. # This fixes: # - adds GL_VERSION_1_4 if it's not there # - adds GL_VERSION_1_3 if it's not there # - adds GL_VERSION_1_2 if it's not there # - fix ARB_imaging (move most functions from GL_VERSION_1_2 to ARB_imaging) # See http://www.opengl.org/developers/documentation/OpenGL12.html for more explanation # - throws away extensions which are natively supported require 'script/glextension.rb' module GLExtGen class GLMunger attr_accessor :nativeSupport def initialize (newNativeSupport) @nativeSupport = newNativeSupport end def processGL (extensionHash) # fix GL_VERSION_1_4 if extensionHash["GL_VERSION_1_4"] == nil extensionHash["GL_VERSION_1_4"] = GLExtension.new("GL_VERSION_1_4") end # fix GL_VERSION_1_3 if extensionHash["GL_VERSION_1_3"] == nil extensionHash["GL_VERSION_1_3"] = GLExtension.new("GL_VERSION_1_3") end # fix GL_VERSION_1_2 if extensionHash["GL_VERSION_1_2"] == nil extensionHash["GL_VERSION_1_2"] = GLExtension.new("GL_VERSION_1_2") end # fix ARB_imaging gl12 = extensionHash["GL_VERSION_1_2"] arbImaging = extensionHash["GL_ARB_imaging"] if gl12 != nil && arbImaging != nil # we move all functions from gl12 to arbImaging arbImaging.functionList.concat(gl12.functionList) gl12.functionList.clear arbImaging.functionList.delete("glDrawRangeElements") arbImaging.functionList.delete("glTexImage3D") arbImaging.functionList.delete("glTexSubImage3D") arbImaging.functionList.delete("glCopyTexSubImage3D") gl12.functionList.push("glDrawRangeElements") gl12.functionList.push("glTexImage3D") gl12.functionList.push("glTexSubImage3D") gl12.functionList.push("glCopyTexSubImage3D") end if nativeSupport != nil nativeSupport.each { |extensionName| print "Processing " + extensionName + " -> " if extensionHash[extensionName] != nil if extensionName.index("VERSION") != nil print "Clearing Functions\n" # for a GL_VERSION definition, we just throw away the functions extensionHash[extensionName].functionList.clear else print "Removing\n" # throw away the extension, as it is double defined extensionHash.delete(extensionName) end else print "No Action\n" end } end end def processWGL (extensionHash) end def processGLX (extensionHash) end end end --- NEW FILE: glextension.rb --- # the GLExtension class is used just for convenience. It manages a list of # functions which are associated with a particular extension. # Note: Not all extension have functions!! module GLExtGen class GLExtension attr_accessor :functionList, :name def initialize (newName) @functionList = [] @name = newName end def addFunction (function) @functionList.push(function) @functionList.uniq end def removePrefix i = @name.index('_') if i == 2 # we have a GL_ extension, watch out for the pesky 3DFX extension if @name[3] != "3"[0] @name[3..-1] else @name[2..-1] end else # we have a WGL_ or GLX_ extension @name[0..(i-1)].downcase + @name[i..-1] end end end end --- NEW FILE: glbackend.rb --- # GLBackEnd -*- mode: ruby; ruby-indent-level: 4 -*- # # This backend generates CPP code require 'script/glextension.rb' require 'script/glfrontend.rb' module GLExtGen class GLBackEnd def initialize end # generate output def generate(frontEnd, glArray, wglArray, glXArray) print "\n" generateHFile(frontEnd, glArray, wglArray, glXArray) generateCPPFile(frontEnd, glArray, wglArray, glXArray) end def writeMembers(frontEnd, file, array) array.each { |item| file.print "#line 22 \"utility/glextgen/script/glbackend.rb\"\n" file.print " bool m", item[1].name, ";\n" } end def writeFunctions(frontEnd, file, array) array.each { |item| file.print "#line 29 \"utility/glextgen/script/glbackend.rb\"\n" file.print " bool Has_", item[1].name, "() const { return mExtensions.m", item[1].name, "; }\n" } end def writeExternFunctionPointers(frontEnd, file, array) array.each { |item| if item[1].functionList.size != 0 file.print "#line 37 \"utility/glextgen/script/glbackend.rb\"\n" file.print "#ifdef ", item[0], "\n" item[1].functionList.each { |function| file.print "extern ", frontEnd.procize(function), " ", function, ";\n" } file.print "#endif //", item[0], "\n\n" end } end def writeStructFunctionPointers(frontEnd, file, array) array.each { |item| if item[1].functionList.size != 0 file.print "#line 50 \"utility/glextgen/script/glbackend.rb\"\n" file.print "#ifdef ", item[0], "\n" item[1].functionList.each { |function| file.print " ", frontEnd.procize(function), " fun_", function, ";\n" } file.print "#endif //", item[0], "\n\n" end } end def writeStructExtensions(frontEnd, file, array) array.each { |item| file.print "#line 62 \"utility/glextgen/script/glbackend.rb\"\n" file.print " bool m", item[1].name, ";\n" } end def copyFile(destFile, srcName) File.open(srcName, "r") { |srcFile| srcFile.each_line { |srcLine| destFile.print srcLine } } end def winGuardOn "#if defined(_WIN32)\n" end def winGuardOff "#endif //_WIN32\n" end def generateHFile(frontEnd, glArray, wglArray, glXArray) print "Generating 'glextensionreg.h'\n" File.open("glextensionreg.h", "w") { |f| copyFile(f, "tocopy/header_begin.txt") f.print "#line 87 \"utility/glextgen/script/glbackend.rb\"\n" if $namespace != nil f.print "\nnamespace ", $namespace, " {\n" end ### here we write out a struct with all possible function pointers f.print "struct GLExtGenFunctionPointers\n{\n" writeStructFunctionPointers(frontEnd, f, glArray) f.print "#line 94 \"utility/glextgen/script/glbackend.rb\"\n" f.print " ", winGuardOn writeStructFunctionPointers(frontEnd, f, wglArray) f.print "#line 94 \"utility/glextgen/script/glbackend.rb\"\n" f.print " ", winGuardOff f.print "};\n" ### here we write out all possible extensions f.print "struct GLExtGenExtensions\n{\n" writeStructExtensions(frontEnd, f, glArray) f.print "#line 105 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOn writeStructExtensions(frontEnd, f, wglArray) f.print "#line 108 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOff f.print "};\n" f.print "\n" f.print "class GLExtensionReg\n" f.print "{\n" f.print "private:\n" f.print winGuardOn f.print " HDC mHDC;\n" f.print winGuardOff ### write out extension definitions for gl f.print " GLExtGenExtensions mExtensions;\n\n" f.print "public:\n" ### loop through all extensions writeFunctions(frontEnd, f, glArray) f.print "#line 119 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOn writeFunctions(frontEnd, f, wglArray) f.print "#line 123 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOff f.print " GLExtensionReg();\n" f.print " ~GLExtensionReg();\n" f.print " void Init(GLExtGenFunctionPointers *funPtr = 0, GLExtGenExtensions *ext = 0);\n" f.printf" bool QueryGLExtension(const char *name);\n" f.print winGuardOn f.printf" bool QueryWGLExtension(const char *name);\n" f.print " HDC GetHDC() const { return mHDC; }\n" f.print " void SetHDC(HDC hdc){ mHDC = hdc; }\n" f.print winGuardOff f.print "};\n\n" if $namespace != nil f.print "} // end ", $namespace, "\n\n" end ### write out extern function pointer definitions writeExternFunctionPointers(frontEnd, f, glArray) f.print "#line 141 \"utility/glextgen/script/glbackend.rb\"\n" ### write out extern function pointer definitions for wgl with define-guard f.print winGuardOn writeExternFunctionPointers(frontEnd, f, wglArray) f.print "#line 146 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOff copyFile(f, "tocopy/header_end.txt") } end def writeFunctionPointers(frontEnd, file, array) array.each { |item| if item[1].functionList.size != 0 file.print "#line 166 \"utility/glextgen/script/glbackend.rb\"\n" file.print "#ifdef ", item[0], "\n" item[1].functionList.each { |function| file.print "#line 169 \"utility/glextgen/script/glbackend.rb\"\n" file.print frontEnd.procize(function), " fun_", function, " = NULL;\n" } file.print "#endif //", item[0], "\n\n" end } end def writeInitMembers(frontEnd, file, array) array.each { |item| file.print "#line 178 \"utility/glextgen/script/glbackend.rb\"\n" file.print " mExtensions.m", item[0], " = false;\n" } end def writeLoadFunctions(frontEnd, file, array) array.each { |item| if item[0].index("extensions_string") == nil file.print "#line 186 \"utility/glextgen/script/glbackend.rb\"\n" file.print "static bool Load_", item[0], "(GLExtensionReg *reg)\n{\n" file.print "#ifdef ", item[0], "\n" # query for the extension, unless we are a GL_VERSION if item[0].index("VERSION") == nil if item[0].index("WGL") == nil file.print " if(reg->QueryGLExtension(\"", item[0], "\") == 0)\n" else if item[0].index("WGL_NV_vertex_array_range") == nil file.print " if(reg->QueryWGLExtension(\"", item[0], "\") == 0)\n" else file.print " if(reg->QueryGLExtension(\"GL_NV_vertex_array_range\") == 0)\n" end end file.print " return false;\n" end item[1].functionList.each { |function| file.print " GET_PROC_ADDRESS(", frontEnd.procize(function), ", fun_", function, ");\n" } file.print " return true;\n#endif //", item[0], "\n return false;\n}\n\n" end } end def writeCallLoadFunctions(frontEnd, file, array) array.each { |item| if item[0].index("extensions_string") == nil file.print "#line 213 \"utility/glextgen/script/glbackend.rb\"\n" if item[0].index("VERSION") != nil file.print " if (mExtensions.m", item[0], ") Load_", item[0], "(this);\n" else file.print " mExtensions.m", item[0], " = Load_", item[0], "(this);\n" end end } end def writeCopyFunctionPointers(frontEnd, file, array) array.each { |item| if item[1].functionList.size != 0 file.print "#line 226 \"utility/glextgen/script/glbackend.rb\"\n" file.print "#ifdef ", item[0], "\n" item[1].functionList.each { |function| file.print " funPtr->fun_", function, " = ", function, ";\n" } file.print "#endif //", item[0], "\n\n" end } end def generateCPPFile(frontEnd, glArray, wglArray, glXArray) print "Generating 'glextensionreg.cpp'\n" File.open("glextensionreg.cpp", "w") { |f| f.print "#line 241 \"utility/glextgen/script/glbackend.rb\"\n" f.print "#include \"glextensionreg.h\"\n"; if $namespace != nil f.print "using namespace ", $namespace, ";\n\n" end copyFile(f, "tocopy/cpp_begin.txt") ### create global function pointers writeFunctionPointers(frontEnd, f, glArray) f.print "#line 251 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOn writeFunctionPointers(frontEnd, f, wglArray) f.print "#line 254 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOff ### create load functions writeLoadFunctions(frontEnd, f, glArray) f.print "#line 259 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOn writeLoadFunctions(frontEnd, f, wglArray) f.print "#line 262 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOff + "\n" f.print "GLExtensionReg::GLExtensionReg()\n" f.print "{\n" f.print " memset(&mExtensions, 0, sizeof(GLExtGenExtensions));\n" f.print winGuardOn f.print " mHDC = NULL;\n" f.print winGuardOff f.print "}\n\n" f.print "GLExtensionReg::~GLExtensionReg()\n" f.print "{\n" f.print "}\n\n" f.print "void GLExtensionReg::Init(GLExtGenFunctionPointers *funPtr, GLExtGenExtensions *ext)\n" f.print "{\n" f.print " char *s = (char*) glGetString(GL_VERSION);\n\n" f.print " if (!s)\n" f.print " return;\n" f.print " s = strstr(s, \"1.\");\n" f.print " if (s != NULL)\n" f.print " {\n" f.print " if (s[2] >= '4')\n" f.print " mExtensions.mGL_VERSION_1_4 = true;\n" f.print " if (s[2] >= '3')\n" f.print " mExtensions.mGL_VERSION_1_3 = true;\n" f.print " if (s[2] >= '2')\n" f.print " mExtensions.mGL_VERSION_1_2 = true;\n" f.print " }\n\n" ### call load functions writeCallLoadFunctions(frontEnd, f, glArray) f.print "#line 296 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOn # here we do some special case processing for the wgl extension stuff f.print " wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) GetProcedure(\"wglGetExtensionsStringARB\");\n" f.print " wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) GetProcedure(\"wglGetExtensionsStringEXT\");\n" f.print " mExtensions.mWGL_ARB_extensions_string = wglGetExtensionsStringARB != NULL;\n" f.print " mExtensions.mWGL_EXT_extensions_string = wglGetExtensionsStringEXT != NULL;\n\n" writeCallLoadFunctions(frontEnd, f, wglArray) f.print "#line 304 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOff + "\n" f.print " if (ext)\n" f.print " memcpy(ext, &mExtensions, sizeof(GLExtGenExtensions));\n\n" f.print " if (funPtr)\n" f.print " {\n" writeCopyFunctionPointers(frontEnd, f, glArray) f.print "#line 313 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOn writeCopyFunctionPointers(frontEnd, f, wglArray) f.print "#line 316 \"utility/glextgen/script/glbackend.rb\"\n" f.print winGuardOff + "\n" f.print " }\n" f.print "}\n\n" } end end end --- NEW FILE: glfrontend.rb --- # GLFrontEnd -*- mode: ruby; ruby-indent-level: 4 -*- # # The front end is responsible for parsing the glext-header files require 'script/glextension.rb' module GLExtGen class GLFrontEnd attr_accessor :files def initialize @files = [] end # insert a tuple of scan arguments def addFile (fileName, extensionExp, functionExp, extensionHash) files.concat([[fileName, Regexp.new(extensionExp), Regexp.new(functionExp), extensionHash]]) end # scan the files registered def scanAll files.each { |item| print "Digesting '" + item[0] + "'...\n" scan(item[0], item[1], item[2], item[3]) } end def scan (fileName, extensionExp, functionExp, extensionHash) predefinedExp = Regexp.new("(.*)APIENTRY gl(.*) \\((.*)"); currentExtension = nil File.open(fileName).each { |line| if line =~ /^(\s*)(\/+)(.*) (gl\w+)/ print "removing misleading line ", line elsif md = predefinedExp.match(line) print "predefined fct gl", md[2], ":\n" elsif md = extensionExp.match(line) extensionName = md[2] currentExtension = extensionHash[extensionName] # if we don't know the extension, we have to add it if currentExtension == nil currentExtension = GLExtension.new(extensionName) extensionHash[extensionName] = currentExtension end # at this point currentExtension has a valid # GLExtension object ... always! elsif md = functionExp.match(line) # add the function name to the current Extension functionName = md[2] if currentExtension != nil currentExtension.addFunction(functionName) end end } end def procize (functionName) "PFN"+functionName.upcase+"PROC" end end end --- NEW FILE: glextgen.rb --- # GLExtGen: # # GLExtGen is a Ruby script which is capable of extracting OpenGL extension # data from header files and generate files for inclusion in OpenGL projects. # # GLExtGen works using a front-end and a back-end. The front-end is responsible # for analyzing the header files and building an intermediate representation. # The backend is then responsible for writing out that information in a way that # the target language can understand it. This design allows different backends # (say for PASCAL/Delphi) to be generated without having to rewrite lots of # code. Unfortunately, this separation is not as good as it could be. For example, # GLBackEnd is really not designed to be derived from. It should be more of an # interface, than an actual implementation. Nevertheless, it works quite well for # C++. If you want something else, I suggest just changing the code in GLBackEnd # perform error checking on config parameters begin if $target != "win32" && $target != "x" raise "Incorrect target specification" end if $path[-1] != '/'[0] && $path[-1] != '\\'[0] $path += '/' print "WARNING: No trailing slash in path ... adjusting\n" print "WARNING: New path is '", $path, "'\n" end require 'script/glextension.rb' require 'script/glfrontend.rb' require 'script/glmunger.rb' require 'script/glbackend.rb' # here we choose the classes we will use frontEndClass = GLExtGen::GLFrontEnd mungerClass = GLExtGen::GLMunger backEndClass = GLExtGen::GLBackEnd # we will use these hash tables to hold string => GLExtension pairs glExtensionHash = {} wglExtensionHash = {} glXExtensionHash = {} # create our front end frontEnd = frontEndClass.new # queue up some jobs to scan frontEnd.addFile($path+"glext.h", '(#ifndef) (GL_\w+)', '(.+) (gl\w+)', glExtensionHash) if $target == "win32" frontEnd.addFile($path+"wglext.h", '(#ifndef) (WGL_\w+)', '(.+) (wgl\w+)', wglExtensionHash) end if $target == "x" frontEnd.addFile($path+"glxext.h", '(#ifndef) (GLX_\w+)', '(.+) (glX\w+)', glXExtensionHash) end # let's work it frontEnd.scanAll # now, for the MS-Windows world, this is fine, but other OpenGL implementations (such as Mesa) # already define some of the symbols, as their GL/gl.h implements version 1.2 and not 1.1 (as # the Windows header). So, what we do is, we analyze the regular gl-header file. extensionExp = Regexp.new('(#ifndef) (GL_\w+)') versionExp = Regexp.new('(#define) (GL_VERSION\w+)') glNativeSupportArray = [] print "\nSearching for native extensions in '"+$path+"gl.h\n" File.open($path+"gl.h").each { |line| if md = extensionExp.match(line) glNativeSupportArray.push(md[2]); print "Found extension: " + md[2] + "\n" elsif md = versionExp.match(line) glNativeSupportArray.push(md[2]); print "Found version: " + md[2] + "\n" end } # before we pass this data to the backend we get a chance to transform it. munger = mungerClass.new(glNativeSupportArray) munger.processGL(glExtensionHash) munger.processWGL(wglExtensionHash) munger.processGLX(glXExtensionHash) # at this point the extension hashes contain valid data (let's cross our fingers) # now we have done all our processing and sort the extensions glExtensionArray = glExtensionHash.sort wglExtensionArray = wglExtensionHash.sort glXExtensionArray = glXExtensionHash.sort # create back end backEnd = backEndClass.new # glExtensionArray.each { |item| # item[1].functionList.each { |func| # print "debug output: " + func + "\n" # } # } # now, we just hand our extension arrays over to the backend # # Note: we are also passing in the frontEnd, because it should contain information # on how to 'procize' a function (generate function pointer typedef given a # function name) backEnd.generate(frontEnd, glExtensionArray, wglExtensionArray, glXExtensionArray) rescue StandardError => bang print "ERROR: ", bang, "\n" end |
From: Markus R. <rol...@us...> - 2005-12-19 19:13:45
|
Update of /cvsroot/simspark/simspark/spark/utility/libobj In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24814/libobj Added Files: Makefile.am _vsnprintf.c libobj.c memcmp.c Log Message: - added spark utility library --- NEW FILE: _vsnprintf.c --- /* -*- mode: c; c-basic-indent: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: _vsnprintf.c,v 1.1 2005/12/19 19:13:30 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* this is an implementation of _vsnprintf as used by windows. the devil library makes use of _vsnprintf, so linking against libIL fails if no _vsnprintf exists. */ #include <stdarg.h> #include <stdio.h> int _vsnprintf(char *str, size_t size, const char *format, va_list ap) { return vsnprintf(str, size, format, ap); } --- NEW FILE: Makefile.am --- noinst_LTLIBRARIES = liblibobject.la liblibobject_la_SOURCES = libobj.c liblibobject_la_LIBADD = @LTLIBOBJS@ --- NEW FILE: memcmp.c --- /* Copyright (C) 1991, 1993, 1995, 1997, 1998 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (te...@si...). NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug...@pr.... 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 2, 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #undef __ptr_t #if defined __cplusplus || (defined __STDC__ && __STDC__) # define __ptr_t void * #else /* Not C++ or ANSI C. */ # undef const # define const # define __ptr_t char * #endif /* C++ or ANSI C. */ #ifndef __P # if defined __GNUC__ || (defined __STDC__ && __STDC__) # define __P(args) args # else # define __P(args) () # endif /* GCC. */ #endif /* Not __P. */ #if defined HAVE_STRING_H || defined _LIBC # include <string.h> #endif #undef memcmp #ifdef _LIBC # include <memcopy.h> # include <endian.h> # if __BYTE_ORDER == __BIG_ENDIAN # define WORDS_BIGENDIAN # endif #else /* Not in the GNU C library. */ # include <sys/types.h> /* Type to use for aligned memory operations. This should normally be the biggest type supported by a single load and store. Must be an unsigned type. */ # define op_t unsigned long int # define OPSIZ (sizeof(op_t)) /* Threshold value for when to enter the unrolled loops. */ # define OP_T_THRES 16 /* Type to use for unaligned operations. */ typedef unsigned char byte; # ifndef WORDS_BIGENDIAN # define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2))) # else # define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2))) # endif #endif /* In the GNU C library. */ #ifdef WORDS_BIGENDIAN # define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1) #else # define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b)) #endif /* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */ /* The strategy of this memcmp is: 1. Compare bytes until one of the block pointers is aligned. 2. Compare using memcmp_common_alignment or memcmp_not_common_alignment, regarding the alignment of the other block after the initial byte operations. The maximum number of full words (of type op_t) are compared in this way. 3. Compare the few remaining bytes. */ #ifndef WORDS_BIGENDIAN /* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine. A and B are known to be different. This is needed only on little-endian machines. */ static int memcmp_bytes __P((op_t, op_t)); # ifdef __GNUC__ __inline # endif static int memcmp_bytes (long unsigned int a, long unsigned int b) { long int srcp1 = (long int) &a; long int srcp2 = (long int) &b; op_t a0, b0; do { a0 = ((byte *) srcp1)[0]; b0 = ((byte *) srcp2)[0]; srcp1 += 1; srcp2 += 1; } while (a0 == b0); return a0 - b0; } #endif static int memcmp_common_alignment __P((long, long, size_t)); /* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t' objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for memory operations on `op_t's. */ #ifdef __GNUC__ __inline #endif static int memcmp_common_alignment (long int srcp1, long int srcp2, size_t len) { op_t a0, a1; op_t b0, b1; switch (len % 4) { default: /* Avoid warning about uninitialized local variables. */ case 2: a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; srcp1 -= 2 * OPSIZ; srcp2 -= 2 * OPSIZ; len += 2; goto do1; case 3: a1 = ((op_t *) srcp1)[0]; b1 = ((op_t *) srcp2)[0]; srcp1 -= OPSIZ; srcp2 -= OPSIZ; len += 1; goto do2; case 0: if (OP_T_THRES <= 3 * OPSIZ && len == 0) return 0; a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; goto do3; case 1: a1 = ((op_t *) srcp1)[0]; b1 = ((op_t *) srcp2)[0]; srcp1 += OPSIZ; srcp2 += OPSIZ; len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) goto do0; /* Fall through. */ } do { a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; if (a1 != b1) return CMP_LT_OR_GT (a1, b1); do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; if (a0 != b0) return CMP_LT_OR_GT (a0, b0); do2: a0 = ((op_t *) srcp1)[2]; b0 = ((op_t *) srcp2)[2]; if (a1 != b1) return CMP_LT_OR_GT (a1, b1); do1: a1 = ((op_t *) srcp1)[3]; b1 = ((op_t *) srcp2)[3]; if (a0 != b0) return CMP_LT_OR_GT (a0, b0); srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; len -= 4; } while (len != 0); /* This is the right position for do0. Please don't move it into the loop. */ do0: if (a1 != b1) return CMP_LT_OR_GT (a1, b1); return 0; } static int memcmp_not_common_alignment __P((long, long, size_t)); /* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory operations on `op_t', but SRCP1 *should be unaligned*. */ #ifdef __GNUC__ __inline #endif static int memcmp_not_common_alignment (long int srcp1, long int srcp2, size_t len) { op_t a0, a1, a2, a3; op_t b0, b1, b2, b3; op_t x; int shl, shr; /* Calculate how to shift a word read at the memory operation aligned srcp1 to make it aligned for comparison. */ shl = 8 * (srcp1 % OPSIZ); shr = 8 * OPSIZ - shl; /* Make SRCP1 aligned by rounding it down to the beginning of the `op_t' it points in the middle of. */ srcp1 &= -OPSIZ; switch (len % 4) { default: /* Avoid warning about uninitialized local variables. */ case 2: a1 = ((op_t *) srcp1)[0]; a2 = ((op_t *) srcp1)[1]; b2 = ((op_t *) srcp2)[0]; srcp1 -= 1 * OPSIZ; srcp2 -= 2 * OPSIZ; len += 2; goto do1; case 3: a0 = ((op_t *) srcp1)[0]; a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[0]; srcp2 -= 1 * OPSIZ; len += 1; goto do2; case 0: if (OP_T_THRES <= 3 * OPSIZ && len == 0) return 0; a3 = ((op_t *) srcp1)[0]; a0 = ((op_t *) srcp1)[1]; b0 = ((op_t *) srcp2)[0]; srcp1 += 1 * OPSIZ; goto do3; case 1: a2 = ((op_t *) srcp1)[0]; a3 = ((op_t *) srcp1)[1]; b3 = ((op_t *) srcp2)[0]; srcp1 += 2 * OPSIZ; srcp2 += 1 * OPSIZ; len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) goto do0; /* Fall through. */ } do { a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; x = MERGE(a2, shl, a3, shr); if (x != b3) return CMP_LT_OR_GT (x, b3); do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; x = MERGE(a3, shl, a0, shr); if (x != b0) return CMP_LT_OR_GT (x, b0); do2: a2 = ((op_t *) srcp1)[2]; b2 = ((op_t *) srcp2)[2]; x = MERGE(a0, shl, a1, shr); if (x != b1) return CMP_LT_OR_GT (x, b1); do1: a3 = ((op_t *) srcp1)[3]; b3 = ((op_t *) srcp2)[3]; x = MERGE(a1, shl, a2, shr); if (x != b2) return CMP_LT_OR_GT (x, b2); srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; len -= 4; } while (len != 0); /* This is the right position for do0. Please don't move it into the loop. */ do0: x = MERGE(a2, shl, a3, shr); if (x != b3) return CMP_LT_OR_GT (x, b3); return 0; } int rpl_memcmp (const void *s1, const void *s2, size_t len) { op_t a0; op_t b0; long int srcp1 = (long int) s1; long int srcp2 = (long int) s2; op_t res; if (len >= OP_T_THRES) { /* There are at least some bytes to compare. No need to test for LEN == 0 in this alignment loop. */ while (srcp2 % OPSIZ != 0) { a0 = ((byte *) srcp1)[0]; b0 = ((byte *) srcp2)[0]; srcp1 += 1; srcp2 += 1; res = a0 - b0; if (res != 0) return res; len -= 1; } /* SRCP2 is now aligned for memory operations on `op_t'. SRCP1 alignment determines if we can do a simple, aligned compare or need to shuffle bits. */ if (srcp1 % OPSIZ == 0) res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ); else res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ); if (res != 0) return res; /* Number of bytes remaining in the interval [0..OPSIZ-1]. */ srcp1 += len & -OPSIZ; srcp2 += len & -OPSIZ; len %= OPSIZ; } /* There are just a few bytes to compare. Use byte memory operations. */ while (len != 0) { a0 = ((byte *) srcp1)[0]; b0 = ((byte *) srcp2)[0]; srcp1 += 1; srcp2 += 1; res = a0 - b0; if (res != 0) return res; len -= 1; } return 0; } #ifdef weak_alias # undef bcmp weak_alias (memcmp, bcmp) #endif --- NEW FILE: libobj.c --- /* -*- mode: c; c-basic-indent: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: libobj.c,v 1.1 2005/12/19 19:13:30 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* this file is intentionally empty */ |
From: Markus R. <rol...@us...> - 2005-12-19 19:13:45
|
Update of /cvsroot/simspark/simspark/spark/utility/glextgen/tocopy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24814/glextgen/tocopy Added Files: cpp_begin.txt cpp_query.txt header_begin.txt header_end.txt Log Message: - added spark utility library --- NEW FILE: header_end.txt --- #line 2 "utility/glextgen/tocopy/header_end.txt" #endif //GLEXTENSIONREG_H__ --- NEW FILE: cpp_query.txt --- static bool TestExtensionString(const char *name, const char *extensions) { /* It takes a bit of care to be fool-proof about parsing the OpenGL extensions string. Don't be fooled by sub-strings, etc. */ const char *start = extensions; char *where, *terminator; where = strchr(name, ' '); if (where || *name == '\0') return false; for (;;) { where = strstr((const char *) start, name); if (!where) break; terminator = where + strlen(name); if (where == start || *(where - 1) == ' ') if (*terminator == ' ' || *terminator == '\0') return true; start = terminator; } return false; } // returns true if the extension is available bool GLExtensionReg::QueryGLExtension(const char *name) { const char *extensions = NULL; /* extension names should not have spaces. */ extensions = (const char*)glGetString(GL_EXTENSIONS); return TestExtensionString(name, extensions); } #if defined(_WIN32) // returns true if the extension is available bool GLExtensionReg::QueryWGLExtension(const char *name) { const char *extensions = NULL; if ((wglGetExtensionsStringARB == NULL) || (mHDC == 0)) if (wglGetExtensionsStringEXT == NULL) return false; else extensions = (const char*) wglGetExtensionsStringEXT(); else extensions = (const char*) wglGetExtensionsStringARB(_dc); return TestExtensionString(name, extensions); } #endif //_WIN32 --- NEW FILE: cpp_begin.txt --- #line 2 "utility/glextgen/tocopy/cpp_begin.txt" #include <string.h> #if !defined(_WIN32) #include <GL/glx.h> #include <GL/glxext.h> #endif #define GET_PROC_ADDRESS(ptr, function) function = (ptr)GetProcedure( #function ); if (function == NULL) return false; void* GetProcedure(const char *name) { #if defined(_WIN32) void *t = wglGetProcAddress(name); #else void *t = NULL;// cant find glxGetProcAddressARB on my system // void *t = glXGetProcAddressARB((unsigned char*)name); #endif //_WIN32 return t; } static bool TestExtensionString(const char *name, const char *extensions) { /* It takes a bit of care to be fool-proof about parsing the OpenGL extensions string. Don't be fooled by sub-strings, etc. */ const char *start = extensions; char *where, *terminator; where = strchr(name, ' '); if (where || *name == '\0') return false; for (;;) { where = strstr((const char *) start, name); if (!where) break; terminator = where + strlen(name); if (where == start || *(where - 1) == ' ') if (*terminator == ' ' || *terminator == '\0') return true; start = terminator; } return false; } // returns true if the extension is available bool GLExtensionReg::QueryGLExtension(const char *name) { const char *extensions = NULL; /* extension names should not have spaces. */ extensions = (const char*)glGetString(GL_EXTENSIONS); return TestExtensionString(name, extensions); } #if defined(_WIN32) // returns true if the extension is available bool GLExtensionReg::QueryWGLExtension(const char *name) { const char *extensions = NULL; if ((wglGetExtensionsStringARB == NULL) || (mHDC == 0)) if (wglGetExtensionsStringEXT == NULL) return false; else extensions = (const char*) wglGetExtensionsStringEXT(); else extensions = (const char*) wglGetExtensionsStringARB(mHDC); return TestExtensionString(name, extensions); } #endif //_WIN32 --- NEW FILE: header_begin.txt --- #line 2 "utility/glextgen/tocopy/header_begin.txt" #ifndef GLEXTENSIONREG_H__ #define GLEXTENSIONREG_H__ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) #define WIN32_LEAN_AND_MEAN 1 #include <windows.h> #endif #define GL_GLEXT_PROTOTYPES #include <GL/gl.h> #include <GL/glext.h> #if defined(_WIN32) #include <GL/wglext.h> #else #include <GL/glx.h> #include <GL/glxext.h> #endif |
From: Markus R. <rol...@us...> - 2005-12-19 19:13:45
|
Update of /cvsroot/simspark/simspark/spark/utility In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24814 Added Files: .cvsignore Makefile.am Log Message: - added spark utility library --- NEW FILE: .cvsignore --- Makefile.in Makefile --- NEW FILE: Makefile.am --- SUBDIRS = glextgen \ libobj \ rcssnet \ sfsexp |
From: Markus R. <rol...@us...> - 2005-12-19 19:13:38
|
Update of /cvsroot/simspark/simspark/spark/utility/glextgen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24814/glextgen Added Files: .cvsignore Makefile.am README glextgen.rb glextgen.rb.in Log Message: - added spark utility library --- NEW FILE: README --- GLExtGen ----------------------------------------------------------------------- The code in this directory is used to generate a OpenGL Extension Loading Library automatically. Besides only very small changes and leaving out unnecessary parts for the rcssserver3D project, it is original code from Marco Koegler (mar...@we...). The original readme.txt file is attached below. Please note that for the version distributed in this directory, we left out the windows binary, as you need ruby for compiling the project anyway. -------------------------------------------------------------------------------- GLExtGen ======== This project was inspired by the OpenGL Extension Loading Library by Lev Povalahev, which can be found here: http://www.uni-karlsruhe.de/~uli2/ The general idea is the same, but I believe that Lev is maintaining his library 'by hand', whereas this solution does it completely automatically. If you are using plain 'C' I suggest using his library, as the backend provided here only generates a C++ class. It should be easy enough to write a C backend, but I currently don't have the time to do that. Disclaimer ---------- The author of this software is not responsible for any harm done by running or modifying it. License - Any-Ware ------------------ The software can be used for any kind of project (private, commercial, whatever)... I hope you have fun with it and it makes your life coding OpenGL applications easier. Found Bugs? ----------- Please contact the author under mar...@we... Installation ------------ Just extract the archive to a directory (Examples use glextgen/). It will then contain the executable (glextgen/*), scripts (glextgen/script/*) and some necessary files (glextgen/tocopy/*). Also make sure that you have installed the following extension header files: * For MS-Windows: - GL/glext.h - GL/wglext.h * For X-Windows (e.g. Mesa under Linux): - GL/glext.h - GL/glxext.h Of course you also need the OpenGL header file (GL/gl.h). A current lazyness of my code requires for all these files to be in the same GL/ directory (you have to specify a path to that directory). I just have a subdirectory glextgen/ containing a copy of these files and use those instead of the actual header files used by the compiler. A very complete set of extension header files can be obtained at: http://oss.sgi.com/projects/ogl-sample/sdk.html These were the files I used to test this thing with (hint, hint)! Configuration ------------- Open up the file glextgen/glextgen.rb. It contains the declaration of two global Variables: $path and $target. You should modify these to fit your configuration $target can take two values: "win32" and "x". It triggers the inclusion of wglext.h or glxext.h, respectively. $path is the path to the directory containing the OpenGL header files (regular and extensions). A few examples are in the glextgen/glextgen.rb file (they are commeted out with '#'). Make sure that you use forward slashes (/) in the paths, otherwise you might trigger an escape sequence. That's it. Generating files using GLExtGen ------------------------------- There are two ways to run GLExtGen, one for people which have Ruby (a scripting language) installed on their machines and one for people which don't (only under Windows, though). If you DO have Ruby installed: - Run the file 'glextgen/glextgen.rb' either by double-clicking on it or entering 'ruby glextgen.rb' at the command prompt while you are in the glextgen/-directory. If you DON'T have Ruby installed: - Run the file 'glextgen/glextgen.exe' either by double-clicking on it or entering 'glextgen.exe' at the command prompt while you are in the glextgen/-directory. This should generate output similar to this (Note: Some paths and the processing stuff might differ): ***BEGIN Example Output Digesting 'wingl/GL/glext.h'... Digesting 'wingl/GL/wglext.h'... Searching for native extensions in 'wingl/GL/gl.h Processing GL_VERSION_1_1 -> No Action Generating 'glextensionreg.h' Generating 'glextensionreg.cpp' ***END Example Output Now, we have two new files in the glextgen/-directory. The files contain an implementation of a class called 'GLExtensionReg,' which brings us to the next topic... Using GLExtensionReg -------------------- This is quite simple: - Add the files glextensionreg.h and glextensionreg.cpp to your project - #include "glextensionreg.h" - Create an instance of GLExtensionReg (I'll refer to it as 'reg'). - After having set up your context (at the point where you would usually initialize your extensions), just call Init() on your GLExtensionReg instance (so, reg.Init() or reg->Init()). This sets up all known and available OpenGL extensions. You can check for the availability of an extension using the 'Has_' functions. So, you might do: reg.Init(); if (reg.Has_GL_ARB_multitexture()) { // use multitexturing glActiveTextureARB(GL_TEXTURE0_ARB); ... etc ... } This can also be used to check for OpenGL versions: reg.Init(); if (reg.Has_GL_VERSION_1_3()) { // use multitexturing ... no need for the ARB functions glActiveTexture(GL_TEXTURE0); ... etc ... } Now, another problem is that the function entry points might differ for multiple OpenGL contexts. So, if you have your general split-view it could happen that the function pointers to call for multitexturing for one context might differ from another (imagine one context using accelerated OpenGL and another using software rendering). So, you would have to keep different sets of function pointers and possibly also extension capabilities (the 'Has'-stuff). Now, this can also be done here: GLExtensionReg reg; GLExtGenFunctionPointers ptr; GLExtGenExtensions extensions; void init(void) { // a context is current // init the function pointers and extensions for the current context reg.Init(&ptr, &extensions); if (extensions.mGL_ARB_multitexture) { ptr.glActiveTextureARB(GL_TEXTURE0_ARB); ... } } OK, hope that gets everyone going. Future Releases --------------- Future releases may contain: - Support for GLX, currently none of the glX-Extensions are written out in the backend as I don't have a good test platform for this :( - Multiple search paths for files (so gl.h and glext.h don't have to be in the same directory) - specification of a destination directory for the generated files - An identical interface for GLExtGenExtensions and GLExtensionReg (both using 'Has'-functions) - Might derive GLExtensionReg from GLExtGenExtensions --- NEW FILE: .cvsignore --- Makefile Makefile.in glextensionreg.cpp glextensionreg.h glextgen.rb --- NEW FILE: Makefile.am --- EXTRA_DIST = README glextgen.rb.in ${rubysources} ${copyfiles} rubysources = script/glbackend.rb script/glextension.rb script/glextgen.rb \ script/glfrontend.rb script/glmunger.rb copyfiles = tocopy/cpp_begin.txt tocopy/cpp_query.txt \ tocopy/header_begin.txt tocopy/header_end.txt if BUILD_KEROSIN all-local: glextensionreg.cpp glextensionreg.h endif clean-local: rm -f glextensionreg.cpp glextensionreg.h glextensionreg.cpp glextensionreg.h: glextgen.rb ${rubysources} ${copyfiles} ruby glextgen.rb kerosin --- NEW FILE: glextgen.rb --- # -*- mode: ruby; ruby-indent-level: 4 -*- # # just redirect to 'script/glextgen.rb' # the 'target' string controls whether wgl or glX extensions are considered # target should be either 'x' or 'win32' $target = "x" # the following string designates the path of the 'GL/' subdirectory $path = "/usr/include/GL/" $namespace = $*[0] require 'script/glextgen.rb' --- NEW FILE: glextgen.rb.in --- # -*- mode: ruby; ruby-indent-level: 4 -*- # # just redirect to 'script/glextgen.rb' # the 'target' string controls whether wgl or glX extensions are considered # target should be either 'x' or 'win32' $target = "@GLTARGET@" # the following string designates the path of the 'GL/' subdirectory $path = "@GLDIR@/" $namespace = $*[0] require 'script/glextgen.rb' |
From: Markus R. <rol...@us...> - 2005-12-19 19:13:38
|
Update of /cvsroot/simspark/simspark/spark/utility/rcssnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24814/rcssnet Added Files: .cvsignore Makefile.am README addr.cpp addr.hpp exception.cpp exception.hpp iosocketstream.hpp isocketstream.hpp osocketstream.hpp socket.cpp socket.hpp socketstreambuf.hpp tcpsocket.cpp tcpsocket.hpp udpsocket.cpp udpsocket.hpp Log Message: - added spark utility library --- NEW FILE: exception.hpp --- // -*-c++-*- /*************************************************************************** exception.hpp - Network associated excpetions ------------------- begin : 07-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCSS_NET_EXCPETION_HPP #define RCSS_NET_EXCEPTION_HPP #include <exception> namespace rcss { namespace net { class HostNotFound : public std::exception { public: HostNotFound( int err ) throw(); const char* what() const throw(); int err() const throw(); private: int m_err; }; class OpenErr : public std::exception { public: OpenErr( int err ) throw(); const char* what() const throw(); int err() const throw(); private: int m_err; }; class BindErr : public std::exception { public: BindErr( int err ) throw(); const char* what() const throw(); int err() const throw(); private: int m_err; }; class ListenErr : public std::exception { public: ListenErr( int err ) throw(); const char* what() const throw(); int err() const throw(); private: int m_err; }; class AcceptErr : public std::exception { public: AcceptErr( int err ) throw(); const char* what() const throw(); int err() const throw(); private: int m_err; }; class GetNameErr : public std::exception { public: GetNameErr( int err ) throw(); const char* what() const throw(); int err() const throw(); private: int m_err; }; class ConnectErr : public std::exception { public: ConnectErr( int err ) throw(); const char* what() const throw(); int err() const throw(); private: int m_err; }; } } #endif --- NEW FILE: udpsocket.hpp --- // -*-c++-*- /*************************************************************************** updsocket.hpp - A simple upd socket class ------------------- begin : 08-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCSS_NET_UDPSOCKET_HPP #define RCSS_NET_UDPSOCKET_HPP #include "socket.hpp" namespace rcss { namespace net { class UDPSocket : public Socket { public: UDPSocket(); UDPSocket( const Addr& addr ); UDPSocket( const Addr& addr, const Addr& dest ); protected: virtual void doOpen( int& fd ); }; } } #endif --- NEW FILE: Makefile.am --- pkglib_LTLIBRARIES = librcssnet3D.la librcssnet3D_la_SOURCES = \ addr.cpp \ exception.cpp \ socket.cpp \ tcpsocket.cpp \ udpsocket.cpp libpkginclude_HEADERS = \ addr.hpp \ exception.hpp \ iosocketstream.hpp \ isocketstream.hpp \ osocketstream.hpp \ socket.hpp \ socketstreambuf.hpp \ tcpsocket.hpp \ udpsocket.hpp librcssnet3D_la_LIBADD = @NET_LIBS@ librcssnet3D_la_LDFLAGS = -version-info @rcssnet3D_version_info@ ## define include directory local to the pkgincludedir libpkgincludedir = $(includedir)/@PACKAGE@/rcssnet EXTRA_DIST = README --- NEW FILE: socketstreambuf.hpp --- // -*-c++-*- /*************************************************************************** socketstreambuf.hpp - A socket stream buffer ------------------- begin : 08-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCSS_NET_SOCKETSTREAMBUF_HPP #define RCSS_NET_SOCKETSTREAMBUF_HPP //g++ 2.95.6 doesn't have the streambuf header, so iostream is used instead //#include <streambuf> #include<iostream> #include "socket.hpp" namespace rcss { namespace net { class SocketStreamBuf : public std::streambuf { public: typedef int int_type; typedef char char_type; enum ConnType { CONN_ON_READ, NO_CONN }; public: SocketStreamBuf( Socket& socket, const Addr& dest, ConnType conn = CONN_ON_READ, std::streamsize bufsize = 8192 ) : m_socket( socket ), m_end_point( dest ), m_bufsize( bufsize ), m_inbuf( NULL ), m_outbuf( NULL ), m_remained( 0 ), m_connect( conn ) {} SocketStreamBuf( Socket& socket, ConnType conn = NO_CONN, std::streamsize bufsize = 8192 ) : m_socket( socket ), m_bufsize( bufsize ), m_inbuf( NULL ), m_outbuf( NULL ), m_remained( 0 ), m_connect( conn ) {} virtual ~SocketStreamBuf() { overflow(); delete [] m_inbuf; delete [] m_outbuf; } void setEndPoint( const Addr& addr ) { m_end_point = addr; } void setConnectType( ConnType conn ) { m_connect = conn; } protected: virtual bool writeData() { int size = (pptr () - m_outbuf) * sizeof(char_type); if( size == 0 ) return true; if( m_socket.isConnected() ) return m_socket.send( m_outbuf, size ) > 0; else return m_socket.send( m_outbuf, size, m_end_point ) > 0; } virtual int_type overflow( int_type c = EOF ) { // this method is supposed to flush the put area of the buffer // to the I/O device // if the buffer was not already allocated nor set by user, // do it just now if( pptr() == NULL ) { m_outbuf = new char_type[m_bufsize]; } else { if( !writeData() ) { return EOF; } } setp( m_outbuf, m_outbuf + m_bufsize ); if( c != EOF ) sputc( c ); return 0; } virtual int sync() { if( pptr() != NULL ) { // just flush the put area if( !writeData() ) { return EOF; } setp( m_outbuf, m_outbuf + m_bufsize ); } return 0; } virtual int_type underflow() { // this method is supposed to read some bytes from the I/O device // if the buffer was not already allocated nor set by user, // do it just now if( gptr() == NULL ) { m_inbuf = new char_type[m_bufsize]; } if( m_remained != 0 ) m_inbuf[0] = m_remained_char; int readn = m_bufsize * sizeof( char_type ) - m_remained; if( m_socket.isConnected() ) readn = m_socket.recv( m_inbuf + m_remained, readn ); else { Addr addr; readn = m_socket.recv( m_inbuf + m_remained, readn, addr ); if( m_connect == CONN_ON_READ && readn > 0 ) m_socket.connect( addr ); } if( readn < 0 || readn == 1 && (m_inbuf + m_remained)[ 0 ] == -1 ) { (m_inbuf + m_remained)[ 0 ] = -1; return EOF; } int totalbytes = readn + m_remained; setg( m_inbuf, m_inbuf, m_inbuf + totalbytes / sizeof(char_type) ); m_remained = totalbytes % sizeof( char_type ); if( m_remained != 0 ) m_remained_char = m_inbuf[totalbytes / sizeof(char_type)]; return sgetc(); } private: // not used SocketStreamBuf( const SocketStreamBuf& ); // not used SocketStreamBuf& operator=( const SocketStreamBuf& ); Socket& m_socket; Addr m_end_point; std::streamsize m_bufsize; char_type* m_inbuf; char_type* m_outbuf; int m_remained; char_type m_remained_char; ConnType m_connect; }; } } #endif --- NEW FILE: tcpsocket.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: tcpsocket.cpp,v 1.1 2005/12/19 19:13:30 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "tcpsocket.hpp" #include "exception.hpp" #include <sys/types.h> #include <sys/socket.h> #include <cerrno> namespace rcss { namespace net { TCPSocket::TCPSocket() { open(); } TCPSocket::TCPSocket( const Addr& addr ) { open(); bind( addr ); } TCPSocket::TCPSocket( const Addr& addr, const Addr& dest ) { open(); bind( addr ); connect( dest ); } TCPSocket::TCPSocket( int socket ) { m_open = true; m_connected = true; m_socket = socket; } void TCPSocket::doOpen( int& fd ) { close(); fd = ::socket(AF_INET, SOCK_STREAM, 0 ); if( fd < 0 ) throw OpenErr( errno ); } Socket* TCPSocket::accept(Addr& addr) { socklen_t len = sizeof(struct sockaddr); int fd = ::accept( m_socket, (struct sockaddr *)&( addr.getAddr() ), &len ); if (fd < 0) { throw AcceptErr( errno ); } return new TCPSocket(fd); } } } --- NEW FILE: .cvsignore --- *.lo .deps .libs Makefile Makefile.in librcssnet3D.la --- NEW FILE: addr.cpp --- // -*-c++-*- /*************************************************************************** addr.cpp - A network address class ------------------- begin : 07-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #include "addr.hpp" #include "exception.hpp" #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> namespace rcss { namespace net { const Addr::HostType Addr::BROADCAST = INADDR_BROADCAST; const Addr::HostType Addr::ANY = INADDR_ANY; class AddrImpl { public: AddrImpl() : m_addr() { memset( (char *)&m_addr, 0, sizeof( m_addr ) ); } AddrImpl( const Addr::AddrType& addr ) : m_addr( addr ) {} AddrImpl( Addr::PortType port ) { memset( (char *)&m_addr, 0, sizeof( m_addr ) ) ; m_addr.sin_family = AF_INET ; m_addr.sin_addr.s_addr = htonl( INADDR_ANY ); m_addr.sin_port = htons( port ); } AddrImpl( Addr::PortType port, Addr::HostType host ) { memset( (char *)&m_addr, 0, sizeof( m_addr ) ) ; m_addr.sin_family = AF_INET ; m_addr.sin_addr.s_addr = htonl( host ); m_addr.sin_port = htons( port ); } AddrImpl( Addr::PortType port, const std::string& host ) : m_host_name( host ) { struct hostent* host_ent = (struct hostent*)gethostbyname( host.c_str() ); if( host_ent == NULL ) throw HostNotFound( h_errno ); memset( (char *)&m_addr, 0, sizeof( m_addr ) ) ; m_addr.sin_family = AF_INET ; m_addr.sin_addr.s_addr = ((struct in_addr *)host_ent->h_addr_list[0])->s_addr; m_addr.sin_port = htons( port ); } const Addr::AddrType& getAddr() const { return m_addr; } Addr::PortType getPort() const { return ntohs( m_addr.sin_port ); } void setPort(Addr::PortType port) { m_addr.sin_port = htons(port); } Addr::HostType getHost() const { return htonl( m_addr.sin_addr.s_addr ); } std::string getHostStr() const { if( m_host_name.empty() ) { m_host_name = inet_ntoa( m_addr.sin_addr ); } return m_host_name; } private: Addr::AddrType m_addr; mutable std::string m_host_name; }; Addr::Addr() : m_impl( new AddrImpl() ) {} Addr::Addr( const AddrType& addr ) : m_impl( new AddrImpl( addr ) ) {} Addr::Addr( PortType port ) : m_impl( new AddrImpl( port ) ) {} Addr::Addr( PortType port, HostType host ) : m_impl( new AddrImpl( port, host ) ) {} Addr::Addr( PortType port, const std::string& host ) : m_impl( new AddrImpl( port, host ) ) {} const Addr::AddrType& Addr::getAddr() const { return m_impl->getAddr(); } Addr::PortType Addr::getPort() const { return m_impl->getPort(); } void Addr::setPort(PortType port) { m_impl->setPort(port); } Addr::HostType Addr::getHost() const { return m_impl->getHost(); } std::string Addr::getHostStr() const { return m_impl->getHostStr(); } bool Addr::operator==( const Addr& addr ) const { return ( addr.getAddr().sin_port == getAddr().sin_port && ( addr.getAddr().sin_addr.s_addr == getAddr().sin_addr.s_addr ) ); } bool Addr::operator < ( const Addr& addr ) const { const Addr::HostType host_a = getHost(); const Addr::HostType host_b = addr.getHost(); if (host_a != host_b) { return host_a < host_b; } return getPort() < addr.getPort(); } std::ostream& operator<<( std::ostream& o, const rcss::net::Addr& addr ) { return o << '(' << addr.getPort() << ':' << addr.getHostStr() << ')'; } } } --- NEW FILE: addr.hpp --- // -*-c++-*- /*************************************************************************** addr.hpp - A network address class ------------------- begin : 07-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCSS_NET_ADDR_HPP #define RCSS_NET_ADDR_HPP struct sockaddr_in; #include <string> #include <boost/shared_ptr.hpp> #include <boost/cstdint.hpp> namespace rcss { namespace net { class AddrImpl; class Addr { public: typedef boost::uint16_t PortType; typedef boost::uint32_t HostType; typedef struct sockaddr_in AddrType; static const HostType BROADCAST; static const HostType ANY; Addr(); Addr( const AddrType& addr ); Addr( PortType port ); Addr( PortType port, HostType host ); Addr( PortType port, const std::string& host ); const AddrType& getAddr() const; PortType getPort() const; void setPort(PortType port); HostType getHost() const; std::string getHostStr() const; bool operator == ( const Addr& addr ) const; bool operator < (const Addr& addr ) const; private: boost::shared_ptr< AddrImpl > m_impl; }; std::ostream& operator<<( std::ostream& o, const Addr& addr ); } } #endif --- NEW FILE: iosocketstream.hpp --- // -*-c++-*- /*************************************************************************** iosocketstream.hpp - An iostream for sockets ------------------- begin : 08-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCSS_NET_IOSOCKETSTREAM_HPP #define RCSS_NET_IOSOCKETSTREAM_HPP #include "socketstreambuf.hpp" #include "isocketstream.hpp" #include "osocketstream.hpp" namespace rcss { namespace net { class IOSocketStream : public SocketStreamBuf, public std::iostream { // The IOSocketStream can be used in threads, however if a read // blocks waiting for input, then the sending at the same time // will also block. If you want to do this then you will need to // either protect the stream with a mutex or create a // ISocketStream for reading and a OSocketStream for // writing. You can pass the same socket to both to have the // reading and writing performed by the same socket. public: IOSocketStream( Socket& socket, const Addr& dest, ConnType conn = CONN_ON_READ, int buffer_size = 8192 ) : SocketStreamBuf( socket, dest, conn, buffer_size ), std::iostream( this ) {} IOSocketStream( Socket& socket, ConnType conn = NO_CONN, int buffer_size = 8192 ) : SocketStreamBuf( socket, conn, buffer_size ), std::iostream( this ) {} private: // not for use IOSocketStream( const IOSocketStream& ); IOSocketStream& operator=( const IOSocketStream& ); }; } } #endif --- NEW FILE: socket.cpp --- /*************************************************************************** socket.cpp - Base newtork socket class ------------------- begin : 08-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #include "socket.hpp" #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <fcntl.h> #include <cerrno> #if defined (HAVE_POLL_H) #include <poll.h> #endif #include "exception.hpp" #ifndef HAVE_SOCKLEN_T typedef int socklen_t; #endif namespace rcss { namespace net { Socket::Socket() : m_socket( 0 ), m_open( false ), m_connected( false ) {} Socket::~Socket() { close(); } void Socket::open() { doOpen( m_socket ); m_open = true; int err = setCloseOnExec(); if( err < 0 ) { err = errno; close(); throw OpenErr( err ); } } void Socket::bind( const Addr& addr ) { int err = ::bind( m_socket, (struct sockaddr *)&( addr.getAddr() ), sizeof( addr.getAddr() ) ); if( err < 0 ) throw BindErr( errno ); } void Socket::listen( int backlog ) { int err = ::listen( m_socket, backlog ); if (err < 0 ) throw ListenErr( errno ); } Socket* Socket::accept(Addr& addr) { throw AcceptErr( EOPNOTSUPP ); return 0; } Addr Socket::getName() const { Addr::AddrType name; socklen_t from_len = sizeof( name ); int err = ::getsockname( m_socket, (struct sockaddr *)&name, &from_len ); if( err < 0 ) throw GetNameErr( errno ); return Addr( name ); } void Socket::connect( const Addr& addr ) { int err = ::connect( m_socket, (const struct sockaddr *)&( addr.getAddr() ), sizeof( addr.getAddr() ) ); if ( err < 0 ) throw ConnectErr( errno ); m_connected = true; } Addr Socket::getPeer() const { Addr::AddrType name; socklen_t from_len = sizeof( name ); int err = ::getpeername( m_socket, (struct sockaddr *)&name, &from_len ); if( err < 0 ) throw GetNameErr( errno ); return Addr( name ); } void Socket::close() { if( m_open ) { m_open = false; ::close( m_socket ); m_socket = 0; } m_connected = false; } int Socket::setCloseOnExec( bool on ) { return fcntl( m_socket, F_SETFD, ( on ? FD_CLOEXEC : ~FD_CLOEXEC ) ); } int Socket::setNonBlocking( bool on ) { int flags = fcntl( m_socket, F_GETFL, 0 ); if( flags == -1 ) return flags; if( on ) return fcntl( m_socket, F_SETFL, O_NONBLOCK | flags ); else return fcntl( m_socket, F_SETFL, ~O_NONBLOCK & flags ); } int Socket::setAsync( bool on ) { #ifdef O_ASYNC int flags = fcntl( m_socket, F_GETFL, 0 ); if ( on ) return fcntl ( m_socket, F_SETFL, O_ASYNC | flags ); else return fcntl ( m_socket, F_SETFL, ~O_ASYNC & flags ); #else errno = EPERM; return -1; #endif } int Socket::setBroadcast( bool on ) { #ifdef SO_BROADCAST int ison = on; return setsockopt( m_socket, SOL_SOCKET, SO_BROADCAST, (void*)&ison, sizeof( int ) ); #else errno = EPERM; return -1; #endif } int Socket::getFD() const { return m_socket; } bool Socket::isOpen() const { return m_open; } bool Socket::isConnected() const { return m_connected; } Addr Socket::getDest() const { return getPeer(); } int Socket::send( const char* msg, size_t len, const Addr& dest, int flags, CheckingType check ) { if( check == DONT_CHECK ) { return ::sendto( m_socket, msg, len, flags, (struct sockaddr *)&( dest.getAddr() ), sizeof( dest.getAddr() ) ); } else { for(;;) { int sent = ::sendto( m_socket, msg, len, flags, (struct sockaddr *)&( dest.getAddr() ), sizeof( dest.getAddr() ) ); if( sent != -1 || ( errno != EINTR && errno != EWOULDBLOCK ) ) return sent; } } } int Socket::send( const char* msg, size_t len, int flags, CheckingType check ) { if( check == DONT_CHECK ) { return ::send( m_socket, msg, len, flags ); } else { for(;;) { int sent = ::send( m_socket, msg, len, flags ); if( sent != -1 || ( errno != EINTR && errno != EWOULDBLOCK ) ) return sent; } } } int Socket::recv( char* msg, size_t len, Addr& from, int flags, CheckingType check ) { if( check == DONT_CHECK ) { Addr::AddrType addr; socklen_t from_len = sizeof( addr ); int rval = ::recvfrom( m_socket, msg, len, flags, (struct sockaddr *)&addr, &from_len ); from = Addr( addr ); return rval; } else { for(;;) { Addr::AddrType addr; socklen_t from_len = sizeof( addr ); int received = ::recvfrom( m_socket, msg, len, flags, (struct sockaddr *)&addr, &from_len ); from = Addr( addr ); if( received != -1 || errno != EINTR ) return received; } } } int Socket::recv( char* msg, size_t len, int flags, CheckingType check ) { if( check == DONT_CHECK ) return ::recv( m_socket, msg, len, flags ); else { for(;;) { int received = ::recv( m_socket, msg, len, flags ); if( received != -1 || errno != EINTR ) return received; } } } int Socket::recv( int timeout, char* msg, size_t len, Addr& from, int flags ) { #if defined (HAVE_POLL_H) pollfd fd = { m_socket, POLLIN | POLLPRI, 0 }; int res = poll( &fd, 1, timeout ); if( res == 0 ) { errno = EAGAIN; return -1; } else if( res == 1 ) { return recv( msg, len, from, flags ); } else { return res; } #else errno = EPERM; return -1; #endif } int Socket::recv( int timeout, char* msg, size_t len, int flags ) { #if defined (HAVE_POLL_H) pollfd fd = { m_socket, POLLIN | POLLPRI, 0 }; int res = poll( &fd, 1, timeout ); if( res == 0 ) { errno = EAGAIN; return -1; } else if( res == 1 ) { return recv( msg, len, flags ); } else { return res; } #else errno = EPERM; return -1; #endif } } } --- NEW FILE: socket.hpp --- // -*-c++-*- /*************************************************************************** socket.hpp - Base newtork socket class ------------------- begin : 08-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCSS_NET_SOCKET_HPP #define RCSS_NET_SOCKET_HPP #include <boost/cstdint.hpp> #include "addr.hpp" namespace rcss { namespace net { class Socket { public: enum CheckingType { CHECK, DONT_CHECK }; Socket(); virtual ~Socket(); void open(); void bind( const Addr& addr ); void listen( int backlog ); virtual Socket* accept(Addr& addr); Addr getName() const; void connect( const Addr& addr ); Addr getPeer() const; void close(); int setCloseOnExec( bool on = true ); int setNonBlocking( bool on = true ); int setAsync( bool on = true ); int setBroadcast( bool on = true ); int getFD() const; bool isOpen() const; bool isConnected() const; Addr getDest() const; // deprecated. Use getPeer instead. int send( const char* msg, size_t len, const Addr& dest, int flags = 0, CheckingType check = CHECK ); int send( const char* msg, size_t len, int flags = 0, CheckingType check = CHECK ); int recv( char* msg, size_t len, Addr& from, int flags = 0, CheckingType check = CHECK ); int recv( char* msg, size_t len, int flags = 0, CheckingType check = CHECK ); // The following two methods allow a timeout to be specified. // Overall, it's slower than the untimed varients so if you do // need to specify a timeout and you just want it the recv to // block or not to block, then you are better off setting the // socket to blocking or non-blocking and using the version // without timeouts. int recv( int timeout, char* msg, size_t len, Addr& from, int flags = 0 ); int recv( int timeout, char* msg, size_t len, int flags = 0 ); protected: virtual void doOpen( int& fd ) = 0; // not used Socket( const Socket& ); Socket& operator=( const Socket& ); protected: int m_socket; bool m_open; bool m_connected; }; } } #endif --- NEW FILE: udpsocket.cpp --- // -*-c++-*- /*************************************************************************** updsocket.cpp - A simple upd socket class ------------------- begin : 08-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #include "udpsocket.hpp" #include <sys/types.h> #include <sys/socket.h> #include <cerrno> #include "exception.hpp" #include <netinet/in.h> namespace rcss { namespace net { UDPSocket::UDPSocket() { open(); } UDPSocket::UDPSocket( const Addr& addr ) { open(); bind( addr ); } UDPSocket::UDPSocket( const Addr& addr, const Addr& dest ) { open(); bind( addr ); connect( dest ); } void UDPSocket::doOpen( int& fd ) { close(); fd = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP ); if( fd < 0 ) throw OpenErr( errno ); } } } --- NEW FILE: exception.cpp --- // -*-c++-*- /*************************************************************************** exception.cpp - Network associated excpetions ------------------- begin : 07-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "exception.hpp" #include <cstring> #include <sys/types.h> #include <netinet/in.h> #ifdef HAVE_ARPA_NAMESER_H #include <arpa/nameser.h> #endif #ifdef HAVE_NETDB_H #include <netdb.h> #endif #ifdef HAVE_RESOLV_H #include <resolv.h> #endif namespace rcss { namespace net { HostNotFound::HostNotFound( int err ) throw() : m_err( err ) {} const char* HostNotFound::what() const throw() { #if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) return "Network error"; #else return hstrerror( m_err ); #endif } int HostNotFound::err() const throw() { return m_err; } OpenErr::OpenErr( int err ) throw() : m_err( err ) {} const char* OpenErr::what() const throw() { return std::strerror( m_err ); } int OpenErr::err() const throw() { return m_err; } BindErr::BindErr( int err ) throw() : m_err( err ) {} const char* BindErr::what() const throw() { return strerror( m_err ); } int BindErr::err() const throw() { return m_err; } ListenErr::ListenErr( int err ) throw() : m_err( err ) {} const char* ListenErr::what() const throw() { return strerror( m_err ); } int ListenErr::err() const throw() { return m_err; } AcceptErr::AcceptErr( int err ) throw() : m_err( err ) {} const char* AcceptErr::what() const throw() { return strerror( m_err ); } int AcceptErr::err() const throw() { return m_err; } GetNameErr::GetNameErr( int err ) throw() : m_err( err ) {} const char* GetNameErr::what() const throw() { return strerror( m_err ); } int GetNameErr::err() const throw() { return m_err; } ConnectErr::ConnectErr( int err ) throw() : m_err( err ) {} const char* ConnectErr::what() const throw() { return strerror( m_err ); } int ConnectErr::err() const throw() { return m_err; } } } --- NEW FILE: tcpsocket.hpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: tcpsocket.hpp,v 1.1 2005/12/19 19:13:30 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef RCSS_NET_TCPSOCKET_HPP #define RCSS_NET_TCPSOCKET_HPP #include "socket.hpp" namespace rcss { namespace net { class TCPSocket : public Socket { public: TCPSocket(); TCPSocket( const Addr& addr ); TCPSocket( const Addr& addr, const Addr& dest ); virtual Socket* accept(Addr& addr); protected: TCPSocket( int socket ); virtual void doOpen( int& fd ); }; } } #endif // RCSS_NET_TCPSOCKET_HPP --- NEW FILE: README --- The files for this library have been taken from the rcssbase package (9.4.5) that can be found in the soccer server repository (www.sf.net/projects/sserver). Additionally, some files have been added to complete the library. This code has been ripped from the rcssbase library so that rcssserver3D users don't need to install so many libraries. Some features were missing (like a tcpsocket), which also could have been added to rcssbase. This way was easier for us (and probably also for most of the users). --- NEW FILE: osocketstream.hpp --- // -*-c++-*- /*************************************************************************** osocketstream.hpp - An ostream for sockets ------------------- begin : 08-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCSS_NET_OSOCKETSTREAM_HPP #define RCSS_NET_OSOCKETSTREAM_HPP #include "socketstreambuf.hpp" namespace rcss { namespace net { class OSocketStream : public SocketStreamBuf, public std::ostream { public: OSocketStream( Socket& socket, const Addr& dest, int buffer_size = 8192 ) : SocketStreamBuf( socket, dest, NO_CONN, buffer_size ), std::ostream( this ) {} OSocketStream( Socket& socket, int buffer_size = 8192 ) : SocketStreamBuf( socket, NO_CONN, buffer_size ), std::ostream( this ) {} private: // not for use OSocketStream(const OSocketStream&); OSocketStream& operator=(const OSocketStream&); }; } } #endif --- NEW FILE: isocketstream.hpp --- // -*-c++-*- /*************************************************************************** isocketstream.hpp - An istream for sockets ------------------- begin : 08-JAN-2003 copyright : (C) 2003 by The RoboCup Soccer Server Maintenance Group. email : sse...@li... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 2 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifndef RCSS_NET_ISOCKETSTREAM_HPP #define RCSS_NET_ISOCKETSTREAM_HPP #include "socketstreambuf.hpp" namespace rcss { namespace net { class ISocketStream : public SocketStreamBuf, public std::istream { public: ISocketStream( Socket& socket, const Addr& dest, ConnType conn = CONN_ON_READ, int buffer_size = 8192 ) : SocketStreamBuf( socket, dest, conn, buffer_size ), std::istream( this ) {} ISocketStream( Socket& socket, ConnType conn = NO_CONN, int buffer_size = 8192 ) : SocketStreamBuf( socket, conn, buffer_size ), std::istream( this ) {} private: // not for use ISocketStream(const ISocketStream&); ISocketStream& operator=(const ISocketStream&); }; } } #endif |
From: Markus R. <rol...@us...> - 2005-12-19 19:13:38
|
Update of /cvsroot/simspark/simspark/spark/utility/sfsexp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24814/sfsexp Added Files: .cvsignore Makefile.am cstring.c cstring.h faststack.c faststack.h io.c malloc_util.c malloc_util.h parser.c sexp.c sexp.h sexp_ops.c sexp_ops.h Log Message: - added spark utility library --- NEW FILE: faststack.h --- /** This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from LANL. **/ /** NOTICE: This software is licensed under the GNU Public License, which is included as LICENSE_GPL in this source distribution. **/ /** NOTE: This library is part of the supermon project, hence the name supermon above. **/ /** * \file faststack.h * * \brief Implementation of a fast stack with smart memory management. * * Author: Matt Sottile (ma...@la...) * See LICENSE for info on licensing. */ #ifndef __FASTSTACK_H__ #define __FASTSTACK_H__ #ifdef _DEBUG_MALLOCS_ #include "malloc_util.h" #endif /** * Structure representing a single level in the stack. Has a pointer to the * level above and below itself and a pointer to a generic blob of data * associated with this level. */ typedef struct stack_level { /** * Pointer to the level above this one. If NULL, then this level is the * top of the stack. If above is non-NULL, this level *may* be the top, * but all that can be guaranteed is that there are other allocated * but potentially unused levels above this one. */ struct stack_level *above; /** * Pointer to the level below this one. If NULL, then this level is the * bottom. */ struct stack_level *below; /** * Pointer to some data associated with this level. User is responsible * for knowing what to cast the \c void \c * pointer into. */ void *data; } stack_lvl_t; /** * Wrapper around the stack levels - keeps a pointer to the current top and * bottom of the stack and a count of the current height. This allows the top * to have non-null above pointer resulting from previously allocated stack * levels that may be recycled later without \c malloc overhead. */ typedef struct stack_wrapper { /** * The top of the stack. If this is NULL, the stack is empty. */ stack_lvl_t *top; /** * The bottom of the stack. If this is NULL, the stack is empty. */ stack_lvl_t *bottom; /** * The current height of the stack, in terms of allocated and used levels. */ int height; } faststack_t; /** functions **/ /* this is for C++ */ #ifdef __cplusplus extern "C" { #endif /** * Return a pointer to an empty stack structure. */ faststack_t *make_stack(); /** * Given a stack structure, destroy it and free all of the stack levels. * <B>Important note</B> : This function <I>does not</I> free the data * pointed to from each level of the stack - the user is responsible * for freeing this data themselves before calling this function to * prevent memory leakage. */ void destroy_stack(faststack_t *s); /** * Given a stack, push a new level on referring to the data pointer. */ faststack_t *push(faststack_t *cur_stack, void *data); /** * Given a stack, pop a level off and return a pointer to that level. * The user is responsible for extracting the data, but the stack_lvl_t * structures pointed to from the level (above and below) should be left * alone. */ stack_lvl_t *pop(faststack_t *s); /* this is for C++ */ #ifdef __cplusplus } #endif /** * Given a stack \a s, examine the data pointer at the top. */ #define top_data(s) (s->top->data) /** * Given a stack \a s, check to see if the stack is empty or not. Value * is boolean true or false. */ #define empty_stack(s) (s->top == NULL) #endif /* __FASTSTACK_H__ */ --- NEW FILE: .cvsignore --- .cvsignore .deps Makefile Makefile.in --- NEW FILE: io.c --- /** This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from LANL. **/ /** NOTICE: This software is licensed under the GNU Public License, which is included as LICENSE_GPL in this source distribution. **/ /** NOTE: This library is part of the supermon project, hence the name supermon above. **/ /*** * Matt's smaller s-expression parsing library * * Written by Matt Sottile (ma...@la...), January 2002. ***/ #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "sexp.h" #include <assert.h> /** * initialize an io-wrapper */ sexp_iowrap_t *init_iowrap(int fd) { sexp_iowrap_t *iow; iow = (sexp_iowrap_t *)malloc(sizeof(sexp_iowrap_t)); assert(iow != NULL); iow->cc = NULL; iow->fd = fd; iow->cnt = 0; return iow; } /** * */ void destroy_iowrap(sexp_iowrap_t *iow) { if (iow == NULL) return; /* idiot */ destroy_continuation(iow->cc); free(iow); } /** * */ sexp_t *read_one_sexp(sexp_iowrap_t *iow) { sexp_t *sx = NULL; if (iow->cnt == 0) { iow->cnt = read(iow->fd,iow->buf,BUFSIZ); if (iow->cnt == 0) return NULL; } iow->cc = cparse_sexp(iow->buf,iow->cnt,iow->cc); while (iow->cc->last_sexp == NULL) { if (iow->cc->error != 0) { fprintf(stderr,"ERROR\n"); return NULL; } iow->cnt = read(iow->fd,iow->buf,BUFSIZ); if (iow->cnt == 0) return NULL; iow->cc = cparse_sexp(iow->buf,iow->cnt,iow->cc); } sx = iow->cc->last_sexp; iow->cc->last_sexp = NULL; return sx; } --- NEW FILE: parser.c --- /** This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified [...1214 lines suppressed...] cc->val = val; cc->esc = esc; cc->squoted = squoted; cc->vcur = vcur; cc->val_allocated = val_allocated; cc->val_used = val_used; if (t[0] == '\0' || t == bufEnd) cc->lastPos = NULL; else cc->lastPos = t; cc->depth = depth; cc->qdepth = qdepth; cc->state = state; cc->stack = stack; cc->last_sexp = NULL; cc->error = 0; } return cc; } --- NEW FILE: sexp_ops.h --- /** This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from LANL. **/ /** NOTICE: This software is licensed under the GNU Public License, which is included as LICENSE_GPL in this source distribution. **/ /** NOTE: This library is part of the supermon project, hence the name supermon above. **/ #ifndef __SEXP_OPS_H__ #define __SEXP_OPS_H__ /** * \file sexp_ops.h * * \brief A collection of useful operations to perform on s-expressions. * * A set of routines for operating on s-expressions. Note that cons, * car, and cdr do <B>not</B> currently have any guarantee to behave in a * identical manner as their LISP or Scheme equivalents. This would be * fairly easy to fix, but not high on the priority list currently. */ #include "sexp.h" #ifdef __cplusplus extern "C" { #endif /*========*/ /* MACROS */ /*========*/ /** * Return the head of a list \a s by reference, not copy. */ #define hd_sexp(s) ((s)->list) /** * Return the tail of a list \a s by reference, not copy. */ #define tl_sexp(s) ((s)->list->next) /** * Return the element following the argument \a s. */ #define next_sexp(s) ((s)->next) /** * Reset the continuation \a c by setting the \c lastPos pointer to * \c NULL. */ #define reset_pcont(c) ((c)->lastPos = NULL) /** * Find an atom in a sexpression data structure and return a pointer to * it. Return NULL if the string doesn't occur anywhere as an atom. * This is a depth-first search algorithm. */ sexp_t *find_sexp(char *name, sexp_t *start); /** * Breadth first search for s-expressions. Depth first search will find * the first occurance of a string in an s-expression by basically finding * the earliest occurance in the string representation of the expression * itself. Breadth first search will find the first occurance of a string * in relation to the structure of the expression itself (IE: the instance * with the lowest depth will be found). */ sexp_t *bfs_find_sexp(char *str, sexp_t *sx); /** * Given an s-expression, determine the length of the list that it encodes. * A null expression has length 0. An atom has length 1. A list has * length equal to the number of sexp_t elements from the list head * to the end of the ->next linked list from that point. */ int sexp_list_length(sexp_t *sx); /** * Copy an s-expression. This is a deep copy - so the resulting s-expression * shares no pointers with the original. The new one can be changed without * damaging the contents of the original. */ sexp_t *copy_sexp(sexp_t *s); /** * Cons: Concatenate two s-expressions together, without references to the * originals. */ sexp_t *cons_sexp(sexp_t *r, sexp_t *l); /** * car: Like hd(), but returning a copy of the head, not a reference to it. */ sexp_t *car_sexp(sexp_t *s); /** * cdr: Like tl(), but returning a copy of the tail, not a reference to it. */ sexp_t *cdr_sexp(sexp_t *s); #ifdef __cplusplus } #endif #endif /* __SEXP_OPS_H__ */ --- NEW FILE: sexp.c --- /** This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from LANL. **/ /** NOTICE: This software is licensed under the GNU Public License, which is included as LICENSE_GPL in this source distribution. **/ /** NOTE: This library is part of the supermon project, hence the name supermon above. **/ /*** * Matt's smaller s-expression parsing library * * Written by Matt Sottile (ma...@la...), January 2002. ***/ #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "sexp.h" #include "faststack.h" /** * Recursively walk an s-expression and free it. */ void destroy_sexp (sexp_t * s) { if (s == NULL) return; if (s->ty == SEXP_LIST) destroy_sexp (s->list); if (s->ty == SEXP_VALUE && s->val != NULL) free(s->val); s->val = NULL; destroy_sexp (s->next); s->next = s->list = NULL; sexp_t_deallocate(s); } /** * Iterative method to walk sx and turn it back into the string * representation of the s-expression. Fills the buffer. */ int print_sexp (char *buf, int size, sexp_t * sx) { int retval; int sz; char *b = buf, *tc; int left = size; int depth = 0; faststack_t *stack; stack_lvl_t *top; sexp_t *tdata; sexp_t *fakehead; if (sx == NULL) { fprintf(stderr,"print_sexp: s-expression is null.\n"); return -1; } fakehead = sexp_t_allocate(); assert(fakehead!=NULL); /* duplicate the head to prevent going down a sx->next path that we don't really want to see. */ fakehead->list = sx->list; fakehead->ty = sx->ty; fakehead->next = NULL; /* this is the important part of fakehead */ fakehead->aty = sx->aty; if (fakehead->ty == SEXP_VALUE) { assert(sx->val != NULL); /* duplicate the head value into the fake head */ fakehead->val = (char *)malloc(sizeof(char)*sx->val_used); assert(fakehead->val != NULL); fakehead->val_used = fakehead->val_allocated = sx->val_used; strcpy(fakehead->val,sx->val); } if (size < 1) { fprintf (stderr, "Warning: print_sexp not provided sufficient space.\n"); return -1; } stack = make_stack (); push (stack, fakehead); while (stack->top != NULL) { top = stack->top; tdata = (sexp_t *) top->data; if (tdata == NULL) { pop (stack); if (depth > 0) { b[0] = ')'; b++; left--; depth--; if (left == 0) { fprintf (stderr, "Warning: print_sexp out of buffer space.\n"); break; } } if (stack->top == NULL) break; top = stack->top; top->data = ((sexp_t *) top->data)->next; if (top->data != NULL) { b[0] = ' '; b++; left--; if (left == 0) { fprintf (stderr, "Warning: print_sexp out of buffer space.\n"); break; } } } else if (tdata->ty == SEXP_VALUE) { if (tdata->aty == SEXP_DQUOTE) { b[0] = '\"'; b++; left--; } else if (tdata->aty == SEXP_SQUOTE) { b[0] = '\''; b++; left--; } if (tdata->aty != SEXP_BINARY) { assert(tdata->val != NULL); tc = tdata->val; /* copy value into string */ while (tc[0] != 0 && left > 0) { /* escape characters that need escaping. */ if ((tc[0] == '\"' || tc[0] == '\\') && tdata->aty == SEXP_DQUOTE) { b[0] = '\\'; b++; left--; if (left == 0) break; } b[0] = tc[0]; b++; tc++; left--; if (left == 0) break; } } else { if (left > 3) { b[0] = '#'; b[1] = 'b'; b[2] = '#'; b+=3; left-=3; if ((sz = snprintf(b,left,"%d#",tdata->binlength)) >= left) { left = 0; break; } b += sz; left -= sz; if (left < tdata->binlength) { left = 0; break; } memcpy(b,tdata->bindata,tdata->binlength); left -= tdata->binlength; b+=tdata->binlength; b[0] = ' '; left--; } else { left = 0; break; } } if (tdata->aty == SEXP_DQUOTE && left > 0) { b[0] = '\"'; b++; left--; } if (left < 0) left = 0; if (left == 0) { fprintf (stderr, "Warning: print_sexp out of buffer space.\n"); break; } top->data = ((sexp_t *) top->data)->next; if (top->data != NULL) { b[0] = ' '; b++; left--; if (left == 0) { fprintf (stderr, "Warning: print_sexp out of buffer space.\n"); break; } } } else if (tdata->ty == SEXP_LIST) { depth++; b[0] = '('; b++; left--; if (left == 0) { fprintf (stderr, "Warning: print_sexp out of buffer space.\n"); break; } push (stack, tdata->list); } else { fprintf (stderr, "ERROR: Unknown type in sexp_t.\n"); fflush (stderr); return -1; } } while (depth != 0) { b[0] = ')'; b++; left--; depth--; if (left == 0) { fprintf (stderr, "Warning: print_sexp out of buffer space.\n"); break; } } if (left != 0) { b[0] = 0; retval = (size-left); } else { b--; b[0] = 0; retval = -1; } destroy_stack (stack); sexp_t_deallocate(fakehead); return retval; } /** * Iterative method to walk sx and turn it back into the string * representation of the s-expression. Fills the buffer. */ int print_sexp_cstr (CSTRING **s, sexp_t *sx, int ss, int gs) { int retval; char *tc; int depth = 0; faststack_t *stack; stack_lvl_t *top; sexp_t *tdata; sexp_t *fakehead; CSTRING *_s; char sbuf[32]; int i; if (sx == NULL) { fprintf(stderr,"print_sexp_cstr warning: s-expression is null.\n"); return -1; } _s = snew(ss); sgrowsize(gs); fakehead = sexp_t_allocate(); assert(fakehead!=NULL); /* duplicate the head to prevent going down a sx->next path that we don't really want to see. */ fakehead->list = sx->list; fakehead->ty = sx->ty; fakehead->next = NULL; /* this is the important part of fakehead */ fakehead->aty = sx->aty; if (fakehead->ty == SEXP_VALUE) { assert(sx->val != NULL); /* duplicate the value of the head into the fake head */ fakehead->val = (char *)malloc(sizeof(char)*sx->val_used); assert(fakehead->val != NULL); fakehead->val_used = fakehead->val_allocated = sx->val_used; strcpy(fakehead->val,sx->val); } stack = make_stack (); push (stack, fakehead); while (stack->top != NULL) { top = stack->top; tdata = (sexp_t *) top->data; if (tdata == NULL) { pop (stack); if (depth > 0) { _s = saddch(_s, ')'); depth--; } if (stack->top == NULL) break; top = stack->top; top->data = ((sexp_t *) top->data)->next; if (top->data != NULL) { _s = saddch(_s, ' '); } } else if (tdata->ty == SEXP_VALUE) { if (tdata->aty == SEXP_DQUOTE) { _s = saddch(_s,'\"'); } else if (tdata->aty == SEXP_SQUOTE) { _s = saddch(_s,'\''); } if (tdata->aty == SEXP_BINARY) { assert(tdata->bindata != NULL); assert(tdata->binlength > 0); sprintf(sbuf,"#b#%d#",tdata->binlength); _s = sadd(_s,sbuf); for (i=0;i<tdata->binlength;i++) _s = saddch(_s,tdata->bindata[i]); _s = saddch(_s,' '); } else { assert(tdata->val != NULL); tc = tdata->val; /* copy value into string */ while (tc[0] != 0) { /* escape characters that need escaping. */ if ((tc[0] == '\"' || tc[0] == '\\') && tdata->aty == SEXP_DQUOTE) { _s = saddch(_s,'\\'); } _s = saddch(_s,tc[0]); tc++; } } if (tdata->aty == SEXP_DQUOTE) { _s = saddch(_s,'\"'); } top->data = ((sexp_t *) top->data)->next; if (top->data != NULL) { _s = saddch(_s,' '); } } else if (tdata->ty == SEXP_LIST) { depth++; _s = saddch(_s,'('); push (stack, tdata->list); } else { fprintf (stderr, "ERROR: Unknown type in sexp_t.\n"); fflush (stderr); return -1; } } while (depth != 0) { _s = saddch(_s,')'); depth--; } *s = _s; retval = _s->curlen; destroy_stack (stack); sexp_t_deallocate(fakehead); return retval; } /** * Allocate a new sexp_t element representing a list. */ sexp_t *new_sexp_list(sexp_t *l) { sexp_t *sx = sexp_t_allocate(); sx->ty = SEXP_LIST; sx->list = l; sx->next = NULL; sx->val = NULL; sx->val_used = sx->val_allocated = 0; return sx; } /** * allocate a new sexp_t element representing a value */ sexp_t *new_sexp_atom(char *buf, int bs) { sexp_t *sx = sexp_t_allocate(); sx->ty = SEXP_VALUE; sx->val = (char *)malloc(sizeof(char)*(bs+1)); assert(sx->val != NULL); sx->val_used = sx->val_allocated = bs+1; strcpy(sx->val,buf); sx->list = sx->next = NULL; return sx; } --- NEW FILE: malloc_util.h --- /** * malloc_util.h : malloc debugging routines * * written by erik a. hendriks (hen...@la...). * * Copyright 2002 Erik Arjan Hendriks. * This software may be used and distributed according to the terms of the * GNU Public License, incorporated herein by reference. */ #ifndef _MALLOC_UTIL_H_ #define _MALLOC_UTIL_H_ #include <sys/types.h> /*-- Memory debugging stuff --*/ void x_init_alloc(void); void x_check_point_count(void); void x_inc_check_point(void); void *x_malloc(char *, int, size_t); void x_free (char *, int, void *); char *x_strdup(char *, int, char *); #ifdef _DEBUG_MALLOCS_ #define malloc(x) x_malloc(__FILE__, __LINE__, (x)) #define safe_malloc(x) x_malloc(__FILE__, __LINE__, (x)) #define free(x) x_free (__FILE__, __LINE__, (x)) #define strdup(x) x_strdup(__FILE__, __LINE__, (x)) #endif #endif --- NEW FILE: faststack.c --- /** This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from LANL. **/ /** NOTICE: This software is licensed under the GNU Public License, which is included as LICENSE_GPL in this source distribution. **/ /** NOTE: This library is part of the supermon project, hence the name supermon above. **/ /** * faststack.c : implementation of fast stack. * * matt sottile / ma...@la... */ #include <stdlib.h> #include <stdio.h> #include "faststack.h" #include "sexp.h" /** * create an empty stack. */ faststack_t * make_stack () { faststack_t *s; s = (faststack_t *) malloc (sizeof (faststack_t)); s->top = NULL; s->bottom = NULL; s->height = 0; return s; } /** * free all levels of a stack */ void destroy_stack (faststack_t * s) { stack_lvl_t *sl; /* start at the bottom */ sl = s->bottom; /* if bottom is null, no levels to free. */ if (sl == NULL) return; /* go up to the top of the allocated stack */ while (sl->above != NULL) sl = sl->above; /* until we get to the bottom (where below is null), free the data at each level and the level itself. */ while (sl->below != NULL) { sl = sl->below; free (sl->above); } /* free the bottom level */ free (sl); /* free the stack wrapper itself. */ free (s); } /** * push a level onto the cur_stack. reuse levels that have * been previously allocated, allocate a new one if none * are available. */ faststack_t * push (faststack_t * cur_stack, void *data) { stack_lvl_t *top = cur_stack->top; stack_lvl_t *tmp; /* if top isn't null, try to push above it. */ if (top != NULL) { /* if above isn't null, set the stack top to it and set the data */ if (top->above != NULL) { top = cur_stack->top = cur_stack->top->above; top->data = data; } else { /* otherwise, allocate a new level. */ tmp = top->above = (stack_lvl_t *) malloc (sizeof (stack_lvl_t)); tmp->below = cur_stack->top; tmp->above = NULL; cur_stack->top = tmp; tmp->data = data; } } else { if (cur_stack->bottom != NULL) { cur_stack->top = cur_stack->bottom; cur_stack->top->data = data; } else { tmp = cur_stack->top = (stack_lvl_t *) malloc (sizeof (stack_lvl_t)); cur_stack->bottom = tmp; tmp->above = NULL; tmp->below = NULL; tmp->data = data; } } cur_stack->height++; return cur_stack; } /** * pop the top of the stack, return the stack level that was * popped of. */ stack_lvl_t * pop (faststack_t * s) { stack_lvl_t *top; top = s->top; /* if stack top isn't null, set the top pointer to the next level down and return the old top. */ if (top != NULL && s->height > 0) { s->top = s->top->below; s->height--; } else { fprintf(stderr,"STACK: non-null top, but height < 0!\n"); } return top; } --- NEW FILE: sexp.h --- /** This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from LANL. **/ /** NOTICE: This software is licensed under the GNU Public License, which is included as LICENSE_GPL in this source distribution. **/ /** NOTE: This library is part of the supermon project, hence the name supermon above. **/ #ifndef __SEXP_H__ #define __SEXP_H__ #include <stdio.h> /* for BUFSIZ only */ #include "faststack.h" #include "cstring.h" /** ** though unlikely to affect performance based on some simple tests ** run recently, this is available for people who wish to disable ** assertion paranoia. beware: if your code has assert() used in it ** and you don't want THOSE assertions disabled, #include <assert.h> ** after the last place sexp.h is included. I put this here to ** avoid the annoyance of "#ifdef .." messes around each assert() **/ #ifdef _NOASSERTS_ #undef assert #define assert(x) { } #endif /** * \mainpage A small and quick S-expression parsing library. * * \section intro Intro * * This library was created to provide s-expression parsing and manipulation * facilities to C and C++ programs. The primary goals were speed and * efficiency - low memory impact, and the highest speed we could achieve in * parsing. Suprisingly, no other libraries on the net were found that * were not bloated with features or involved embedding a full-fledged * LISP or Scheme interpreter into our programs. So, this library evolved * to fill this gap. As such, it does not guarantee that every valid LISP * expression is parseable (although every parseable expression is valid LISP), * and many features that are not required aren't implemented. See Rivest's * S-expression library for an example of a much more featureful library. * * What features does this library include? At the heart of the code is a * continuation-based parser implementing a basic state machine. Continuations * allow users to accumulate multiple streams of characters, and parse * each stream simultaneously. A continuation allows the parser to stop * midstream, start working on a new expression, and return to the first * without corruption of complex state management in the users code. No * threads, no forking, nothing more than a data structure that must be passed * in and captured as data becomes available to parse. Once an expression * has been parsed, a simple structure is returned that represents * the "abstract syntax tree" of the parsed expression. For the majority * of users, the parser and this data structure will be all that they will * ever need to see. For convenience reasons, other functions such as I/O * wrappers and AST traversal routines have been included, but they are * not required if users don't wish to use them. * * \section performance Performance Results * * The standard benchmark to compare versions of this parser has been the * "torture.c" file included in the tests/ subdirectory. This file takes * a large s-expression via STDIN, and parses, unparses, and destroys it * 1,000 times. The following numbers reflect tests done on a * representative expression from Supermon, the tool that this code was * created for. * * - <B>v0.1.1</B> : 1.61s * - <B>v0.1.2</B> : 1.12s * - <B>v0.2.0</B> : 1.07s * - <B>v0.2.1</B> : 1.09s * - <B>v0.2.2</B> : 1.09s * - <B>v0.2.3</B> : 1.11s * - <B>v0.3.0</B> : 0.42s * - <B>v0.3.1</B> : ?.??s * - <B>v0.3.2</B> : ?.??s * * \section license License Information * * This software and ancillary information (herein called "SOFTWARE") * called Supermon is made available under the terms described * here. The SOFTWARE has been approved for release with associated * LA-CC Number LA-CC 99-51. * * Unless otherwise indicated, this SOFTWARE has been authored by an * employee or employees of the University of California, operator of the * Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with * the U.S. Department of Energy. The U.S. Government has rights to use, * reproduce, and distribute this SOFTWARE, and to allow others to do so. * The public may copy, distribute, prepare derivative works and publicly * display this SOFTWARE without charge, provided that this Notice and * any statement of authorship are reproduced on all copies. Neither the * Government nor the University makes any warranty, express or implied, * or assumes any liability or responsibility for the use of this * SOFTWARE. * * If SOFTWARE is modified to produce derivative works, such modified * SOFTWARE should be clearly marked, so as not to confuse it with the * version available from LANL. * * This software is licensed under the GNU Public License, which * is included as LICENSE_GPL in this source distribution. * * This library is part of the Supermon project, hence the name * "Supermon" above. See http://www.acl.lanl.gov/supermon/ for details on * that project. */ /** * \file sexp.h * * \brief API for a small, fast and portable s-expression parser library. * * Written by Matt Sottile (ma...@la...), January 2002. See LICENSE * file for licensing details. */ /*==============*/ /* ENUMERATIONS */ /*==============*/ /** * An element in an s-expression can be one of three types: a <i>value</i> * represents an atom with an associated text value. A <i>list</i> * represents an s-expression, and the element contains a pointer to * the head element of the associated s-expression. */ typedef enum { /** * An atom of some type. See atom type (aty) field of element structure * for details as to which atom type this is. */ SEXP_VALUE, /** * A list. This means the element points to an element representing the * head of a list. */ SEXP_LIST } elt_t; /** * For an element that represents a value, the value can be interpreted * as a more specific type. A <i>basic</i> value is a simple string with * no whitespace (and therefore no quotes required). A <i>double quote</i> * value, or <i>dquote</i>, is one that contains characters (such as * whitespace) that requires quotation marks to contain the string. A * <i>single quote</i> value, or <i>squote</i>, represents an element that is * prefaced with a single tick-mark. This can be either an atom or * s-expression, and the result is that the parser does not attempt to parse * the element following the tick mark. It is simply stored as text. This * is similar to the meaning of a tick mark in the Scheme or LISP family * of programming languages. */ typedef enum { /** * Basic, unquoted value. */ SEXP_BASIC, /** * Single quote (tick-mark) value - contains a string representing * a non-parsed portion of the s-expression. */ SEXP_SQUOTE, /** * Double-quoted string. Similar to a basic value, but potentially * containing white-space. */ SEXP_DQUOTE, /** * Binary data. This is used when the specialized parser is active * and supports inlining of binary blobs of data inside an expression. */ SEXP_BINARY } atom_t; /*============*/ /* STRUCTURES */ /*============*/ /** * An s-expression is represented as a linked structure of elements, * where each element is either an <I>atom</I> or <I>list</I>. An * atom corresponds to a string, while a list corresponds to an * s-expression. The following grammar represents our definition of * an s-expression:<P> * * <pre> * sexpr ::= ( sx ) * sx ::= atom sxtail | sexpr sxtail | 'sexpr sxtail | 'atom sxtail | NULL * sxtail ::= sx | NULL * atom ::= quoted | value * quoted ::= "ws_string" * value ::= nws_string * </pre> * <P> * * An atom can either be a quoted string, which is a string containing * whitespace (possibly) surrounded by double quotes, or a non-whitespace * string that does not require surrounding quotes. An element representing * an atom will have a type of <i>value</i> and data stored in the <i>val</i> * field. An element of type <i>list</i> represents an s-expression * corresponding to <i>sexpr</i> in the grammar, and will have a pointer to * the head of the appropriate s-expression. Details regarding these fields * and their values given with the fields themselves. Notice that a single * quote can appear directly before an s-expression or atom, similar to the * use in LISP. */ typedef struct elt { /** * The element has a type that determines how the structure is used. If * the type is <B>SEXP_VALUE</B>, then a programmer knows that the val field * is meaningful and contains the data associated with this element of the * s-expression. If the type is <B>SEXP_LIST</B>, then the list field * contains a pointer to the s-expression element representing the head of * the list. For each case, the field for the opposite case contains no * meaningful data and using them in any way is likely to cause an error. */ elt_t ty; /** * If the type of the element is <B>SEXP_VALUE</B> this field will contain * the actual data represented by this element. */ char *val; /** * Number of bytes allocated for val. */ int val_allocated; /** * Number of bytes used in val (<= val_allocated). */ int val_used; /** * If the type of the element is <B>SEXP_LIST</B>, this field will contain * a pointer to the head element of the list. */ struct elt *list; /** * The <I>next</I> field is a pointer to the next element in the current * expression. If this element is the last element in the s-expression, * this field will be <I>NULL</I>. */ struct elt *next; /** * For elements that represent <I>values</I>, this field will specify the * specific type of value that it represents. This can be used by * functions to determine how this value should be printed (ie: how it * should be quoted) or interpreted (ie: interpreting s-expressions that * are prefixed with a tick-mark.). */ atom_t aty; /** * For elements that represent <i>binary</I> blobs, this field will * point to a memory location where the data resides. The length * of this memory blob is the next field. char* implies byte sized * elements. */ char *bindata; /** * The length of the data pointed at by bindata in bytes. */ unsigned int binlength; } sexp_t; /** * parser mode flag used by continuation to toggle special parser * behaviour. */ typedef enum { /** * normal (LISP-style) s-expression parser behaviour. */ PARSER_NORMAL, /** * treat atoms beginning with #b# as inlined binary data. everything * else is treated the same as in PARSER_NORMAL mode. */ PARSER_INLINE_BINARY } parsermode_t; /** * A continuation is used by the parser to save and restore state between * invocations to support partial parsing of strings. For example, if we * pass the string "(foo bar)(goo car)" to the parser, we want to be able * to retrieve each s-expression one at a time - it would be difficult to * return all s-expressions at once without knowing how many there are in * advance (this would require more memory management than we want...). * So, by using a continuation-based parser, we can call it with this string * and have it return a continuation when it has parsed the first * s-expression. Once we have processed the s-expression (accessible * through the <i>last_sexpr</i> field of the continuation), we can call * the parser again with the same string and continuation, and it will be * able to pick up where it left off.<P> * * We use continuations instead of a state-ful parser to allow multiple * concurrent strings to be parsed by simply maintaining a set of * continuations. Manipulating continuations by hand is required if the * continuation-based parser is called directly. This is <b>not * recommended</b> unless you are willing to deal with potential errors and * are willing to learn exactly how the continuation relates to the * internals of the parser. A simpler approach is to use either the * <i>parse_sexp</i> function that simply returns an s-expression without * exposing the continuations, or the <i>iparse_sexp</i> function that * allows iteratively popping one s-expression at a time from a string * containing one or more s-expressions. Refer to the documentation for * each parsing function for further details on behavior and usage. */ typedef struct pcont { /** * The parser stack used for iterative parsing. */ faststack_t *stack; /** * The last full s-expression encountered by the parser. If this is * NULL, the parser has not encountered a full s-expression and more * data is required for the current s-expression being parsed. If this * is non-NULL, then the parser has encountered one s-expression and may * be partially through parsing the next s-expression. */ sexp_t *last_sexp; /** * Pointer to a temporary buffer used to store atom values during parsing. */ char *val; /** * Current number of bytes allocated for val. */ int val_allocated; /** * Current number of used bytes in val. */ int val_used; /** * Pointer to the character following the last character in the current * atom value being parsed. */ char *vcur; /** * Pointer to the last character to examine in the string being parsed. * When the parser is called with the continuation, this is the first * character that will be processed. If this is NULL, the parser will * start parsing at the beginning of the string passed into the parser. */ char *lastPos; /** * This is a pointer to the beginning of the current string being * processed. lastPos is a pointer to some value inside the string * that this points to. */ char *sbuffer; /** * This is the depth of parenthesis (the number of left parens encountered) * that the parser is currently working with. */ unsigned int depth; /** * This is the depth of parenthesis encountered after a single quote (tick) * if the character immediately following the tick was a left paren. */ unsigned int qdepth; /** * This is the state ID of the current state of the parser in the * DFA representing the parser. The current parser is a DFA based parser * to simplify restoring the proper state from a continuation. */ unsigned int state; /** * This is a flag indicating whether the next character to be processed * should be assumed to have been prefaced with a '\' character to escape * it. */ unsigned int esc; /** * Flag whether or not we are processing an atom that was preceeded by * a single quote. */ unsigned int squoted; /** * Error code. Used to indicate that the continuation being returned does * not represent a successful parsing and thus the contents aren't of much * value. If this value is 0, no error occurred. Otherwise, it will be 1. */ unsigned int error; /** * Mode. The parsers' specialized behaviours can be activated by * tweaking the mode setting. There are currently two available: * normal and inline_binary. Inline_binary treats atoms that start * with #b# specially, assuming that they have the structure: * * #b#s#data * * Where s is a positive (greater than 0) integer representing the length * of the data, and data is s bytes of binary data following the # * sign. After the s bytes, it is assumed normal s-expression data * continues. */ parsermode_t mode; /* ----------------------------------------------------------------- * These fields below are related to dealing with INLINE_BINARY mode * ----------------------------------------------------------------- */ /** * Length to expect of the current binary data being read in. * this also corresponds to the size of the memory allocated for * reading this binary data into. */ unsigned int binexpected; /** * Number of bytes of the binary blob that have already been read in. */ unsigned int binread; /** * Pointer to the memory containing the binary data being read in. */ char *bindata; } pcont_t; /** * This structure is a wrapper around a standard I/O file descriptor and * the parsing infrastructure (continuation and a buffer) required to * parse off of it. This is used so that routines can hide the loops and * details required to accumulate up data read off of the file descriptor * and parse expressions individually out of it. */ typedef struct sexp_iowrap { /** * Continuation used to parse off of the file descriptor. */ pcont_t *cc; /** * The file descriptor. Currently CANNOT be a socket since implementation * uses read(), not recv(). */ int fd; /** * Buffer to read data into before parsing. */ char buf[BUFSIZ]; /** * Byte count for last read. If it is -1, there was an error. Otherwise, * it will be a value from 0 to BUFSIZ. */ int cnt; } sexp_iowrap_t; /*===========*/ /* FUNCTIONS */ /*===========*/ /* this is for C++ users */ #ifdef __cplusplus extern "C" { #endif /** * Set the parameters on atom value buffer allocation and growth sizes. * This is an important point for performance tuning, as many factors in * the expected expression structure must be taken into account such as: * * - Average size of atom values * - Variance in sizes of atom values * - Amount of memory that is tolerably ''wasted'' (allocated but not * used) * * The \a ss parameter specifies the initial size of all atom buffers. * Ideally, this should be sufficiently large to capture MOST atom values, * or at least close enough such that one growth is required. The * \a gs parameter specifies the number of bytes to increase the buffer size * by when space is exhausted. A safe choice for parameter sizes would * be on the order of the average size for \a ss, and one standard * deviation for \a gs. This ensures that 50% of all expressions are * guaranteed to fit in the initial buffer, and rougly 80-90% will fit in * one growth. If memory is not an issue, choosing ss to be the mean plus * one standard deviation will capture 80-90% of expressions in the initial * buffer, and a gs of one standard deviation will capture nearly all * expressions. * * Note: These parameters can be tuned at runtime as needs change, and they * will be applied to all expressions and expression elements parsed after * they are modified. They will not be applied retroactively to expressions * that have already been parsed. */ void set_parser_buffer_params(int ss, int gs); /** * return an allocated sexp_t. This structure may be an already allocated * one from the stack or a new one if none are available. Use this instead * of manually mallocing if you want to avoid excessive mallocs. <I>Note: * Mallocing your own expressions is fine - you can even use * sexp_t_deallocate to deallocate them and put them in the pool.</I> * Also, if the stack has not been initialized yet, this does so. */ sexp_t *sexp_t_allocate(); /** * given a malloc'd sexp_t element, put it back into the already-allocated * element stack. This method will allocate a stack if one has not been * allocated already. */ void sexp_t_deallocate(sexp_t *s); /** * In the event that someone wants us to release ALL of the memory used * between calls by the library, they can free it. If you don't call * this, the caches will be persistent for the lifetime of the library * user. */ void sexp_cleanup(); /** * print a sexp_t struct as a string in the LISP style. If the buffer * is large enough and the conversion is successful, the return value * represents the length of the string contained in the buffer. If the * buffer was too small, or some other error occurred, the return * value is -1 and the contents of the buffer should not be assumed to * contain any useful information. */ int print_sexp(char *loc, int size, sexp_t *e); /** * print a sexp_t structure to a buffer, growing it as necessary instead * of relying on fixed size buffers like print_sexp. Important arguments * to tune for performance reasons are <tt>ss</tt> and <tt>gs</tt> - the * buffer start size and growth size. */ int print_sexp_cstr(CSTRING **s, sexp_t *e, int ss, int gs); /** * Allocate a new sexp_t element representing a list. */ sexp_t *new_sexp_list(sexp_t *l); /** * allocate a new sexp_t element representing a value */ sexp_t *new_sexp_atom(char *buf, int bs); /** * create an initial continuation for parsing the given string */ pcont_t *init_continuation(char *str); /** * destroy a continuation. This involves cleaning up what it contains, * and cleaning up the continuation itself. */ void destroy_continuation (pcont_t * pc); /** * create an IO wrapper structure around a file descriptor. */ sexp_iowrap_t *init_iowrap(int fd); /** * destroy an IO wrapper structure */ void destroy_iowrap(sexp_iowrap_t *iow); /** * given and IO wrapper handle, read one s-expression off of it. this * expression may be contained in a continuation, so there is no * guarantee that under the covers an IO read actually is occuring. * returning null implies no s-expression was able to be read. */ sexp_t *read_one_sexp(sexp_iowrap_t *iow); /** * wrapper around parser for compatibility. */ sexp_t *parse_sexp(char *s, int len); /** * wrapper around parser for friendlier continuation use * pre-condition : continuation (cc) is NON-NULL! */ sexp_t *iparse_sexp(char *s, int len, pcont_t *cc); /** * given a LISP style s-expression string, parse it into a set of * connected sexp_t structures. */ pcont_t *cparse_sexp(char *s, int len, pcont_t *pc); /** * given a sexp_t structure, free the memory it uses (and recursively free * the memory used by all sexp_t structures that it references). Note * that this will call the deallocation routine for sexp_t elements. * This means that memory isn't freed, but stored away in a cache of * pre-allocated elements. This is an optimization to speed up the * parser to eliminate wasteful free and re-malloc calls. */ void destroy_sexp(sexp_t *s); /* this is for C++ users */ #ifdef __cplusplus } #endif #include "sexp_ops.h" #endif /* __SEXP_H__ */ --- NEW FILE: cstring.c --- /* ACL:license */ /* This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from LANL. */ /* ACL:license */ /** * Implementation of stuff in cstring.h to make ron happy */ #include "cstring.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> /** * growth size for cstrings -- default is 8k. use sgrowsize() to adjust. */ static size_t cstring_growsize = 8192; void sgrowsize(size_t s) { assert(s > 0); cstring_growsize = s; } CSTRING *snew(size_t s) { CSTRING *cs; cs = (CSTRING *)malloc(sizeof(CSTRING)); assert(cs != NULL); cs->len = s; cs->curlen = 0; cs->base = (char *)calloc(sizeof(char),s); assert(cs->base != NULL); return cs; } CSTRING *sadd(CSTRING *s, char *a) { int alen; char *newbase; /* no string, so bail */ if (s == NULL) { return NULL; } /* nothing to add, return s */ if (a == NULL) { return s; } alen = strlen(a); if (s->curlen + alen >= s->len) { newbase = (char *)realloc(s->base,s->len+cstring_growsize+alen); if (! newbase) { perror("realloc string"); s->len = s->curlen = 0; s->base = 0; return 0; } s->len += cstring_growsize + alen; s->base = newbase; } memcpy(&s->base[s->curlen],a,alen); s->curlen += alen; s->base[s->curlen] = 0; return s; } CSTRING *saddch(CSTRING *s, char a) { char *newbase; if (s == NULL) { return NULL; } if (s->curlen + 1 >= s->len) { newbase = (char *)realloc(s->base,s->len+cstring_growsize+1); if (! newbase) { perror("realloc string"); s->len = s->curlen = 0; s->base = 0; return 0; } s->len += cstring_growsize+1; s->base = newbase; } s->base[s->curlen] = a; s->curlen++; s->base[s->curlen] = 0; return s; } CSTRING *strim(CSTRING *s) { char *newbase; if (s == NULL) { return NULL; } /* no trimming necessary? */ if (s->len == s->curlen+1) { return s; } newbase = (char *)realloc(s->base,s->curlen+1); if (!newbase) { perror("realloc string in trim"); s->len = s->curlen = 0; s->base = 0; return NULL; } s->len = s->curlen+1; s->base = newbase; return s; } char *toCharPtr(CSTRING *s) { return s->base; } void sempty(CSTRING *s) { s->curlen = 0; } void sdestroy(CSTRING *s) { free(s->base); free(s); } --- NEW FILE: sexp_ops.c --- /** This software and ancillary information (herein called "SOFTWARE") called Supermon is made available under the terms described here. The SOFTWARE has been approved for release with associated LA-CC Number LA-CC 99-51. Unless otherwise indicated, this SOFTWARE has been authored by an employee or employees of the University of California, operator of the Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The U.S. Government has rights to use, reproduce, and distribute this SOFTWARE, and to allow others to do so. The public may copy, distribute, prepare derivative works and publicly display this SOFTWARE without charge, provided that this Notice and any statement of authorship are reproduced on all copies. Neither the Government nor the University makes any warranty, express or implied, or assumes any liability or responsibility for the use of this SOFTWARE. If SOFTWARE is modified to produce derivative works, such modified SOFTWARE should be clearly marked, so as not to confuse it with the version available from LANL. **/ /** NOTICE: This software is licensed under the GNU Public License, which is included as LICENSE_GPL in this source distribution. **/ /** NOTE: This library is part of the supermon project, hence the name supermon above. **/ #include <assert.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "sexp_ops.h" /** * Given an s-expression, find the atom inside of it with the * value matchine name, and return a reference to it. If the atom * doesn't occur inside start, return NULL. */ sexp_t * find_sexp (char *name, sexp_t * start) { sexp_t *temp; if (start == NULL) return NULL; if (start->ty == SEXP_LIST) { temp = find_sexp (name, start->list); if (temp == NULL) return find_sexp (name, start->next); else return temp; } else { assert(start->val != NULL); if (strcmp (start->val, name) == 0) return start; else return find_sexp (name, start->next); } return NULL; /* shouldn't get here */ } /** * Breadth first search - look at ->next before ->list when seeing list * elements of an expression. */ sexp_t *bfs_find_sexp(char *str, sexp_t *sx) { sexp_t *t = sx; sexp_t *rt; if (sx == NULL) return NULL; while (t != NULL) { if (t->ty == SEXP_VALUE) { assert(t->val != NULL); if (strcmp(t->val,str) == 0) { return t; } } t = t->next; } t = sx; while (t != NULL) { if (t->ty == SEXP_LIST) { rt = bfs_find_sexp(str,t->list); if (rt != NULL) return rt; } t = t->next; } return NULL; } /** * Give the length of a s-expression list. */ int sexp_list_length(sexp_t *sx) { int len = 0; sexp_t *t; if (sx == NULL) return 0; if (sx->ty == SEXP_VALUE) return 1; t = sx->list; while (t != NULL) { len++; t = t->next; } return len; } /** * Copy an s-expression. */ sexp_t *copy_sexp(sexp_t *s) { sexp_t *snew; if (s == NULL) return NULL; snew = sexp_t_allocate(); assert(snew != NULL); snew->ty = s->ty; if (snew->ty == SEXP_VALUE) { snew->aty = s->aty; assert(s->val != NULL); /** allocate space **/ snew->val = (char *)malloc(sizeof(char)*s->val_used); assert(snew->val != NULL); snew->val_used = snew->val_allocated = s->val_used; strcpy(snew->val,s->val); snew->list = NULL; } else { snew->list = copy_sexp(s->list); } snew->next = copy_sexp(s->next); return snew; } /** * Cons: Concatenate two s-expressions together, without references to the * originals. */ sexp_t *cons_sexp(sexp_t *r, sexp_t *l) { sexp_t *cr, *cl, *t; cr = copy_sexp(r); if (cr->ty == SEXP_VALUE) { fprintf(stderr,"Cannot cons non-lists.\n"); destroy_sexp(cr); return NULL; } else { t = cr->list; while (t != NULL && t->next != NULL) t = t->next; } cl = copy_sexp(l); if (cl->ty == SEXP_LIST) { if (t != NULL && cl != NULL) { t->next = cl->list; /* free(cl); */ /* memory leak fix: SMJ, 4/24/2002 */ sexp_t_deallocate(cl); } } else { fprintf(stderr,"Cannot cons non-lists.\n"); destroy_sexp(cr); destroy_sexp(cl); return NULL; } return cr; } /** * car: similar to head, except this is a copy and not just a reference. */ sexp_t *car_sexp(sexp_t *s) { sexp_t *cr, *ocr; /* really dumb - calling on null */ if (s == NULL) { fprintf(stderr,"car called on null sexpr.\n"); return NULL; } /* less dumb - calling on an atom */ if (s->ty == SEXP_VALUE) { fprintf(stderr,"car called on an atom.\n"); return NULL; } /* ocr = (sexp_t *)malloc(sizeof(sexp_t));*/ ocr = sexp_t_allocate(); assert(ocr != NULL); ocr->ty = SEXP_LIST; ocr->next = NULL; /* allocate the new sexp_t */ /* cr = (sexp_t *)malloc(sizeof(sexp_t)); */ cr = sexp_t_allocate(); assert(cr != NULL); ocr->list = cr; /* copy the head of the sexpr */ if (s->list->ty == ... [truncated message content] |
From: Markus R. <rol...@us...> - 2005-12-19 19:11:11
|
Update of /cvsroot/simspark/simspark/spark/utility/glextgen/script In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23707/script Log Message: Directory /cvsroot/simspark/simspark/spark/utility/glextgen/script added to the repository |
From: Markus R. <rol...@us...> - 2005-12-19 19:11:11
|
Update of /cvsroot/simspark/simspark/spark/utility/glextgen/tocopy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23707/tocopy Log Message: Directory /cvsroot/simspark/simspark/spark/utility/glextgen/tocopy added to the repository |
From: Markus R. <rol...@us...> - 2005-12-19 19:10:22
|
Update of /cvsroot/simspark/simspark/spark/utility/sfsexp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22898/sfsexp Log Message: Directory /cvsroot/simspark/simspark/spark/utility/sfsexp added to the repository |
From: Markus R. <rol...@us...> - 2005-12-19 19:10:22
|
Update of /cvsroot/simspark/simspark/spark/utility/libobj In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22898/libobj Log Message: Directory /cvsroot/simspark/simspark/spark/utility/libobj added to the repository |
From: Markus R. <rol...@us...> - 2005-12-19 19:10:21
|
Update of /cvsroot/simspark/simspark/spark/utility/rcssnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22898/rcssnet Log Message: Directory /cvsroot/simspark/simspark/spark/utility/rcssnet added to the repository |
From: Markus R. <rol...@us...> - 2005-12-19 19:10:20
|
Update of /cvsroot/simspark/simspark/spark/utility/glextgen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22898/glextgen Log Message: Directory /cvsroot/simspark/simspark/spark/utility/glextgen added to the repository |
From: Markus R. <rol...@us...> - 2005-12-19 19:04:47
|
Update of /cvsroot/simspark/simspark/spark/utility In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21164/utility Log Message: Directory /cvsroot/simspark/simspark/spark/utility added to the repository |
From: Markus R. <rol...@us...> - 2005-12-19 19:00:11
|
Update of /cvsroot/simspark/simspark/spark/config.aux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19388/config.aux Log Message: Directory /cvsroot/simspark/simspark/spark/config.aux added to the repository |
From: Markus R. <rol...@us...> - 2005-12-18 18:07:19
|
Update of /cvsroot/simspark/simspark/spark/oxygen/physicsserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8502 Modified Files: joint.cpp Log Message: - removed duplicate newline in debug output Index: joint.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/joint.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** joint.cpp 18 Dec 2005 11:10:09 -0000 1.2 --- joint.cpp 18 Dec 2005 18:07:10 -0000 1.3 *************** *** 117,121 **** GetLog()->Debug() << "(Joint) Attaching '" << path1 << "' to '" ! << path2 << "'\n" << std::endl; dJointAttach(mODEJoint, id1, id2); --- 117,121 ---- GetLog()->Debug() << "(Joint) Attaching '" << path1 << "' to '" ! << path2 << '\n'; dJointAttach(mODEJoint, id1, id2); |
From: Markus R. <rol...@us...> - 2005-12-18 17:54:09
|
Update of /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5320 Modified Files: rubysceneimporter.cpp rubysceneimporter.h Log Message: - changed RubySceneImporter to defer method calls on Nodes until after the Scene is completely setup. Methods that the Transform node supports are carried out immediately (most import SetName). Other defered methods, like the 'attach' call on Joint nodes can therefore now reference nodes that were not constructed when the call is parsed. Index: rubysceneimporter.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter/rubysceneimporter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rubysceneimporter.h 13 Dec 2005 21:48:50 -0000 1.1 --- rubysceneimporter.h 18 Dec 2005 17:53:56 -0000 1.2 *************** *** 33,36 **** --- 33,46 ---- typedef std::map<std::string, int> TParameterMap; + //! defines a method invocation + struct MethodInvocation + { + boost::weak_ptr<zeitgeist::Node> node; + std::string method; + zeitgeist::ParameterList parameter; + }; + + typedef std::list<MethodInvocation> TMethodInvocationList; + //! a parameter environment struct ParamEnv *************** *** 38,41 **** --- 48,52 ---- TParameterMap parameterMap; boost::shared_ptr<zeitgeist::ParameterList> parameter; + TMethodInvocationList invocationList; ParamEnv(); *************** *** 75,79 **** --- 86,95 ---- bool ReadDeltaGraph(sexp_t* sexp, boost::shared_ptr<oxygen::BaseNode> root); boost::shared_ptr<zeitgeist::Object> CreateInstance(const std::string& className); + + void PushInvocation(const MethodInvocation& invoc); + bool Invoke(const MethodInvocation& invoc); + bool InvokeMethods(); bool ReadMethodCall(sexp_t* _sexp, boost::shared_ptr<oxygen::BaseNode> node); + bool ReplaceVariable(std::string& param); bool EvalParameter(sexp_t* sexp, std::string& value); Index: rubysceneimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter/rubysceneimporter.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rubysceneimporter.cpp 13 Dec 2005 21:48:50 -0000 1.1 --- rubysceneimporter.cpp 18 Dec 2005 17:53:56 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- #include <zeitgeist/fileserver/fileserver.h> #include <zeitgeist/scriptserver/scriptserver.h> + #include <oxygen/sceneserver/transform.h> #include <boost/scoped_array.hpp> *************** *** 55,58 **** --- 56,71 ---- */ + #define S_NODE "node" + #define S_SELECT "select" + #define S_PWD "pwd" + #define S_TEMPLATE "template" + #define S_DEFINE "define" + #define S_ATTACH "attach" + + #define S_DELTASCENE "RubyDeltaScene" + #define S_SCENEGRAPH "RubySceneGraph" + + #define S_FROMSTRING "<from string>"; + RubySceneImporter::RubySceneImporter() : SceneImporter() { *************** *** 100,104 **** shared_ptr<ParameterList> parameter) { ! mFileName = "<from string>"; return ParseScene(scene.c_str(),scene.size(),root,parameter); } --- 113,117 ---- shared_ptr<ParameterList> parameter) { ! mFileName = S_FROMSTRING; return ParseScene(scene.c_str(),scene.size(),root,parameter); } *************** *** 146,149 **** --- 159,163 ---- destroy_continuation(pcont); + InvokeMethods(); PopParameter(); return ok; *************** *** 204,211 **** mDeltaScene = false; ! if (val == "RubyDeltaScene") { mDeltaScene = true; ! } else if (val != "RubySceneGraph") { return false; --- 218,225 ---- mDeltaScene = false; ! if (val == S_DELTASCENE) { mDeltaScene = true; ! } else if (val != S_SCENEGRAPH) { return false; *************** *** 446,449 **** --- 460,540 ---- } + void RubySceneImporter::PushInvocation(const MethodInvocation& invoc) + { + shared_ptr<Class> baseNodeClass = + shared_dynamic_cast<Class>(GetCore()->Get("/classes/oxygen/Transform")); + + if (baseNodeClass.get() == 0) + { + GetLog()->Error() + << "(RubySceneImporter) ERROR: failed to get class object for Transform\n"; + return; + } + + if (baseNodeClass->SupportsCommand(invoc.method)) + { + // invoke basic methods, i.e. methods already supported by + // Transform immediately (e.g. setName, setLocalPos etc.) + Invoke(invoc); + } else + { + // defer methods on other nodes, to allow for forward + // references to nodes that are not installed yet + // (e.g. 'attach' on Joint nodes) + ParamEnv& env = GetParamEnv(); + env.invocationList.push_back(invoc); + } + } + + bool RubySceneImporter::Invoke(const MethodInvocation& invoc) + { + if (invoc.node.expired()) + { + GetLog()->Error() + << "(RubySceneImporter) ERROR: Invoke called with expired node\n"; + return false; + } + + // invoke the method on the object + shared_ptr<Node> node = invoc.node.lock(); + shared_ptr<Class> theClass = node->GetClass(); + + if (theClass.get() == 0) + { + GetLog()->Error() + << "(RubySceneImporter) ERROR: cannot get class object for node " + << node->GetFullPath() << "\n"; + return false; + } + + if (! theClass->SupportsCommand(invoc.method)) + { + GetLog()->Error() + << "(RubySceneImporter) ERROR: in file '" << mFileName + << "': unknown method name '" + << invoc.method << "' for node '" << node->GetFullPath() + << "' (a " << theClass->GetName() << ")\n"; + return false; + } + + node->Invoke(invoc.method, invoc.parameter); + return true; + } + + bool RubySceneImporter::InvokeMethods() + { + RubySceneImporter::ParamEnv& env = GetParamEnv(); + + for ( + TMethodInvocationList::const_iterator iter = env.invocationList.begin(); + iter != env.invocationList.end(); + ++iter + ) + { + const MethodInvocation& invoc = (*iter); + Invoke(invoc); + } + } + bool RubySceneImporter::ReadMethodCall(sexp_t* sexp, shared_ptr<BaseNode> node) { *************** *** 457,462 **** sexp = sexp->next; ! // collect the parameters ! ParameterList parameter; while (sexp != 0) --- 548,555 ---- sexp = sexp->next; ! // build method invocation struct ! MethodInvocation invocation; ! invocation.node = node; ! invocation.method = method; while (sexp != 0) *************** *** 484,513 **** } ! parameter.AddValue(param); sexp = sexp->next; } ! // invoke the method on the object ! shared_ptr<Class> theClass = node->GetClass(); ! ! if (theClass.get() == 0) ! { ! GetLog()->Error() ! << "(RubySceneImporter) ERROR: cannot get class object for node " ! << node->GetFullPath() << "\n"; ! return false; ! } ! ! if (! theClass->SupportsCommand(method)) ! { ! GetLog()->Error() ! << "(RubySceneImporter) ERROR: in file '" << mFileName ! << "': unknown method name '" ! << method << "' for node '" << node->GetFullPath() ! << "' (a " << theClass->GetName() << ")\n"; ! return false; ! } ! ! node->Invoke(method, parameter); return true; } --- 577,585 ---- } ! invocation.parameter.AddValue(param); sexp = sexp->next; } ! PushInvocation(invocation); return true; } *************** *** 648,652 **** string name(sexp->val); ! if (name == "node") { while ( --- 720,724 ---- string name(sexp->val); ! if (name == S_NODE) { while ( *************** *** 672,676 **** if ( (sub->ty == SEXP_VALUE) && ! (string(sub->val) == "node") ) { --- 744,748 ---- if ( (sub->ty == SEXP_VALUE) && ! (string(sub->val) == S_NODE) ) { *************** *** 711,715 **** string name(sexp->val); ! if (name == "node") { sexp = sexp->next; --- 783,787 ---- string name(sexp->val); ! if (name == S_NODE) { sexp = sexp->next; *************** *** 724,728 **** root = node; } ! else if (name == "select") { sexp = sexp->next; --- 796,800 ---- root = node; } ! else if (name == S_SELECT) { sexp = sexp->next; *************** *** 739,752 **** root = node; } ! else if (name == "pwd") { ! GetLog()->Error() << "DEBUG: pwd: " << root->GetFullPath() << "\n"; } ! else if (name == "template") { sexp = sexp->next; return ParseTemplate(sexp); } ! else if (name == "define") { sexp = sexp->next; --- 811,824 ---- root = node; } ! else if (name == S_PWD) { ! GetLog()->Debug() << "DEBUG: pwd: " << root->GetFullPath() << "\n"; } ! else if (name == S_TEMPLATE) { sexp = sexp->next; return ParseTemplate(sexp); } ! else if (name == S_DEFINE) { sexp = sexp->next; |
From: Markus R. <rol...@us...> - 2005-12-18 11:10:21
|
Update of /cvsroot/simspark/simspark/spark/oxygen/physicsserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2489 Modified Files: joint.cpp Log Message: - Log the full path of both bodies that are attached in Joint::Attach to the debug channel. This is useful for debugging the setup of articulated bodies Index: joint.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/joint.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** joint.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- joint.cpp 18 Dec 2005 11:10:09 -0000 1.2 *************** *** 91,96 **** } ! const dBodyID id1 = (body1.get() == 0) ? 0 : body1->GetODEBody(); ! const dBodyID id2 = (body2.get() == 0) ? 0 : body2->GetODEBody(); dJointAttach(mODEJoint, id1, id2); --- 91,121 ---- } ! string path1,path2; ! dBodyID id1,id2; ! ! static const char strStaticEnv[] = "<static environment>"; ! ! if (body1.get() == 0) ! { ! id1 = 0; ! path1 = strStaticEnv; ! } else ! { ! id1 = body1->GetODEBody(); ! path1 = body1->GetFullPath(); ! } ! ! if (body2.get() == 0) ! { ! id2 = 0; ! path2 = strStaticEnv; ! } else ! { ! id2 = body2->GetODEBody(); ! path2 = body2->GetFullPath(); ! } ! ! GetLog()->Debug() << "(Joint) Attaching '" << path1 << "' to '" ! << path2 << "'\n" << std::endl; dJointAttach(mODEJoint, id1, id2); |
From: Markus R. <rol...@us...> - 2005-12-18 11:08:50
|
Update of /cvsroot/simspark/simspark/spark/spark In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2313 Added Files: spark.rb Log Message: - added utitlity funtions to spark.rb that configure the LogServer --- NEW FILE: spark.rb --- # # spark.rb, setup kerosin application framework # # # define constants used to setup spark # # (OpenGL rendering) # # the default OpenGLSystem used for rendering $defaultOpenGLSystem = 'OpenGLSystemSDL' # the name of the bundle that contains the default OpenGLSystem $defaultOpenGLBundle = 'openglsyssdl' # (MonitorControl) constants # # define the monitor update interval in cylcles $monitorInterval = 10; $serverType = 'tcp' $serverPort = 3200 # (SparkMonitorClient) constants # $monitorServer = '127.0.0.1' $monitorPort = 3200 # socket type ('tcp' or 'udp') $monitorType = 'tcp' # # below is a set of utility functions for the user app # def sparkSetupMonitor print "(spark.rb) sparkSetupMonitor\n" # add the agent control node simulationServer = get($serverPath+'simulation'); monitorClient = new('SparkMonitorClient', $serverPath+'simulation/SparkMonitorClient') monitorClient.setServer($monitorServer) monitorClient.setPort($monitorPort) if ($monitorType == 'udp') monitorClient.setClientTypeUDP() else if ($monitorType == 'tcp') monitorClient.setClientTypeTCP() else print "(spark.rb) unknown monitor socket type " print $monitorType print "\n" end end rubySceneImporter = get($serverPath+'scene/RubySceneImporter') rubySceneImporter.setUnlinkOnCompleteScenes(true); end # # install a class below the SparkMonitorClient that implementes the # simulation specific monitor processing # def sparkRegisterCustomMonitor(className) print "(spark.rb) sparkRegisterCustomMonitor " + className + "\n" new(className, $serverPath+'simulation/SparkMonitorClient/'+className) end # # install a class below the Spark RenderControl node that implements # application specific render logic # def sparkRegisterCustomRender(className) print "(spark.rb) sparkRegisterCustomRender " + className + "\n" new(className, $serverPath+'simulation/RenderControl/'+className) end # # install a class below the Spark InputControl node that implements # application specific input processing # def sparkRegisterCustomInput(className) print "(spark.rb) sparkRegisterCustomInput " + className + "\n" new(className, $serverPath+'simulation/InputControl/'+className) end # # install a class below the Spark MonitorSystem node that parses # commands received from a monitor client # def sparkRegisterMonitorCmdParser(className) print "(spark.rb) sparkRegisterMonitorCmdParser " + className + "\n" new(className, $serverPath+'monitor/SparkMonitor/'+className) end def sparkSetupServer print "(spark.rb) sparkSetupServer\n" # add the agent control node simulationServer = get($serverPath+'simulation'); simulationServer.initControlNode('oxygen/AgentControl','AgentControl') monitorControl = new('oxygen/MonitorControl', $serverPath+'simulation/MonitorControl') monitorControl.setMonitorInterval($monitorInterval) monitorControl.setServerPort($serverPort) if ($serverType == 'udp') monitorControl.setServerTypeUDP() else if ($serverType == 'tcp') monitorControl.setServerTypeTCP() else print "(spark.rb) unknown monitor socket type " print $serverType print "\n" end end end def sparkSetupRendering(openGLSystem = $defaultOpenGLSystem) print "(spark.rb) sparkSetupRendering\n" print "(spark.rb) using OpenGLSystem '" + openGLSystem + "'\n" # # setup the GeometryServer geometryServer = new('oxygen/GeometryServer', $serverPath+'geometry') importBundle 'voidmeshimporter' geometryServer.initMeshImporter("VoidMeshImporter"); # # setup the kerosin render framework openGLServer = new('kerosin/OpenGLServer', $serverPath+'opengl'); if (openGLSystem == $defaultOpenGLSystem) importBundle($defaultOpenGLBundle) end openGLServer.init(openGLSystem) new('kerosin/RenderServer', $serverPath+'render'); new('kerosin/ImageServer', $serverPath+'image'); new('kerosin/TextureServer', $serverPath+'texture'); # # setup the InputServer # use the SDL input system and use a german keyboard layout importBundle 'inputsdl'; inputServer = new('kerosin/InputServer', $serverPath+'input') inputServer.setScanCodeMapping('german.scan.rb'); inputServer.init('InputSystemSDL') # add devices inputServer.createDevice('Timer') inputServer.createDevice('Keyboard') inputServer.createDevice('Mouse') # setup the FontServer new('kerosin/FontServer', $serverPath+'font'); # # register render control node to the simulation server simulationServer = get($serverPath+'simulation'); simulationServer.initControlNode('kerosin/RenderControl','RenderControl') end def sparkSetupInput() print "(spark.rb) sparkSetupRendering\n" # # register input control node to the simulation server simulationServer = get($serverPath+'simulation'); # add the input control node simulationServer.initControlNode('kerosin/InputControl','InputControl') end # add a camera with an FPS Controller to the scene at path def sparkAddFPSCamera( path, x = 0.0, y = 0.0, z = 4, maxSpeed = 15.0, accel = 40.0, drag = 4, addCollider = false, colliderRadius = 2.0 ) print "(spark.rb) sparkAddFPSCamera at " + path + "\n" # add a camera. The camera movement is controlled using an # FPSController. cameraTransform = new('oxygen/Transform',path) cameraTransform.setLocalPos(x,y,z) new('oxygen/Camera',path+'/camera') # the camera is not affected by gravity but restricted to a maximum # speed body = new('oxygen/Body',path+'/physics') body.useGravity(false); velCtr = new('oxygen/VelocityController',path+'/physics/velctr') velCtr.setMaxVelocity(maxSpeed) # add an FPSController to move the camera and set the applied # acceleration fpsController = new('oxygen/FPSController',path+'/physics/controller') fpsController.setAcceleration(accel) inputControl = get($serverPath+'simulation/InputControl') inputControl.setFPSController(path+'/physics/controller') # add an DragController to work against the camera acceleration dragController = new('oxygen/DragController',path+'/physics/drag') dragController.setLinearDrag(drag) if addCollider # add an Collider that allows the camera to push objects collider = new('oxygen/SphereCollider', path+'/geometry') collider.setRadius(colliderRadius) handler = new('oxygen/ContactJointHandler', path+'geometry/contact') handler.setContactBounceMode true handler.setMinBounceVel 2 end end # # registers a new logTarget to the LogServer # # valid logTarget value are ':cout' and ':cerr' for stdout and stderr # output, as well as any other file name, e.g. 'log.txt' # # logType denotes the debug to be attached to the # logtarget. Valid streams are 'eNone', 'eDebug' and 'eWarning' # def sparkEnableLog(logTarget, logType) print "(spark.rb) sparkEnableLog logTarget="+logTarget+" logType="+logType+"\n" logServer = get($serverPath+'log') logServer.addStream(logTarget, logType) end # logs all error output to cerr def sparkLogErrorToCerr() sparkEnableLog(':cerr', 'eError') end # logs all debug output to cerr def sparkLogDebugToCerr() sparkEnableLog(':cerr', 'eDebug') end # logs all output to cerr def sparkLogAllToCerr() sparkEnableLog(':cerr', 'eAll') end # logs all error output to 'fileName' def sparkLogErrorToFile(fileName) sparkEnableLog(fileName, 'eError') end # logs all debug output to 'fileName' def sparkLogDebugToFile(fileName) sparkEnableLog(fileName, 'eDebug') end # logs all output to 'fileName' def sparkLogAllToFile(filenName) sparkEnableLog(fileName, 'eAll') end # # setup spark # # # scene and server path $scenePath = '/usr/scene/' $serverPath = '/sys/server/' # # set up logging logServer = get($serverPath+'log') logServer.addStream(':cerr', 'eError') # # setup the PhysicsServer new('oxygen/PhysicsServer', $serverPath+'physics') # # setup the SceneServer sceneServer = new('oxygen/SceneServer', $serverPath+'scene') sceneServer.createScene($scenePath) # # setup the GeometryServer geometryServer = new('oxygen/GeometryServer', $serverPath+'geometry') importBundle 'voidmeshimporter' geometryServer.initMeshImporter("VoidMeshImporter"); # use the ruby scene importer to import scenes importBundle 'rubysceneimporter' sceneServer.initSceneImporter("RubySceneImporter"); # create world and space aspects world = new('oxygen/World', $scenePath+'world') world.setGravity(0.0, 0.0, -9.81) new('oxygen/Space', $scenePath+'space') # # setup the MaterialServer new('kerosin/MaterialServer', $serverPath+'material'); # # setup the MonitorServer monitorServer = new('oxygen/MonitorServer', $serverPath+'monitor') # register the SparkMonitor system importBundle 'sparkmonitor' monitorServer.registerMonitorSystem('SparkMonitor') # # setup the GameControlServer gameControlServer = new('oxygen/GameControlServer', $serverPath+'gamecontrol') # register the s-expression parser to the GameControlServer importBundle "sexpparser" gameControlServer.initParser('SexpParser') # register the SceneEffector to the GameControlServer importBundle "sceneeffector" gameControlServer.initEffector('SceneEffector') # # setup the SimulationServer simulationServer = new('oxygen/SimulationServer', $serverPath+'simulation') # # import the spark perceptors and effector set importBundle "sparkagent" |
From: Markus R. <rol...@us...> - 2005-12-13 21:50:51
|
Update of /cvsroot/simspark/simspark/spark/spark In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1535/spark Log Message: Directory /cvsroot/simspark/simspark/spark/spark added to the repository |
From: Markus R. <rol...@us...> - 2005-12-13 21:49:05
|
Update of /cvsroot/simspark/simspark/spark/plugin/sparkagent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885/sparkagent Added Files: .cvsignore Makefile.am export.cpp hinge2action.h hinge2effector.cpp hinge2effector.h hinge2effector_c.cpp hinge2perceptor.cpp hinge2perceptor.h hinge2perceptor_c.cpp timeperceptor.cpp timeperceptor.h timeperceptor_c.cpp Log Message: - added spark specific plugins --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in --- NEW FILE: hinge2effector_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: hinge2effector_c.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "hinge2effector.h" void CLASS(Hinge2Effector)::DefineClass() { DEFINE_BASECLASS(oxygen/Effector); } --- NEW FILE: timeperceptor_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: timeperceptor_c.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "timeperceptor.h" void CLASS(TimePerceptor)::DefineClass() { DEFINE_BASECLASS(oxygen/Perceptor); } --- NEW FILE: export.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: export.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <zeitgeist/zeitgeist.h> #include "hinge2perceptor.h" #include "hinge2effector.h" #include "timeperceptor.h" ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(Hinge2Effector); ZEITGEIST_EXPORT(Hinge2Perceptor); ZEITGEIST_EXPORT(TimePerceptor); ZEITGEIST_EXPORT_END() --- NEW FILE: timeperceptor.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: timeperceptor.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "timeperceptor.h" #include <zeitgeist/logserver/logserver.h> using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; TimePerceptor::TimePerceptor() : Perceptor() { } TimePerceptor::~TimePerceptor() { } void TimePerceptor::OnLink() { mSimulationServer = shared_dynamic_cast<SimulationServer> (GetCore()->Get("/sys/server/simulation")); if (mSimulationServer.get() == 0) { GetLog()->Error() << "(TimePerceptor) ERROR: SimulationServer not found\n"; } } void TimePerceptor::OnUnlink() { mSimulationServer.reset(); } bool TimePerceptor::Percept(boost::shared_ptr<oxygen::PredicateList> predList) { if (mSimulationServer.get() == 0) { return false; } Predicate& predicate = predList->AddPredicate(); predicate.name = "time"; predicate.parameter.Clear(); ParameterList& nowElement = predicate.parameter.AddList(); nowElement.AddValue(string("now")); nowElement.AddValue(mSimulationServer->GetTime()); ParameterList& stepElement = predicate.parameter.AddList(); stepElement.AddValue(string("step")); stepElement.AddValue(mSimulationServer->GetSimStep()); return true; } --- NEW FILE: hinge2effector.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: hinge2effector.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "hinge2effector.h" #include "hinge2action.h" using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; Hinge2Effector::Hinge2Effector() : Effector() { SetName("hinge2"); } Hinge2Effector::~Hinge2Effector() { } bool Hinge2Effector::Realize(boost::shared_ptr<ActionObject> action) { if (mJoint.get() == 0) { return false; } shared_ptr<Hinge2Action> hinge2Action = shared_dynamic_cast<Hinge2Action>(action); if (hinge2Action.get() == 0) { GetLog()->Error() << "ERROR: (Hinge2Effector) cannot realize an " << "unknown ActionObject\n"; return false; } mJoint->SetAngularMotorVelocity (Joint::AI_SECOND, hinge2Action->GetMotorVelocity()); return true; } shared_ptr<ActionObject> Hinge2Effector::GetActionObject(const Predicate& predicate) { for(;;) { if (mJoint.get() == 0) { break; } if (predicate.name != GetPredicate()) { GetLog()->Error() << "ERROR: (KickEffector) invalid predicate" << predicate.name << "\n"; break; } Predicate::Iterator iter = predicate.begin(); float velocity; if (! predicate.AdvanceValue(iter, velocity)) { GetLog()->Error() << "ERROR: (KickEffector) motor velocity expected\n"; break; } return shared_ptr<Hinge2Action>(new Hinge2Action(GetPredicate(),velocity)); } return shared_ptr<ActionObject>(); } void Hinge2Effector::OnLink() { mJoint = make_shared(FindParentSupportingClass<Hinge2Joint>()); if (mJoint.get() == 0) { GetLog()->Error() << "(Hinge2Effector) ERROR: found no Hinge2Joint parent\n"; } } void Hinge2Effector::OnUnlink() { mJoint.reset(); } --- NEW FILE: timeperceptor.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: timeperceptor.h,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef TIMEPERCEPTOR_H #define TIMEPERCEPTOR_H #include <oxygen/agentaspect/perceptor.h> #include <oxygen/simulationserver/simulationserver.h> class TimePerceptor : public oxygen::Perceptor { public: TimePerceptor(); virtual ~TimePerceptor(); //! \return true, if valid data is available and false otherwise. bool Percept(boost::shared_ptr<oxygen::PredicateList> predList); protected: virtual void OnLink(); virtual void OnUnlink(); protected: /** cached reference to the SimulationServer */ boost::shared_ptr<oxygen::SimulationServer> mSimulationServer; }; DECLARE_CLASS(TimePerceptor); #endif //TIMEPERCEPTOR_H --- NEW FILE: hinge2effector.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: hinge2effector.h,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef HINGE2EFFECTOR_H #define HINGE2EFFECTOR_H #include <oxygen/agentaspect/effector.h> #include <oxygen/physicsserver/hinge2joint.h> class Hinge2Effector : public oxygen::Effector { public: Hinge2Effector(); virtual ~Hinge2Effector(); /** realizes the action described by the ActionObject */ virtual bool Realize(boost::shared_ptr<oxygen::ActionObject> action); /** returns the name of the predicate this effector implements. */ virtual std::string GetPredicate() { return GetName(); } /** constructs an Actionobject, describing a predicate */ virtual boost::shared_ptr<oxygen::ActionObject> GetActionObject(const oxygen::Predicate& predicate); /** setup the reference to the ball body node */ virtual void OnLink(); /** remove the reference to the ball body node */ virtual void OnUnlink(); protected: /** cached reference to the monitor joint */ boost::shared_ptr<oxygen::Hinge2Joint> mJoint; }; DECLARE_CLASS(Hinge2Effector); #endif // HINGE2EFFECTOR_H --- NEW FILE: hinge2perceptor.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: hinge2perceptor.h,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef HINGE2PERCEPTOR_H #define HINGE2PERCEPTOR_H #include <oxygen/agentaspect/perceptor.h> #include <oxygen/physicsserver/hinge2joint.h> class Hinge2Perceptor : public oxygen::Perceptor { public: Hinge2Perceptor(); virtual ~Hinge2Perceptor(); //! \return true, if valid data is available and false otherwise. bool Percept(boost::shared_ptr<oxygen::PredicateList> predList); protected: virtual void OnLink(); virtual void OnUnlink(); void InsertAxisAngle(oxygen::Predicate& predicate, oxygen::Joint::EAxisIndex idx); void InsertAxisRate(oxygen::Predicate& predicate, oxygen::Joint::EAxisIndex idx); protected: /** cached reference to the monitor joint */ boost::shared_ptr<oxygen::Hinge2Joint> mJoint; }; DECLARE_CLASS(Hinge2Perceptor); #endif //HINGE2PERCEPTOR_H --- NEW FILE: hinge2perceptor_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: hinge2perceptor_c.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "hinge2perceptor.h" void CLASS(Hinge2Perceptor)::DefineClass() { DEFINE_BASECLASS(oxygen/Perceptor); } --- NEW FILE: hinge2perceptor.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: hinge2perceptor.cpp,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "hinge2perceptor.h" #include <zeitgeist/logserver/logserver.h> using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; Hinge2Perceptor::Hinge2Perceptor() : Perceptor() { } Hinge2Perceptor::~Hinge2Perceptor() { } void Hinge2Perceptor::OnLink() { mJoint = make_shared(FindParentSupportingClass<Hinge2Joint>()); if (mJoint.get() == 0) { GetLog()->Error() << "(Hinge2Perceptor) ERROR: found no Hinge2Joint parent\n"; } } void Hinge2Perceptor::OnUnlink() { mJoint.reset(); } void Hinge2Perceptor::InsertAxisAngle(Predicate& predicate, Joint::EAxisIndex idx) { ParameterList& axisElement = predicate.parameter.AddList(); axisElement.AddValue(string("axis")); axisElement.AddValue(static_cast<int>(idx)); axisElement.AddValue(mJoint->GetAngle(idx)); } void Hinge2Perceptor::InsertAxisRate(Predicate& predicate, Joint::EAxisIndex idx) { ParameterList& axisElement = predicate.parameter.AddList(); axisElement.AddValue(string("rate")); axisElement.AddValue(static_cast<int>(idx)); axisElement.AddValue(mJoint->GetAngleRate(idx)); } bool Hinge2Perceptor::Percept(boost::shared_ptr<oxygen::PredicateList> predList) { if (mJoint.get() == 0) { return false; } Predicate& predicate = predList->AddPredicate(); predicate.name = "hinge2"; predicate.parameter.Clear(); ParameterList& nameElement = predicate.parameter.AddList(); nameElement.AddValue(string("name")); nameElement.AddValue(GetName()); InsertAxisAngle(predicate,Joint::AI_FIRST); InsertAxisRate(predicate,Joint::AI_SECOND); return true; } --- NEW FILE: Makefile.am --- pkglib_LTLIBRARIES = sparkagent.la sparkagent_la_SOURCES = \ hinge2action.h \ hinge2perceptor.h \ hinge2perceptor.cpp \ hinge2perceptor_c.cpp \ hinge2effector.h \ hinge2effector.cpp \ hinge2effector_c.cpp \ timeperceptor.h \ timeperceptor.cpp \ timeperceptor_c.cpp \ export.cpp sparkagent_la_LDFLAGS = -module -version-info 0:0:0 AM_CPPFLAGS = -I${top_srcdir}/lib -I${top_srcdir}/utility @RUBY_CPPFLAGS@ --- NEW FILE: hinge2action.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: hinge2action.h,v 1.1 2005/12/13 21:48:50 rollmark Exp $ 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; version 2 of the License. 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef HINGE2ACTION_H #define HINGE2ACTION_H #include <oxygen/gamecontrolserver/actionobject.h> class Hinge2Action : public oxygen::ActionObject { public: Hinge2Action(const std::string& predicate, float velocity) : ActionObject(predicate), mVelocity(velocity) {}; virtual ~Hinge2Action() {} float GetMotorVelocity() { return mVelocity; } protected: float mVelocity; }; #endif // HINGE2ACTION_H |