Update of /cvsroot/playerstage/code/player/libplayercore
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7260/libplayercore
Modified Files:
driver.cc playerinterfacegen.py plugins.cc
Log Message:
fixes to for pluggable interfaces
modified python tools to allow easier pluggable interface definition
change example to generate more files automatically
Index: playerinterfacegen.py
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/playerinterfacegen.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** playerinterfacegen.py 21 Sep 2007 03:31:50 -0000 1.4
--- playerinterfacegen.py 18 Dec 2007 02:10:42 -0000 1.5
***************
*** 11,15 ****
UTILS_MODE = "--utils"
! USAGE = "USAGE: playerinterfacegen.py [%s | %s | %s] [<interface
file>|<interface dir>]" % (HEADER_MODE, FUNCTIONTABLE_MODE, UTILS_MODE)
class msg:
--- 11,17 ----
UTILS_MODE = "--utils"
! PLUGIN_MODE = "--plugin"
!
! USAGE = "USAGE: playerinterfacegen.py [%s | %s | %s] [%s] [<interface
file>|<interface dir>]" % (HEADER_MODE, FUNCTIONTABLE_MODE, UTILS_MODE,
PLUGIN_MODE)
class msg:
***************
*** 23,27 ****
return (interface_code, interface_name)
! def processfile(mode, filename):
interface_code, interface_name = get_interface(filename)
interface_def = "PLAYER_%s_CODE" % interface_name.upper()
--- 25,29 ----
return (interface_code, interface_name)
! def processfile(mode, filename, plugin):
interface_code, interface_name = get_interface(filename)
interface_def = "PLAYER_%s_CODE" % interface_name.upper()
***************
*** 77,80 ****
--- 79,90 ----
#define %(string)s %(code)d
""" % {"comment": m.comment, "string": m.msg_subtype_string, "code":
m.msg_subtype_code}
+
+ ifndefsymbol = '_' + interface_name.upper() + '_INTERFACE_H_'
+ if plugin:
+ print '#ifndef ' + ifndefsymbol
+ print '#define ' + ifndefsymbol + '\n'
+
+ print "#include <libplayercore/player.h>"
+
print """
***************
*** 109,118 ****
"interface_types" : interface_types,
"interface_comment" : interface_comment}
!
elif mode == FUNCTIONTABLE_MODE:
print "\n /* %s messages */" % interface_name
for m in interface_messages:
print " {", interface_def, ",", m.msg_type, ",", m.msg_subtype_string,
","
print " (player_pack_fn_t)%(dt_base)s_pack,
(player_copy_fn_t)%(dt)s_copy,
(player_cleanup_fn_t)%(dt)s_cleanup,(player_clone_fn_t)%(dt)s_clone,(player_free_fn_t)%(dt)s_free,(player_sizeof_fn_t)%(dt)s_sizeof},"
% { "dt_base": m.datatype[:-2], "dt": m.datatype}
def process_for_utils(targetfile):
--- 119,150 ----
"interface_types" : interface_types,
"interface_comment" : interface_comment}
! if plugin:
! print "#endif // " + ifndefsymbol
elif mode == FUNCTIONTABLE_MODE:
+ if plugin:
+ print """
+ #include "%(interface_name)s_interface.h"
+ #include "%(interface_name)s_xdr.h"
+
+ // Function table for this interface
+ static playerxdr_function_t %(interface_name)s_ftable[] =
+ {
+ """ % {"interface_name": interface_name}
print "\n /* %s messages */" % interface_name
for m in interface_messages:
print " {", interface_def, ",", m.msg_type, ",", m.msg_subtype_string,
","
print " (player_pack_fn_t)%(dt_base)s_pack,
(player_copy_fn_t)%(dt)s_copy,
(player_cleanup_fn_t)%(dt)s_cleanup,(player_clone_fn_t)%(dt)s_clone,(player_free_fn_t)%(dt)s_free,(player_sizeof_fn_t)%(dt)s_sizeof},"
% { "dt_base": m.datatype[:-2], "dt": m.datatype}
+ if plugin:
+ print """
+ /* This NULL element signals the end of the list */
+ {0,0,0,NULL,NULL,NULL}
+ };
+
+ playerxdr_function_t* player_plugininterf_gettable (void)
+ {
+ return %(interface_name)s_ftable;
+ }
+ """ % {"interface_name": interface_name}
+
def process_for_utils(targetfile):
***************
*** 146,149 ****
--- 178,182 ----
mode = HEADER_MODE
targetfile = "interfaces"
+ plugin = False
for option in sys.argv[1:]:
***************
*** 153,162 ****
elif option == HEADER_MODE or option == FUNCTIONTABLE_MODE or option ==
UTILS_MODE:
mode = option
else:
targetfile = option
print "/* START OF AUTOGENERATED CODE */"
! print "/* This file or section was automatically generated by
playerinterfacegen.py"
! print "To modify the interfaces in this file please edit their interface
definition in libplayercore/interfaces/ */"
if mode == UTILS_MODE:
--- 186,200 ----
elif option == HEADER_MODE or option == FUNCTIONTABLE_MODE or option ==
UTILS_MODE:
mode = option
+ elif option == PLUGIN_MODE:
+ plugin = True
else:
targetfile = option
print "/* START OF AUTOGENERATED CODE */"
! if plugin:
! print "/* This file or section was automatically generated by
playerinterfacegen.py */"
! else:
! print "/* This file or section was automatically generated by
playerinterfacegen.py"
! print "To modify the interfaces in this file please edit their interface
definition in libplayercore/interfaces/ */"
if mode == UTILS_MODE:
***************
*** 166,172 ****
for file in glob.glob(os.path.join(targetfile ,"*.def")):
if not os.path.isdir(file):
! processfile(mode, file)
else:
! processfile(mode, targetfile)
print "/* END OF AUTOGENERATED CODE */"
--- 204,210 ----
for file in glob.glob(os.path.join(targetfile ,"*.def")):
if not os.path.isdir(file):
! processfile(mode, file, plugin)
else:
! processfile(mode, targetfile, plugin)
print "/* END OF AUTOGENERATED CODE */"
Index: plugins.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/plugins.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** plugins.cc 10 Jul 2007 09:01:52 -0000 1.8
--- plugins.cc 18 Dec 2007 02:10:42 -0000 1.9
***************
*** 153,167 ****
{
getcwd(fullpath, PATH_MAX);
! strcat(fullpath,"/");
}
! strcat(fullpath,cfgdir);
! strcat(fullpath,"/");
! strcat(fullpath,pluginname);
! free(tmp);
PLAYER_MSG1(1, "trying to load %s...", fullpath);
if((handle = lt_dlopenext(fullpath)))//, RTLD_NOW)))
PLAYER_MSG0(1, "success");
else
! PLAYER_MSG1(2, "failed (%s)\n", lt_dlerror());
}
--- 153,167 ----
{
getcwd(fullpath, PATH_MAX);
! strncat(fullpath,"/", PATH_MAX);
}
! strncat(fullpath,cfgdir, PATH_MAX);
! strncat(fullpath,"/", PATH_MAX);
! strncat(fullpath,pluginname, PATH_MAX);
PLAYER_MSG1(1, "trying to load %s...", fullpath);
if((handle = lt_dlopenext(fullpath)))//, RTLD_NOW)))
PLAYER_MSG0(1, "success");
else
! PLAYER_MSG1(1, "failed (%s)\n", lt_dlerror());
! free(tmp); // this should ha
}
***************
*** 170,182 ****
{
memset(fullpath,0,PATH_MAX);
! strcpy(fullpath,PLAYER_INSTALL_PREFIX);
! strcat(fullpath,"/lib/");
! strcat(fullpath,pluginname);
PLAYER_MSG1(1, "trying to load %s...", fullpath);
- fflush(stdout);
if((handle = lt_dlopenext(fullpath)))
PLAYER_MSG0(1, "success");
else
! PLAYER_MSG1(2, "failed (%s)\n", lt_dlerror() );
}
--- 170,181 ----
{
memset(fullpath,0,PATH_MAX);
! strncpy(fullpath,PLAYER_INSTALL_PREFIX, PATH_MAX);
! strncat(fullpath,"/lib/", PATH_MAX);
! strncat(fullpath,pluginname, PATH_MAX);
PLAYER_MSG1(1, "trying to load %s...", fullpath);
if((handle = lt_dlopenext(fullpath)))
PLAYER_MSG0(1, "success");
else
! PLAYER_MSG1(1, "failed (%s)\n", lt_dlerror() );
}
***************
*** 190,194 ****
PLAYER_MSG0(1, "success");
else
! PLAYER_MSG1(2, "failed (%s)\n", lt_dlerror());
}
--- 189,193 ----
PLAYER_MSG0(1, "success");
else
! PLAYER_MSG1(1, "failed (%s)\n", lt_dlerror());
}
Index: driver.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/driver.cc,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** driver.cc 1 Nov 2007 22:16:16 -0000 1.34
--- driver.cc 18 Dec 2007 02:10:42 -0000 1.35
***************
*** 80,83 ****
--- 80,84 ----
interf, -1, NULL) != 0)
{
+ PLAYER_ERROR1("Failed to find provides block for interface %d",interf);
this->SetError(-1);
return;
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit