What is the definition of "Symbol" in the context of typescript compiler API? - typescript-compiler-api

I am looking for the definition and examples of the term "Symbol" in the context of the typescript compiler API.
how is it constructed?
what is it used for?
Thank you!

Related

Flowtype libdefs -- How to export a class definition from one module and extend it in another?

The project I'm working on uses some 3rd-party libraries in which a main module defines classes that are imported and extended by other, associated modules. In my case the main module is three.js, a JavaScript 3D computer graphics library, and the other modules are extensions that extend the features of the main module. These superclasses are an important part of the interface to the extensions, and I would like to include their contribution. Flow has been a great tool for typechecking the rest of the project, but I haven't been able to describe this particular situation well.
I've played with the existing three.js libdef and looked through several others for ideas, without luck. You can certainly declare/export a class in one module and import its type into another, but while that can be used to describe function parameters and such, you can't define a class that extends the imported type: flow complains that it "Cannot reference type ... [1] from a value position. [type-as-value]". I tried using the Class utility type, but that doesn't seem to be available in a libdef: using it causes a "Cannot resolve name Class. [cannot-resolve-name]" error. Am I missing something obvious here? Perhaps there's an well-known workaround?
Thanks in advance for any suggestions.

what are the usage of callStaticObjectMethod callStaticMethod

The qt documentation is poor in QAndroidJniObject object. Could you possibly tell me what the difference between callStaticObjectMethod and callStaticMethod is and when should I use them?
If you have any working example, It would be appreciated if address them in you answers. (like Q notifier)
Thank you
As I've mentioned in a comment, the callStaticMethod is used with primitive types (which are listed here). This function returns the type you requested (ex. jint) not QAndroidJniObject.
And callStaticObjectMethod is used with methods returning an object type (which are listed here). It returns the QAndroidJniObject.
You can find example code in Qt unit test files on their git repository

Haxe get function parameter type

I have haxe code like this:
var fn:String->Int = function(s:String):Int{
return 1;
}
getParameterType(fn,1);//Should return String as it is first parameter of fn
what should function getParameterType code look like?
The Haxe Reflection APIs can be found here: Reflect and Type.
Looking through them, there doesn't seem to be any way to check the types of arguments on functions, probably because this information isn't available at runtime on many of the platforms. Javascript for instance is loosely typed, and the information you are looking for is not included by default.
So you have three options:
Use RTTI (Run Time Type Info). If a class is marked with #:rtti metadata (in Haxe 3, or if it implements haxe.rtti.Infos in Haxe 2), then information about that class, including the types of function parameters, is available in Xml format at run time. You will have to look at the Xml to figure out what the argument is. This will only work for functions which are attached to classes though, it won't work for anonymous functions.
Use macros. This is outside the scope of my answer, but maybe ask on the Haxe mailing list if you need help :) If the argument type is known at compile time, it can be made known to macros, and you can probably save that information back somewhere so it is available at run time.
Figure out another usage that doesn't require you to know the type :)
Of course, if you only need the information at compile-time, not at run-time, you can do: $type(fn) anywhere in your code and when you compile it will let you know the exact type signature of "fn".

WinRT Reflection (C++/CX)

how can I introspect an object in C++/CX? I known how to get its class name (using IInspectable) but I wasn't able to figure out how to get a list of its properties or how to invoke methods if I have just a name of the method (string). I searched for an answer here and at Google but what I found is related to the .NET layer of WinRT (the System.Reflection namespace doesn't seem to be available in C++/CX).
As hinted by svick, you take the class name (retrieved from IInspectable::GetRuntimeClassName), hand it to RoGetMetaDataFile. This returns an IMetaDataImport2. Now call IMetaDataImport2::FindTypeDefByName. This returns a typedef token. Now call IMetaDataImport2::GetTypeDefProps which will give you properties about the type.
From the typedef properties, you can retrieve other information - enumerate the methods/fields if it's an interface/struct (or enum), find the type of the runtime class (if it's an interface or a class), etc.
C++ doesn't provide any specific APIs to reflect on WinRT types, these types are fully defined in CX compliant metadata files and you can use the CLR native metadata APIs to read their definition. There is a snippet at
http://social.msdn.microsoft.com/Forums/windowsapps/en-US/211ef583-db11-4e55-926b-6d9ab53dbdb4/ccx-reflection
James McNellis released a full C++ library for CX reflection last year
http://seaplusplus.com/2012/04/26/cxxreflect-native-reflection-for-the-windows-runtime/
Even most of the normal .Net reflection isn't included in the subset of .Net available to WinRT applications. And I didn't find any reflection-related types in the WinRT documentation. This means that (unless I overlooked something) reflection is simply not exposed by the available APIs.
Although I don't see why it shouldn't be available. The metadata is there, which should be enough.
When looking at the C++-specific functions, there is the function RoGetMetaDataFile(). It seems it should be possible to use it to get the metadata. But it's a native C++ function, not C++/CX. This means it's not easy to use (manual memory management, …) and I doubt it will be allowed in apps that are in the Store.

Get ActionScript Classes that Implement an Interface

In ActionScript (AS3) how do I find all the classes that implement a particular interface?
In OOP terms, you never want to be able to do this: the primary characteristic of interfaces is they are terms of a contract. Any class can choose to fulfill that contract and be able to say "I implement this interface".
Any code that references an instance of the interface don't care what class actually implements it: they don't have to; that's the really cool part of interfaces.
But if you want to find out, grep for "implements IFred"
Cheers
I've figured out how to do this and posted a demo on my blog. It uses the getDefinitionNames library mentioned in the comments above.
In Flash Builder I use ctrl-h and search for method names or the actual name of the interface.

Resources