var input_person = new Module.Person();
var input_phone_number = new Module.PhoneNumber();
var input_pb = new Module.AddressBook();
var output_person = new Module.Person();

var output_pb = new Module.AddressBook();

my_data = "bla"

input_person.set_id(10);
input_person.set_name("test");
input_person.set_email("my_email");
//input_phone_number.set_number("102343");
input_phone_number = input_person.add_phone();//input_phone_number);
input_phone_number.set_number("013248034");
//input_person.add_phone();
//input_person.phone(0).set_number("12345");

my_data = input_person.SerializeAsString();
size = input_person.ByteSize();
output_person.ParseFromString(my_data);

console.log(output_person.name + "\n");
console.log(output_person.email + "\n");
console.log(output_person.id + "\n");
console.log(output_person.phone(0).number);
//console.log(my_data + "\n");
//alert(person.name);

Module.ShutdownProtobufLibrary();

input_person.clear_phone();
//input_phone_number.delete();
input_person.delete(); // TODO: Funktion zur Speicherfreigabe binden
output_person.delete();
input_pb.delete();
output_pb.delete();
/*
var input_pb = new Module.AddressBook();
var output_pb = new Module.AddressBook();
var phone_number = new Module.PhoneNumber();
var customizer_input = new Module.pbCustomizer(input_pb);
var customizer_output = new Module.pbCustomizer(output_pb);

//var phone_number = new Module.PhoneNumber();
//var pb_array = new Module.pbArray();

//my_string = "test\n"
//var my_buffer = Module._malloc(100);
//var my_buffer = new Int8Array(100);

input_pb.set_some_val(250000000);
input_pb.add_phone(phone_number);

size = input_pb.ByteSize();
//var my_buffer = Module._malloc(size);
//var my_buffer = [0x00, 0x00, 0x00];

//my_string = input_pb.SerializeAsString();
//output_pb.ParseFromString(my_string);
my_string =  customizer_input.SerializeToArray(size);
customizer_output.ParseFromArray(my_string, size);

//console.log('my_string result: ' + my_string + '\n');
//console.log('test \n');
console.log(my_string);
//////////////////instance.SerializeToString(my_string);
//alert(input_pb.some_val);
alert(output_pb.some_val);
input_pb.delete();
output_pb.delete();
customizer_input.delete();
customizer_output.delete();
phone_number.delete();
//pb_array.delete();
*/
