This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Expand eggdrop using C++?

Discussion of Eggdrop's code and module programming in C.
Post Reply
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Expand eggdrop using C++?

Post by sKy »

Is there a way to plug in C++ code into eggdrop (like plug in tcl scripts into eggdrop)? I don`t mean modules in C.

Is there some eggdrop -> tcl -> C++ bridge? I found cpptcl on sourceforge, but I have no idea if it could work with eggdrop.
socketapi | Code less, create more.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

How would you run C++-code if you don't either compile it into the binary itself, or a loadable module?

That said, the last C++-project was many years ago, when 1.3.24 was state of the art in eggdrop.. This was eggdrop2 (not eggdrop v2.xx), which did not make much progress and siezed development shortly after it was made official. Since then, development on the plain C eggdrop had continued for several years.

It has been ages since I messed with C++, so I cannot say how much work it would be to write an eggdrop-module in C++.
NML_375
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

nml375 wrote:How would you run C++-code if you don't either compile it into the binary itself, or a loadable module?
I have no idea. That`s why I ask here. :)

I saw a very inspiring function in Delphi. If I got it right you can just write anywhere in your source
ASM
- ASM code here <
END ASM. Kinda cool if you really need asm.

Thought it`s possible third party tcl script to have a similar function in tcl too.

That`s why I am asking.


Modules seam kinda complicated. For debugging you always need to recompile the hole bot and if you think about sharing your work for endusers it`s kinda uncomfortable for them tool compared to tcl scripts.

What do you mean with 'compile it into the binary itself'? I can compile it.. Sure. But how to plug it into eggdrop? Recompile? :/
socketapi | Code less, create more.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Tcl is a pure scripting-language, while C and C++ are programming languages...
Simply put, tcl is parsed at runtime, using "alot" of resources at runtime to interpret instructions. C (and C++) however, is compiled into machinecode, which is then used for execution.

Using assembler instructions in a scripting-language (asm) really is'nt practicle, as asm knows nothing of variables, fancy function names, etc. It basically is a mnemonic with a few parameters, usually being register address, memory address, or direct values. Languages such as tcl does'nt even allow you to find out the address where a variable is stored...

Most c/c++-compilers can handle assembly-instructions, and in many cases these can be intermixed with C and/or C++.

Now, for writing your own modules, checking the source of the various ones that comes with eggdrop is a good start, especially the woobie-module, as it's mainly there for demonstration purposes.
Roughly put however, you'll be expected to create a given set of functions that will be called upon certain events, such as when the module is loaded and unloaded. These should setup whatever needs to be done for your module to operate properly, such as registering functions and variables with tcl, creating/dropping bind-tables, etc... The ctcp-module makes quite a decent example on that.
NML_375
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

GCC also supports assembler inclusion. Also running C++ code via TCL sounds a little strange, C++ isn't really made designed as interpreted language. Expect for the OOP there are only very few reasons to use C++ instead of C, not sure, but I believe I read somewhere that C even runs faster than C++, but might have been out of the context.
Then only thing that would make sense to "interpret C++" would be to compile to temp file and execute it ^-^, you could of course embedded code into a mainframe of source, to run headerless code, but I doubt that would make much sense, you would probably rather stick to development environment with interactive debugging etc..
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

I found now Tcl 8.4 has a load command (loads machine code) and Tcl 8.5 has also an unload command but didn`t try this with eggdrop yet. Sure you would still need to compile the source on a platform you want to run it.
socketapi | Code less, create more.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Actually, loadable tcl modules has been around since 7.5 and possibly earlier (too long ago to remember). And yes, just like eggdrop modules, these has to be compiled into a loadable binary library prior being loaded.
In fact, this is used by many scripts using mysql-databases along with tclmysql.

Also worth noting, with eggdrop modules, as long as you do not touch any of "eggdrop's" files, but simply work with the files of your module, there would be no need to compile anything else than your module. In fact, make would'nt even try to rebuild your eggdrop as it would see all files and dependancies as unchanged, and thus not needed to rebuild.
NML_375
K
Kappa007
Voice
Posts: 38
Joined: Tue Jul 26, 2005 9:53 pm

Post by Kappa007 »

@sKy: i did a sample module in C++ a while back just search the forum...
Post Reply