Victor A. Wagner, Jr. | 1 Jun 2002 06:24

Re: Re: Problem with test/cpp_main.cpp

At Friday 2002/05/31 09:49, you wrote:
>----- Original Message -----
>From: "Victor A. Wagner, Jr." <vawjr <at> rudbek.com>
>
>
> > surely changing the required signature to allow for const is a better
>solution
> > putting const in the signature ALLOWS you to pas both const _and_
>non-const
> > items.
>
>Are you sure? If it was a simple pointer than this would be true, but it's a
>pointer to a pointer. (Or an array of pointers if you prefer.) The following
>does
>not compile in MSVC6 SP5 (and I don't think it should):
>
>void test(const char**) { }
>
>int main(int argc, char** argv)
>{
>    test(argv);
>    return 0;
>}
>
>error C2664: 'test' : cannot convert parameter 1 from 'char ** ' to 'const
>char ** '
>Conversion loses qualifiers

The following DOES compile on MSVC6 SP5 and MSVC.NET

(Continue reading)

Gennadiy Rozental | 1 Jun 2002 06:43

Re: Re: Problem with test/cpp_main.cpp


"Victor A. Wagner, Jr." <vawjr <at> rudbek.com> wrote in message
news:4.3.1.2.20020531212236.0344fbd0 <at> mail.rudbek.com...

> >error C2664: 'test' : cannot convert parameter 1 from 'char ** ' to
'const
> >char ** '
> >Conversion loses qualifiers
>
> The following DOES compile on MSVC6 SP5 and MSVC.NET
>
> typedef char* charstar;
> void test(const charstar* ) { }

the thing is that const char**      == char const*  *, while
                       const charstar*   == char *const  *

Use boost coding guidance to avoid confusion

Gennadiy.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Victor A. Wagner, Jr. | 1 Jun 2002 07:09

Re: Re: Re: Problem with test/cpp_main.cpp

thanks... as a general rule I stay away from the ** as much as I can.  IMO 
it is slightly unfortunate that type* isn't a new type (as it was, e.g., in 
Pascal), but we use what we have.
At Friday 2002/05/31 21:43, you wrote:

>"Victor A. Wagner, Jr." <vawjr <at> rudbek.com> wrote in message
>news:4.3.1.2.20020531212236.0344fbd0 <at> mail.rudbek.com...
>
> > >error C2664: 'test' : cannot convert parameter 1 from 'char ** ' to
>'const
> > >char ** '
> > >Conversion loses qualifiers
> >
> > The following DOES compile on MSVC6 SP5 and MSVC.NET
> >
> > typedef char* charstar;
> > void test(const charstar* ) { }
>
>the thing is that const char**      == char const*  *, while
>                        const charstar*   == char *const  *
>
>Use boost coding guidance to avoid confusion
>
>Gennadiy.
>
>
>
>
>
>
(Continue reading)

Martin Fuchs | 1 Jun 2002 12:28
Picon
Gravatar

Re: String scanning (was String formatting library: interest?)

> I would imagine that there is no corresponding library because of the
> vast number of ways to validate and transform input, from the low-level
> tokenizer library all the way up to full parsing with semantic
expressions,
> etc.

boost::format is based on ostream output functionality.
It roughly takes a format string and translates it into ostream actions.
I think some thing similar could be done to implement a string/stream, which
internally uses std::istream.

Martin

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Alec Ross | 1 Jun 2002 11:43
Picon
Picon

Re: [Fwd: reformatter for boost c++ code?]

In message <OE50NIBY0KkJNfJfuyh0000ad39 <at> hotmail.com>, William E. Kempf
<williamkempf <at> hotmail.com> writes
>----- Original Message -----
>From: "Larry Evans" <jcampbell3 <at> prodigy.net>
...
>What a coincidence.  I started searching for a "code beautifier" for use
>with my own Boost coding just yesterday.  Here's a list of the ones I've
>found and my comments:
>
...

FWIW I just noticed an ad in CUJ, for such a product at:

        www.ochresoftware.com
--

-- 
Alec Ross
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

David GD Wilson | 1 Jun 2002 21:01

mirroring class instances between c++ and python

Hi,

I am hoping someone has managed to get this problem working before and
can give me some pointers as to how to accomplish the task.

What I am trying to do is have a class in C++ that is mirrored in
python. This means that each instance of a class that is created will
have a python class created along with it and that python instance can
call into the c++ instance and vice versa.

i.e

CTest = c++ class
PTest = python class

CTest ca - ca references pa so it can call methods implemented in python
PTest pa - pa references ca so it can call methods implemented in c++

I have managed to create the python class from c++ and export the c++
class using boost.python however I am having great difficulty in making
the two classes reference each other - I get damaged memory blocks, this
suggests that I am doing something incorrectly!

Here is a snippet of the code I am using to make the python class
reference the c++ class:

// create argument for python class - the c++ instance pm
PyObject *pArgs = Py_BuildValue( "(O&)",
BOOST_PYTHON_CONVERSION::to_python,
static_cast< CTest* >( pm ) );
(Continue reading)

David Abrahams | 1 Jun 2002 22:56
Favicon
Gravatar

Re: mirroring class instances between c++ and python

David,

Please post followups to the C++-sig (c++-sig <at> python.org).

----- Original Message -----
From: "David GD Wilson" <firestar <at> thenorth.org>

> Hi,
>
> I am hoping someone has managed to get this problem working before and
> can give me some pointers as to how to accomplish the task.
>
> What I am trying to do is have a class in C++ that is mirrored in
> python. This means that each instance of a class that is created will
> have a python class created along with it and that python instance can
> call into the c++ instance and vice versa.

That's the normal case for classes which have overridable virtual functions
as described at http://www.boost.org/libs/python/doc/overriding.html.

Why not just use class_builder<CTest,CTest>?

Every constructor you expose must have a hidden initial PyObject* parameter
not described in the parameters to constructor<...>, so:

struct CTest
{
    CTest(PyObject* self, Arg1 a1, Arg2 a2...)
        : m_self(self)
          ...
(Continue reading)

David Abrahams | 1 Jun 2002 23:56
Favicon
Gravatar

function<> request

Would it be possible to make the function0...functionN headers a part of
the public interface to this library? I need to use function2 in the
Boost.Python library and would rather my users didn't have to process all
those other headers.

TIA,
Dave

+---------------------------------------------------------------+
                  David Abrahams
      C++ Booster (http://www.boost.org)               O__  ==
      Pythonista (http://www.python.org)              c/ /'_ ==
  resume: http://users.rcn.com/abrahams/resume.html  (*) \(*) ==
          email: david.abrahams <at> rcn.com
+---------------------------------------------------------------+

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Zorba the Hutt | 2 Jun 2002 00:29
Favicon

Interest in binary serializaton library?


I've been playing around with making a binary serialization library in the
same style of C++'s streams (in fact, nearly identical) and I was wondering
if there would be any interest in adding it to Boost once it's more
together. Or whether there's one already :)

For those curious about details . . .

It's designed to parallel the C++ stream hierachy (fstream becomes bfstream,
iostream becomes biostream, ifstream becomes bifstream), with the exception
that it's not templated. Since it's dealing on a byte level at all times it
seemed kind of useless. It uses the already-existing streambuf classes to do
the actual work, so adding other people's extended streams to it would be
extremely fast. I'm not having any support for formatters at the moment
(because what would they do? :P) but aside from that, just about everything
that works on C++ streams will work on these binary streams.

As for endian-ness, I'm making that an option in the .open() call - you can
choose native, bigendian, littleendian, or network byte order. I'm leaning
towards native being the default, just because people who understand why
their bytes are in the wrong order will also be able to figure out how to
change it.

Different size of datatypes will be completely ignored, in effect ;) If you
pass it a 4-byte integer, it'll write 4 bytes. If you want crossplatform
code to write the same files across different platforms with different
integer sizes, the coder should use typedefs to define 32-bit and 16-bit
datatypes, then interface with those.

I'm using the same operator<< semantics that iostream does. I'm not planning
(Continue reading)

David GD Wilson | 2 Jun 2002 04:03

RE: mirroring class instances between c++ and python

Dave,

Thanks for the response. I have looked into the method you have
suggested below. However unsure how I can create a CTest instance within
my c++ code? I can see how it will work if I create the CTest/PTest from
inside python, but I need to create the CTest/PTest from c++.

Is this going to be possible with the method you have suggested?

Thanks for any help.
David

> -----Original Message-----
> From: David Abrahams [mailto:david.abrahams <at> rcn.com]
> Sent: 01 June 2002 21:56
> To: "David GD Wilson"; pysig; boost
> Subject: Re: [boost] mirroring class instances between c++ and python
> 
> David,
> 
> Please post followups to the C++-sig (c++-sig <at> python.org).
> 
> ----- Original Message -----
> From: "David GD Wilson" <firestar <at> thenorth.org>
> 
> 
> > Hi,
> >
> > I am hoping someone has managed to get this problem working before
and
(Continue reading)


Gmane