images page 3 - Dave's Blog

Search
My timeline on Mastodon

Retweet of FxSiteCompat

2016 Jan 27, 7:44
#Firefox 46 Developer Edition is out! Non-HTTPS pages w/ login form are now marked insecure https://www.fxsitecompat.com/versions/46/  pic.twitter.com/o2WZ6K2KxN
PermalinkComments

Retweet of mathias

2016 Jan 27, 10:29
Take any Facebook/Instagram photo URL.👉 append `.txt` → ASCII art👉 append `.html` → colored ASCII artE.g. https://scontent-ams3-1.cdninstagram.com/t51.2885-15/e35/11906246_1700002456899911_1391970345_n.jpg.html …
PermalinkComments

Tweet from David_Risney

2016 Jan 27, 9:15
Whatever happened to sitcom couples? Conspiracy and death. https://medium.com/@iamchrisscott/whatever-happened-to-television-s-most-famous-couples-c9d569a892ea#.w2wijr6he … Had to recheck URL I wasn't on clickhole
PermalinkComments

Retweet of f4grx

2016 Jan 26, 7:43
@FakeUnicode also UNICODE CONSORTIUM FACE REVIEWING EMOJI CODEPOINT REQUESTS
PermalinkComments

Retweet of FakeUnicode

2016 Jan 26, 7:15
OH COME ON. SERIOUSLY?? pic.twitter.com/EMdqGylC4L
PermalinkComments

Retweet of ericlaw

2016 Jan 26, 5:09
pic.twitter.com/cxDdy6pDax
PermalinkComments

Retweet of edwardsanchez

2016 Jan 26, 4:51
First time I see transparent LED being used. Feels science fictiony.
PermalinkComments

Retweet of iainthomson

2016 Jan 25, 10:04
What computer users see in security warning boxes #enigma2016 Very, very true. pic.twitter.com/8V4SlGwKAV
PermalinkComments

Retweet of TheAVClub

2016 Jan 25, 4:05
ICYMI: “Weird Al” Yankovic joins Comedy Bang! Bang! as bandleader and co-host http://avc.lu/1nkaxWC 
PermalinkComments

Retweet of xeni

2016 Jan 25, 1:18
UK film censors forced to watch a 2-day long movie of paint drying cc: @greatdismal http://boingboing.net/2016/01/25/uk-film-censors-forced-to-watc.html … pic.twitter.com/M8LWjiWUXe
PermalinkComments

Retweet of FakeUnicode

2016 Jan 24, 10:52
.@alolita How Ancient Egypt fell. "But great Pharaoh, we need a snake playing croquet." "You have like 50 snake symbols." "But, croquet!"
PermalinkComments

Retweet of Crash_Games

2016 Jan 24, 10:25
I sure missed these guys. pic.twitter.com/eMFPs4fNUP
PermalinkComments

Retweet of waxpancake

2016 Jan 24, 9:10
"This is a cool song but it was taken down by youtube so I fixed the audio." 😂 (thx, @sarahjeong) http://youtu.be/-5KnWfx_H-s 
PermalinkComments

Tweet from David_Risney

2016 Jan 24, 3:13
Unicode includes 24 clock face code points, so obv here's my Unicode clock: http://david-risney.github.io/UnicodeClock/ 
PermalinkComments

Retweet of JustRogDigiTec

2016 Jan 22, 5:43
This is becoming increasingly more relevant as high quality games/apps move to #html5https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/ …#html5games #webGL
PermalinkComments

Retweet of ericlaw

2016 Jan 21, 10:22
Madlibs for the 21st Century https://twitter.com/technicallyron/status/690175736225882112 …
PermalinkComments

JavaScript Types and WinRT Types

2016 Jan 21, 5:35

MSDN covers the topic of JavaScript and WinRT type conversions provided by Chakra (JavaScript Representation of Windows Runtime Types and Considerations when Using the Windows Runtime API), but for the questions I get about it I’ll try to lay out some specifics of that discussion more plainly. I’ve made a TL;DR JavaScript types and WinRT types summary table.

WinRT Conversion JavaScript
Struct ↔️ JavaScript object with matching property names
Class or interface instance JavaScript object with matching property names
Windows.Foundation.Collections.IPropertySet JavaScript object with arbitrary property names
Any DOM object

Chakra, the JavaScript engine powering the Edge browser and JavaScript Windows Store apps, does the work to project WinRT into JavaScript. It is responsible for, among other things, converting back and forth between JavaScript types and WinRT types. Some basics are intuitive, like a JavaScript string is converted back and forth with WinRT’s string representation. For other basic types check out the MSDN links at the top of the page. For structs, interface instances, class instances, and objects things are more complicated.

A struct, class instance, or interface instance in WinRT is projected into JavaScript as a JavaScript object with corresponding property names and values. This JavaScript object representation of a WinRT type can be passed into other WinRT APIs that take the same underlying type as a parameter. This JavaScript object is special in that Chakra keeps a reference to the underlying WinRT object and so it can be reused with other WinRT APIs.

However, if you start with plain JavaScript objects and want to interact with WinRT APIs that take non-basic WinRT types, your options are less plentiful. You can use a plain JavaScript object as a WinRT struct, so long as the property names on the JavaScript object match the WinRT struct’s. Chakra will implicitly create an instance of the WinRT struct for you when you call a WinRT method that takes that WinRT struct as a parameter and fill in the WinRT struct’s values with the values from the corresponding properties on your JavaScript object.

// C# WinRT component
public struct ExampleStruct
{
public string String;
public int Int;
}

public sealed class ExampleStructContainer
{
ExampleStruct value;
public void Set(ExampleStruct value)
{
this.value = value;
}

public ExampleStruct Get()
{
return this.value;
}
}

// JS code
var structContainer = new ExampleWinRTComponent.ExampleNamespace.ExampleStructContainer();
structContainer.set({ string: "abc", int: 123 });
console.log("structContainer.get(): " + JSON.stringify(structContainer.get()));
// structContainer.get(): {"string":"abc","int":123}

You cannot have a plain JavaScript object and use it as a WinRT class instance or WinRT interface instance. Chakra does not provide such a conversion even with ES6 classes.

You cannot take a JavaScript object with arbitrary property names that are unknown at compile time and don’t correspond to a specific WinRT struct and pass that into a WinRT method. If you need to do this, you have to write additional JavaScript code to explicitly convert your arbitrary JavaScript object into an array of property name and value pairs or something else that could be represented in WinRT.

However, the other direction you can do. An instance of a Windows.Foundation.Collections.IPropertySet implementation in WinRT is projected into JavaScript as a JavaScript object with property names and values corresponding to the key and value pairs in the IPropertySet. In this way you can project a WinRT object as a JavaScript object with arbitrary property names and types. But again, the reverse is not possible. Chakra will not convert an arbitrary JavaScript object into an IPropertySet.

// C# WinRT component
public sealed class PropertySetContainer
{
private Windows.Foundation.Collections.IPropertySet otherValue = null;

public Windows.Foundation.Collections.IPropertySet other
{
get
{
return otherValue;
}
set
{
otherValue = value;
}
}
}

public sealed class PropertySet : Windows.Foundation.Collections.IPropertySet
{
private IDictionary map = new Dictionary();

public PropertySet()
{
map.Add("abc", "def");
map.Add("ghi", "jkl");
map.Add("mno", "pqr");
}
// ... rest of PropertySet implementation is simple wrapper around the map member.


// JS code
var propertySet = new ExampleWinRTComponent.ExampleNamespace.PropertySet();
console.log("propertySet: " + JSON.stringify(propertySet));
// propertySet: {"abc":"def","ghi":"jkl","mno":"pqr"}

var propertySetContainer = new ExampleWinRTComponent.ExampleNamespace.PropertySetContainer();
propertySetContainer.other = propertySet;
console.log("propertySetContainer.other: " + JSON.stringify(propertySetContainer.other));
// propertySetContainer.other: {"abc":"def","ghi":"jkl","mno":"pqr"}

try {
propertySetContainer.other = { "123": "456", "789": "012" };
}
catch (e) {
console.error("Error setting propertySetContainer.other: " + e);
// Error setting propertySetContainer.other: TypeError: Type mismatch
}

There’s also no way to implicitly convert a DOM object into a WinRT type. If you want to write third party WinRT code that interacts with the DOM, you must do so indirectly and explicitly in JavaScript code that is interacting with your third party WinRT. You’ll have to extract the information you want from your DOM objects to pass into WinRT methods and similarly have to pass messages out from WinRT that say what actions the JavaScript should perform on the DOM.

PermalinkCommentschakra development javascript winrt

Retweet of GundersenMarius

2016 Jan 19, 10:49
I love this diagram in the WHATWG spec. It explains it much better than words could pic.twitter.com/RflCT5JIGu
PermalinkComments

Retweet of BoingBoing

2016 Jan 19, 8:50
We'll probably never "Free Mickey." #copyfight http://boingboing.net/2016/01/19/well-probably-never-free-m.html … pic.twitter.com/Z4nQfGRfvm
PermalinkComments

Retweet of evacide

2016 Jan 19, 8:00
EFF litigates the US governnent into still more transparency into how it decides to use 0days, by @agcrocker. https://www.eff.org/deeplinks/2016/01/eff-pries-more-transparency-zero-days-governments-grasp …
PermalinkComments
Older EntriesNewer Entries Creative Commons License Some rights reserved.