Re: C interpreters

2008-02-02 Thread Jim Stapleton
Thanks, it's decent, seems to not act like a full shell though.

If I ctrl-z while in emacs, it drops me out of CH as well as emacs.

still, it's a nice play toy.

thanks,
-Jim Stapleton

On Jan 31, 2008 9:54 PM, Gary Kline [EMAIL PROTECTED] wrote:

 On Thu, Jan 31, 2008 at 10:12:35AM -0500, Jim Stapleton wrote:
  Thanks, and that'll make shared (.so) libraries just fine?
 
  Well, that was certainly a relief. That very much describes the C
  interface I made already. I'm working on a alternate ports listing
  system, and I wanted to use something that I didn't mind programming
  in /and/ I knew should be available on any FreeBSD system without
  requireing more port installs, so I went with C or C++. I want it to
  be easy to write back-end database modules, in case people don't want
  to use the two that I write (SQLite2 and a my own flat-file system).
  There are only three functions that need wrapped: open, query, close.
  Open returns that void* pointer, query and close take it as the first
  argument.
 
  Any ideas on the C interpreter? It's been a while since I've done a
  lot of C/C++.


 hi jim,


 the bestt one i know of is free, named ch.  cost only $25 for the
 whole deal.   used mostly by the hardware sectoor so far.  i'd
 like to see it be adopted by the open ource folks too.i
 haven't used it much so far becuse my C progras are mostly for
 myself and  1000 lines.  v. small company, forget the name.

 gary

 
  Thanks,
  -Jim Stapleton
  ___
  freebsd-questions@freebsd.org mailing list
  http://lists.freebsd.org/mailman/listinfo/freebsd-questions
  To unsubscribe, send any mail to [EMAIL PROTECTED]

 --
   Gary Kline  [EMAIL PROTECTED]   www.thought.org  Public Service Unix
 http://jottings.thought.org   http://transfinite.thought.org



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


C interpreters

2008-01-31 Thread Jim Stapleton
Does anyone have a recommendation on C interpreters? I want to do some
development in C, but I would also like to have the ability of playing
with an interactive command line a-la python, as it eases the
playing process of figuring out what I am doing.

There are a few options in the ports tree and I'm wondering if anyone
has played with them and has an oppinion. I've seen ccscrpt and cint,
I also know root has a C interpereter (though I don't know how good it
is, and it's for scientific numerical analysis, not generic
programming).


as a secondary (probably stupid) question: how hard is it to write a
library in C++ and allow C programs to use it?

Thanks,
-Jim Stapleton
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: C interpreters

2008-01-31 Thread Heiko Wundram (Beenic)
Am Donnerstag, 31. Januar 2008 14:48:15 schrieb Jim Stapleton:
 as a secondary (probably stupid) question: how hard is it to write a
 library in C++ and allow C programs to use it?

To write a library in C++ to which C programs have access, you'll have to 
write a set of wrapper functions for every method of a class you want to 
expose to C which basically get an object pointer as the first parameter and 
the actual method arguments as the rest. For example:

test.cc
---

#include test.hh
#include test.h

Test::Test()
{
}

int Test::something(int data)
{
return 0;
}

extern C {

TestObject NewTest() {
return new Test();
}

int TestSomething(TestObject ob, int data) {
return reinterpret_castTest*(ob)-something(data);
}

}

test.hh
---

#ifndef TEST_HH
#define TEST_HH

class Test
{
Test();
int something(int data);
};

#endif // TEST_HH

test.h
--

#ifndef TEST_H
#define TEST_H

typedef void* TestObject;

#ifdef __cplusplus
extern C {
#endif /* __cplusplus */

TestObject NewTest();
int TestSomething(TestObject ob, int data);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* TEST_H */

test.c
--

#include test.h

int main(int argc, char** argv)
{
TestObject testob;

testob = NewTest();
TestSomething(testob,1);
}

This lets you use the compiled test.cc (for example, as a library, to get 
around the problem of having to link your C-program against libstdc++) 
together with a C program.

Be aware of the fact that C doesn't know function overloading, so you'll 
basically have to implement that by defining different methods for every type 
of overloaded function you want to accept.

Depending on how large the C++ framework is which you're trying to wrap (and 
in how much it uses advanced C++ features), this is an easy (i.e., 
repetitive) or a hard/close to impossible task, especially when it comes to 
templates.

YMMV.

-- 
Heiko Wundram
Product  Application Development
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: C interpreters

2008-01-31 Thread Jim Stapleton
Thanks, and that'll make shared (.so) libraries just fine?

Well, that was certainly a relief. That very much describes the C
interface I made already. I'm working on a alternate ports listing
system, and I wanted to use something that I didn't mind programming
in /and/ I knew should be available on any FreeBSD system without
requireing more port installs, so I went with C or C++. I want it to
be easy to write back-end database modules, in case people don't want
to use the two that I write (SQLite2 and a my own flat-file system).
There are only three functions that need wrapped: open, query, close.
Open returns that void* pointer, query and close take it as the first
argument.

Any ideas on the C interpreter? It's been a while since I've done a
lot of C/C++.

Thanks,
-Jim Stapleton
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: C interpreters

2008-01-31 Thread Gary Kline
On Thu, Jan 31, 2008 at 10:12:35AM -0500, Jim Stapleton wrote:
 Thanks, and that'll make shared (.so) libraries just fine?
 
 Well, that was certainly a relief. That very much describes the C
 interface I made already. I'm working on a alternate ports listing
 system, and I wanted to use something that I didn't mind programming
 in /and/ I knew should be available on any FreeBSD system without
 requireing more port installs, so I went with C or C++. I want it to
 be easy to write back-end database modules, in case people don't want
 to use the two that I write (SQLite2 and a my own flat-file system).
 There are only three functions that need wrapped: open, query, close.
 Open returns that void* pointer, query and close take it as the first
 argument.
 
 Any ideas on the C interpreter? It's been a while since I've done a
 lot of C/C++.


hi jim,


the bestt one i know of is free, named ch.  cost only $25 for the
whole deal.   used mostly by the hardware sectoor so far.  i'd
like to see it be adopted by the open ource folks too.i
haven't used it much so far becuse my C progras are mostly for
myself and  1000 lines.  v. small company, forget the name.

gary

 
 Thanks,
 -Jim Stapleton
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]

-- 
  Gary Kline  [EMAIL PROTECTED]   www.thought.org  Public Service Unix
http://jottings.thought.org   http://transfinite.thought.org


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]