js2cpp.js 490 B

12345678910111213141516171819202122232425262728293031
  1. var js2cppX = {
  2. alloc:function(){
  3. var context = {
  4. _items:{},
  5. _id:0,
  6. create:function (data, id) {
  7. if (typeof(id) === "undefined")
  8. {
  9. this._id += 1;
  10. id = this._id;
  11. }
  12. this._items[id] = data;
  13. return id;
  14. },
  15. get:function(id){
  16. return this._items[id];
  17. },
  18. free:function(id){
  19. delete this._items[id];
  20. },
  21. get_size:function(){
  22. return Object.keys(this._items).length;
  23. }
  24. }
  25. return context;
  26. }
  27. };
  28. var js2cpp = js2cppX.alloc();