Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed tabs

  • Loading branch information...
commit d9bf1b74f35afb8fce2c3fdbc6ee15bc370ccaba 1 parent 816e65d
Joe Ferner authored January 27, 2012
160  src/dissector.cpp
@@ -34,7 +34,7 @@ Dissector::Dissector(int linkLayerType) : m_linkLayerType(linkLayerType) {
34 34
   s_ct->SetClassName(v8::String::NewSymbol("Dissector"));
35 35
 
36 36
   NODE_SET_PROTOTYPE_METHOD(s_ct, "_dissect", dissect);
37  
-	NODE_SET_PROTOTYPE_METHOD(s_ct, "close", close);
  37
+  NODE_SET_PROTOTYPE_METHOD(s_ct, "close", close);
38 38
 
39 39
   target->Set(v8::String::NewSymbol("Dissector"), s_ct->GetFunction());
40 40
 }
@@ -42,14 +42,14 @@ Dissector::Dissector(int linkLayerType) : m_linkLayerType(linkLayerType) {
42 42
 /*static*/ v8::Handle<v8::Value> Dissector::New(const v8::Arguments& args) {
43 43
   v8::HandleScope scope;
44 44
 
45  
-	BENCHMARK_GLOBAL_START();
  45
+  BENCHMARK_GLOBAL_START();
46 46
 
47 47
   REQ_NUMBER_ARG(0, linkLayerType);
48 48
   int linkLayerTypeVal = linkLayerType->Value();
49 49
 
50 50
   Dissector *self = new Dissector(linkLayerTypeVal);
51 51
 
52  
-	memset(&self->m_cfile, 0, sizeof(capture_file));
  52
+  memset(&self->m_cfile, 0, sizeof(capture_file));
53 53
   cap_file_init(&self->m_cfile);
54 54
 
55 55
   // read preferences
@@ -81,7 +81,7 @@ Dissector::Dissector(int linkLayerType) : m_linkLayerType(linkLayerType) {
81 81
   nstime_set_unset(&self->m_prev_dis_ts);
82 82
   nstime_set_unset(&self->m_prev_cap_ts);
83 83
 
84  
-	self->m_data_offset = 0;
  84
+  self->m_data_offset = 0;
85 85
 
86 86
   self->Wrap(args.This());
87 87
   return args.This();
@@ -91,102 +91,102 @@ Dissector::~Dissector() {
91 91
 }
92 92
 
93 93
 /*static*/ v8::Handle<v8::Value> Dissector::dissect(const v8::Arguments& args) {
94  
-	v8::HandleScope handleScope;
  94
+  v8::HandleScope handleScope;
95 95
 
96  
-	BENCHMARK_START(dissect);
  96
+  BENCHMARK_START(dissect);
97 97
   Dissector* self = ObjectWrap::Unwrap<Dissector>(args.This());
98 98
 
99 99
   struct wtap_pkthdr whdr;
100 100
   guchar *data;
101  
-	v8::Local<v8::Object> dataBuffer;
102  
-
103  
-	whdr.pkt_encap = self->m_encap;
104  
-
105  
-	if(args.Length() != 1) {
106  
-		return v8::ThrowException(v8::Exception::Error(v8::String::New("Dissect takes 3 arguments.")));
107  
-	}
108  
-
109  
-	// no packet information just a buffer
110  
-	if(node::Buffer::HasInstance(args[0])) {
111  
-		v8::Local<v8::Value> dataBufferValue = args[0];
112  
-		dataBuffer = dataBufferValue->ToObject();
113  
-		int dataBufferLength = node::Buffer::Length(dataBuffer);
114  
-		data = (guchar*)node::Buffer::Data(dataBuffer);
115  
-		whdr.ts.secs = 0;
116  
-		whdr.ts.nsecs = 0;
117  
-		whdr.caplen = dataBufferLength;
118  
-		whdr.len = dataBufferLength;
119  
-	}
120  
-
121  
-	// packet information with a buffer in the "data" property
122  
-	else {
123  
-		REQ_OBJECT_ARG(0, packet);
124  
-		v8::Local<v8::Value> dataBufferValue = packet->Get(v8::String::New("data"));
125  
-		if(dataBufferValue->IsUndefined()) {
126  
-			return v8::ThrowException(v8::Exception::Error(v8::String::New("First argument must contain a member 'data' that is a buffer.")));
127  
-		}
128  
-		dataBuffer = dataBufferValue->ToObject();
129  
-		data = (guchar*)node::Buffer::Data(dataBuffer);
130  
-		int dataBufferLength = node::Buffer::Length(dataBuffer);
131  
-
132  
-		v8::Local<v8::Value> header = packet->Get(v8::String::New("header"));
133  
-		if(header->IsUndefined()) {
134  
-			whdr.ts.secs = 0;
135  
-			whdr.ts.nsecs = 0;
136  
-			whdr.caplen = dataBufferLength;
137  
-			whdr.len = dataBufferLength;
138  
-		} else {
139  
-			v8::Local<v8::Object> headerObj = header->ToObject();
140  
-			whdr.ts.secs = getNumberFromV8Object(headerObj, "timestampSeconds", 0);
141  
-			whdr.ts.nsecs = getNumberFromV8Object(headerObj, "timestampMicroseconds", 0);
142  
-			whdr.caplen = getNumberFromV8Object(headerObj, "capturedLength", dataBufferLength);
143  
-			whdr.len = getNumberFromV8Object(headerObj, "originalLength", dataBufferLength);
144  
-		}
145  
-	}
  101
+  v8::Local<v8::Object> dataBuffer;
  102
+
  103
+  whdr.pkt_encap = self->m_encap;
  104
+
  105
+  if(args.Length() != 1) {
  106
+    return v8::ThrowException(v8::Exception::Error(v8::String::New("Dissect takes 3 arguments.")));
  107
+  }
  108
+
  109
+  // no packet information just a buffer
  110
+  if(node::Buffer::HasInstance(args[0])) {
  111
+    v8::Local<v8::Value> dataBufferValue = args[0];
  112
+    dataBuffer = dataBufferValue->ToObject();
  113
+    int dataBufferLength = node::Buffer::Length(dataBuffer);
  114
+    data = (guchar*)node::Buffer::Data(dataBuffer);
  115
+    whdr.ts.secs = 0;
  116
+    whdr.ts.nsecs = 0;
  117
+    whdr.caplen = dataBufferLength;
  118
+    whdr.len = dataBufferLength;
  119
+  }
  120
+
  121
+  // packet information with a buffer in the "data" property
  122
+  else {
  123
+    REQ_OBJECT_ARG(0, packet);
  124
+    v8::Local<v8::Value> dataBufferValue = packet->Get(v8::String::New("data"));
  125
+    if(dataBufferValue->IsUndefined()) {
  126
+      return v8::ThrowException(v8::Exception::Error(v8::String::New("First argument must contain a member 'data' that is a buffer.")));
  127
+    }
  128
+    dataBuffer = dataBufferValue->ToObject();
  129
+    data = (guchar*)node::Buffer::Data(dataBuffer);
  130
+    int dataBufferLength = node::Buffer::Length(dataBuffer);
  131
+
  132
+    v8::Local<v8::Value> header = packet->Get(v8::String::New("header"));
  133
+    if(header->IsUndefined()) {
  134
+      whdr.ts.secs = 0;
  135
+      whdr.ts.nsecs = 0;
  136
+      whdr.caplen = dataBufferLength;
  137
+      whdr.len = dataBufferLength;
  138
+    } else {
  139
+      v8::Local<v8::Object> headerObj = header->ToObject();
  140
+      whdr.ts.secs = getNumberFromV8Object(headerObj, "timestampSeconds", 0);
  141
+      whdr.ts.nsecs = getNumberFromV8Object(headerObj, "timestampMicroseconds", 0);
  142
+      whdr.caplen = getNumberFromV8Object(headerObj, "capturedLength", dataBufferLength);
  143
+      whdr.len = getNumberFromV8Object(headerObj, "originalLength", dataBufferLength);
  144
+    }
  145
+  }
146 146
 
147 147
   frame_data *fdata = new frame_data();
148 148
   epan_dissect_t *edt = new epan_dissect_t();
149 149
 
150  
-	BENCHMARK_START(epanDissect);
  150
+  BENCHMARK_START(epanDissect);
151 151
   self->m_cfile.count++;
152 152
   frame_data_init(fdata, self->m_cfile.count, &whdr, self->m_data_offset, self->m_cum_bytes);
153 153
   epan_dissect_init(edt, TRUE, TRUE);
154 154
   frame_data_set_before_dissect(fdata, &self->m_cfile.elapsed_time, &self->m_first_ts, &self->m_prev_dis_ts, &self->m_prev_cap_ts);
155 155
   epan_dissect_run(edt, &self->m_cfile.pseudo_header, data, fdata, &self->m_cfile.cinfo);
156  
-	frame_data_set_after_dissect(fdata, &self->m_cum_bytes, &self->m_prev_dis_ts);
157  
-	self->m_data_offset += whdr.caplen;
158  
-	BENCHMARK_END(epanDissect);
  156
+  frame_data_set_after_dissect(fdata, &self->m_cum_bytes, &self->m_prev_dis_ts);
  157
+  self->m_data_offset += whdr.caplen;
  158
+  BENCHMARK_END(epanDissect);
159 159
 
160  
-	v8::Local<v8::Value> result = DissectorNode::New(NULL, fdata, edt, edt->tree);
  160
+  v8::Local<v8::Value> result = DissectorNode::New(NULL, fdata, edt, edt->tree);
161 161
 
162  
-	BENCHMARK_END(dissect);
  162
+  BENCHMARK_END(dissect);
163 163
   return handleScope.Close(result);
164 164
 }
165 165
 
166 166
 /*static*/ v8::Handle<v8::Value> Dissector::close(const v8::Arguments& args) {
167  
-	v8::HandleScope handleScope;
168  
-	#ifdef BENCHMARK
169  
-		Dissector* self = node::ObjectWrap::Unwrap<Dissector>(args.This());
170  
-	#endif
171  
-
172  
-	BENCHMARK_GLOBAL_END();
173  
-
174  
-	BENCHMARK_PRINT_START();
175  
-	BENCHMARK_PRINT(dissect);
176  
-	BENCHMARK_PRINT(epanDissect);
177  
-	BENCHMARK_PRINT(dissectorNodeNew);
178  
-	BENCHMARK_PRINT(dissectorNodeNewRoot);
179  
-	BENCHMARK_PRINT(createChildren);
180  
-	BENCHMARK_PRINT(createChildrenItem);
181  
-	BENCHMARK_PRINT(getAbbreviation);
182  
-	BENCHMARK_PRINT(lazyDissectorNodeNew);
183  
-	BENCHMARK_PRINT_END();
184  
-
185  
-	#ifdef BENCHMARK
186  
-		printf("packet count: %d\n", self->m_cfile.count);
187  
-	#endif
188  
-
189  
-	return v8::Undefined();
  167
+  v8::HandleScope handleScope;
  168
+  #ifdef BENCHMARK
  169
+    Dissector* self = node::ObjectWrap::Unwrap<Dissector>(args.This());
  170
+  #endif
  171
+
  172
+  BENCHMARK_GLOBAL_END();
  173
+
  174
+  BENCHMARK_PRINT_START();
  175
+  BENCHMARK_PRINT(dissect);
  176
+  BENCHMARK_PRINT(epanDissect);
  177
+  BENCHMARK_PRINT(dissectorNodeNew);
  178
+  BENCHMARK_PRINT(dissectorNodeNewRoot);
  179
+  BENCHMARK_PRINT(createChildren);
  180
+  BENCHMARK_PRINT(createChildrenItem);
  181
+  BENCHMARK_PRINT(getAbbreviation);
  182
+  BENCHMARK_PRINT(lazyDissectorNodeNew);
  183
+  BENCHMARK_PRINT_END();
  184
+
  185
+  #ifdef BENCHMARK
  186
+    printf("packet count: %d\n", self->m_cfile.count);
  187
+  #endif
  188
+
  189
+  return v8::Undefined();
190 190
 }
191 191
 
192 192
 e_prefs* Dissector::readPrefs(v8::Handle<v8::Value> *error) {
342  src/dissectorNode.cpp
@@ -45,100 +45,100 @@ int DissectorNode::getPositionInPacket(proto_node *node, field_info *fi) {
45 45
 }
46 46
 
47 47
 const char* DissectorNode::fixEscapes(const char* src, char* dest) {
48  
-	const char* read = src;
49  
-	char* write = dest;
50  
-	while(*read) {
51  
-		if(*read == '\\') {
52  
-			read++;
53  
-			switch(*read) {
  48
+  const char* read = src;
  49
+  char* write = dest;
  50
+  while(*read) {
  51
+    if(*read == '\\') {
  52
+      read++;
  53
+      switch(*read) {
54 54
         case '\0': goto endOfRead;
55 55
         case '\\': *write++ = '\\'; read++; break;
56  
-				case 't': *write++ = '\t'; read++; break;
57  
-				case 'r': *write++ = '\r'; read++; break;
58  
-				case 'n': *write++ = '\n'; read++; break;
59  
-				default:
60  
-					*write++ = '\\';
61  
-					*write++ = *read++;
62  
-					break;
63  
-			}
64  
-		} else {
65  
-			*write++ = *read++;
66  
-		}
67  
-	}
  56
+        case 't': *write++ = '\t'; read++; break;
  57
+        case 'r': *write++ = '\r'; read++; break;
  58
+        case 'n': *write++ = '\n'; read++; break;
  59
+        default:
  60
+          *write++ = '\\';
  61
+          *write++ = *read++;
  62
+          break;
  63
+      }
  64
+    } else {
  65
+      *write++ = *read++;
  66
+    }
  67
+  }
68 68
 endOfRead:
69  
-	*write++ = '\0';
70  
-	return dest;
  69
+  *write++ = '\0';
  70
+  return dest;
71 71
 }
72 72
 
73 73
 v8::Handle<v8::Value> DissectorNode::getDataSourceName(tvbuff_t *tvb) {
74  
-	v8::HandleScope scope;
75  
-	for (GSList *src_le = m_edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
76  
-		data_source *src = (data_source*)src_le->data;
77  
-		if(tvb == src->tvb) {
78  
-			char *name = strdup(get_data_source_name(src));
79  
-			char *paren = strchr(name, '(');
80  
-			if(paren) *paren = '\0';
81  
-			strtrim(name);
82  
-			v8::Local<v8::String> result = v8::String::New(name);
83  
-			delete[] name;
84  
-			return scope.Close(result);
85  
-		}
86  
-	}
87  
-	return v8::Undefined();
  74
+  v8::HandleScope scope;
  75
+  for (GSList *src_le = m_edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
  76
+    data_source *src = (data_source*)src_le->data;
  77
+    if(tvb == src->tvb) {
  78
+      char *name = strdup(get_data_source_name(src));
  79
+      char *paren = strchr(name, '(');
  80
+      if(paren) *paren = '\0';
  81
+      strtrim(name);
  82
+      v8::Local<v8::String> result = v8::String::New(name);
  83
+      delete[] name;
  84
+      return scope.Close(result);
  85
+    }
  86
+  }
  87
+  return v8::Undefined();
88 88
 }
89 89
 
90 90
 /*static*/ v8::Local<v8::Object> DissectorNode::New(DissectorNode *root, frame_data *fdata, epan_dissect_t *edt, proto_node *node) {
91  
-	v8::HandleScope scope;
  91
+  v8::HandleScope scope;
92 92
   BENCHMARK_START(dissectorNodeNew);
93 93
   v8::Local<v8::Function> ctor = s_ct->GetFunction();
94 94
   v8::Local<v8::Object> obj = ctor->NewInstance();
95 95
   DissectorNode *self = new DissectorNode(root, fdata, edt, node);
96  
-	self->Wrap(obj);
  96
+  self->Wrap(obj);
97 97
 
98 98
   if(self->isRoot()) {
99 99
     BENCHMARK_START(dissectorNodeNewRoot);
100 100
     obj->Set(v8::String::New("root"), v8::Boolean::New(true));
101 101
 
102  
-		v8::Local<v8::Object> dataSources = v8::Object::New();
103  
-		for (GSList *src_le = edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
104  
-			data_source *src = (data_source*)src_le->data;
105  
-			tvbuff_t *tvb = src->tvb;
106  
-			v8::Local<v8::Object> lazyDataSource = LazyDataSource::New(self, tvb);
107  
-			dataSources->SetAccessor(self->getDataSourceName(src->tvb)->ToString(), dataSourceGetter, dataSourceSetter, lazyDataSource);
108  
-		}
109  
-		obj->Set(v8::String::New("dataSources"), dataSources);
  102
+    v8::Local<v8::Object> dataSources = v8::Object::New();
  103
+    for (GSList *src_le = edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
  104
+      data_source *src = (data_source*)src_le->data;
  105
+      tvbuff_t *tvb = src->tvb;
  106
+      v8::Local<v8::Object> lazyDataSource = LazyDataSource::New(self, tvb);
  107
+      dataSources->SetAccessor(self->getDataSourceName(src->tvb)->ToString(), dataSourceGetter, dataSourceSetter, lazyDataSource);
  108
+    }
  109
+    obj->Set(v8::String::New("dataSources"), dataSources);
110 110
     BENCHMARK_END(dissectorNodeNewRoot);
111 111
   }
112 112
 
113 113
   field_info *fi = PNODE_FINFO(node);
114 114
   if(fi) {
115  
-		self->m_sizeInPacket = fi->length;
116  
-		self->m_posInPacket = getPositionInPacket(node, fi);
  115
+    self->m_sizeInPacket = fi->length;
  116
+    self->m_posInPacket = getPositionInPacket(node, fi);
117 117
     obj->Set(v8::String::New("sizeInPacket"), v8::Integer::New(self->m_sizeInPacket));
118 118
     obj->Set(v8::String::New("positionInPacket"), v8::Integer::New(self->m_posInPacket));
119 119
     obj->Set(v8::String::New("abbreviation"), self->getAbbreviation(node));
120  
-		obj->Set(v8::String::New("dataSource"), self->getDataSourceName(fi->ds_tvb));
  120
+    obj->Set(v8::String::New("dataSource"), self->getDataSourceName(fi->ds_tvb));
121 121
 
122 122
     if (fi->rep) {
123  
-			obj->SetAccessor(v8::String::New("representation"), representationGetter, representationSetter);
124  
-		}
  123
+      obj->SetAccessor(v8::String::New("representation"), representationGetter, representationSetter);
  124
+    }
125 125
 
126  
-		obj->SetAccessor(v8::String::New("value"), valueGetter, valueSetter);
127  
-		obj->SetAccessor(v8::String::New("rawData"), rawDataGetter, rawDataSetter);
  126
+    obj->SetAccessor(v8::String::New("value"), valueGetter, valueSetter);
  127
+    obj->SetAccessor(v8::String::New("rawData"), rawDataGetter, rawDataSetter);
128 128
   }
129 129
 
130  
-	self->createChildren();
  130
+  self->createChildren();
131 131
 
132 132
   BENCHMARK_END(dissectorNodeNew);
133 133
   return scope.Close(obj);
134 134
 }
135 135
 
136 136
 v8::Handle<v8::Value> DissectorNode::getAbbreviation(proto_node *node) {
137  
-	v8::HandleScope scope;
  137
+  v8::HandleScope scope;
138 138
   BENCHMARK_START(getAbbreviation);
139  
-	field_info *fi = PNODE_FINFO(node);
140  
-	if(fi) {
141  
-		const char *abbr = fi->hfinfo->abbrev;
  139
+  field_info *fi = PNODE_FINFO(node);
  140
+  if(fi) {
  141
+    const char *abbr = fi->hfinfo->abbrev;
142 142
     if(abbr) {
143 143
       if(strcmp(abbr, "text") == 0) {
144 144
         v8::Handle<v8::Value> result = getRepresentation(node);
@@ -159,153 +159,153 @@ v8::Handle<v8::Value> DissectorNode::getAbbreviation(proto_node *node) {
159 159
       BENCHMARK_END(getAbbreviation);
160 160
       return scope.Close(result);
161 161
     }
162  
-	}
  162
+  }
163 163
   BENCHMARK_END(getAbbreviation);
164  
-	return scope.Close(v8::Undefined());
  164
+  return scope.Close(v8::Undefined());
165 165
 }
166 166
 
167 167
 void DissectorNode::createChildren() {
168 168
   BENCHMARK_START(createChildren);
169  
-	proto_tree_children_foreach(m_node, createChildrenItem, this);
  169
+  proto_tree_children_foreach(m_node, createChildrenItem, this);
170 170
   BENCHMARK_END(createChildren);
171 171
 }
172 172
 
173 173
 /*static*/ void DissectorNode::createChildrenItem(proto_node *node, gpointer data) {
174 174
   BENCHMARK_START(createChildrenItem);
175  
-	DissectorNode *self = (DissectorNode*)data;
176  
-	v8::Local<v8::Object> lazyNode = LazyDissectorNode::New(self->m_fdata, self->m_edt, node);
  175
+  DissectorNode *self = (DissectorNode*)data;
  176
+  v8::Local<v8::Object> lazyNode = LazyDissectorNode::New(self->m_fdata, self->m_edt, node);
177 177
   v8::Handle<v8::Value> abbreviationVal = self->getAbbreviation(node);
178  
-	self->handle_->SetAccessor(abbreviationVal->ToString(), childGetter, childSetter, lazyNode);
  178
+  self->handle_->SetAccessor(abbreviationVal->ToString(), childGetter, childSetter, lazyNode);
179 179
   BENCHMARK_END(createChildrenItem);
180 180
 }
181 181
 
182 182
 /*static*/ v8::Handle<v8::Value> DissectorNode::childGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
183  
-	v8::HandleScope scope;
184  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
185  
-	if(self->m_childStorage->Has(property)) {
186  
-		return scope.Close(self->m_childStorage->Get(property));
187  
-	} else {
188  
-		#ifdef SHOW_CREATES
189  
-			v8::String::AsciiValue propertyStr(property);
190  
-			printf("***** create child: %s\n", *propertyStr);
191  
-		#endif
192  
-
193  
-		LazyDissectorNode *lazyNode = node::ObjectWrap::Unwrap<LazyDissectorNode>(info.Data()->ToObject());
194  
-		v8::Local<v8::Object> newNodeObj = New(self->m_root, self->m_fdata, self->m_edt, lazyNode->getProtoNode());
195  
-		self->m_childStorage->Set(property, newNodeObj);
196  
-		return scope.Close(newNodeObj);
197  
-	}
  183
+  v8::HandleScope scope;
  184
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  185
+  if(self->m_childStorage->Has(property)) {
  186
+    return scope.Close(self->m_childStorage->Get(property));
  187
+  } else {
  188
+    #ifdef SHOW_CREATES
  189
+      v8::String::AsciiValue propertyStr(property);
  190
+      printf("***** create child: %s\n", *propertyStr);
  191
+    #endif
  192
+
  193
+    LazyDissectorNode *lazyNode = node::ObjectWrap::Unwrap<LazyDissectorNode>(info.Data()->ToObject());
  194
+    v8::Local<v8::Object> newNodeObj = New(self->m_root, self->m_fdata, self->m_edt, lazyNode->getProtoNode());
  195
+    self->m_childStorage->Set(property, newNodeObj);
  196
+    return scope.Close(newNodeObj);
  197
+  }
198 198
 }
199 199
 
200 200
 /*static*/ void DissectorNode::childSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
201  
-	v8::HandleScope scope;
202  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
203  
-	self->m_childStorage->Set(property, value);
  201
+  v8::HandleScope scope;
  202
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  203
+  self->m_childStorage->Set(property, value);
204 204
 }
205 205
 
206 206
 /*static*/ v8::Handle<v8::Value> DissectorNode::dataSourceGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
207  
-	v8::HandleScope scope;
208  
-	LazyDataSource *lazyDataSource = node::ObjectWrap::Unwrap<LazyDataSource>(info.Data()->ToObject());
209  
-	DissectorNode *self = lazyDataSource->getParent();
210  
-	if(self->m_dataSourceStorage->Has(property)) {
211  
-		return scope.Close(self->m_dataSourceStorage->Get(property));
212  
-	} else {
213  
-		#ifdef SHOW_CREATES
214  
-			v8::String::AsciiValue propertyStr(property);
215  
-			printf("***** create datasource: %s\n", *propertyStr);
216  
-		#endif
217  
-
218  
-		node::Buffer *buf = lazyDataSource->createBuffer();
219  
-		self->m_dataSourceStorage->Set(property, buf->handle_);
220  
-		return scope.Close(buf->handle_);
221  
-	}
  207
+  v8::HandleScope scope;
  208
+  LazyDataSource *lazyDataSource = node::ObjectWrap::Unwrap<LazyDataSource>(info.Data()->ToObject());
  209
+  DissectorNode *self = lazyDataSource->getParent();
  210
+  if(self->m_dataSourceStorage->Has(property)) {
  211
+    return scope.Close(self->m_dataSourceStorage->Get(property));
  212
+  } else {
  213
+    #ifdef SHOW_CREATES
  214
+      v8::String::AsciiValue propertyStr(property);
  215
+      printf("***** create datasource: %s\n", *propertyStr);
  216
+    #endif
  217
+
  218
+    node::Buffer *buf = lazyDataSource->createBuffer();
  219
+    self->m_dataSourceStorage->Set(property, buf->handle_);
  220
+    return scope.Close(buf->handle_);
  221
+  }
222 222
 }
223 223
 
224 224
 /*static*/ void DissectorNode::dataSourceSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
225  
-	v8::HandleScope scope;
226  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
227  
-	self->m_dataSourceStorage->Set(property, value);
  225
+  v8::HandleScope scope;
  226
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  227
+  self->m_dataSourceStorage->Set(property, value);
228 228
 }
229 229
 
230 230
 /*static*/ v8::Handle<v8::Value> DissectorNode::representationGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
231  
-	v8::HandleScope scope;
232  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  231
+  v8::HandleScope scope;
  232
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
233 233
 
234  
-	if(self->m_representation.IsEmpty()) {
235  
-		self->m_representation = v8::Persistent<v8::String>::New(getRepresentation(self->m_node)->ToString());
236  
-	}
  234
+  if(self->m_representation.IsEmpty()) {
  235
+    self->m_representation = v8::Persistent<v8::String>::New(getRepresentation(self->m_node)->ToString());
  236
+  }
237 237
 
238  
-	return scope.Close(self->m_representation);
  238
+  return scope.Close(self->m_representation);
239 239
 }
240 240
 
241 241
 /*static*/ v8::Handle<v8::Value> DissectorNode::getRepresentation(proto_node *node) {
242  
-	v8::HandleScope scope;
243  
-	field_info *fi = PNODE_FINFO(node);
244  
-	if(fi && fi->rep) {
245  
-		char *temp = new char[strlen(fi->rep->representation)+2]; // TODO: avoid copy
246  
-		fixEscapes(fi->rep->representation, temp);
247  
-		v8::Local<v8::String> result = v8::String::New(temp);
248  
-		delete[] temp;
249  
-		return scope.Close(result);
250  
-	}
251  
-	return scope.Close(v8::Undefined());
  242
+  v8::HandleScope scope;
  243
+  field_info *fi = PNODE_FINFO(node);
  244
+  if(fi && fi->rep) {
  245
+    char *temp = new char[strlen(fi->rep->representation)+2]; // TODO: avoid copy
  246
+    fixEscapes(fi->rep->representation, temp);
  247
+    v8::Local<v8::String> result = v8::String::New(temp);
  248
+    delete[] temp;
  249
+    return scope.Close(result);
  250
+  }
  251
+  return scope.Close(v8::Undefined());
252 252
 }
253 253
 
254 254
 /*static*/ void DissectorNode::representationSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
255  
-	v8::HandleScope scope;
256  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
257  
-	self->m_representation.Dispose();
258  
-	self->m_representation = v8::Persistent<v8::Value>::New(value);
  255
+  v8::HandleScope scope;
  256
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  257
+  self->m_representation.Dispose();
  258
+  self->m_representation = v8::Persistent<v8::Value>::New(value);
259 259
 }
260 260
 
261 261
 /*static*/ v8::Handle<v8::Value> DissectorNode::valueGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
262  
-	v8::HandleScope scope;
263  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  262
+  v8::HandleScope scope;
  263
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
264 264
 
265  
-	if(self->m_value.IsEmpty()) {
266  
-		field_info *fi = PNODE_FINFO(self->m_node);
  265
+  if(self->m_value.IsEmpty()) {
  266
+    field_info *fi = PNODE_FINFO(self->m_node);
267 267
     int showStringChopPos = 0;
268 268
     char *showString = proto_construct_match_selected_string(fi, self->m_edt);
269  
-		if (showString != NULL) {
270  
-			char *p = strstr(showString, "==");
271  
-			if(p) {
272  
-				showStringChopPos = (int)(p - showString) + 3;
273  
-			}
  269
+    if (showString != NULL) {
  270
+      char *p = strstr(showString, "==");
  271
+      if(p) {
  272
+        showStringChopPos = (int)(p - showString) + 3;
  273
+      }
274 274
 
275  
-			if (showString[strlen(showString)-1] == '"') {
276  
-					showString[strlen(showString)-1] = '\0';
277  
-					showStringChopPos++;
278  
-			}
  275
+      if (showString[strlen(showString)-1] == '"') {
  276
+          showString[strlen(showString)-1] = '\0';
  277
+          showStringChopPos++;
  278
+      }
279 279
 
280 280
       char *theString = &(showString[showStringChopPos]);
281 281
       char *temp = new char[strlen(theString)+2]; // TODO: avoid copy
282 282
       fixEscapes(theString, temp);
283 283
       self->m_value = v8::Persistent<v8::String>::New(v8::String::New(temp));
284 284
       delete[] temp;
285  
-		}
286  
-	}
  285
+    }
  286
+  }
287 287
 
288  
-	return scope.Close(self->m_value);
  288
+  return scope.Close(self->m_value);
289 289
 }
290 290
 
291 291
 /*static*/ void DissectorNode::valueSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
292  
-	v8::HandleScope scope;
293  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
294  
-	self->m_value.Dispose();
295  
-	self->m_value = v8::Persistent<v8::Value>::New(value);
  292
+  v8::HandleScope scope;
  293
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  294
+  self->m_value.Dispose();
  295
+  self->m_value = v8::Persistent<v8::Value>::New(value);
296 296
 }
297 297
 
298 298
 /*static*/ v8::Handle<v8::Value> DissectorNode::rawDataGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
299  
-	v8::HandleScope scope;
300  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  299
+  v8::HandleScope scope;
  300
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
301 301
 
302  
-	if(self->m_rawData.IsEmpty()) {
303  
-		#ifdef SHOW_CREATES
304  
-			v8::String::AsciiValue propertyStr(property);
305  
-			printf("***** create rawData: %s\n", *propertyStr);
306  
-		#endif
  302
+  if(self->m_rawData.IsEmpty()) {
  303
+    #ifdef SHOW_CREATES
  304
+      v8::String::AsciiValue propertyStr(property);
  305
+      printf("***** create rawData: %s\n", *propertyStr);
  306
+    #endif
307 307
 
308  
-		v8::Local<v8::Object> dataSources = self->m_root->handle_->Get(v8::String::New("dataSources"))->ToObject();
  308
+    v8::Local<v8::Object> dataSources = self->m_root->handle_->Get(v8::String::New("dataSources"))->ToObject();
309 309
     v8::Local<v8::Value> dataSourceNameObj = self->handle_->Get(v8::String::New("dataSource"));
310 310
     if(!dataSourceNameObj->IsNull() && !dataSourceNameObj->IsUndefined()) {
311 311
       v8::Local<v8::String> dataSourceName = dataSourceNameObj->ToString();
@@ -317,41 +317,41 @@ void DissectorNode::createChildren() {
317 317
       };
318 318
       self->m_rawData = v8::Persistent<v8::Value>::New(sliceFn->CallAsFunction(dataSource, 2, sliceArgs));
319 319
     }
320  
-	}
  320
+  }
321 321
 
322  
-	return scope.Close(self->m_rawData);
  322
+  return scope.Close(self->m_rawData);
323 323
 }
324 324
 
325 325
 /*static*/ void DissectorNode::rawDataSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
326  
-	v8::HandleScope scope;
327  
-	DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
328  
-	self->m_rawData.Dispose();
329  
-	self->m_rawData = v8::Persistent<v8::Value>::New(value);
  326
+  v8::HandleScope scope;
  327
+  DissectorNode *self = node::ObjectWrap::Unwrap<DissectorNode>(info.This());
  328
+  self->m_rawData.Dispose();
  329
+  self->m_rawData = v8::Persistent<v8::Value>::New(value);
330 330
 }
331 331
 
332 332
 DissectorNode::DissectorNode(DissectorNode *root, frame_data *fdata, epan_dissect_t *edt, proto_node *node) {
333  
-	m_fdata = fdata;
334  
-	if(root == NULL) {
335  
-		m_root = this;
336  
-	} else {
337  
-		m_root = root;
338  
-	}
  333
+  m_fdata = fdata;
  334
+  if(root == NULL) {
  335
+    m_root = this;
  336
+  } else {
  337
+    m_root = root;
  338
+  }
339 339
   m_edt = edt;
340 340
   m_node = node;
341  
-	m_childStorage = v8::Persistent<v8::Object>::New(v8::Object::New());
342  
-	m_dataSourceStorage = v8::Persistent<v8::Object>::New(v8::Object::New());
  341
+  m_childStorage = v8::Persistent<v8::Object>::New(v8::Object::New());
  342
+  m_dataSourceStorage = v8::Persistent<v8::Object>::New(v8::Object::New());
343 343
 }
344 344
 
345 345
 DissectorNode::~DissectorNode() {
346  
-	m_representation.Dispose();
347  
-	m_value.Dispose();
348  
-	m_childStorage.Dispose();
349  
-	m_dataSourceStorage.Dispose();
350  
-	m_rawData.Dispose();
351  
-	if(isRoot()) {
352  
-		epan_dissect_cleanup(m_edt);
353  
-	  frame_data_cleanup(m_fdata);
354  
-		delete m_edt;
355  
-		delete m_fdata;
356  
-	}
  346
+  m_representation.Dispose();
  347
+  m_value.Dispose();
  348
+  m_childStorage.Dispose();
  349
+  m_dataSourceStorage.Dispose();
  350
+  m_rawData.Dispose();
  351
+  if(isRoot()) {
  352
+    epan_dissect_cleanup(m_edt);
  353
+    frame_data_cleanup(m_fdata);
  354
+    delete m_edt;
  355
+    delete m_fdata;
  356
+  }
357 357
 }
16  src/lazyDataSource.cpp
@@ -16,7 +16,7 @@
16 16
 }
17 17
 
18 18
 /*static*/ v8::Local<v8::Object> LazyDataSource::New(DissectorNode *parent, tvbuff_t *tvb) {
19  
-	v8::HandleScope scope;
  19
+  v8::HandleScope scope;
20 20
   v8::Local<v8::Function> ctor = s_ct->GetFunction();
21 21
   v8::Local<v8::Object> obj = ctor->NewInstance();
22 22
   LazyDataSource *self = new LazyDataSource(parent, tvb);
@@ -26,8 +26,8 @@
26 26
 }
27 27
 
28 28
 LazyDataSource::LazyDataSource(DissectorNode *parent, tvbuff_t *tvb) {
29  
-	m_parent = parent;
30  
-	m_tvb = tvb;
  29
+  m_parent = parent;
  30
+  m_tvb = tvb;
31 31
 }
32 32
 
33 33
 LazyDataSource::~LazyDataSource() {
@@ -35,9 +35,9 @@ LazyDataSource::~LazyDataSource() {
35 35
 }
36 36
 
37 37
 node::Buffer* LazyDataSource::createBuffer() {
38  
-	guint length = tvb_length(m_tvb);
39  
-	const guchar *cp = tvb_get_ptr(m_tvb, 0, length);
40  
-	node::Buffer *buf = node::Buffer::New(length);
41  
-	memcpy(node::Buffer::Data(buf), cp, length);
42  
-	return buf;
  38
+  guint length = tvb_length(m_tvb);
  39
+  const guchar *cp = tvb_get_ptr(m_tvb, 0, length);
  40
+  node::Buffer *buf = node::Buffer::New(length);
  41
+  memcpy(node::Buffer::Data(buf), cp, length);
  42
+  return buf;
43 43
 }
6  src/lazyDissectorNode.cpp
@@ -18,8 +18,8 @@ BENCHMARK_DEF_EXTERN(lazyDissectorNodeNew);
18 18
 }
19 19
 
20 20
 /*static*/ v8::Local<v8::Object> LazyDissectorNode::New(frame_data *fdata, epan_dissect_t *edt, proto_node *node) {
21  
-	v8::HandleScope scope;
22  
-	BENCHMARK_START(lazyDissectorNodeNew);
  21
+  v8::HandleScope scope;
  22
+  BENCHMARK_START(lazyDissectorNodeNew);
23 23
   v8::Local<v8::Function> ctor = s_ct->GetFunction();
24 24
   v8::Local<v8::Object> obj = ctor->NewInstance();
25 25
   LazyDissectorNode *self = new LazyDissectorNode(fdata, edt, node);
@@ -29,7 +29,7 @@ BENCHMARK_DEF_EXTERN(lazyDissectorNodeNew);
29 29
 }
30 30
 
31 31
 LazyDissectorNode::LazyDissectorNode(frame_data *fdata, epan_dissect_t *edt, proto_node *node) {
32  
-	m_fdata = fdata;
  32
+  m_fdata = fdata;
33 33
   m_edt = edt;
34 34
   m_node = node;
35 35
 }

0 notes on commit d9bf1b7

Please sign in to comment.
Something went wrong with that request. Please try again.