Created
September 20, 2018 21:30
-
-
Save sgraham/3935c64d5bc1b67eea1f6e3b38fef6f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2018 The Chromium Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license that can be | |
// found in the LICENSE file. | |
// | |
// WARNING: This file is machine generated by fidlgen_js. | |
/** | |
* @enum {number} | |
*/ | |
const Blorp = { | |
ALPHA: 1, | |
BETA: 2, | |
GAMMA: 0x48, | |
}; | |
const _kTT_Blorp = _kTT_int8; | |
/** | |
* @interface | |
*/ | |
function Testola() {} | |
Testola.prototype.doSomething = function() {}; | |
/** | |
* @param {TODO} num | |
*/ | |
Testola.prototype.printInt = function(num) {}; | |
/** | |
* @param {TODO} msg | |
*/ | |
Testola.prototype.printMsg = function(msg) {}; | |
/** | |
* @param {TODO} blorp | |
* @param {TODO} msg | |
* @param {TODO} stuff | |
*/ | |
Testola.prototype.variousArgs = function(blorp, msg, stuff) {}; | |
const _kTestola_doSomething_Ordinal = 1; | |
const _kTestola_printInt_Ordinal = 2; | |
const _kTestola_printMsg_Ordinal = 3; | |
const _kTestola_variousArgs_Ordinal = 4; | |
/** | |
* @constructor | |
* @implements Testola | |
*/ | |
function TestolaProxy() { | |
this.channel = zx.ZX_HANDLE_INVALID; | |
} | |
TestolaProxy.prototype.$bind = function(channel) { | |
this.channel = channel; | |
}; | |
TestolaProxy.prototype.doSomething = function() { | |
if (this.channel === zx.ZX_HANDLE_INVALID) { | |
throw "channel closed"; | |
} | |
var $encoder = new $fidl_Encoder(_kTestola_doSomething_Ordinal); | |
$encoder.alloc(16 - $fidl_kMessageHeaderSize); | |
var $result = zx.channelWrite(this.channel, | |
$encoder.messageData(), | |
$encoder.messageHandles()); | |
if ($result !== zx.ZX_OK) { | |
throw "zx.channelWrite failed: " + $result; | |
} | |
}; | |
TestolaProxy.prototype.printInt = function(num) { | |
if (this.channel === zx.ZX_HANDLE_INVALID) { | |
throw "channel closed"; | |
} | |
var $encoder = new $fidl_Encoder(_kTestola_printInt_Ordinal); | |
$encoder.alloc(20 - $fidl_kMessageHeaderSize); | |
_kTT_int32.enc($encoder, 16, num); | |
var $result = zx.channelWrite(this.channel, | |
$encoder.messageData(), | |
$encoder.messageHandles()); | |
if ($result !== zx.ZX_OK) { | |
throw "zx.channelWrite failed: " + $result; | |
} | |
}; | |
TestolaProxy.prototype.printMsg = function(msg) { | |
if (this.channel === zx.ZX_HANDLE_INVALID) { | |
throw "channel closed"; | |
} | |
var $encoder = new $fidl_Encoder(_kTestola_printMsg_Ordinal); | |
$encoder.alloc(32 - $fidl_kMessageHeaderSize); | |
_kTT_String_Nonnull.enc($encoder, 16, msg); | |
var $result = zx.channelWrite(this.channel, | |
$encoder.messageData(), | |
$encoder.messageHandles()); | |
if ($result !== zx.ZX_OK) { | |
throw "zx.channelWrite failed: " + $result; | |
} | |
}; | |
const _kTT_VEC_Nonnull_uint32 = { | |
enc: function(e, o, v) { | |
if (v === null || v === undefined) throw "non-null vector required"; | |
e.data.setUint32(o, v.length, $fidl__kLE); | |
e.data.setUint32(o + 4, 0, $fidl__kLE); | |
e.data.setUint32(o + 8, 0xffffffff, $fidl__kLE); | |
e.data.setUint32(o + 12, 0xffffffff, $fidl__kLE); | |
e.outOfLine.push([function(e, body) { | |
var start = e.alloc(body.length * 4); | |
for (var i = 0; i < body.length; i++) { | |
_kTT_uint32.enc(e, start + (i * 4), body[i]); | |
} | |
}, | |
v]); | |
}, | |
}; | |
TestolaProxy.prototype.variousArgs = function(blorp, msg, stuff) { | |
if (this.channel === zx.ZX_HANDLE_INVALID) { | |
throw "channel closed"; | |
} | |
var $encoder = new $fidl_Encoder(_kTestola_variousArgs_Ordinal); | |
$encoder.alloc(56 - $fidl_kMessageHeaderSize); | |
_kTT_Blorp.enc($encoder, 16, blorp); | |
_kTT_String_Nonnull.enc($encoder, 24, msg); | |
_kTT_VEC_Nonnull_uint32.enc($encoder, 40, stuff); | |
var $result = zx.channelWrite(this.channel, | |
$encoder.messageData(), | |
$encoder.messageHandles()); | |
if ($result !== zx.ZX_OK) { | |
throw "zx.channelWrite failed: " + $result; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment