GNU Smalltalk Object doesn't understand init - smalltalk

I have just started learning GNU Smalltalk from this page.
My question is if this page is outdated? In the class creation example it has the r := super new. ^r init massage, however running Object new init i get
Object: Object new "<0x7f930e71d800>" error: did not understand #init
I am running the gst version 3.2.91.

The documentation explicitly says:
So what we need to do is ask the object to set itself up. By saying r
init, we are sending the init message to our new Account. We’ll
define this method in the next section—for now just assume that
sending the init message will get our Account set up.
In other words, you have to keep reading to learn how to define init.

Related

What error should I return when a COM object has been deleted but is being attempted to be referenced?

I have extended an API in C++ written on a legacy framework that is used via JavaScript/VB. There is an object that can create from another object. However, the coder can hold on to that object (it's exposed) and do operations on it. Also, the object can be deleted. Because of that last part, I need to keep the object around, even when it is deleted in case the developer tries to reference through that object, and if they attempt to do so, return an error (HRESULT), otherwise, it could cause a crash.
What is the best common HRESULT that I should use? I can't seem to find one that matches what I want.
The only one that I found the winerr.h file that might be relivant is ERROR_FLT_DELETING_OBJECT, but I don't think it is meant for that.
EDIT
Perhaps I should not use the word delete and replace it with instead detach. The object is to be detached from the main object, but is still lives on till the gc cleans up. However, if the user were to attempt to use this detached object, I want them to wake up to the fact that they have already detached it and that they shouldn't be playing with it any more.
EXAMPLE
var newObj = container.create_newObject();
newObj.doStuff();
container.doStuffWithNewObject(newObject);
container.RemoveObject(newObj);
newObj.doStuff(); // ERROR - see, still have reference and attempting to do stuff.
container.doStuffWithNewObject(newObject); // ERROR

Setting SessionProperty exception

I have various mule unit tests that extend my ABCTestTransformer - this creates a new instance of ABCTransformer but also extends the AbstractTransformerTestCase
On the tests when they create a new instance of ABCTransformer and get to this line within the transformer in the public Object transformMessage(MuleMessage message, String outputEncoding) method is where all the tests fail
message.setSessionProperty(data here)
I keep getting the following exception
failed with
exception(s)[org.mule.api.transformer.TransformerException: Detected
an attempt to set a invocation or session property, but a MuleEvent
hasn't been created using this message yet.
These unit tests were working with Mule 3.2 but I am migrating to 3.6 and I am now having issues.
Anyone able to shed any light on this?
Thanks
I think the setSessionProperty is already deprecated.
You may try this as an alternative.
message.setProperty(yourkey, value, PropertyScope.SESSION);
Hope this helps :)
As I understand it, you are setting the value on a wrong sequence, you should call the testEvent first before setting the values. Below is the screenshot, with setting a session variable that works, this is created with lower version of Munit and mule 3.4.
HTH

CoreLocation Framework: Does locationManager send a message with filled in parameters everytime it logs a new location?

In the process of learning iOS development and I am currently being taught how to use the core location framework.
I'm told that we need to create an instance of CLLocationManager, and then set a delegate, then implement this method:
-(void) locationManager: (CLLocationManager*)manager
didUpdateToLocation: (CLLocation*)newLocation
fromLocation: (CLLocation*)oldLocation
The book doesn't thoroughly explain how the location is actually received. From what I'm understanding, whenever locationManager logs a new location, it then sends a message (to the delegate?) with the selector being the above method, filling the parameters with the location data? Then we must implement this method and choose what to do with these parameters.
Is this correct? and if not, could someone explain to me exactly what is going on?
Thanks in advance, this is confusing me a ton.
Right, although the message you should implement starting in iOS 6 is -locationManager:didUpdateLocations:. After setting up the delegate, call -startUpdatingLocation and the Location Manager will start sending -locationManager:didUpdateLocations: (or the other method) whenever the location changes until you tell it to stop. Your implementation of that method an do whatever you like -- update a position on a map, log the location to a file, look up the nearest gas stations... There's some reason that you're asking for location updates, and whatever that reason is, this lets you do it.

Resque not performing any methods

I've got Resque set up in my Rails 3.2 app and have an after hook which successfully calls
Resque.enqueue(SomeJob, self.class.name, id)
I can see the job getting fired off, but no methods in my SomeJob class are getting executed. I've got a logger set up confirming the SomeJob gets executed but the log statement inside my self.perform block never gets called.
def self.perform
log.debug("working")
end
So far I've tried methods named self.work, work, self.perform, perform and nothing seems to get called. The Resque documentation seems to be geared towards a pending 2.0.0 release but I can't quite get this to work even with 1.24.1 or 1.22.
What is the magic method that gets called in Resque? Is there any way to explicitly call it in Resque.enqueue?
At first glance it looks like you're passing in two arguments (self.class.name and id), but the self.perform method isn't able to accept them, so it could be silently failing with an invalid argument error.
My suggestion would be to change the self.perform method to the following:
def self.perform(class_name, id)
log.debug("working: class_name=#{class_name} id=#{id}")
end

Media Foundation: another way to call IMFActivate::ShutdownObject?

Here is a question about IMFActivate::ActivateObject and IMFActivate::ShutdownObject in Media Foundation.
According to MSDN, the component that calls ActivateObject is responsible for calling ShutdownObject.
But there are two examples not following this rule:
http://msdn.microsoft.com/en-us/library/dd388503%28VS.85%29.aspx
and
http://msdn.microsoft.com/en-us/library/dd317912%28VS.85%29.aspx
In these two examples, they call ActivateObject and then release IMFActivate interface without calling ShutdownObject method.
This is going to lead to memory leaking, right? Or there is another way to release the resource occupied by the object?
(Can I use IMFMediaSource::Shutdown to release the object instead of using IMFActivate::ShutdownObject)
Thanks in advance.
You're right that you're supposed to call IMFActivate::ShutdownObject when you're done using the object you activated. However, notice that the sample in question is instantiating an IMFMediaSource to be returned in an out param.
HRESULT CreateVideoDeviceSource(IMFMediaSource **ppSource)
If CreateVideoDeviceSource were to do a ShutdownObject on the IMFMediaSource it instantiated and then hand it back to you, it would be in a shut-down state and therefore probably unusable.
To answer your question about what you're supposed to do about this, you can probably get away with a pMyMediaSource->Shutdown() after you're all done using it.
More info: IMFActivate's other use in Media Foundation is for allowing an MF object to be instantiated in a different process (useful because the MF Media Session will play DRM-protected content in a separate process); in that case, the MF Media Session will indeed call IMFActivate::ShutdownObject on any IMFActivates you gave it.