any type conversion

Hi,   
I started trying to implement the WebIDL "4.2. ECMAScript type mapping", but got stuck:(  

The terminology of the spec seems a little confused (or I'm just confused) between types defined in WebIDL and terminology used in ECMAScript5.  

This is as far as I was able to get...

function convertAny(value){
/*
Since the IDL any type is the union of all other IDL types, it can correspond to any ECMAScript value type.
How to convert an ECMAScript value to an IDL any value depends on the type of the ECMAScript value:
*/

var type = ECMAScript.Type(value);  
var idlType;
switch(type){  
  
//The undefined value
case("Undefined"):
// The IDL value is an object reference to a special object that represents the ECMAScript undefined value.
idlType = undefined;  
break;
…


}

I don't know what you mean by an object reference to a "special object"? And clearly, the above code doesn't seems achieve anything useful… So I'm not able to understand what you want me to implement there:(   
  
Also, it's confusing that the algorithm is not written in terms of types (i.e., values derived from Type(x) in ECMAScript). If it was, may make things a bit more clear.   

Confused,
Marcos  

Received on Monday, 19 March 2012 19:09:12 UTC