SYNTHESIZE_SINGLETON_FOR_CLASS - objective-c

will some body explain me in detail that what is SYNTHESIZE_SINGLETON_FOR_CLASS and why we should use it. actually i have search on net that it allow us to access a data without creating object but we can do that by using static method.
so plz if someone can provide me a ref where i can get complete detatil of SYNTHESIZE_SINGLETON_FOR_CLASS from zero.

Do you mean http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html?
SYNTHESIZE_SINGLETON_FOR_CLASS is just a C macro defined that produce the same code template described in Apple's Creating a Singleton Instance section of the Cocoa Fundamentals Guide. This link already provides the detail what each method does.

Related

How to dynamically create fb instances during runtime on a plc?

I'm new to PLC programming and we need to create a library for a project. We need dynamically created function block instances during the runtime. There is a concept described on the codesys homepage:
https://help.codesys.com/webapp/fb_factory;product=LibDevSummary;version=3.5.15.0
We tried to implement the example but without success. Unfortunately, there is no further information about the concept on the codesys homepage.
Has anybody some advice how to dynamically create fb instances during the runtime on a plc?
When you want to create an instance of an FB dynamically you need first to put the following attribute above the FB-Declaration:
{attribute 'enable_dynamic_creation'}
Then you must make sure you are not calling __NEW(FB_NAME) cyclically.
Then you assign the result of __NEW(FB_NAME) to a pointer:
//Put this is the declaration section
pfbName : POINTER TO FB_NAME;
//Your call to create a dynamic instance
pfbName := __NEW(FB_NAME);
If your pointer = 0 after __NEW returns, it means __NEW failed to allocate memory.
I made a simple classic OOP Person, Teacher, Student example here.
Basically, changing the value of numberOfTeachers inside PLC_PRG will cause the reinitializarion of the array people with the first numberOfTeachers entries being Teachers, and the rest being Students. You can look at the Device Logs where I write messages for creation/destruction of Teacher/Studemt.
PS. I am myself still exploring the possibilities of the Factory Design in CODESYS, so excuse me if I made any mistakes!

Where can I find the descriptin of LibreOffice API for BASIC

I wanted to create a few macros for LibreOffice using BASIC. However I cannot find the API description. It is absent in help as well as in interet. When I try to google it I get masses of examples in C++, Java, Python, but not a single www with BASIC.
For example where from can I get the hierarchy of objects and their methods?
LibreOffice Basic uses essentially the same API as PyUNO and Java. That is, they all use the UNO API. To get started, the OpenOffice development guide helpfully describes the two main ways to step into the object hierarchy, the Global variables ThisComponent and, less commonly, StarDesktop. There also is a specialty variant in LO Base, ThisDatabaseDocument. To get the properties and methods of these objects, execute MsgBox oObject.DBG_properties or .DBG_methods. It often is easier to copy the longer lists that are returned by this method into a text editor for searching. You will find that all, or nearly all, of the methods and properties you reveal will be described in the LibreOffice UNO IDL API. The documentation for the API is not that descriptive, but you will be able to fill in some essential details using that resource Every Object has properties that can be reviewed by .DBG_properties.
The key properties for navigating the object hierarchy are .Parent, .Model, .CurrentController and occasionally .Source. The key methods are getByName() and getByIndex(). It also is helpful that events which trigger macros typically return an event object whose source or parent is the object that initiated the macro, for example, a command button. This object can be accessed by referring to it along with the Sub, i.e., Sub SubName (oEventObject As Variant)....

Where can i find a document explaining how Objective-C is implemented

I mean the fundamental runtime. How is method dispatching implemented (via a selector hashtable?). What is a selector anyway? How is the object model as you can add methods later with some low level API etc.
I need to look at it from a compiler programming point of view, not a simple user of the language.
Use the source.
http://www.opensource.apple.com/source/objc4/objc4-437/
And for parsing, look to Clang:
http://clang.llvm.org/get_started.html
Here's a few docs to get you started (should help you google the right questions):
http://www.mulle-kybernetik.com/artikel/Optimization/opti-9.html
http://developer.apple.com/documentation/Cocoa/Reference/ObjCRuntimeRef/index.html

What is the secret to understanding MSDN COM documentation?

I am looking for "typical" way one navigates MSDN to get a COM class to do what they want.
Example problem: I am looking for an API way to unblock a local file (remove internet zone/mark of the web from a file programmatically).
I found one post on stackoverflow.com that talked about clsid_persistentzoneidentifier. so i searched in MSDN and got to http://msdn.microsoft.com/en-us/library/ms537029(VS.85).aspx. What I am looking for,is what one does after they get to this url. From this location, I am not able to figure what the sequence of operations should be. How do I connect this IZoneIdentifier to IPersistFile? etc. There must be something basic that I am missing wrt COM related documentation. MSDN has interfaces and objects, but nothing that helps me visualize a "sequence" diagram of sorts. Nothing that will get me to understand which COM objects are from same class. hence can/or should be QueryInterfaced, adn which should be CoCreated.
The documentation for that indicates a few things.
The first is that you can call CoCreateInstance, passing CLSID_PersistentZoneIdentifier to get an implementation of these two interfaces:
IPersistFile
IZoneIdentifier
It also says:
Use IPersistFile to attach the object
to the target file and IZoneIdentifier
to examine or to manipulate the zone
ID.
That being said, you can look at the documentation for IPersistFile here:
http://msdn.microsoft.com/en-us/library/ms687223(VS.85).aspx
It shows that there is a Load method, which is what you want to call with the filename to load the implementation with details about the file.
From there, you can call QueryInterface on the IUnknown interface implementation to get the IZoneIdentifier interface and then call the Remove method on it to set the zone to the local machine.
For that purpose, if it's not obvious from the documentation, I like to find sample programs in which relevent APIs are used: either using Google, or perhaps from whichever of the Microsoft SDKs is relevent.
Microsoft SDKs, for example this one, include sample programs.

How do you implement C#4's IDynamicObject interface?

To implement "method-missing"-semantics and such in C# 4.0, you have to implement IDynamicObject:
public interface IDynamicObject
{
MetaObject GetMetaObject(Expression parameter);
}
As far as I can figure out IDynamicObject is actually part of the DLR, so it is not new. But I have not been able to find much documentation on it.
There are some very simple example implementations out there (f.x. here and here), but could anyone point me to more complete implementations or some real documentation?
Especially, how exactly are you supposed to handle the "parameter"-parameter?
The short answer is that the MetaObject is what's responsible for actually generating the code that will be run at the call site. The mechanism that it uses for this is LINQ expression trees, which have been enhanced in the DLR. So instead of starting with an object, it starts with an expression that represents the object, and ultimately it's going to need to return an expression tree that describes the action to be taken.
When playing with this, please remember that the version of System.Core in the CTP was taken from a snapshot at the end of August. It doesn't correspond very cleanly to any particular beta of IronPython. A number of changes have been made to the DLR since then.
Also, for compatibility with the CLR v2 System.Core, releases of IronPython starting with either beta 4 or beta 5 now rename everything in that's in the System namespace to be in the Microsoft namespace instead.
If you want an end to end sample including source code, resulting in a dynamic object that stores value for arbitrary properties in a Dictionary then my post "A first look at Duck Typing in C# 4.0" could be right for you. I wrote that post to show how dynamic object can be cast to statically typed interfaces. It has a complete working implementation of a Duck that is a IDynamicObject and may acts like a IQuack.
If you need more information contact me on my blog and I will help you along, as good as I can.
I just blogged about how to do this here:
http://mikehadlow.blogspot.com/2008/10/dynamic-dispatch-in-c-40.html
Here is what I have figured out so far:
The Dynamic Language Runtime is currently maintained as part of the IronPython project. So that is the best place to go for information.
The easiest way to implement a class supporting IDynamicObject seems to be to derive from Microsoft.Scripting.Actions.Dynamic and override the relevant methods, for instance the Call-method to implement function call semantics. It looks like Microsoft.Scripting.Actions.Dynamic hasn't been included in the CTP, but the one from IronPython 2.0 looks like it will work.
I am still unclear on the exact meaning of the "parameter"-parameter, but it seems to provide context for the binding of the dynamic-object.
This presentation also provides a lot of information about the DLR:
Deep Dive: Dynamic Languages in Microsoft .NET by Jim Hugunin.