Esempio n. 1
0
static int List_set(DOH *lo, int n, DOH *val) {
  List *l = (List *) ObjData(lo);
  if (!val)
    return -1;
  assert(!((n < 0) || (n >= l->nitems)));
  if (!DohCheck(val)) {
    val = NewString(val);
    Decref(val);
  }
  Delete(l->items[n]);
  l->items[n] = val;
  Incref(val);
  Delete(val);
  return 0;
}
Esempio n. 2
0
String *Swig_scopename_last(const String *s) {
  char *tmp = Char(s);
  char *c = tmp;
  char *cc = c;
  char *co = 0;
  if (!strstr(c, "::"))
    return NewString(s);

  co = strstr(cc, "operator ");
  if (co) {
    return NewString(co);
  }


  while (*c) {
    if ((*c == ':') && (*(c + 1) == ':')) {
      cc = c;
      c += 2;
    } else {
      if (*c == '<') {
	int level = 1;
	c++;
	while (*c && level) {
	  if (*c == '<')
	    level++;
	  if (*c == '>')
	    level--;
	  c++;
	}
      } else {
	c++;
      }
    }
  }
  return NewString(cc + 2);
}
Esempio n. 3
0
String *
Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self) {
  String *func, *nname;
  int i = 0;
  Parm *p = parms;
  SwigType *pt;
  int comma = 0;

  if (!self) self = (char *) "(this)->";

  func = NewString("");
  nname = SwigType_namestr(name);
  if (!p) return func;
  Append(func,self);
  pt = Getattr(p,"type");

  /* If the method is invoked through a dereferenced pointer, we don't add any casts
     (needed for smart pointers).  Otherwise, we cast to the appropriate type */

  if (Strstr(func,"*this")) {
    Replaceall(func,"this", Swig_cparm_name(p,0));
  } else {
    Replaceall(func,"this", SwigType_rcaststr(pt, Swig_cparm_name(p,0)));
  }

  if (SwigType_istemplate(name)) {
      Printf(func,"template %s(", nname);
  } else {
      Printf(func,"%s(", nname);
  }
  i++;
  p = nextSibling(p);
  while (p) {
    String *pname;
    pt = Getattr(p,"type");
    if ((SwigType_type(pt) != T_VOID)) {
      if (comma) Printf(func,",");
      pname = Swig_cparm_name(p,i);
      Printf(func,"%s", SwigType_rcaststr(pt, pname));
      comma = 1;
      i++;
    }
    p = nextSibling(p);
  }
  Printf(func,")");
  Delete(nname);
  return func;
}
Esempio n. 4
0
void Swig_cparse_replace_descriptor(String *s) {
  char tmp[512];
  String *arg = 0;
  SwigType *t;
  char *c = 0;

  while ((c = strstr(Char(s), "$descriptor("))) {
    char *d = tmp;
    int level = 0;
    while (*c) {
      if (*c == '(')
	level++;
      if (*c == ')') {
	level--;
	if (level == 0) {
	  break;
	}
      }
      *d = *c;
      d++;
      c++;
    }
    *d = 0;
    arg = NewString(tmp + 12);
    t = Swig_cparse_type(arg);
    Delete(arg);
    arg = 0;

    if (t) {
      String *mangle;
      String *descriptor;

      mangle = SwigType_manglestr(t);
      descriptor = NewStringf("SWIGTYPE%s", mangle);
      SwigType_remember(t);
      *d = ')';
      d++;
      *d = 0;
      Replace(s, tmp, descriptor, DOH_REPLACE_ANY);
      Delete(mangle);
      Delete(descriptor);
      Delete(t);
    } else {
      Swig_error(Getfile(s), Getline(s), "Bad $descriptor() macro.\n");
      break;
    }
  }
}
Esempio n. 5
0
	String* String::NewString(const char* str, const int64_t len){
		if(!str) return NewString();
		String* o =SafeNew<String>();
		if(len >= 0){
			o->m_length =len;
		}
		else{
			o->m_length =strlen(str);
		}
		o->m_data =reinterpret_cast< char* >(ALLOCATE(o->m_length + 1));
		if(o->m_length > 0){
			memcpy(o->m_data, str, (size_t)o->m_length);
		}
		o->m_data[o->m_length] =0;
		return o;
	}
Esempio n. 6
0
SwigScanner *
NewSwigScanner() {
  SwigScanner *s;
  s = (SwigScanner *) malloc(sizeof(SwigScanner));
  s->line = 1;
  s->file = 0;
  s->nexttoken = -1;
  s->start_line = 1;
  s->string_start = 0;
  s->yylen = 0;
  s->idstart = "";
  s->scanobjs = NewList();
  s->text = NewString("");
  s->str = 0;
  return s;
}
Esempio n. 7
0
/* Returns the function type, t, constructed from the parameters, parms */
SwigType *SwigType_add_function(SwigType *t, ParmList *parms) {
  String *pstr;
  Parm *p;

  Insert(t, 0, ").");
  pstr = NewString("f(");
  p = parms;
  for (p = parms; p; p = nextSibling(p)) {
    if (p != parms)
      Putc(',', pstr);
    Append(pstr, Getattr(p, "type"));
  }
  Insert(t, 0, pstr);
  Delete(pstr);
  return t;
}
Esempio n. 8
0
/*
 * Turn screen tracing on or off.
 *
 * If turning it on, screentrace_how contains TSS_FILE or TSS_PRINTER,
 *  and screentrace_name is NULL (use the default) or the name of a
 *  file, printer command (Unix) or printer (Windows).
 */
static void
toggle_screenTrace(toggle_index_t ix _is_unused, enum toggle_type tt)
{
    char *tracefile_buf = NULL;
    char *tracefile;

    if (toggled(SCREEN_TRACE)) {
	/* Turn it on. */
	status_screentrace((screentrace_count = 0));
	if (onetime_screentrace_name != NULL) {
	    tracefile = tracefile_buf = onetime_screentrace_name;
	    onetime_screentrace_name = NULL;
	} else if (screentrace_how == TSS_FILE &&
		appres.screentrace_file != NULL) {
	    tracefile = appres.screentrace_file;
	} else {
	    if (screentrace_how == TSS_FILE) {
		tracefile = tracefile_buf =
		    screentrace_default_file(screentrace_ptype);
	    } else {
		tracefile = tracefile_buf = screentrace_default_printer();
	    }
	}
	if (!screentrace_cb(screentrace_how, screentrace_ptype,
		    NewString(tracefile))) {

	    set_toggle(SCREEN_TRACE, false);
	    status_screentrace((screentrace_count = -1));
	}
    } else {
	/* Turn it off. */
	if (ctlr_any_data() && !trace_skipping) {
	    do_screentrace(false);
	}
	end_screentrace(tt == TT_FINAL);
	screentrace_last_how = screentrace_how;
	screentrace_how = TSS_FILE; /* back to the default */
	screentrace_ptype = P_TEXT; /* back to the default */
	status_screentrace((screentrace_count = -1));
    }

    if (tracefile_buf != NULL) {
	Free(tracefile_buf);
    }

    trace_gui_toggle();
}
/**
  Password may be stored as encrypted by Configuration Driver. When change a
  password, user will be challenged with old password. To validate user input old
  password, we will send the clear text to Configuration Driver via Callback().
  Configuration driver is responsible to check the passed in password and return
  the validation result. If validation pass, state machine in password Callback()
  will transit from BROWSER_STATE_VALIDATE_PASSWORD to BROWSER_STATE_SET_PASSWORD.
  After user type in new password twice, Callback() will be invoked to send the
  new password to Configuration Driver.

  @param  Selection              Pointer to UI_MENU_SELECTION.
  @param  MenuOption             The MenuOption for this password Question.
  @param  String                 The clear text of password.

  @retval EFI_NOT_AVAILABLE_YET  Callback() request to terminate password input.
  @return In state of BROWSER_STATE_VALIDATE_PASSWORD:
  @retval EFI_SUCCESS            Password correct, Browser will prompt for new
                                 password.
  @retval EFI_NOT_READY          Password incorrect, Browser will show error
                                 message.
  @retval Other                  Browser will do nothing.
  @return In state of BROWSER_STATE_SET_PASSWORD:
  @retval EFI_SUCCESS            Set password success.
  @retval Other                  Set password failed.

**/
EFI_STATUS
PasswordCallback (
  IN  UI_MENU_SELECTION           *Selection,
  IN  UI_MENU_OPTION              *MenuOption,
  IN  CHAR16                      *String
  )
{
  EFI_STATUS                      Status;
  EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess;
  EFI_BROWSER_ACTION_REQUEST      ActionRequest;
  EFI_IFR_TYPE_VALUE              IfrTypeValue;

  ConfigAccess = Selection->FormSet->ConfigAccess;
  if (ConfigAccess == NULL) {
    return EFI_UNSUPPORTED;
  }

  //
  // Prepare password string in HII database
  //
  if (String != NULL) {
    IfrTypeValue.string = NewString (String, Selection->FormSet->HiiHandle);
  } else {
    IfrTypeValue.string = 0;
  }

  //
  // Send password to Configuration Driver for validation
  //
  Status = ConfigAccess->Callback (
                           ConfigAccess,
                           EFI_BROWSER_ACTION_CHANGING,
                           MenuOption->ThisTag->QuestionId,
                           MenuOption->ThisTag->HiiValue.Type,
                           &IfrTypeValue,
                           &ActionRequest
                           );

  //
  // Remove password string from HII database
  //
  if (String != NULL) {
    DeleteString (IfrTypeValue.string, Selection->FormSet->HiiHandle);
  }

  return Status;
}
Esempio n. 10
0
String *SwigType_prefix(const SwigType *t) {
  char *c, *d;
  String *r = 0;

  c = Char(t);
  d = c + strlen(c);

  /* Check for a type constructor */
  if ((d > c) && (*(d - 1) == '.'))
    d--;

  while (d > c) {
    d--;
    if (*d == '>') {
      int nest = 1;
      d--;
      while ((d > c) && (nest)) {
	if (*d == '>')
	  nest++;
	if (*d == '<')
	  nest--;
	d--;
      }
    }
    if (*d == ')') {
      /* Skip over params */
      int nparen = 1;
      d--;
      while ((d > c) && (nparen)) {
	if (*d == ')')
	  nparen++;
	if (*d == '(')
	  nparen--;
	d--;
      }
    }

    if (*d == '.') {
      char t = *(d + 1);
      *(d + 1) = 0;
      r = NewString(c);
      *(d + 1) = t;
      return r;
    }
  }
  return NewStringEmpty();
}
Esempio n. 11
0
void start_inline(char *text, int line) {
  InFile *in;

  /* Save current state */
  in_head->line_number = cparse_line;
  in_head->in_file = cparse_file;

  in = (InFile *) malloc(sizeof(InFile));
  in->f = NewString(text);
  Seek(in->f,0,SEEK_SET);
  in->in_file = Swig_copy_string(cparse_file);
  in->line_number = line;
  in->prev = in_head;
  in_head = in;
  LEX_in = in->f;
  cparse_line = line;
}
Esempio n. 12
0
File: glue.c Progetto: hharte/c3270
/* Pop up an error dialog, based on an error number. */
void
popup_an_errno(int errn, const char *fmt, ...)
{
	va_list args;
	char *s;

	va_start(args, fmt);
	(void) vsnprintf(vmsgbuf, sizeof(vmsgbuf), fmt, args);
	va_end(args);
	s = NewString(vmsgbuf);

	if (errn > 0)
		popup_an_error("%s: %s", s, strerror(errn));
	else
		popup_an_error("%s", s);
	Free(s);
}
Esempio n. 13
0
/*
 * Whitespace stripper.
 */
char *
strip_whitespace(const char *s)
{
    char *t = NewString(s);

    while (*t && my_isspace(*t)) {
	t++;
    }
    if (*t) {
	char *u = t + strlen(t) - 1;

	while (my_isspace(*u)) {
	    *u-- = '\0';
	}
    }
    return t;
}
Esempio n. 14
0
jobject wrapJSObject(JNIEnv *pEnv, v8::Handle<v8::Value> value)
{
  v8::HandleScope handle_scope;

  if (value.IsEmpty() || value->IsNull() || value->IsUndefined()) return NULL;
  if (value->IsTrue()) return NewBoolean(pEnv, JNI_TRUE);
  if (value->IsFalse()) return NewBoolean(pEnv, JNI_FALSE);

  if (value->IsInt32()) return NewInt(pEnv, value->Int32Value());
  if (value->IsUint32()) return NewLong(pEnv, value->IntegerValue());
  if (value->IsString()) return NewString(pEnv, v8::Handle<v8::String>::Cast(value));
  if (value->IsDate()) return NewDate(pEnv, v8::Handle<v8::Date>::Cast(value));
  if (value->IsNumber()) return NewDouble(pEnv, value->NumberValue());

//  return wrap(value->ToObject());
  return NULL;
}
Esempio n. 15
0
void 
Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object) {
  DOH *n;

  /*  Printf(stdout,"name:  '%s', '%s'\n", name, decl);*/
  n = Getattr(namehash,name);
  if (!n) {
    n = NewHash();
    Setattr(namehash,name,n);
  }
  /* Add an object based on the declarator value */
  if (!decl) {
    Setattr(n,NewString("*"),object);
  } else {
    Setattr(n,Copy(decl),object);
  }
}
Esempio n. 16
0
String *
Swig_name_set(const String_or_char *vname) {
  String *r;
  String *f;

  r = NewString("");
  if (!naming_hash) naming_hash = NewHash();
  f = Getattr(naming_hash,"set");
  if (!f) {
    Append(r,"%v_set");
  } else {
    Append(r,f);
  }
  Replace(r,"%v",vname, DOH_REPLACE_ANY);
  Replace(r,"::","_", DOH_REPLACE_ANY);
  return r;
}
Esempio n. 17
0
String *
Swig_name_wrapper(const String_or_char *fname) {
  String *r;
  String *f;

  r = NewString("");
  if (!naming_hash) naming_hash = NewHash();
  f = Getattr(naming_hash,"wrapper");
  if (!f) {
    Append(r,"_wrap_%f");
  } else {
    Append(r,f);
  }
  Replace(r,"%f",fname, DOH_REPLACE_ANY);
  name_mangle(r);
  return r;
}
Esempio n. 18
0
	const String String::operator=(const char* c){
		if (c != NULL)
		{
			if (sizeMemory < strlen(c) + 1)
			{
				delete[] strng;
				sizeMemory = strlen(c) + 1;
				NewString(sizeMemory);
			}
			strcpy_s(strng, sizeMemory, c);
		}
		else {
			Clear();
		}

		return *this;
	}
static void set_about_item(void){
	Str255 aboutitem;
	StringHandle abouthandle;

	GetMenuItemText( GetMenuHandle(mApple), iAbout, aboutitem);
	abouthandle = NewString( aboutitem);
	if( abouthandle){
		StringPtr curApName = LMGetCurApName();
		long len = Munger( (Handle)abouthandle, 1, "MathLink\252", 9, curApName + 1, *curApName); 
		if( len > 0){
			**abouthandle = (unsigned char)len; 
			HLock( (Handle)abouthandle);
			SetMenuItemText( GetMenuHandle(mApple), iAbout, *abouthandle);
		}
		DisposeHandle( (Handle)abouthandle);
	}
}
Esempio n. 20
0
JNIEXPORT jstring JNICALL Java_com_ssb_droidsound_plugins_VICEPlugin_N_1loadFile(JNIEnv *env, jclass cl, jstring name)
{
    __android_log_print(ANDROID_LOG_VERBOSE, "VICEPlugin", "in load()");

    const char* cname = env->GetStringUTFChars(name, 0);
    int ret = psid_load_file(cname);
    env->ReleaseStringUTFChars(name, cname);
    
    if (ret != 0)
    {
        return NewString(env, (const char *) "failure code from psid_load_file()");
    }

    c64_song_init();

    return 0;
}
Esempio n. 21
0
SwigType *
SwigType_base(SwigType *t) {
  char *c;
  char *lastop = 0;
  c = Char(t);

  lastop = c;

  /* Search for the last type constructor separator '.' */
  while (*c) {
    if (*c == '.') {
      if (*(c+1)) {
	lastop = c+1;
      }
      c++;
      continue;
    }
    if (*c == '<') {
      /* Skip over template---it's part of the base name */
      int ntemp = 1;
      c++;
      while ((*c) && (ntemp > 0)) {
	if (*c == '>') ntemp--;
	else if (*c == '<') ntemp++;
	c++;
      }
      if (ntemp) break;
      continue;
    }
    if (*c == '(') {
      /* Skip over params */
      int nparen = 1;
      c++;
      while ((*c) && (nparen > 0)) {
	if (*c == '(') nparen++;
	else if (*c == ')') nparen--;
	c++;
      }
      if (nparen) break;
      continue;
    }
    c++;
  }
  return NewString(lastop);
}
Esempio n. 22
0
	const String String::operator+=(const char* c){
		if (c != NULL)
		{
			
				char* tmp = strng;
				strcpy_s(tmp, sizeMemory, strng);

				sizeMemory = Length() + strlen(c) + 1;
				NewString(sizeMemory);
				strcpy_s(strng, sizeMemory , tmp);
				delete[] tmp;

			
			strcat_s(strng, sizeMemory, c);
		}

		return *this;
	}
Esempio n. 23
0
File: parms.c Progetto: kanbang/Colt
String *ParmList_protostr(ParmList *p) {
  String *out;
  SwigType *t;

  out = NewString("");
  while(p) {
    if (Getattr(p,"hidden")) {
      p = nextSibling(p);
      continue;
    }
    t = Getattr(p,"type");
    Printf(out,"%s", SwigType_str(t,0));
    p = nextSibling(p);
    if (p)
      Printf(out,",");
  }
  return out;
}
Esempio n. 24
0
//-----------------------------------------------------------------------------
// Replace a string in the list with one which has the desired font
Boolean
WXmList::ChangeItemFont( int pos, char* newtag )
{
   int count = ItemCount();
   if( count < pos ) {
      return FALSE;
   }	
	
   XmStringTable ListStrings =  Items();

   if( pos == 0 ){ // Zero indicates the last element
      pos = count;
   }
   WXmString OldString( ListStrings[pos-1] );
   WXmString NewString(OldString.CopyUsingFont(newtag));
   ReplaceItemsPos((XmString*)&NewString, 1, 1);
   return TRUE;
} // WXmList::ChangeItemFont( WXmList* pList, int pos, char* newtag )
Esempio n. 25
0
void _json_loader(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    v8::Isolate* isolate = args.GetIsolate();
    obj_ptr<Buffer_base> src = Buffer_base::getInstance(args.Data());

    exlib::string strScript;
    src->toString(strScript);
    v8::Local<v8::Value> v;

    result_t hr = json_base::decode(strScript, v);
    if (hr < 0) {
        ThrowResult(hr);
        return;
    }

    v8::Local<v8::Object> module = v8::Local<v8::Object>::Cast(args[5]);
    module->Set(NewString(isolate, "exports"), v);
}
Esempio n. 26
0
HandleProxy* FunctionTemplateProxy::CreateInstance(int32_t managedObjectID, int32_t argCount, HandleProxy** args)
{
	auto hArgs = new Handle<Value>[argCount];
    for (auto i = 0; i < argCount; i++)
        hArgs[i] = args[i]->Handle();
    auto obj = _FunctionTemplate->GetFunction()->NewInstance(argCount, hArgs);
    delete[] hArgs; // TODO: (does "disposed" still need to be called here for each item?)

    if (managedObjectID == -1)
        managedObjectID = _EngineProxy->GetNextNonTemplateObjectID();

    auto proxyVal = _EngineProxy->GetHandleProxy(obj);
    proxyVal->_ObjectID = managedObjectID;
    //??auto count = obj->InternalFieldCount();
    obj->SetAlignedPointerInInternalField(0, this); // (stored a reference to the proxy instance for the call-back functions)
    obj->SetInternalField(1, NewExternal(reinterpret_cast<void*>(managedObjectID))); // (stored a reference to the managed object for the call-back functions)
    obj->SetHiddenValue(NewString("ManagedObjectID"), NewInteger(managedObjectID)); // (won't be used on template created objects [fields are faster], but done anyhow for consistency)
    return proxyVal;
}
Esempio n. 27
0
/*
 * After you are done with a site (by closing it or quitting), we
 * need to update the list of recent sites called.
 */
void UpdateRecentSitesList(char *host, char *lastdir)
{
	recentsite *r;
	char *ndir;

	if (keep_recent) {	
		r = FindRecentSite(host, 1);
		if (r == NULL)
			AddRecentSite(host, lastdir);
		else {
			/* Update the last time connected, and the directory we left in. */
			if ((ndir = NewString(*lastdir ? lastdir : "/")) != NULL) {
				free(r->dir);
				r->dir = ndir;
			}
			(void) time(&r->lastcall);
		}
	}
}	/* UpdateRecentSitesList */
Esempio n. 28
0
// Primary initialization function. Sets everything up and takes care of the program
char *Start(int run_vegastrike) {
	InitGraphics();

	DATA.name = NewString("");
	DATA.author = NewString("");
	DATA.description = NewString("");
	DATA.briefing = NewString("");
	DATA.path = NewString("");
	DATA.numplayers = NewString("");

	ShowMain(1);
	gtk_main();
	return DATA.path;
}
Esempio n. 29
0
String *SwigType_namestr(const SwigType *t) {
  String *r;
  String *suffix;
  List *p;
  int i, sz;
  char *d = Char(t);
  char *c = strstr(d, "<(");

  if (!c || !strstr(c + 2, ")>"))
    return NewString(t);

  r = NewStringWithSize(d, c - d);
  if (*(c - 1) == '<')
    Putc(' ', r);
  Putc('<', r);

  p = SwigType_parmlist(c + 1);
  sz = Len(p);
  for (i = 0; i < sz; i++) {
    String *str = SwigType_str(Getitem(p, i), 0);
    /* Avoid creating a <: token, which is the same as [ in C++ - put a space after '<'. */
    if (i == 0 && Len(str))
      Putc(' ', r);
    Append(r, str);
    if ((i + 1) < sz)
      Putc(',', r);
    Delete(str);
  }
  Putc(' ', r);
  Putc('>', r);
  suffix = SwigType_templatesuffix(t);
  if (Len(suffix) > 0) {
    String *suffix_namestr = SwigType_namestr(suffix);
    Append(r, suffix_namestr);
    Delete(suffix_namestr);
  } else {
    Append(r, suffix);
  }
  Delete(suffix);
  Delete(p);
  return r;
}
Esempio n. 30
0
void Swig_warnfilter(const String_or_char *wlist, int add) {
  char *c;
  char *cw;
  String *s;
  if (!filter)
    filter = NewStringEmpty();

  s = NewString("");
  Clear(s);
  cw = Char(wlist);
  while (*cw != '\0') {
    if (*cw != ' ') {
      Putc(*cw, s);
    }
    ++cw;
  }
  c = Char(s);
  c = strtok(c, ", ");
  while (c) {
    if (isdigit((int) *c) || (*c == '+') || (*c == '-')) {
      /* Even if c is a digit, the rest of the string might not be, eg in the case of typemap 
       * warnings (a bit odd really), eg: %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) */
      if (add) {
	Insert(filter, 0, c);
	if (isdigit((int) *c)) {
	  Insert(filter, 0, "-");
	}
      } else {
	char *temp = (char *)malloc(sizeof(char)*strlen(c) + 2);
	if (isdigit((int) *c)) {
	  sprintf(temp, "-%s", c);
	} else {
	  strcpy(temp, c);
	}
	Replace(filter, temp, "", DOH_REPLACE_FIRST);
        free(temp);
      }
    }
    c = strtok(NULL, ", ");
  }
  Delete(s);
}