Non-standard C features?

  • Follow


Sorry for this newbie question.

From the lcc-win32 user manual.

--8<--

The framework provided by lcc-win32 centers about providing a simple
interface for calling all the functions associated with a certain control.
The general syntax for using this objects is:

object->Method(arguments)

This is a short hand for the normmaly used C syntax, that has ben
simplified. In strict C you woould be required to write:

object->lpVtbl->Method(object,arguments);

--8<---

I'm puzzled about this. Does this mean that lcc supports some kind of C++
style method calling, or this is achieved with macros or some such? What is
'the framework' to which it refers? Where shoudl I be looking to read about
this stuff?

Thanks

John Vaudin
mailto:john@vaudin.net






0
Reply John 7/3/2003 5:13:11 PM

"John Vaudin" <john@vaudin.net> wrote in message
news:be1o7p$aij$1$8302bc10@news.demon.co.uk...
> Sorry for this newbie question.
>
> From the lcc-win32 user manual.
>
> --8<--
>
> The framework provided by lcc-win32 centers about providing a simple
> interface for calling all the functions associated with a certain control.
> The general syntax for using this objects is:
>
> object->Method(arguments)
>
> This is a short hand for the normmaly used C syntax, that has ben
> simplified. In strict C you woould be required to write:
>
> object->lpVtbl->Method(object,arguments);
>

I can't find any of that in the lcc-win32 docs.

> I'm puzzled about this. Does this mean that lcc supports some kind of C++
> style method calling, or this is achieved with macros or some such? What
is
> 'the framework' to which it refers? Where shoudl I be looking to read
about
> this stuff?

An example that might help using these methods is on my web site in the
libraries section. It's called 'StringObject'.

John


0
Reply John 7/3/2003 6:39:10 PM


"John" <John.zzzPortal@btinternet.com> wrote in message news:be1t7a$cpgq$1@ID-97861.news.dfncis.de...
>
> "John Vaudin" <john@vaudin.net> wrote in message
> news:be1o7p$aij$1$8302bc10@news.demon.co.uk...
> > Sorry for this newbie question.
> >
> > From the lcc-win32 user manual.
> >
> > --8<--
> >
> > The framework provided by lcc-win32 centers about providing a simple
> > interface for calling all the functions associated with a certain control.
> > The general syntax for using this objects is:
> >
> > object->Method(arguments)
> >
> > This is a short hand for the normmaly used C syntax, that has ben
> > simplified. In strict C you woould be required to write:
> >
> > object->lpVtbl->Method(object,arguments);
> >
>
> I can't find any of that in the lcc-win32 docs.

It is under the Table of Contents listing "The Framework"

Robert Wishlaw


0
Reply Robert 7/4/2003 1:01:22 AM

"Andi.Martin" <Andi.Martin@freenet.de> wrote in message
news:be28sd$6qt$00$1@news.t-online.com...
> Hi John,
>
> lcc does not access to C++Object in that manner you mean...
> And a trick or non C isn't it too! The docs only try to open your mind and
> see that some things in C++ are useful but not even necessary or
> improvement.
> So if you look how objects work (and they also have to serve to mnemonics
of
> your ICs) you would see, that this is accessable even in assembler, so it
is
> in C too.
> So called "virtual method tables (VMT)" in C++ are only a structure of
> function pointers and this is a really old thing in C.
>
> Example:
  :
> You have now an "object", which is accessible like that:
> x=MyObject->Vtbl->GetXValueFunc(MyObject);

I understand function pointers, and I understand how C++ implements virtual
functions using vtbls.

I have a very specific question though.

In your example you use

obj->vtbl->method(args)

No problem - I understand this.

BUT the documentation says

> > The general syntax for using this objects is:
> >
> > object->Method(arguments)
> >
> > This is a short hand for the normmaly used C syntax, that has ben
> > simplified. In strict C you woould be required to write:
> >
> > object->lpVtbl->Method(object,arguments);

Which implies to me that I can rewrite

obj->vtbl->method(args)    as     obj->method(args)

Either the documentation is wrong and this is not true, or LCC implements
some kind of language extention to allow this syntax.

I really just want to know which it is. I am begining to suspect that the
documentation is misleading, but I'd be grateful if someone could explain.

Thanks

John



0
Reply John 7/4/2003 10:20:30 PM

"John Vaudin" <john@vaudin.net> wrote in message
news:be4ujj$as3$1$8300dec7@news.demon.co.uk...
>
> Which implies to me that I can rewrite
>
> obj->vtbl->method(args)    as     obj->method(args)

Or even obj.method()

> Either the documentation is wrong and this is not true, or LCC implements
> some kind of language extention to allow this syntax.

Yes, it's an extension.

As I wrote before.
===============
An example that might help using these methods is on my web site in the
libraries section. It's called 'StringObject'.
===============

http://www.btinternet.com/~john.findlay1/
http://www.john.findlay1.btinternet.co.uk/

John


0
Reply John 7/5/2003 5:57:53 AM

"John" <John.zzzPortal@btinternet.com> wrote in message
news:be5pbi$1f6p1$1@ID-97861.news.dfncis.de...
>
> "John Vaudin" <john@vaudin.net> wrote in message
> news:be4ujj$as3$1$8300dec7@news.demon.co.uk...
> >
> > Which implies to me that I can rewrite
> >
> > obj->vtbl->method(args)    as     obj->method(args)
>
> Or even obj.method()
>
> > Either the documentation is wrong and this is not true, or LCC
implements
> > some kind of language extention to allow this syntax.
>
> Yes, it's an extension.
>
> As I wrote before.
> ===============
> An example that might help using these methods is on my web site in the
> libraries section. It's called 'StringObject'.
> ===============

I have looked at the example. It answers some of my questions but not all.

In C++ the compiler knows to do this because you have a reference to an
object of some class with a virtual function defined on it. How does LCC
know to apply this magic? Is the name pVtbl magic in some way? I'd still
like to see some kind of documentation.

I have looked through the section on 'Special Features of lcc-win32' and I
can see no mention of this extension. I'm sure, given a spare moment, I
could knock up some test cases and deduce the bahviour, but I don't really
think that should be necessary.

John


0
Reply John 7/7/2003 9:01:57 AM

"John Vaudin" <john@vaudin.net> wrote in message
news:bebcu7$u5$1$8300dec7@news.demon.co.uk...

<snip>
>
> I have looked at the example. It answers some of my questions but not all.
>
> In C++ the compiler knows to do this because you have a reference to an
> object of some class with a virtual function defined on it. How does LCC
> know to apply this magic? Is the name pVtbl magic in some way? I'd still
> like to see some kind of documentation.

Can't help with the documentation but yes, it's a special feature added by
Jacob.

When used in the fashion shown by my example the object is implicit and
passed as the first parameter.

Depending on if the object is a pointer to struct you would do

obj->Func(something);

If the object is a struct you would do

obj.Func(something);

I don't know what else to say - :)

John




0
Reply John 7/7/2003 10:22:55 AM

"Robert Wishlaw" <rwishlaw@shaw.ca> wrote in message
news:Cl4Na.351759$3C2.9505612@news3.calgary.shaw.ca...
>
> "John" <John.zzzPortal@btinternet.com> wrote in message
news:be1t7a$cpgq$1@ID-97861.news.dfncis.de...
> >
> > "John Vaudin" <john@vaudin.net> wrote in message
> > news:be1o7p$aij$1$8302bc10@news.demon.co.uk...
> > > Sorry for this newbie question.
> > >
> > > From the lcc-win32 user manual.
> > >
> > > --8<--
> > >
> > > The framework provided by lcc-win32 centers about providing a simple
> > > interface for calling all the functions associated with a certain
control.
> > > The general syntax for using this objects is:
> > >
> > > object->Method(arguments)
> > >
> > > This is a short hand for the normmaly used C syntax, that has ben
> > > simplified. In strict C you woould be required to write:
> > >
> > > object->lpVtbl->Method(object,arguments);
> > >
> >
> > I can't find any of that in the lcc-win32 docs.
>
> It is under the Table of Contents listing "The Framework"

Thanks Robert, only just found it in lcc.chm !!

Perhaps it should be called

lcc-win32_user_manual.chm

John




0
Reply John 7/8/2003 8:22:56 AM

7 Replies
192 Views

(page loaded in 0.052 seconds)

Similiar Articles:













7/7/2012 7:59:53 PM


Reply: