VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/share/emscripten/tests/webidl/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/emscripten/tests/webidl/post.js
// Part 1

var sme = new Module.Parent(42);
sme.mulVal(2);
Module.print('*')
Module.print(sme.getVal());
sme.parentFunc(90);
Module.print(typeof sme.getAsConst());

Module.print('c1');

var c1 = new Module.Child1();
Module.print(c1.getVal());
c1.mulVal(2);
Module.print(c1.getVal());
Module.print(c1.getValSqr());
Module.print(c1.getValSqr(3));
Module.print(c1.getValTimes()); // default argument should be 1
Module.print(c1.getValTimes(2));
c1.parentFunc(90);

Module.print('c1 v2');

c1 = new Module.Child1(8); // now with a parameter, we should handle the overloading automatically and properly and use constructor #2
Module.print(c1.getVal());
c1.mulVal(2);
Module.print(c1.getVal());
Module.print(c1.getValSqr());
Module.print(c1.getValSqr(3));

Module.print('c2')

var c2 = new Module.Child2();
Module.print(c2.getVal());
c2.mulVal(2);
Module.print(c2.getVal());
Module.print(c2.getValCube());
var succeeded;
try {
  succeeded = 0;
  Module.print(c2.doSomethingSecret()); // should fail since private
  succeeded = 1;
} catch(e) {}
Module.print(succeeded);
try {
  succeeded = 0;
  Module.print(c2.getValSqr()); // function from the other class
  succeeded = 1;
} catch(e) {}
Module.print(succeeded);
try {
  succeeded = 0;
  c2.getValCube(); // sanity
  succeeded = 1;
} catch(e) {}
Module.print(succeeded);

Module.Child2.prototype.printStatic(); // static calls go through the prototype

// virtual function
c2.virtualFunc();
Module.Child2.prototype.runVirtualFunc(c2);
c2.virtualFunc2();

// extend a class from JS
var c3 = new Module.Child2JS;

c3.virtualFunc = function() {
  Module.print('*js virtualf replacement*');
};
c3.virtualFunc2 = function() {
  Module.print('*js virtualf2 replacement*');
};
c3.virtualFunc3 = function(x) {
  Module.print('*js virtualf3 replacement ' + x + '*');
};

c3.virtualFunc();
Module.Child2.prototype.runVirtualFunc(c3);
c3.virtualFunc2();
c3.virtualFunc3(123); // this one is not replaced!
try {
  c3.virtualFunc4(123);
} catch(e) {
  Module.print('caught: ' + e);
}

// Test virtual method dispatch from c++
Module.Child2.prototype.runVirtualFunc3(c3, 43);

c2.virtualFunc(); // original should remain the same
Module.Child2.prototype.runVirtualFunc(c2);
c2.virtualFunc2();
Module.print('*ok*');

// Part 2

var suser = new Module.StringUser("hello", 43);
suser.Print(41, "world");
suser.PrintFloat(12.3456);

var bv = new Module.RefUser(10);
var bv2 = new Module.RefUser(11);
Module.print(bv2.getValue(bv));

Module.print(typeof bv2.getMe());
Module.print(bv2.getMe().getValue(bv));
Module.print(bv2.getMe().getValue(bv2));

Module.print(typeof bv2.getCopy());
Module.print(bv2.getCopy().getValue(bv));
Module.print(bv2.getCopy().getValue(bv2));

bv2.getAnother().PrintFloat(21.12);

Module.print(new Module.Inner().get());
new Module.Inner().mul(2);

Module.print(Module.enum_value1);
Module.print(Module.enum_value2);

// Enums from classes are accessed via the class.
enumClassInstance = new Module.EnumClass();
Module.print([enumClassInstance.GetEnum(), Module.EnumClass.e_val].join(','));

// Enums from namespaces are accessed via the top-level module, as with classes defined
// in namespaces, see `Inner` above.
Module.print(Module.e_namespace_val);

typeTester = new Module.TypeTestClass();

Module.print('return char ' + typeTester.ReturnCharMethod());
typeTester.AcceptCharMethod((2<<6)-1);
// Prints -1 because the c++ code accepts unsigned char.
typeTester.AcceptCharMethod((2<<7)-1);

// Prints -1 because all integers are signed in javascript.
Module.print('return unsigned char ' + typeTester.ReturnUnsignedCharMethod());
typeTester.AcceptUnsignedCharMethod((2<<7)-1);

// Prints -1 because all integers are signed in javascript.
Module.print('return unsigned short ' + typeTester.ReturnUnsignedShortMethod());
typeTester.AcceptUnsignedShortMethod((2<<15)-1);

// Prints -1 because all integers are signed in javascript.
Module.print('return unsigned long ' + typeTester.ReturnUnsignedLongMethod());
typeTester.AcceptUnsignedLongMethod((2<<31)-1);
var voidPointerUser = new Module.VoidPointerUser();

voidPointerUser.SetVoidPointer(3);
Module.print('void * ' + voidPointerUser.GetVoidPointer());

//

Module.print('\ndone.')


VaKeR 2022