Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rely on internal embind implementation for the type of context … #10

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Don't rely on internal embind implementation for the type of context …
…(0,1 or 2-sided)
  • Loading branch information
nmichaud committed Jan 21, 2018
commit 43d5f74374d73fb2a90e4eafafef3cffe052a15f
23 changes: 7 additions & 16 deletions packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ function parse_data(data, names, types) {
* @class
* @hideconstructor
*/
function view(pool, ctx, gnode, config, id, name, callbacks) {
function view(pool, ctx, sides, gnode, config, id, name, callbacks) {
this.ctx = ctx;
this.nsides = sides;
this.gnode = gnode;
this.config = config || {};
this.pool = pool;
Expand Down Expand Up @@ -318,20 +319,7 @@ function parse_data(data, names, types) {
* @returns {number} sides The number of sides of this `View`.
*/
view.prototype.sides = function() {
let name;
if (this.ctx.constructor.name) {
name = this.ctx.constructor.name;
} else {
name = this.ctx.constructor.toString().match(/function ([^\(]+)/)[1];
}
switch (name) {
case 't_ctx1':
return 1;
case 't_ctx2':
return 2;
default:
return 0;
}
return this.nsides;
}

view.prototype._column_names = function() {
Expand Down Expand Up @@ -784,6 +772,7 @@ table.prototype.view = function(config) {
}

let context;
let sides = 0;
if ((config.row_pivot && config.row_pivot.length > 0) || (config.column_pivot && config.column_pivot.length > 0)) {
if (config.column_pivot && config.column_pivot.length > 0) {
config.row_pivot = config.row_pivot || [];
Expand All @@ -796,6 +785,7 @@ table.prototype.view = function(config) {
aggregates,
sort
);
sides = 2;
this.pool.register_context(this.id, name, __MODULE__.t_ctx_type.TWO_SIDED_CONTEXT, context.$$.ptr);

if (config.row_pivot_depth !== undefined) {
Expand All @@ -818,6 +808,7 @@ table.prototype.view = function(config) {
aggregates,
sort
);
sides = 1;
this.pool.register_context(this.id, name, __MODULE__.t_ctx_type.ONE_SIDED_CONTEXT, context.$$.ptr);

if (config.row_pivot_depth !== undefined) {
Expand All @@ -831,7 +822,7 @@ table.prototype.view = function(config) {
this.pool.register_context(this.id, name, __MODULE__.t_ctx_type.ZERO_SIDED_CONTEXT, context.$$.ptr);
}

return new view(this.pool, context, this.gnode, config, this.id, name, this.callbacks);
return new view(this.pool, context, sides, this.gnode, config, this.id, name, this.callbacks);
}

/**
Expand Down