Reputation: 25897
As we all know that WinRT is an enhanced version of Microsoft's Component Object Model (COM). I didn't get much chance to work directly with COM components except to manage distributed transactions over a decade ago. I'm sure COM is used a lot internally at OS level.
I was reading that WinRT types are subject to COM-style restrictions. I was able to get few restrictions by searching over internet as below:
Can someone help me with some good high level restrictions imposed for COM types or may be point me to some good resource where I can get an exhaustive information on this. I tried googling a lot but to no help.
Upvotes: 1
Views: 542
Reputation: 18127
Check Restriction and Rules part of Wikipedia article
Since Windows Runtime is projected to various languages, some restrictions on fundamental data types exist so as to host all such languages. Programmers must be careful with the behavior of those types when used with public access (for method parameters, method return values, properties, etc.
Basic types
In .NET languages and C++, a rich set of data types exists, representing various numerals.
In JavaScript, a Number can only represent up to 53 bits of precision.
In WinRT, the only lacking numeral data type is 8-bit signed integer relative to .NET and C++. JavaScript developers must be careful when dealing with big numbers while coding for WinRT.
Strings
Strings are immutable in .NET and JavaScript, but mutable in C++.
A null pointer passed as a string to WinRT by C++ is converted to an empty string
In .Net, null being passed as a string to WinRT is converted to an empty string
In JavaScript, null being passed as a string to WinRT is converted to a string with the word null. This is due to JavaScript's keyword null being represented as a null object
Similar results occur when passing undefined to WinRT from JavaScript
Structs
In .NET and C++, structs are value types, and such a struct can contain any type in it.
JavaScript does not directly support structs.
In WinRT, use of structs is allowed only for containing types that have value semantics, including numerals, strings, and other structs. Pointers or interface references are disallowed.
References
In .NET, objects are passed by reference, whereas numerals and structs are >passed by value.
In C++, all types can be passed by reference or value.
In WinRT, interfaces are passed by reference; all other types are passed by value.
Arrays
In .NET, C++, and JavaScript arrays are reference types.
In WinRT, arrays are value types.
Events
In .NET and C++, clients subscribe to events using += operator.
In JavaScript, addEventListener function or setting on property is used to subscribe to events.
In WinRT, all languages can use their own way to subscribe to events.
Collections
Some .NET collections map directly to WinRT collections.
WinRT Vector type resembles arrays and the array syntax is used to consume them.
WinRT Map type is a key/value pair collection, and is projected as Dictionary in .NET languages.
Method overloading
All WinRT languages (.NET, C++, JavaScript) support overloading on parameters
.NET and C++ also support overloading on type.
In WinRT, only parameter number is used for overloading.
Asynchrony
All WinRT methods are designed such that any method taking longer than 50 milliseconds is an async method.
The established naming pattern to distinguish asynchronous methods is Async. For the full runtime library, all methods that have a chance to last longer than 50 ms are implemented as asynchronous methods only.
Upvotes: 1