Example #1
0
Eval prim_make_socket(Expr args) {
	Symbol domain = take_typed(&args, SYMBOL).sym;
	Symbol type = take_typed(&args, SYMBOL).sym;
	take_nil(args);
	
	int real_domain, real_type;
	
	if(!wcscmp(domain, L"inet"))
		real_domain = AF_INET;
	else if(!wcscmp(domain, L"inet6"))
		real_domain = AF_INET6;
	else if(!wcscmp(domain, L"unix"))
		real_domain = AF_UNIX;
	else
		error(L"Unknown socket domain \"%ls\"", domain);
	
	if(!wcscmp(type, L"stream"))
		real_type = SOCK_STREAM;
	else if(!wcscmp(type, L"datagram"))
		real_type = SOCK_DGRAM;
	else if(!wcscmp(type, L"seqpacket"))
		real_type = SOCK_SEQPACKET;
	else
		error(L"Unknown socket type \"%ls\"", type);
	
	int fd = socket(real_domain, real_type, 0);
	if(fd < 0)
		return final_eval(typed(END_OBJ));
	
	Expr e = typed(PORT);
	e.port = fdopen(fd, "r+");
	return final_eval(e);
}
Example #2
0
 static void ParseSubchunks(const Binary::Data& data, Builder& target)
 {
   try
   {
     Binary::TypedContainer typed(data);
     for (std::size_t pos = 0; pos < typed.GetSize(); )
     {
       const SubChunkHeader* const hdr = typed.GetField<SubChunkHeader>(pos);
       Require(hdr != nullptr);
       if (hdr->ID == 0 && 0 != (pos % 4))
       {
         //in despite of official format description, subchunks can be not aligned by 4 byte boundary
         ++pos;
       }
       else
       {
         Dbg("ParseSubchunk id=%u, type=%u, size=%u", uint_t(hdr->ID), uint_t(hdr->Type), fromLE(hdr->DataSize));
         pos += sizeof(*hdr) + hdr->GetDataSize();
         Require(pos <= typed.GetSize());
         ParseSubchunk(*hdr, target);
       }
     }
   }
   catch (const std::exception&)
   {
     //ignore
   }
 }
Example #3
0
Eval prim_minus(Expr args) {
	Expr init = take_typed(&args, NUMBER), diff = typed(NUMBER);
	mpq_init(diff.num);
	Expr s = sum(args);
	mpq_sub(diff.num, init.num, s.num);
	return final_eval(diff);
}
Example #4
0
 Data::FreeFunctor Data::free() {
   RDataShadow* data = rdata();
   if(typed()) {
     return data->d.typed.type->function.dfree;
   } else {
     return data->d.untyped.dfree;
   }
 }
Example #5
0
 Data::MarkFunctor Data::mark() {
   RDataShadow* data = rdata();
   if(typed()) {
     return data->d.typed.type->function.dmark;
   } else {
     return data->d.untyped.dmark;
   }
 }
Example #6
0
Expr read_special(FILE* in) {
	wint_t c = fgetwc(in);
	if(c == L't' || c == L'T') {
		Expr e = typed(BOOLEAN);
		e.boolean = true;
		return e;
	} else if(c == L'f' || c == L'F') {
		Expr e = typed(BOOLEAN);
		e.boolean = false;
		return e;
	} else if(c == L'_') {
		return typed(IGNORE);
	} else if(c == L'\'') {
		bool failed = false;
		Expr e = typed(CHARACTER);
		e.chara = read_lit_char(in, false, &failed);
		if(failed)
			error(L"Illegal isolated literal character");
		return e;
	} else
		error(L"Unknown special expression");
	return dummy_expr;
}
Example #7
0
DialPage::DialPage()
{
   QGraphicsGridLayout* mainLayout = new QGraphicsGridLayout();
   setLayout(mainLayout);
   currentNumber = new Plasma::Frame(this);
   currentNumber->setText("Dial");
   currentNumber->setFrameShadow(Plasma::Frame::Sunken);
   currentNumber->setMinimumSize(0,50);
   currentNumber->setStyleSheet("background-color:#AAAAFF;border-size:2px;border-style:sunken;");
   //currentNumber->setEnabledBorders(FrameSvg::EnabledBorders::Raised);
   mainLayout->addItem(currentNumber,0,0,1,6);

   QString numbers[12] =
       {"1", "2", "3",
        "4", "5", "6",
        "7", "8", "9",
        "*", "0", "#"};

   QString texts[12] =
       {  ""  ,  "abc",  "def" ,
        "ghi" ,  "jkl",  "mno" ,
        "pqrs",  "tuv",  "wxyz",
          ""  ,   ""  ,   ""   };

   for(int i = 0 ; i < 12 ; i++) {
      DialButton* newButton = new DialButton(this);
      newButton->setMinimumHeight(40);
      newButton->setLetter(numbers[i]);
      newButton->setText(numbers[i]+((!texts[i].isEmpty())?("\n"+texts[i]):""));
      mainLayout->addItem(newButton,1+i/3,2*(i%3),1,2);
      connect(newButton,SIGNAL(typed(QString)),this, SLOT(charTyped(QString)));
   }

   Plasma::PushButton* newButton = new Plasma::PushButton(this);
   newButton->setText("Call");
   newButton->setIcon(KIcon("/usr/share/kde4/apps/sflphone-plasmoid/icons/outgoing.svg"));
   mainLayout->addItem(newButton,5,0,1,3);

   Plasma::PushButton* cancelButton = new Plasma::PushButton(this);
   cancelButton->setText("Cancel");
   cancelButton->setIcon(KIcon("/usr/share/kde4/apps/sflphone-plasmoid/icons/hang_up.svg"));
   mainLayout->addItem(cancelButton,5,3,1,3);

   connect(newButton, SIGNAL(clicked()), this, SLOT(call()));
   connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
}
Example #8
0
int	querywin::handleInput(void)
{
	cstring	typed = in->get();

	if(typed.length() != 0)
	{
		// Commands are prefixed by a /. If it's not, it's a message
		if(typed[0] != '/')
			tk << CMDLINE << sessionid << " " << escape(person) 
			 	      << " \"msg " << escape(person) << " " 
				      << escape(typed) << "\"" << end;
		else	// skip / when passing to cmdhandler!
			tk << CMDLINE << sessionid << " " << escape(person) 
			   << " \"" << escape(typed(1)) << "\"" << end;
		
		in->del();
	}
	return TCL_OK;
}
Example #9
0
Eval eval_once(Expr e, Env* env) {
	Expr r;
	int i;
	switch(e.type) {
		case SYMBOL:
			return final_eval(*lookup(e.sym, env));
		
		case PAIR:
			return apply(e.pair[0], e.pair[1], env);
		
		case ARRAY:
			r = typed(ARRAY);
			r.array.len = e.array.len;
			r.array.items = ALLOC(sizeof(Expr) * r.array.len);
			for(i = 0; i < r.array.len; i++)
				r.array.items[i] = eval(e.array.items[i], env);
			return final_eval(r);
		
		default:
			return final_eval(e);
	}
}
Example #10
0
///Proxy to make the view more convinient to use
void Dialpad::clicked(QString& text)
{
   emit typed(text);
}
Example #11
0
Expr init_prim(wchar_t* s, Prim f) {
	Expr e = typed(PRIMITIVE);
	e.prim = f;
	*lookup_add(uniq_symbol(s), &ground_env) = e;
	return e;
}
Example #12
0
Eval prim_make_end_obj(Expr e) {
	take_nil(e);
	return final_eval(typed(END_OBJ));
}