comparison src/variables.cc @ 4179:8734ba917fea

[project @ 2002-11-14 04:31:19 by jwe]
author jwe
date Thu, 14 Nov 2002 04:31:19 +0000
parents 62afb31c1f85
children fa3482b34599
comparison
equal deleted inserted replaced
4178:b75f74a76941 4179:8734ba917fea
269 } 269 }
270 270
271 return retval; 271 return retval;
272 } 272 }
273 273
274 static inline bool
275 is_variable (const std::string& name)
276 {
277 bool retval = false;
278
279 if (! name.empty ())
280 {
281 symbol_record *sr = curr_sym_tab->lookup (name);
282
283 if (! sr)
284 sr = fbi_sym_tab->lookup (name);
285
286 retval = (sr && sr->is_variable ());
287 }
288
289 return retval;
290 }
291
274 string_vector 292 string_vector
275 generate_struct_completions (const std::string& text, 293 generate_struct_completions (const std::string& text,
276 std::string& prefix, std::string& hint) 294 std::string& prefix, std::string& hint)
277 { 295 {
278 string_vector names; 296 string_vector names;
285 hint = ""; 303 hint = "";
286 else 304 else
287 hint = text.substr (pos+1); 305 hint = text.substr (pos+1);
288 306
289 prefix = text.substr (0, pos); 307 prefix = text.substr (0, pos);
290 } 308
291 309 std::string base_name = prefix;
292 int parse_status; 310
293 311 pos = base_name.find_first_of ("{(.");
294 unwind_protect::begin_frame ("generate_struct_completions"); 312
295 313 if (pos != NPOS)
296 unwind_protect_str (Vwarning_option); 314 base_name = base_name.substr (0, pos);
297 unwind_protect_bool (discard_error_messages); 315
298 unwind_protect_int (error_state); 316 if (is_variable (base_name))
299 317 {
300 Vwarning_option = "off"; 318 int parse_status;
301 discard_error_messages = true; 319
302 320 unwind_protect::begin_frame ("generate_struct_completions");
303 octave_value tmp = eval_string (prefix, true, parse_status); 321
304 322 unwind_protect_str (Vwarning_option);
305 unwind_protect::run_frame ("generate_struct_completions"); 323 unwind_protect_bool (discard_error_messages);
306 324 unwind_protect_int (error_state);
307 if (tmp.is_defined () && tmp.is_map ()) 325
308 names = tmp.map_keys (); 326 Vwarning_option = "off";
327 discard_error_messages = true;
328
329 octave_value tmp = eval_string (prefix, true, parse_status);
330
331 unwind_protect::run_frame ("generate_struct_completions");
332
333 if (tmp.is_defined () && tmp.is_map ())
334 names = tmp.map_keys ();
335 }
336 }
309 337
310 return names; 338 return names;
311 } 339 }
340
341 // XXX FIXME XXX -- this will have to be much smarter to work
342 // "correctly".
312 343
313 bool 344 bool
314 looks_like_struct (const std::string& text) 345 looks_like_struct (const std::string& text)
315 { 346 {
316 bool retval = false; 347 bool retval = false;
317 348
349 #if 0
318 symbol_record *sr = curr_sym_tab->lookup (text); 350 symbol_record *sr = curr_sym_tab->lookup (text);
319 351
320 if (sr && ! sr->is_function ()) 352 if (sr && ! sr->is_function ())
321 { 353 {
322 int parse_status; 354 int parse_status;
334 366
335 unwind_protect::run_frame ("looks_like_struct"); 367 unwind_protect::run_frame ("looks_like_struct");
336 368
337 retval = (tmp.is_defined () && tmp.is_map ()); 369 retval = (tmp.is_defined () && tmp.is_map ());
338 } 370 }
371 #endif
339 372
340 return retval; 373 return retval;
341 } 374 }
342 375
343 DEFUN (isglobal, args, , 376 DEFUN (isglobal, args, ,