Deprecated: Function set_magic_quotes_runtime() is deprecated in /DISK2/WWW/lokiware.info/mff/wakka.php on line 35
Můj zápočtový prográmek na /Úvod Do Unixu s Petrem Baudišem.
(z http://pasky.or.cz/~pasky/vyuka/2006-SWI095/) Navrhnete a naimplementujte "shellovou knihovnu" (proste skript, ktery naincludujete pomoci prikazu . do jineho a jeho primarnim ucelem je poskytovat nejake funkce), ktera prida moznost psat v shellu "objektove": tedy si nadefinovat nejake tridy (mnozina metod a atributu) a pak z nich vytvaret instance. Objektove programovani je zalozeno na trech principech (detaily viz treba Wikipedie). Dedicnost byste meli umet urcite (alespon jednoduchou). Zapouzdreni nemusite vynucovat. Polymorfismus byste umet meli, pri rozumnem navrhu Vam ale muze vyplynout automaticky. Pamatujte, ze nejakym (alespon neprimym) zpusobem by metody mely mit moznost brat jako parametry a vracet jak objekty, tak "obycejne hodnoty" (stringy, cisla, v bashi pole). Konkretni reseni je cele na Vas, optimalizujte na flexibilitu a snadnost pouziti. Muzete v teto uloze pouzivat GNU rozsireni bashe, kdyz Vam to k necemu bude. Musite dodat alespon zakladni dokumentaci API (rozhrani) vasi knihovny. 4 body berte jako dolni hranici pri splneni pozadavku, pokud bude Vas navrh a implementace pekny a elegantni, muzete nasbirat i znatelne vice. Dalsi hromady bodu muzete ziskat napriklad za generickou implementaci (de)serializace. nebo jine veci, ktere by mohly byt uzitecne.
OVERVIEW ObjSh tries to (partially) mimic the behavior and syntax of the Objective-C (ObjC) runtime used in Apple Cocoa (former NeXTSTEP, OPENSTEP) and GNUstep environments. For those who don't know ObjC it may resemble to SmallTalk. Objects are always dynamically allocated (and therefore refered to by pointers (sort of)) and dynamically typed. Object pointers are implemented as strings in the format "ObjSh_*", using an ordinary string in a construct where only an object can be used (for instance as a message target) results in a runtime error. Memory management is based on reference counting and autorelease pools, as it is in GNUstep and Apple ObjC 1.0. There are no restrictions on instance variable or method argument contents, all characters are properly escaped. There are restrictions on instance variable names, class names and method names similar to regular shell restrictions on variable and function names, see below for details. Emphasis has been put on portability (see COMPATIBILITY below). ObjSh provides - a runtime and class definition engine in objsh.sh - a root class called Object (simillar to ObjC Object and NSObject) in Object.sh - the AutoreleasePool class for more convenient memory management in Object.sh Interesting Links: - http://en.wikipedia.org/wiki/Objective-C - http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/chapter_1_section_1.html - http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/AutoreleasePools.html