@@ -133,7 +133,6 @@ let rec main() =
133133 List. iter (fun x -> if generated x then gen_class_file x) classes;
134134 TypeSet. iter gen_enum ! enums;
135135 gen_maps() ;
136- gen_i18n_errors() ;
137136 gen_http_actions() ;
138137 gen_relations() ;
139138 let sorted_members = List. sort String. compare ! api_members in
@@ -326,8 +325,6 @@ using System;
326325using System.Collections;
327326using System.Collections.Generic;
328327
329- using CookComputing.XmlRpc;
330-
331328
332329namespace XenAPI
333330{
@@ -714,7 +711,7 @@ and exposed_param p =
714711and exposed_call_params message classname params =
715712 let exposedParams = List. map exposed_call_param params in
716713 let name = String. lowercase classname in
717- let refParam = sprintf " ( _%s != null) ? _%s : \"\" " name name in
714+ let refParam = sprintf " _%s ?? \"\" " name in
718715 let exposedParams = if is_method_static message then exposedParams else refParam::exposedParams in
719716 String. concat " , " (" session.uuid" ::exposedParams)
720717
@@ -1273,8 +1270,8 @@ and convert_to_proxy thing ty = (*function*)
12731270 | Int -> sprintf " %s.ToString()" thing
12741271 | Bool
12751272 | Float -> thing
1276- | Ref _ -> sprintf " ( %s != null) ? %s : \"\" " thing thing
1277- | String -> sprintf " ( %s != null) ? %s : \"\" " thing thing
1273+ | Ref _ -> sprintf " %s ?? \"\" " thing
1274+ | String -> sprintf " %s ?? \"\" " thing
12781275 | Enum (name ,_ ) -> sprintf " %s_helper.ToString(%s)" name thing
12791276 | Set (Ref name ) -> sprintf " (%s != null) ? Helper.RefListToStringArray(%s) : new string[] {}" thing thing
12801277 | Set (String) -> thing
@@ -1320,159 +1317,24 @@ and is_static_readonly field =
13201317 | DynamicRO -> " false"
13211318 | _ -> " false"
13221319
1323- and i18n_header out_chan =
1324- let print format = fprintf out_chan format in
1325- print
1326- " <?xml version=\" 1.0\" encoding=\" utf-8\" ?>
1327- <root>
1328- <!--
1329- Microsoft ResX Schema
1330-
1331- Version 2.0
1332-
1333- The primary goals of this format is to allow a simple XML format
1334- that is mostly human readable. The generation and parsing of the
1335- various data types are done through the TypeConverter classes
1336- associated with the data types.
1337-
1338- Example:
1339-
1340- ... ado.net/XML headers & schema ...
1341- <resheader name=\" resmimetype\" >text/microsoft-resx</resheader>
1342- <resheader name=\" version\" >2.0</resheader>
1343- <resheader name=\" reader\" >System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
1344- <resheader name=\" writer\" >System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
1345- <data name=\" Name1\" ><value>this is my long string</value><comment>this is a comment</comment></data>
1346- <data name=\" Color1\" type=\" System.Drawing.Color, System.Drawing\" >Blue</data>
1347- <data name=\" Bitmap1\" mimetype=\" application/x-microsoft.net.object.binary.base64\" >
1348- <value>[base64 mime encoded serialized .NET Framework object]</value>
1349- </data>
1350- <data name=\" Icon1\" type=\" System.Drawing.Icon, System.Drawing\" mimetype=\" application/x-microsoft.net.object.bytearray.base64\" >
1351- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
1352- <comment>This is a comment</comment>
1353- </data>
1354-
1355- There are any number of \" resheader\" rows that contain simple
1356- name/value pairs.
1357-
1358- Each data row contains a name, and value. The row also contains a
1359- type or mimetype. Type corresponds to a .NET class that support
1360- text/value conversion through the TypeConverter architecture.
1361- Classes that don't support this are serialized and stored with the
1362- mimetype set.
1363-
1364- The mimetype is used for serialized objects, and tells the
1365- ResXResourceReader how to depersist the object. This is currently not
1366- extensible. For a given mimetype the value must be set accordingly:
1367-
1368- Note - application/x-microsoft.net.object.binary.base64 is the format
1369- that the ResXResourceWriter will generate, however the reader can
1370- read any of the formats listed below.
1371-
1372- mimetype: application/x-microsoft.net.object.binary.base64
1373- value : The object must be serialized with
1374- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
1375- : and then encoded with base64 encoding.
1376-
1377- mimetype: application/x-microsoft.net.object.soap.base64
1378- value : The object must be serialized with
1379- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
1380- : and then encoded with base64 encoding.
1381-
1382- mimetype: application/x-microsoft.net.object.bytearray.base64
1383- value : The object must be serialized into a byte array
1384- : using a System.ComponentModel.TypeConverter
1385- : and then encoded with base64 encoding.
1386- -->
1387- <xsd:schema id=\" root\" xmlns=\"\" xmlns:xsd=\" http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\" urn:schemas-microsoft-com:xml-msdata\" >
1388- <xsd:import namespace=\" http://www.w3.org/XML/1998/namespace\" />
1389- <xsd:element name=\" root\" msdata:IsDataSet=\" true\" >
1390- <xsd:complexType>
1391- <xsd:choice maxOccurs=\" unbounded\" >
1392- <xsd:element name=\" metadata\" >
1393- <xsd:complexType>
1394- <xsd:sequence>
1395- <xsd:element name=\" value\" type=\" xsd:string\" minOccurs=\" 0\" />
1396- </xsd:sequence>
1397- <xsd:attribute name=\" name\" use=\" required\" type=\" xsd:string\" />
1398- <xsd:attribute name=\" type\" type=\" xsd:string\" />
1399- <xsd:attribute name=\" mimetype\" type=\" xsd:string\" />
1400- <xsd:attribute ref=\" xml:space\" />
1401- </xsd:complexType>
1402- </xsd:element>
1403- <xsd:element name=\" assembly\" >
1404- <xsd:complexType>
1405- <xsd:attribute name=\" alias\" type=\" xsd:string\" />
1406- <xsd:attribute name=\" name\" type=\" xsd:string\" />
1407- </xsd:complexType>
1408- </xsd:element>
1409- <xsd:element name=\" data\" >
1410- <xsd:complexType>
1411- <xsd:sequence>
1412- <xsd:element name=\" value\" type=\" xsd:string\" minOccurs=\" 0\" msdata:Ordinal=\" 1\" />
1413- <xsd:element name=\" comment\" type=\" xsd:string\" minOccurs=\" 0\" msdata:Ordinal=\" 2\" />
1414- </xsd:sequence>
1415- <xsd:attribute name=\" name\" type=\" xsd:string\" use=\" required\" msdata:Ordinal=\" 1\" />
1416- <xsd:attribute name=\" type\" type=\" xsd:string\" msdata:Ordinal=\" 3\" />
1417- <xsd:attribute name=\" mimetype\" type=\" xsd:string\" msdata:Ordinal=\" 4\" />
1418- <xsd:attribute ref=\" xml:space\" />
1419- </xsd:complexType>
1420- </xsd:element>
1421- <xsd:element name=\" resheader\" >
1422- <xsd:complexType>
1423- <xsd:sequence>
1424- <xsd:element name=\" value\" type=\" xsd:string\" minOccurs=\" 0\" msdata:Ordinal=\" 1\" />
1425- </xsd:sequence>
1426- <xsd:attribute name=\" name\" type=\" xsd:string\" use=\" required\" />
1427- </xsd:complexType>
1428- </xsd:element>
1429- </xsd:choice>
1430- </xsd:complexType>
1431- </xsd:element>
1432- </xsd:schema>
1433- <resheader name=\" resmimetype\" >
1434- <value>text/microsoft-resx</value>
1435- </resheader>
1436- <resheader name=\" version\" >
1437- <value>2.0</value>
1438- </resheader>
1439- <resheader name=\" reader\" >
1440- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
1441- </resheader>
1442- <resheader name=\" writer\" >
1443- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
1444- </resheader>
1445- "
1446- and i18n_footer out_chan =
1447- let print format = fprintf out_chan format in
1448- print
1449- " </root>\n "
14501320and gen_i18n_errors () =
14511321 Friendly_error_names. parse_sr_xml sr_xml;
14521322 Friendly_error_names. parse_resx resx_file;
1453- let out_chan = open_out (Filename. concat destdir " FriendlyErrorNames.resx" )
1323+ let errors = Friendly_error_names. friendly_names_all Datamodel. errors in
1324+ let json = `O [
1325+ " i18n_errors" , `A (List. map (fun (x , y ) ->
1326+ `O [
1327+ " i18n_error_key" , `String x;
1328+ " i18n_error_description" , `String y;
1329+ ];) errors);
1330+ ]
14541331 in
1455- finally (fun () ->
1456- i18n_header out_chan;
1457- List. iter (gen_i18n_error_field out_chan)
1458- (Friendly_error_names. friendly_names_all Datamodel. errors);
1459- i18n_footer out_chan)
1460- (fun () -> close_out out_chan)
1461-
1462-
1463- and gen_i18n_error_field out_chan (error , desc ) =
1464- let print format = fprintf out_chan format in
1465- (* Note that we can't use Xml.to_string for the whole block, because
1466- we need the output to be whitespace-identical to what Visual Studio
1467- would produce. We need to use it for the inner <value> though, to
1468- get the escaping right. *)
1469- print " <data name=\" %s\" xml:space=\" preserve\" >\n %s\n </data>\n "
1470- error
1471- (Xml. to_string (Xml. Element (" value" , [] , [(Xml. PCData desc)])))
1332+ render_file (" FriendlyErrorNames.mustache" , " FriendlyErrorNames.resx" ) json templdir destdir
14721333
14731334let populate_releases () =
14741335 render_file (" ApiVersion.mustache" , " ApiVersion.cs" ) json_releases templdir destdir
14751336
14761337let _ =
14771338 main() ;
1339+ gen_i18n_errors() ;
14781340 populate_releases()
0 commit comments