Opened 2 years ago

Closed 2 years ago

#5185 closed change (fixed)

[emscripten] More compact definition of class prototypes

Reported by: trev Assignee: trev
Priority: P4 Milestone:
Module: Core Keywords:
Cc: Blocked By:
Blocking: #4122 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29421701/

Description

Background

The bindings will currently declare a class as follows:

exports.InvalidFilter = createClass(exports.Filter, 0);
exports.InvalidFilter.prototype.foo = ...;
exports.InvalidFilter.prototype.bar = ...;

This is unnecessarily verbose.

What to change

Pass in all properties to be declared on the prototype to the createClass function:

exports.InvalidFilter = createClass(exports.Filter, 0, {
  foo: ...,
  bar: ...,
});

The createClass function can then call Object.getOwnPropertyDescriptors() in order to copy these properties to the class prototype (this will work for getters and setters as well).

Change History (3)

comment:1 Changed 2 years ago by trev

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed 2 years ago by abpbot

A commit referencing this issue has landed:
Issue 5185 - [emscripten More compact definition of class prototypes]

comment:3 Changed 2 years ago by trev

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.