-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathnumpyState.js
More file actions
129 lines (118 loc) · 4.06 KB
/
numpyState.js
File metadata and controls
129 lines (118 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
define ([
'require'
, 'nbextensions/visualpython/src/common/vpCommon'
, 'nbextensions/visualpython/src/numpy/api/numpyStateApi'
, 'nbextensions/visualpython/src/common/metaDataHandler'
], function(requirejs, vpCommon,
numpyStateApi, md) {
"use strict";
// numpy 함수의 state 데이터를 다루는 api
var { changeOldToNewState, findStateValue } = numpyStateApi;
/**
* @class NumpyStateGenerator
* @constructor
*/
var NumpyStateGenerator = function() {
// this.prefix = `# Auto-Generated by VisualPython`;
this.prefix = '';
this.postfix = '';
this.state = {
};
this.mdHandler;
/** 모든 numpy 함수 state에 들어가는 데이터 들 */
Object.assign(this.state, {
prefixCode: ''
, postfixCode: ``
, userOptionList: []
});
};
/**
* pageList index.js 파일에서 importPackage 인스턴스의 this를 가져오는 메소드
* @param {ImportPackage Instance this} importPackageThis
*/
NumpyStateGenerator.prototype.setImportPackageThis = function(importPackageThis) {
this.importPackageThis = importPackageThis;
}
NumpyStateGenerator.prototype.getImportPackageThis = function() {
return this.importPackageThis;
}
NumpyStateGenerator.prototype.setMetahandler = function(funcID) {
this.mdHandler = new md.MdHandler(funcID);
}
/** metadata init */
NumpyStateGenerator.prototype.setAPIBlockMetadataHandler = function() {
var importPackageThis = this.getImportPackageThis();
this.setMetahandler(importPackageThis.funcID);
this.mdHandler.generateMetadata(importPackageThis);
this.mdHandler.metadata = importPackageThis.metadata = {
funcID: importPackageThis.funcID
, options: [{
id: 'vp_numpyState',
state: this.state
}]
, postfix: {
value: this.state.postfixCode
}
, prefix: {
value: this.state.prefixCode
}
}
}
NumpyStateGenerator.prototype.setMetadata = function(paramMetadata = null) {
var importPackageThis = this.getImportPackageThis();
if (paramMetadata) {
this.state = paramMetadata.options[0].state;
}
importPackageThis.metadata = {
funcID: importPackageThis.funcID
, options: [{
id: 'vp_numpyState',
state: this.state
}]
, postfix: {
value: this.state.postfixCode
}
, prefix: {
value: this.state.prefixCode
}
}
}
NumpyStateGenerator.prototype.saveMetadata = function() {
var importPackageThis = this.getImportPackageThis();
this.mdHandler.saveMetadata(importPackageThis.metadata);
}
/** 자식 클래스에서 반드시! 오버라이드 되는 메소드
* nummpy 패키지에서 blueprint에 저장된 state를 받아 새로운 state를 만드는 함수
* @override
* @param {Object} state
*/
NumpyStateGenerator.prototype.makeState = function(state) {
Object.assign(this.state, state);
}
/**
state 값 변경 함수
@param {Object} newState
*/
NumpyStateGenerator.prototype.setState = function(newState) {
this.state = changeOldToNewState(this.state, newState);
this.consoleState();
this.setMetadata();
}
/**
모든 state 값을 가져오는 함수
*/
NumpyStateGenerator.prototype.getStateAll = function() {
return this.state;
}
/**
특정 state Name 값을 가져오는 함수
@param {string} stateKeyName
*/
NumpyStateGenerator.prototype.getState = function(stateKeyName) {
return findStateValue(this.state, stateKeyName);
}
NumpyStateGenerator.prototype.consoleState = function() {
// console.log(this.state);
}
return NumpyStateGenerator;
});