realbasic-plugins
[Top] [All Lists]

Re: Overloading a Constructor

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Re: Overloading a Constructor
From: Phil M <phil at mobleybros dot com>
Date: Sat, 22 Jul 2006 08:48:16 -0400
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
References: <1hiujoy dot syxsec18mziq3M%support at monkeybreadsoftware dot de> <943F2C42-8E51-40A8-A7D8-A261FFC0B8CC at mobleybros dot com> <D73DF16D-4CE1-445A-921E-496312F5769D at great-white-software dot com> <A2101EDA-C903-415E-9130-3AFA4F58C62C at mobleybros dot com> <75F652C0-92EF-410B-8B5A-16404AD01E10 at mac dot com>
On Jul 22, 2006, at 8:33 AM, Alfred Van Hoek wrote:

Well, one of the other things that I am confused about is declaring the method. Does the name of the method in C have to be the same as the "description" written in the REALmethodDefinition? (all examples I have seen have shown the same name). I tried naming my C methods "Constructor" but I had some sort of compile error.

A REALmethodDefinition maps a C-function to a RB method declaration. So if you define a method map like

{ (REALproc) MyCMethodConstructor, REALnoImplementation, "Constructor(p As Picture)" },

Does each function (such as "MyCMethodConstructor") need to have a unique name?

Then the user can only instantiate your class with: myClass As yourClass = new yourClass(p). By defining a single constructor in the REALmethodDefinition you also automatically disable the default ability to call "new yourClass()".

OK, that might be the reason why I was crashing... I also had a default constructor/initializer defined.

I currently am trying to have three constructors (though I would rather have two with a default value). The problem is that the constructor that I really want to use takes a Picture as a parameter and all attempts to use this constructor have crashed.

Then you do something wrong elsewhere.

Might be the reason above.

It is like an RB experience... And just forget about the "Initializer" and "Finalizer" declarations. Those are never exposed to the user of your plugin. They are only meant if you need to do things under the hood. For example you need to allocate memory, respectively deallocate memory. If it is a simple struct you are dealing with, then the initializer and/or finalizer can be nil.

Well I am allocating/deallocating memory, but I also use the "Initializer" to set all of the struct values to their default values.


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>