Re: Creating and using a .DLL/.SO?
- Posted by jeremy (admin) Dec 25, 2008
- 1122 views
How will this work when I want to load multiple dll/so files that have the same function names? For instance:
dbi_pgsql.so, dbi_mysql.so, dbi_sqlite.so, dbi_eds.so:
dbi_open(), dbi_query(), dbi_close()
In code, I could do something like:
public function dbi_load_driver(sequence name) atom driver_id = open_dll("mod_" & name) return { driver_id, define_c_func(driver_id, "dbi_open", ...), ... } end function public function dbi_open(driver, ...) return c_func(driver[FUNC_DBI_OPEN], ...) end function ...
Thus, a Euphoria program could connect to multiple database servers/files at the same time, varrying, and have no idea what the actual underlying database would be. A common interface, loaded at runtime. The application could be extended for database support far beyond what the original author ever knew. Simply develop a new, conforming DBI driver and the application would be able to then access that database.
So, in this case, I would not want the contents of the mod_pgsql.so and mod_mysql.so automatically available to the runtime. I would think this type of thing would happen frequently. For instance, any type of pluggable module. Say you have a modular system to load a file: mod_text.so, mod_rtf.so, mod_html.so, mod_xml.so, etc... All of them would include a function called: open_file()... and would return some type of common data type for your application. I may want to open/parse html files, xml, rtf, etc... all at the same time, so all modules would be loaded, but all have the exact same function names.
Jeremy