[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=0c15b20c036db846654c37f32cf2d14743f22166 commit 0c15b20c036db846654c37f32cf2d14743f22166 Author: Raster Date: Mon Jun 14 09:15:23 2021 -0700 Wiki page start changed with summary [] by Raster --- pages/start.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/pages/start.txt b/pages/start.txt index 2d2f4a9b1..28658b6b6 100644 --- a/pages/start.txt +++ b/pages/start.txt @@ -71,4 +71,3 @@ Many of our **Enlightenment Developer Days** events have been sponsored and paid [[https://www.gandi.net|{{:thanks-gandi.svg|Gandi}}]] [[https://www.samsung.com|{{:thanks-samsung.svg|Samsung}}]] [[https://openwide.fr|{{:thanks-openwide.svg|Openwide}}]] - --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=b562d6d4f6bcb35b884de7dfee2d7ba01c6c5446 commit b562d6d4f6bcb35b884de7dfee2d7ba01c6c5446 Author: Raster Date: Thu Jul 2 19:34:54 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/start.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/start.txt b/pages/start.txt index fc3fec6..800b2d2 100644 --- a/pages/start.txt +++ b/pages/start.txt @@ -1,7 +1,7 @@ ~~Title: Enlightenment Main~~ +{{page>start-shortcuts}} {{page>start-event}} - {{page>start-release}} {{ :e-logo-title.png?nolink&150 |}} --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=19dfe20ec8b715187a6ec4ed0f27bd258fd69ee0 commit 19dfe20ec8b715187a6ec4ed0f27bd258fd69ee0 Author: Raster Date: Mon Jun 22 01:50:04 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 236 +++-- 1 file changed, 170 insertions(+), 66 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 2b572ac..1d2b38e 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -3,7 +3,7 @@ Preface -//This is not a theoretical C language specifications document. It is a practical primer for the vast majority of real life cases of C usage that are relevant to EFL on todays common architectures. It covers application executables and shared library concepts and is written from a Linux/UNIX perspective where you would have your code running with an OS doing memory mappings and probably protection for you. It really is fundamentally not much different on Android, iOS, OSX or even Windows.// +//This is not a theoretical C language specifications document. It is a practical primer for the vast majority of real life cases of C usage that are relevant to EFL on today's common architectures. It covers application executables and shared library concepts and is written from a Linux/UNIX perspective where you would have your code running with an OS doing memory mappings and probably protection for you. It really is fundamentally not much different on Android, iOS, OSX or even Windows.// //It won't cover esoteric details of "strange architectures". It pretty much covers C as a high level assembly language that is portable across a range of modern architectures.// @@ -159,10 +159,10 @@ double things[200]; struct mydata - { - int count; - double items[100]; - }; +{ + int count; + double items[100]; +}; struct mydata bob; @@ -175,41 +175,41 @@ A function is a basic unit of execution. Conceptually a function hides an implem struct sandwich - { -struct bread_slice top; -struct bread_slice bottom; -enum filling *fillings; -int num_fillings; - }; +{ + struct bread_slice top; + struct bread_slice bottom; + enum filling *fillings; + int num_fillings; +}; enum filling - { -FILLING_HAM, -FILLING_CHEESE, -FILLING_BUTTER - }; +{ + FILLING_HAM, + FILLING_CHEESE, + FILLING_BUTTER +}; struct sandwich * make_sandwich(enum filling *fillings, int num_fillings) - { -struct sandwich *sandwich; -int i; +{ + struct sandwich *sandwich; + int i; -sandwich = malloc(sizeof(struct sandwich)); -if (!sandwich) return NULL; -get_bread_top(&(sandwich->top)); -get_bread_bottom(&(sandwich->bottom)); -sandwich->fillings = malloc(sizeof(enum filling) * num_fillings); -if (!sandwich->fillings) - { -free(sandwich); -return NULL; - } -for (i = 0; i < num_fillings; i++) - sandwich->fillings[i] = fillings[i]; -sandwich->num_fillings = num_fillings; -return sandwich; - } + sandwich = malloc(sizeof(struct sandwich)); + if (!sandwich) return NULL; + get_bread_top(&(sandwich->top)); + get_bread_bottom(&(sandwich->bottom)); + sandwich->fillings = malloc(sizeof(enum filling) * num_fillings); + if (!sandwich->fillings) +{ + free(sandwich); + return NULL; +} + for (i = 0; i < num_fillings; i++) +sandwich->fillings[i] = fillings[i]; + sandwich->num_fillings = num_fillings; + return sandwich; +} I may call the function as follows: @@ -268,19 +268,19 @@ You can use this with structs and enums as well to make new types that represen struct sandwich - { -struct bread_slice top; -struct bread_slice bottom; -enum filling *fillings; -int num_fillings; - }; +{ + struct bread_slice top; + struct bread_slice bottom; + enum filling *fillings; + int num_fillings; +}; enum filling - { -FILLING_HAM, -FILLING_CHEESE, -FILLING_BUTTER - }; +{ + FILLING_HAM, + FILLING_CHEESE, + FILLING_BUTTER +}; typedef struct sandwich Sandwich; typedef enum filling Filling; @@ -399,13 +399,13 @@ You can define macros that take parameters. They will produce the code that you int myfunc(void) - { +{ #ifdef _WIN32 -// windows specific code here + // windows specific code here #else -// generic code here + // generic code here #endif - } +} Another very common use of the pre-processor is to compile only some pieces of code in specific circumstances. A common use-case is for portability (but you can also use this along with #includes, macros etc. to use the pre-processor as a code-generation tool to save a lot of re-typing of almost the same bits of code). On one platform you may have to have some pieces of code work in a specific way that differs from other platforms.
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=4a8d08028e14399fe2d91cf8e6594ed166975ca8 commit 4a8d08028e14399fe2d91cf8e6594ed166975ca8 Author: Raster Date: Mon Jun 22 00:27:16 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 64 +- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 1e1e80f..2b572ac 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -600,7 +600,7 @@ A good [[http://man7.org/linux/man-pages/man2/syscalls.2.html|list of system cal Memory is really a sequence of bytes from the view of a CPU, but when you access data types like ''short''s or ''int''s etc. that consume multiple bytes, the order that they are read from in memory and assigned to slots from the LSB (Least Significant Byte) to the MSB (Most Significant byte). There are 2 commonly referred to ways of accessing these bytes in multi-byte types, called **Big Endian** and **Little Endian**. [[http://en.wikipedia.org/wiki/Endianness|Endianess]] these days is m [...] ^Architecture ^Endianess ^ -^x86 |Little| +|x86 |Little| |x86_64 |Little| |ARM |Little| |PowerPC |Big | @@ -616,6 +616,68 @@ In memory, in order from lowest memory address to highest, endianess looks as fo |1393589900 |''53107e8c'' |''53107e8c'' |''8c7e1053'' | Function pointers + +Pointers are the stuff of life when it comes to C and machines. They tell you where everything lives. Where your data is and where the next bit of data after this one is and so on. Following this setup, functions also live somewhere in memory. They actually have pointers. These are function pointers. This is an amazingly powerful feature of C that most don't being to discover until much later. It allows you to do things like say "When this operation has finished, call //THIS// function h [...] + +The downside of function pointers is the added mental load to handle the indirection, as well as the horrible syntax. So for a function with a prototype of: + + +int *myfunc (struct t *tim, int num, char *str); + + +You would declare the function pointer as: + + +int *(*myfunc) (struct t *tim, int num, char *str) + + +So you pass this function pointer in as parameter ''funcptr'' in the following function: + + +void dothis(int num, int *(*funcptr) (struct t *tim, int num, char *str)); + + +Or in a structure: + + +struct t + { +int num; +int *(*funcptr) (struct t *tim, int num, char *str); + }; + + +You may find it easier to typedef these function pointer types so they are simpler to write later such as: + + +typedef int *(*MyCallbacktype) (struct t *tim, int num, char *str); + +void dothis(int num, MyCallbacktype funcptr); + + +You can use any compatible (returns the same types and accepts the same parameters) function names as actual function pointers such as: + + +typedef int *(*MyCallbacktype) (struct t *tim, int num, char *str); + +void dothis(int num, MyCallbacktype funcptr); + +int *task_a(struct t *tim, int num, char *str) + { +// ... content task a here + } + +int *task_b(struct t *tim, int num, char *str) + { +// ... content of task b here + } + +if (rand() < 100) dothis(99, task_b); +else dothis(100, task_a); + + +Function pointers are extremely important and useful and form the backbone of EFL in the form of the following Callbacks. + Callbacks Threads --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=5d37fa32552ac582783f15c3324c8a9a295bac16 commit 5d37fa32552ac582783f15c3324c8a9a295bac16 Author: Raster Date: Sun Jun 21 23:51:29 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 19 +++ 1 file changed, 19 insertions(+) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 0e35c45..1e1e80f 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -596,6 +596,25 @@ A good [[http://man7.org/linux/man-pages/man2/syscalls.2.html|list of system cal Endianess + +Memory is really a sequence of bytes from the view of a CPU, but when you access data types like ''short''s or ''int''s etc. that consume multiple bytes, the order that they are read from in memory and assigned to slots from the LSB (Least Significant Byte) to the MSB (Most Significant byte). There are 2 commonly referred to ways of accessing these bytes in multi-byte types, called **Big Endian** and **Little Endian**. [[http://en.wikipedia.org/wiki/Endianness|Endianess]] these days is m [...] + +^Architecture ^Endianess ^ +^x86 |Little| +|x86_64 |Little| +|ARM |Little| +|PowerPC |Big | +|MIPS |Big | +|SPARC|Big | +|Alpha|Big | + +That means that the majority of people will find themselves programming for a little endian environment. This does not mean you can assume it everywhere. Many file formats store data in a big endian fashion, as do many network protocols, so when you deal with memory and have to save and load it or transmit it across a network, you need to be very careful about endianess and have to convert as necessary. Also be aware that alignment also matters. + +In memory, in order from lowest memory address to highest, endianess looks as follows for an 4 byte ''int'' type: + +^Decimal^Hex ^Big endian ^Little endian^ +|1393589900 |''53107e8c'' |''53107e8c'' |''8c7e1053'' | + Function pointers Callbacks Threads --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=07a75e639063383e3ae673fb479a4b7d843da719 commit 07a75e639063383e3ae673fb479a4b7d843da719 Author: Raster Date: Sun Jun 21 23:17:27 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 30 +- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 8dee97f..0e35c45 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -563,7 +563,35 @@ The difference between ABI and API is that API covers the interface in general b System calls - +System calls are special API calls. They are almost all buried inside libc. Function calls here inside libc issue a special interrupt to switch into kernel mode and passing in parameters. Once switched into kernel mode, no application code is executing anymore. All code is from the kernel, and its job is to implement the functionality of the system call. This code runs in "kernel space" and basically has full privileges to do anything it likes. Kernels though will enforce access and secu [...] + +System calls are rather expensive. They can cost hundreds if not thousands of CPU cycles. Also once they return, your code will not run at full speed for a while, because Kernels will flush and empty caches, so the L1, L2 (and maybe L3) caches all need to warm up again. Avoid system calls if you can because they are far more expensive than a simple function call within an app or between an app and a library. Also be aware that context switches between 2 processes or a page fault (swappin [...] + +A good [[http://man7.org/linux/man-pages/man2/syscalls.2.html|list of system calls can be found here]], but a common list of important ones is: + + * open() + * close() + * read() + * write() + * lseek() + * stat() + * mmap() + * munmap() + * madvise() + * mprotect() + * fcntl() + * ioctl() + * connect() + * accept() + * bind() + * access() + * select() + * getpid() + * getuid() + * gettimeofday() + * clock_gettime/() + * time() + * mkdir() --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=f06eb8cf1eeb35c9a8a15e50aa1ca8e3b87e394a commit f06eb8cf1eeb35c9a8a15e50aa1ca8e3b87e394a Author: Raster Date: Sun Jun 21 22:37:30 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 25 + 1 file changed, 25 insertions(+) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 6f7d398..8dee97f 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -538,8 +538,33 @@ Pkg-config relies on setting your ''PKG_CONFIG_PATH'' environment variable to in Add as many directories as you like with a '':'' character between them. They will be searched in order from the first to last, until a matching ''.pc'' file is found. API calls + +A library (or in fact any part of a program can too) exports API calls. These are mostly actual function calls, with the prototypes (telling the compiler the function name, what it returns and what it accepts as parameters) in the header files. The headers may also provide macros to use and perhaps also global variables. When an application runs, it's the functions and variables that matter. These are exposed as "symbols". + +Symbols are listed as strings in a symbol table. This could be thought of as an array of strings, with locations where that function (or variable) is stored in the library. At runtime, libraries are linked and these symbols are looked up, with pointers to these functions being "fixed up" by the runtime linker. If a symbol is missing in a library that something else needs, you will get a runtime linking error (and generally execution stops here before even main() is called). + +If the types that a function returns or accepts changes, then there is an ABI (Application Binary Interface) break. Libraries should never do this without also jumping up a major version e.g. from 1.x to 2.0, or 2.x to 3.0 etc. This major version change indicates that there is a break in ABI (or API). On Linux you will see the version of the library in its filename: + + libeina.so.1.4.99 + +For example. When compiling, the compiler looks for a file called ''libeina.so'' in the link search path (usually ''/lib'' and ''/usr/lib'', unless you also add directories with ''-L'' such as ''-L/usr/local/lib''). If this file (''libeina.so'') is a symbolic link (symlink), this is dereferenced. Generally this is the symlink setup used for shared libraries: + +^File ^^Link ^ +|//libeina.so//| => |//libeina.so.1// | +|//libeina.so.1// | => |//libeina.so.1.4//| +|//libeina.so.1.4//| => |//lineina.so.1.4.99// | +|**libiena.so.1.4.99** || | + +After this dereferencing, the compiler will embed into the binary being compiled the need to link to ''libiena.so.1''. If this doesn't exist anywhere in the runtime search path (which is different to the compile time one - this is normally ''/lib'' and ''/usr/lib'' and ''/etc/ld.so.conf'' can extend this list, as well as the ''LD_LIBRARY_PATH'' environment variable can set the search path at runtime something like ''/usr/local/lib:/usr/lib:/lib'' which would mean to look in ''/usr/local/ [...] + +It is also possible to manually load a shared object file (thus the ''.so'' extension) manually using calls such as ''dlopen()'' and ''dlsym()''. This will led you load a shared object file and manually look for specific symbols in the file and get a pointer per symbol. This is often a way API/ABI calls are found from modules. + +The difference between ABI and API is that API covers the interface in general both at compile AND at runtime, but ABI is specifically post-compilation at runtime. If ABI stays the same, but API changes, then existing binaries will keep working fine. If you wish to adapt to the new API you will need to recompile and possibly change some of your code to adapt to these changes. + System calls + + Endianess --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=b90686bce9b87684bdf3148d81cb6522ec05af54 commit b90686bce9b87684bdf3148d81cb6522ec05af54 Author: Raster Date: Wed Jun 17 23:03:30 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 7456794..6f7d398 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -495,7 +495,7 @@ Generally you allocate memory with functions such as ''malloc()'', ''calloc()'', The memory of your process, other than memory used to store the code/instructions loaded from disk, is primarily made up of 2 elements. The [[http://en.wikipedia.org/wiki/Call_stack|stack]] and the [[http://en.wikipedia.org/wiki/Memory_management|heap]]. Your memory space will generally look something as follows, often with the stack high up in memory (at high addresses) and pieces of code from the process and libraries mapped in from disk, as well as heap space being allocated there too [...] -{{ memstackheap.svg?nolink |Complete memory space diagram }} +{{ memheapstack.svg?nolink |Complete memory space diagram }} The stack is managed for you mostly by the compiler and runtime. As the application runs, every time a function is called, a new blob of memory is "pushed" at the "top" of the stack (conceptually stacks grow.. thus the top is where the newest item(s) are on the stack, but often the stack grows down in memory, so to push you subtract values from the top of the stack and to pop, you add again). This memory contains the parameters passed to each function, and will contain return values from [...] --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=fca7b6ba65b81292835ee4a856800bf9f2fa43fa commit fca7b6ba65b81292835ee4a856800bf9f2fa43fa Author: Raster Date: Wed Jun 17 23:02:02 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 233243b..7456794 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -493,15 +493,17 @@ Generally you allocate memory with functions such as ''malloc()'', ''calloc()'', Stack and heap === -The memory of your process, other than memory used to store the code/instructions loaded from disk, is primarily made up of 2 elements. The [[http://en.wikipedia.org/wiki/Call_stack|stack]] and the [[http://en.wikipedia.org/wiki/Memory_management|heap]]. +The memory of your process, other than memory used to store the code/instructions loaded from disk, is primarily made up of 2 elements. The [[http://en.wikipedia.org/wiki/Call_stack|stack]] and the [[http://en.wikipedia.org/wiki/Memory_management|heap]]. Your memory space will generally look something as follows, often with the stack high up in memory (at high addresses) and pieces of code from the process and libraries mapped in from disk, as well as heap space being allocated there too [...] -The stack is managed for you mostly by the compiler and runtime. As the application runs, every time a function is called, a new blob of memory is "pushed" at the "top" of the stack. This memory contains the parameters passed to the function, and will contain return values from the function as well as a return address to go back (to read instructions from) to when this function returns. It is a very simple structure, and yet incredibly useful. Note that stack often have limited sizes (so [...] +{{ memstackheap.svg?nolink |Complete memory space diagram }} -The heap is where more permanent memory is stored, and data here remains until explicitly freed. Most objects and larger data will life here. Getting memory in the heap is more costly in terms of time, but the limit on memory in the heap is generally "all available memory on the system", given caveats of fragmentation of memory, and possible process allocation limits imposed by the OS. +The stack is managed for you mostly by the compiler and runtime. As the application runs, every time a function is called, a new blob of memory is "pushed" at the "top" of the stack (conceptually stacks grow.. thus the top is where the newest item(s) are on the stack, but often the stack grows down in memory, so to push you subtract values from the top of the stack and to pop, you add again). This memory contains the parameters passed to each function, and will contain return values from [...] + +The heap is where more permanent memory is stored. Data here remains until explicitly freed. Most objects and larger data will live here. Getting memory in the heap is more costly in terms of time taken to allocate it or free it (but once allocated, access cost is the same). The limit on memory in the heap is generally "all available memory on the system", given caveats of fragmentation of memory, and possible process allocation limits imposed by the OS. Libraries -A shared library is simple a large bit of code you can "load" when your application (or library) is loaded, where the code in it is shared with other users on the system. It mostly is provided by another group of developers, and thus may change its internals without your application or library needing to be re-compiled. If there is a bug in the library it may be fixed later on by an update to the library. Everyone who installs the update gets the fix. Same for new features. Libraries hav [...] +A shared library is simple a large bit of code you can "load" when your application (or library) is loaded, where the code in it is shared with other users on the system. It mostly is provided by another group of developers, and thus may change its internals without your application or library needing to be re-compiled. If there is a bug in the library it may be fixed later on by an update to the library. Everyone who installs the update gets the fix (next time the process is executed). [...] If you want to do something privileged, or hide data, it needs to cross a process boundary. Normally you'll speak some form of IPC to a privileged "root" process for example. Of course all of this "we share everything" with libraries also means that code in your application could corrupt/mess/destroy data the library is maintaining, as well as vice-versa. There is no protection between a library, another library and your process. This lack of protection means performance is very good and [...] --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=f00f4bf554a61df54745ad374c5f687620bea97d commit f00f4bf554a61df54745ad374c5f687620bea97d Author: Raster Date: Wed Jun 17 02:20:00 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 89af214..233243b 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -503,13 +503,13 @@ The heap is where more permanent memory is stored, and data here remains until e A shared library is simple a large bit of code you can "load" when your application (or library) is loaded, where the code in it is shared with other users on the system. It mostly is provided by another group of developers, and thus may change its internals without your application or library needing to be re-compiled. If there is a bug in the library it may be fixed later on by an update to the library. Everyone who installs the update gets the fix. Same for new features. Libraries hav [...] -If you want to do something privileged, or hide data, it needs to cross a process boundary. Normally you're speak some form of IPC to a privileged "root" process for example. Of course all of this "we share everything" with libraries also means that code in your application could corrupt/mess/destroy data the library is maintaining, as well as vice-versa. There is no protection between a library, another library and your process. This lack of protection means performance is very good and [...] +If you want to do something privileged, or hide data, it needs to cross a process boundary. Normally you'll speak some form of IPC to a privileged "root" process for example. Of course all of this "we share everything" with libraries also means that code in your application could corrupt/mess/destroy data the library is maintaining, as well as vice-versa. There is no protection between a library, another library and your process. This lack of protection means performance is very good and [...] The benefit of a shared library is to avoid needing a re-compile to get improvements, save writing all the code the library shares with you, and to share the memory the code in the shared library would consume. As it is a //SHARED// library, the code from that library is loaded only once on the system. It may add to the virtual size of the process, but this space is shared across every process using that library, so the cost is paid just once. -Generally a library exposes an API (a set of functions to call). It will provide header files you #include in your application (or library). you would link to the library and thus, at runtime, the "runtime linker" (ld.so often), will glue in the function symbols in your code to the library you link to. This is all done at the start of process startup before the main() function is called. There is a cost to this, but it is generally worth paying for the benefits. your code will then be ab [...] +Generally a library exposes an API (a set of functions to call). It will provide header files you #include in your application (or library). You would link to the library and thus, at runtime, the "runtime linker" (ld.so often), will glue in the function symbols in your code to the library you link to. This also is done for global variables exposed by the library as well. This is all done at the start of process startup before the main() function is called. There is a cost to this, but i [...] -You generally would compile your code to link to a library as follows, assuming the source for your application is ''hello.c'', the binary you wish to output is ''hello'' and the libray you want to link to is ''eina'' (often the file on disk will be ''libeina.so'' for the development environment). +You generally would compile your code to link to a library as follows, assuming the source for your application is ''hello.c'', the binary you wish to output is ''hello'' and the library you want to link to is ''eina'' (often the file on disk will be ''libeina.so'' for the development environment). cc hello.c -o hello -leina --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=c8ef296973cbe8c77bfb70e4390b55f31d0e3a7f commit c8ef296973cbe8c77bfb70e4390b55f31d0e3a7f Author: Raster Date: Tue Jun 16 00:57:32 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/efl/start.txt | 46 +++--- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/pages/docs/efl/start.txt b/pages/docs/efl/start.txt index ef3d0cc..96a77e5 100644 --- a/pages/docs/efl/start.txt +++ b/pages/docs/efl/start.txt @@ -28,29 +28,29 @@ EFL is a range of libraries that cover APIs to solve every day problems we, and You will use a range of libraries to make use of the above, and so learning the naming of these is important to know where to look. They will be in Ecore, Evas, Edje, Elementary (Elm), Ecore_IMF, Eet, Emotion, Ecore_Con, Ecore_IPC, Eio, Eldbus, Elocation, Ecore_Audio, Ecore_File and Efreet. It is very useful to know the names of parts of EFL and what they are responsible for: ^Component ^Domain ^Description ^ -|Ecore |Mainloop Input & Display | | -|Ector |Vector Graphics | | -|Edje|Theme Graphics & Animation | | -|Eet |Data Storage & Serialization | | -|Eeze|Device UDev Wrapper | | -|Efl |Core Shared | | -|Efreet |Standards (Fredesktop.org) | | -|Eina|Core Data Types | | -|Eio |Async I/O| | -|Eldbus |Dbus & Event Glue| | -|Elementary |High Level & Widgets | | -|Elocation |Location | | -|Elua|Lua Execution| | -|Embryo |Bytecode VM & Compiler | | -|Emile |Compression & Encryption | | -|Emotion |Video & Audio Olayback | | -|Eo |Object System| | -|Eloian |Object Code Generation | | -|Ephysics|Physics & Object Glue| | -|Escape |PS3 LibC Filler | | -|Ethumb |Image Thumbnailer| | -|Evas|Scene Graph & Rendering | | -|Evil|Windows LibC Filler | | +|Ecore |Mainloop Input & Display |Mainloop, low level display and input system, connections and IPC | +|Ector |Vector Graphics |*INTERNAL* Vector rendering API used by Evas | +|Edje|Theme Graphics & Animation |Layout and abstraction for graphical elements that lay out items to define a look and feel with animation and basic event response | +|Eet |Data Storage & Serialization |Data structure serialization and multi-key data storage in files with compression and encryption with fast random-access read | +|Eeze|Device UDev Wrapper |A thin wrapper over UDev for finding devices on Linux | +|Efl |Core Shared |*INTERNAL* Core things shared between EFL libraries | +|Efreet |Standards|Handle desktop file, menus and icons from freedesktop.org | +|Eina|Core Data Types |Core utilities for threading, data types (lists, hashes etc.) and more | +|Eio |Async I/O|Handle async File I/O | +|Eldbus |D-Bus & Event Glue |Glue in D-Bus protocol handling as a client and server into EFL | +|Elementary |High Level & Widgets |High level wrapper on EFL as well as a full widget set with buttons, boxes, scrollers, sliders etc. | +|Elocation |Location |Used for location and mapping services | +|Elua|Lua Execution|*INTERNAL* Lua wrapper and convenience layer for running a Lua script engine | +|Embryo |Bytecode VM & Compiler |A compiler and tiny VM execution library for the Small/Pawn language used by Edje for scripting | +|Emile |Compression & Encryption |*INTERNAL* Compression and encryption utilities and abstractions | +|Emotion |Video & Audio Playback |Wrapping Gstreamer, Xine and/or VLC to provide Video playback in Evas objects as well as audio playback controls | +|Eo |Object System|Core object system for EFL with handling of classes, references, inheritance, safe object access and method execution etc. | +|Eloian |Object Code Generation |Used with Eo to generate both C boilerplate src, and for generating bindings | +|Ephysics|Physics & Object Glue|Glues the Bullet physics library to Evas objects and is used by Edje | +|Escape |PS3 LibC Filler |*INTERNAL* Fills in missing LibC functionality for PS3 | +|Ethumb |Image Thumbnailer|A library and service for async thumbnail generation and caching | +|Evas|Scene Graph & Rendering |A complete scene graph and rendering abstraction as well as event router for UI and general graphics needs
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=ae50e75efa65054fd19dcc56a58597740aa3195f commit ae50e75efa65054fd19dcc56a58597740aa3195f Author: Raster Date: Mon Jun 15 23:30:38 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/efl/start.txt | 45 + 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/pages/docs/efl/start.txt b/pages/docs/efl/start.txt index 33ab758..ef3d0cc 100644 --- a/pages/docs/efl/start.txt +++ b/pages/docs/efl/start.txt @@ -5,14 +5,7 @@ EFL -EFL is a range of libraries that cover APIs to solve every day -problems we, and others have encountered. You can see it having -various API layers, with some intended for very low-level controls and -access that no one but specialists (eg writing a window manager -itself) will need, through to higher level "just writing a notepad" -application. The lower you go, the less portable things can be. Here -we will cover the EFL features and APIs used to make things portably -and cleanly. We will cover these topics here: +EFL is a range of libraries that cover APIs to solve every day problems we, and others have encountered. You can see it having various API layers, with some intended for very low-level controls and access that no one but specialists (eg writing a window manager itself) will need, through to higher level "just writing a notepad" application. The lower you go, the less portable things can be. Here we will cover the EFL features and APIs used to make things portably and cleanly. We will cov [...] * Data structures (lists, hash tables, growable buffers/strings etc.) * Main loop event, I/O and timing core @@ -32,14 +25,34 @@ and cleanly. We will cover these topics here: * Location API * Basic Audio playback, recording and mixing -You will use a range of libraries to make use of the above, and so -learning the naming of these is important to know where to look. They -will be in Ecore, Evas, Edje, Elementary (Elm), Ecore_IMF, Eet, -Emotion, Ecore_Con, Ecore_IPC, Eio, Eldbus, Elocation, Ecore_Audio, -Ecore_File and Efreet. - -We will make an assumption that you have a reasonable grasp of the C -programming language here. Perhaps you might want to read the [[docs/c/start]] if you are new to C, or need a refresher. +You will use a range of libraries to make use of the above, and so learning the naming of these is important to know where to look. They will be in Ecore, Evas, Edje, Elementary (Elm), Ecore_IMF, Eet, Emotion, Ecore_Con, Ecore_IPC, Eio, Eldbus, Elocation, Ecore_Audio, Ecore_File and Efreet. It is very useful to know the names of parts of EFL and what they are responsible for: + +^Component ^Domain ^Description ^ +|Ecore |Mainloop Input & Display | | +|Ector |Vector Graphics | | +|Edje|Theme Graphics & Animation | | +|Eet |Data Storage & Serialization | | +|Eeze|Device UDev Wrapper | | +|Efl |Core Shared | | +|Efreet |Standards (Fredesktop.org) | | +|Eina|Core Data Types | | +|Eio |Async I/O| | +|Eldbus |Dbus & Event Glue| | +|Elementary |High Level & Widgets | | +|Elocation |Location | | +|Elua|Lua Execution| | +|Embryo |Bytecode VM & Compiler | | +|Emile |Compression & Encryption | | +|Emotion |Video & Audio Olayback | | +|Eo |Object System| | +|Eloian |Object Code Generation | | +|Ephysics|Physics & Object Glue| | +|Escape |PS3 LibC Filler | | +|Ethumb |Image Thumbnailer| | +|Evas|Scene Graph & Rendering | | +|Evil|Windows LibC Filler | | + +We will make an assumption that you have a reasonable grasp of the C programming language here. Perhaps you might want to read the [[docs/c/start]] if you are new to C, or need a refresher. --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=822ceef964ef295835af817c6191d97ae8745fb6 commit 822ceef964ef295835af817c6191d97ae8745fb6 Author: Raster Date: Thu May 28 04:39:07 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 32 ++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index d5eb355..89af214 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -508,17 +508,45 @@ If you want to do something privileged, or hide data, it needs to cross a proces The benefit of a shared library is to avoid needing a re-compile to get improvements, save writing all the code the library shares with you, and to share the memory the code in the shared library would consume. As it is a //SHARED// library, the code from that library is loaded only once on the system. It may add to the virtual size of the process, but this space is shared across every process using that library, so the cost is paid just once. Generally a library exposes an API (a set of functions to call). It will provide header files you #include in your application (or library). you would link to the library and thus, at runtime, the "runtime linker" (ld.so often), will glue in the function symbols in your code to the library you link to. This is all done at the start of process startup before the main() function is called. There is a cost to this, but it is generally worth paying for the benefits. your code will then be ab [...] - + +You generally would compile your code to link to a library as follows, assuming the source for your application is ''hello.c'', the binary you wish to output is ''hello'' and the libray you want to link to is ''eina'' (often the file on disk will be ''libeina.so'' for the development environment). + + cc hello.c -o hello -leina + +This assumes the library is in a standard directory the compiler always looks in. This would be ''/lib'' and ''/usr/lib''. If the library is not there, you need to tell the compiler of a new location to look at with the ''-L'' option such as the following if the eina library you wish to link to is located in ''/usr/local/lib'': + + cc hello.c -o hello -leina -L/usr/local/lib + +Of course that is just the linking. The include files may also require an option to tell the compiler to look somewhere other than ''/usr/include''. That option is the ''-I'' option as follows if the include files needed are in ''/usr/local/include/eina-1'': + + cc hello.c -o hello -leina -L/usr/local/lib -I/usr/local/include/eina-1 + +This of course is rather painful, and that is why a modern system called [[http://en.wikipedia.org/wiki/Pkg-config|Pkg-config]] was created, and it is far easier to use. The above would become a simpler: + + cc hello.c -o hello `pkg-config --cflags --libs eina` + +In this case ''pkg-config'' will provide the compiler flags needed to link to eina. If you want to use multiple libraries, just list them as follows: + + cc hello.c -o hello `pkg-config --cflags --libs eina ecore embryo` + +Pkg-config relies on setting your ''PKG_CONFIG_PATH'' environment variable to indicate where to look for the ''.pc'' files that contain the include and linking information. You may want to do a one-time setup of this environment variable in your shell setup like: + + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig + +Add as many directories as you like with a '':'' character between them. They will be searched in order from the first to last, until a matching ''.pc'' file is found. + API calls System calls - Alignment + Endianess Function pointers Callbacks Threads + + === Also See === Now you have read our less-than-perfect primer on C for those wanting to get into developing on EFL or using it from the C APIs we have, you may also want to look at the following list of pages and pick up some more information or fill in the gaps we do not cover here //(feel free to link to more articles that are good for teaching C from new developers through to advanced)//. --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=68fb006d729468afb5f8bc2b37c81f82e6e5c91b commit 68fb006d729468afb5f8bc2b37c81f82e6e5c91b Author: Raster Date: Thu May 28 04:17:48 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 0a67536..d5eb355 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -95,7 +95,7 @@ An example: CPUs will do arithmetic, logic operations, change what it is they execute, and read from or write to memory to deal with data. In the end, everything to a CPU is effectively a number, somewhere to store it to or load it from and some operation you do to it. -To computers, numbers are a string of "bits". A bit can be on or off. Just like you may be used to numbers, with each digit having 10 values (0 through to 9), A computer sees numbers more simply. It is 0, or it is 1. Just like you can have a bigger number by adding a digit (1 digit can encode 10 values, 2 digits can encode 100 values, 3 can encode 1000 values etc.), So too with the binary (0 or 1) numbering system computers use. Every binary digit you add doubles the number of values you [...] +To computers, numbers are a string of "bits". A bit can be on or off. Just like you may be used to numbers, with each digit having 10 values (0 through to 9), A computer sees numbers more simply. It is 0, or it is 1. Just like you can have a bigger number by adding a digit (1 digit can encode 10 values, 2 digits can encode 100 values, 3 can encode 1000 values etc.), So too with the binary (0 or 1) numbering system computers use. Every binary digit you add doubles the number of values you [...] ^Binary ^Hexadecimal ^Decimal ^ |101 |d |14 | @@ -434,7 +434,7 @@ So only compile the active code in when enabled in the compilation process. Memory -Reality is that languages like C are really a slightly more convenient and portable interface to the actual machine you have. That means the CPU, it's instructions and processing as well as memory that the CPU will access one way or another. Let's visualize just some of this. Imagine memory as simply a series of boxes than can contain a number that has a value from 0 to 255 (if unsigned). To do signed values we just interpret values differently. We can have from -128 to 127 as values. Wh [...] +Reality is that languages like C are really a slightly more convenient and portable interface to the actual machine you have. That means the CPU, it's instructions and processing as well as memory that the CPU will access one way or another. Let's visualize just some of this. Imagine memory as simply a series of boxes than can contain a number that has a value from 0 to 255 (if unsigned). To do signed values we just interpret values differently. We can have from -128 to 127 as values. Wh [...] ^Byte ^Value ^ |0|01| @@ -493,7 +493,7 @@ Generally you allocate memory with functions such as ''malloc()'', ''calloc()'', Stack and heap === -The memory of your process, other than memory used to store the code/instructions loaded from disk, is primarily made up of 2 elements. The [[stack|http://en.wikipedia.org/wiki/Call_stack]] and the [[heap|http://en.wikipedia.org/wiki/Memory_management]]. +The memory of your process, other than memory used to store the code/instructions loaded from disk, is primarily made up of 2 elements. The [[http://en.wikipedia.org/wiki/Call_stack|stack]] and the [[http://en.wikipedia.org/wiki/Memory_management|heap]]. The stack is managed for you mostly by the compiler and runtime. As the application runs, every time a function is called, a new blob of memory is "pushed" at the "top" of the stack. This memory contains the parameters passed to the function, and will contain return values from the function as well as a return address to go back (to read instructions from) to when this function returns. It is a very simple structure, and yet incredibly useful. Note that stack often have limited sizes (so [...] --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=b39fb9e43da7ac3a54d38863d77032d2c12dc977 commit b39fb9e43da7ac3a54d38863d77032d2c12dc977 Author: Raster Date: Thu May 28 00:02:04 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 37 +++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index cfa9117..d846ffc 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -95,7 +95,7 @@ An example: CPUs will do arithmetic, logic operations, change what it is they execute, and read from or write to memory to deal with data. In the end, everything to a CPU is effectively a number, somewhere to store it to or load it from and some operation you do to it. -To computers, numbers are a string of "bits". A bit can be on or off. Just like you may be used to numbers, with each digit having 10 values (0 through to 9), A computer sees numbers more simply. It is 0, or it is 1. Just like you can have a bigger number by adding a digit (1 digit can encode 10 values, 2 digits can encode 100 values, 3 can encode 1000 values etc.), So too with the binary (0 or 1) numbering system computers use. Every binary digit you add doubles the number of values you [...] +To computers, numbers are a string of "bits". A bit can be on or off. Just like you may be used to numbers, with each digit having 10 values (0 through to 9), A computer sees numbers more simply. It is 0, or it is 1. Just like you can have a bigger number by adding a digit (1 digit can encode 10 values, 2 digits can encode 100 values, 3 can encode 1000 values etc.), So too with the binary (0 or 1) numbering system computers use. Every binary digit you add doubles the number of values you [...] ^Binary ^Hexadecimal ^Decimal ^ |101 |d |14 | @@ -150,7 +150,7 @@ You can even tell the compiler to make sure it has an initial value. If you don' int bob = 42; -Once you have declared a variable, you can now use it. You can group values together in repeating sequences using //arrays// or in mixed groups called //structs// that contain a sequence of variables structured as indicated. Order is important and is maintained in memory. You can at times take advantage of this ordering for doing things like "inheritance". Arrays also have strict ordering in memory, so you can later on use pointers and simple arithmetic to walk up and down an array to ac [...] +Once you have declared a variable, you can now use it. You can group values together in repeating sequences using //arrays// or in mixed groups called //structs// that contain a sequence of variables structured as indicated. Order is important and is maintained in memory. You can at times take advantage of this ordering for doing things like "inheritance". Arrays also have strict ordering in memory, so you can later on use pointers and simple arithmetic to walk up and down an array to ac [...] int bobs[100]; @@ -433,6 +433,39 @@ So only compile the active code in when enabled in the compilation process. Memory + +Reality is that languages like C are really a slightly more convenient and portable interface to the actual machine you have. That means the CPU, it's instructions and processing as well as memory that the CPU will access one way or another. Let's visualize just some of this. Imagine memory as simply a series of boxes than can contain a number that has a value from 0 to 255 (if unsigned). To do signed values we just interpret values differently. We can have from -128 to 127 as values. Wh [...] + +^Byte ^Value ^ +|0|01| +|1|2e| +|2|fe| +|3|00| +|4|1a| +|5|43| +|6|aa| +|... |... | + +And so on. All memory is a massive set of these bytes, one after the other. On modern systems you don't have hundreds or even thousands of these boxes, but you have millions or even billions of them. You can group them together to store more than just a small value. This is what shorts, ints, longs and long longs do (as well as floats and doubles). They simply tell the CPU to take a set of 2, 4 or 8 bytes together to be a larger value. + +Let us see how a struct might map onto memory in this way. This struct: + + +struct mydata +{ + intnumber1; + char string1[15]; + intnumber2; + double floating_point1; + char char1; + float floating_point2; + short short1; + intnumber3; + double floating_array[3]; +}; + + + Libraries API calls System calls --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=9655a54122269407190f13fc45ba931d1f15dcb0 commit 9655a54122269407190f13fc45ba931d1f15dcb0 Author: Raster Date: Mon May 18 02:21:29 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/efl/advanced/start.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/pages/docs/efl/advanced/start.txt b/pages/docs/efl/advanced/start.txt index 0fb493e..b5a58fc 100644 --- a/pages/docs/efl/advanced/start.txt +++ b/pages/docs/efl/advanced/start.txt @@ -1,8 +1,6 @@ ~~Title: Advanced EFL Topics~~ ~~CODE-c~~ -{{page>index}} - Advanced topics with more detail These are some more advanced topics for developers, once they have gotten up to speed with the [[/docs/efl/start|getting started]] documentation. --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=32d1d58ceb73bc81ae3ba5df91f72451051c9a95 commit 32d1d58ceb73bc81ae3ba5df91f72451051c9a95 Author: Raster Date: Mon May 18 02:19:07 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/efl/advanced/start.txt | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pages/docs/efl/advanced/start.txt b/pages/docs/efl/advanced/start.txt index ab552a3..0fb493e 100644 --- a/pages/docs/efl/advanced/start.txt +++ b/pages/docs/efl/advanced/start.txt @@ -7,4 +7,8 @@ These are some more advanced topics for developers, once they have gotten up to speed with the [[/docs/efl/start|getting started]] documentation. - * [[dnd|DND (Drag and Drop)]] \ No newline at end of file + * [[dnd|DND (Drag and Drop)]] + + + +~~DISCUSSIONS~~ \ No newline at end of file --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=74daf0482cb1a1a70dfd4fc9a1ac6a6e9105b719 commit 74daf0482cb1a1a70dfd4fc9a1ac6a6e9105b719 Author: Raster Date: Sat May 16 22:29:11 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 5 + 1 file changed, 5 insertions(+) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 2b382f4..485c7d0 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -447,6 +447,11 @@ So only compile the active code in when enabled in the compilation process. Now you have read our less-than-perfect primer on C for those wanting to get into developing on EFL or using it from the C APIs we have, you may also want to look at the following list of pages and pick up some more information or fill in the gaps we do not cover here //(feel free to link to more articles that are good for teaching C from new developers through to advanced)//. * [[http://www.cprogramming.com/tutorial/c-tutorial.html|C tutorial]] + * [[http://www.le.ac.uk/users/rjm1/cotter|Introduction to C]] + * [[http://www.tutorialspoint.com/cprogramming|C tutorial]] + * [[http://www.cac.cornell.edu/VW/Cintro|C Intro]] + * [[http://www.ntu.edu.sg/home/ehchua/programming/cpp/c0_Introduction.html|C programming tutorial]] + * [[http://en.wikipedia.org/wiki/C_(programming_language)|Wikipedia C language page]] --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=1a1b048958033cc9a3ee98fe4720d99f9a25c72d commit 1a1b048958033cc9a3ee98fe4720d99f9a25c72d Author: Raster Date: Sat May 16 22:21:54 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 85 ++ 1 file changed, 85 insertions(+) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index e1b25b3..2b382f4 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -343,6 +343,91 @@ The ''do while'' loop is just like ''while'' But the test statement is executed Pre-processor and Macros +You already had your first encounter with the C pre-processor with the ''#include'' line in the first "Hello world" example above. The pre-processor is "executed" during compilation before the code is actually parsed by the C compiler proper. The job of the pre-processor in general is to "generate" more code. This mechanism is used to save a lot of repetitive typing, copy & pasting, conditional compilation (compile section of code A instead of code B based on compile-time information), a [...] + +== System include headers == + +#include + + +These headers define functions, types and even other pre-processor macros for use in your code. These headers are generally provided by system libraries (such as libc or EFL etc.) and you generally would place such include lines at the top of your C source files to indicate you are "including" the content of that file. Remember that this file is also passed through the pre-processor and thus can recurse, including more files than can include more files and so on. All the content of these [...] + +== Local headers == + +#include "myheader.h" + + +Once your projects get a bit larger, you will divide your application or library up into many .c and .h files. The headers (.h files) will define things from other parts of your source code base. you likely will use a Makefile or some similar mechanism to compile your project file by file and then link it together. You will compile the .c files, and include .h files along the way. The ''"'' quotes as opposed to the ''<>'' is that this here searches in the same directory as the source fil [...] + +== Defined values == + +#define NUM_ITEMS 100 + +int x = NUM_ITEMS; + + +It is useful to avoid "magic numbers" in your code to define them in a central place (at the top of your .c files or in a shared common .h file) and give them a name. If you need to change them later, you change them in one place only. This also helps document the purpose of this magic value as it gives it a descriptive name, improving maintainability. Note that you can also "undefine" a value with an ''#undef NUM_ITEMS'' for example. This will remove the definition from that point on in [...] + + +#define MY_TITLE "Hello world" + +printf("This is: %n", MY_TITLE); + + +You can define anything. It literally is a "string replacement" system, so it will replace the defined toke with what you define it as. This works with numbers, strings, functions and whole sections of text. You can even define a definition with other definitions inside of it: + + +#define NUM_ITEMS 100 +#define MY_STRING "Hello", NUM_ITEMS + +printf("This string: %s has %i items\n", MY_STRING); + + +== More complex macros == + +#define SIMPLE_FUNC(x, y) complex_func(100, 200, x, "hello", 4.8, y) + +int x = rand(); +SIMPLE_FUNC("Boo", 10 * x); + + +You can define macros that take parameters. They will produce the code that you specify exactly as given, replacing instances of the tokens given as parameters as they are passed into the macro. This is extremely useful in being able to simplify and make code more concise. The tokens passed in don't have to even have to be simple single values. They can be entire expressions going on and on, even entire snippets of code. Such macros are very powerful, and a common convention in C is to m [...] + +== Conditional compilation == + +int +myfunc(void) + { +#ifdef _WIN32 +// windows specific code here +#else +// generic code here +#endif + } + + +Another very common use of the pre-processor is to compile only some pieces of code in specific circumstances. A common use-case is for portability (but you can also use this along with #includes, macros etc. to use the pre-processor as a code-generation tool to save a lot of re-typing of almost the same bits of code). On one platform you may have to have some pieces of code work in a specific way that differs from other platforms. This commonly happens with Windows vs Linux vs BSD etc. [...] + +You can use this also to compile your code with features enabled or not. You can define pre-processor values on the command line with ''-D'' with most compilers, such as ''-DMY_FEATURE=1'' for example which is the same as putting in the code ''#define M
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=32cadc8c1c1408a5563ba4d150c071a469f9b10f commit 32cadc8c1c1408a5563ba4d150c071a469f9b10f Author: Raster Date: Thu May 14 07:55:24 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index e5feabc..e1b25b3 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -341,6 +341,8 @@ The ''while'' loop simple checks the statement in the braces following the while The ''do while'' loop is just like ''while'' But the test statement is executed at the end of each loop, not at the start, so you are guaranteed that the inner scope code of the loop will execute at least once before a test. + Pre-processor and Macros + Memory --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=462639b71d0658aa924236635dd39c7bd5e6079f commit 462639b71d0658aa924236635dd39c7bd5e6079f Author: Raster Date: Thu May 14 04:58:40 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 119 +++-- 1 file changed, 116 insertions(+), 3 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 2886999..e5feabc 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -14,10 +14,11 @@ Let's start with the traditional "Hello world" C application. This is about as s #include +// This is my very first program int main(int argc, char **argv) { - printf("Hello world!\n"); + printf("Hello world!\n"); /* Print some stuff */ return 0; } @@ -67,6 +68,8 @@ return 0; You will notice a few things. First lines starting with ''#'' are commands, but don't have a '';''. This is normal because these lines are processed by the pre-processor. All code in C goes through the C pre-processor and this basically generates more code for the compiler to actually deal with. Other lines that are not starting a function, ending it or defining control end every statement in C with a '';'' character. If you don't do this, the statement continues until a '';'' is found, [...] +Note that we can do comments for human-eyes-only that the compiler ignores by having the first 2 letters if any line be ''%%//%%'' excluding whitespace (spaces, tabs etc.). Everything until the end of the line on such lines will be ignored by the compiler. For comments stretching over multiple lines or only for a small section of a line, you can start such a comment with ''%%/*%%'' and that comment will continue for as long as needed (across multiple lines) until a matching ''%%*/%%'' is found. + If we look at how the application is compiled, We execute the C compiler, give it 1 or more source files to compile and the with ''-o'' tell it what output file to produce (the executable) cc hello.c -o hello @@ -218,7 +221,7 @@ struct filling my_fillings[3] = {FILLING_HAM, FILLING_CHEESE, FILLING_BUTTER}; sandwich = make_sandwich(my_fillings, 3); -You will notice we used little markers such at * to indicate the variable is a //POINTER// to that type of variable. This also is used for return types of functions. This level of indirection (to return something that points to the the real thing) is very common, because it is very efficient (returning only 4 or 8 bytes of data) and keeping the original data exactly where it is without needing any copies. It means we can modify the same object from many locations by passing around a poin [...] +You will notice we used little markers such at * to indicate the variable is a //POINTER// to that type of variable. The sandwich structure is located over at "byte 1837616 in memory" for example (and the next N bytes will be the data for the sandwich). This also is used for return types of functions. This level of indirection (to return something that points to the the real thing) is very common, because it is very efficient (returning only 4 or 8 bytes of data) and keeping the original [...] We also use the //&// operator to get the pointer //TO// that element in memory. This is a great way of passing in "please do something to THIS THING HERE that i have". In the above case, we call an imaginary function that we haven't specified above to "get a bread slice" and place it into the top and bottom elements of the sandwich. @@ -227,14 +230,124 @@ So back to functions, They exist mostly to hide complexity. Many simple things y In C (and on a machine) everything lives in memory somewhere, and so functions can even have pointers. This is a very useful mechanism to say "call this thing here, when this other things happens". What "this thing here" is can be modified at runtime to point to any function you like. These are often referred to as Callbacks. See below for more details on these. Types + +C provides a host of basic types. The common ones are: + +^Type ^Description ^ +|char |A single byte almost always signed except on ARM where it likely is unsigned by default (use signed char explicitly to get signed on ARM) | +|unsigned char |A single byte that has no sign | +|short |2 bytes together as a short word, signed | +|unsigned short |2 bytes together as a short word, unsigned | +|int|4 bytes together as a word, signed | +|unsigned int |4 bytes together as a word, unsigned | +|long |4 or 8 bytes (32 or 64 bit) together as a word, signed | +|unsigned long |4 or 8 bytes (32 or 64 bit) together as a word, unsigned | +|long long |8 bytes together as a word, signed | +|unsigned long long |8 bytes together as a word, u
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=253322e9058a4b3ea4bee53a32345af7f6bd0911 commit 253322e9058a4b3ea4bee53a32345af7f6bd0911 Author: Raster Date: Tue May 12 04:03:23 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index cd41d8e..2886999 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -194,6 +194,8 @@ make_sandwich(enum filling *fillings, int num_fillings) sandwich = malloc(sizeof(struct sandwich)); if (!sandwich) return NULL; +get_bread_top(&(sandwich->top)); +get_bread_bottom(&(sandwich->bottom)); sandwich->fillings = malloc(sizeof(enum filling) * num_fillings); if (!sandwich->fillings) { @@ -211,11 +213,19 @@ I may call the function as follows: struct sandwich *sandwich; -struct filling my_fillings[3] = {FILLING_HAM, CHEESE, BUTTER}; +struct filling my_fillings[3] = {FILLING_HAM, FILLING_CHEESE, FILLING_BUTTER}; sandwich = make_sandwich(my_fillings, 3); +You will notice we used little markers such at * to indicate the variable is a //POINTER// to that type of variable. This also is used for return types of functions. This level of indirection (to return something that points to the the real thing) is very common, because it is very efficient (returning only 4 or 8 bytes of data) and keeping the original data exactly where it is without needing any copies. It means we can modify the same object from many locations by passing around a poin [...] + +We also use the //&// operator to get the pointer //TO// that element in memory. This is a great way of passing in "please do something to THIS THING HERE that i have". In the above case, we call an imaginary function that we haven't specified above to "get a bread slice" and place it into the top and bottom elements of the sandwich. + +So back to functions, They exist mostly to hide complexity. Many simple things you will see are actually rather complex, and are many detailed steps to get it right. Functions encapsulate this and hide it at a higher level. They are basically ways of summarizing "this bit of code here" with a defined set of input parameters (0 or more) and a return value (or no return) when the function is done. When a function is called, execution waits for it to finish before resuming in the current scope. + +In C (and on a machine) everything lives in memory somewhere, and so functions can even have pointers. This is a very useful mechanism to say "call this thing here, when this other things happens". What "this thing here" is can be modified at runtime to point to any function you like. These are often referred to as Callbacks. See below for more details on these. + Types Arithmetic Logic --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=d9d9bf0ab781d7d0b88108e6c3aacbb192e522b2 commit d9d9bf0ab781d7d0b88108e6c3aacbb192e522b2 Author: Raster Date: Fri May 8 20:08:06 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 61 +- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index bc70b0c..cd41d8e 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -59,19 +59,19 @@ The next thing that happens is for the code to call a function ''printf()'' with printf("Hello world!\n"); -Now finally we return from the main function with the value 0. The ''main()'' function of an application is special. It always returns an integer that indicates the "success" of the application. This is used by the shell executing the process to determine success. A return of ''0'' indicates the process ran successfully. +Now finally we return from the main function with the value 0. The ''main()'' function of an application is special. It always returns an integer that indicates the "success" of the application. This is used by the shell executing the process to determine success. A return of ''0'' indicates the process ran successfully. Any other return value is an indicator of failure. return 0; -You will notice a few things. First lines starting with ''#'' are commands, but don't have a '';''. This is normal because these lines are processed by the pre-processor. All code in C goes through the C pre-processor and this basically generates more code. Other lines that are not starting a function, ending it or defining control end every statement in C with a '';'' character. If you don't do this, the statement continues until a '';'' is found, even if it goes across multiple lines. +You will notice a few things. First lines starting with ''#'' are commands, but don't have a '';''. This is normal because these lines are processed by the pre-processor. All code in C goes through the C pre-processor and this basically generates more code for the compiler to actually deal with. Other lines that are not starting a function, ending it or defining control end every statement in C with a '';'' character. If you don't do this, the statement continues until a '';'' is found, [...] If we look at how the application is compiled, We execute the C compiler, give it 1 or more source files to compile and the with ''-o'' tell it what output file to produce (the executable) cc hello.c -o hello -Often ''cc'' will be replaced with things like ''gcc'' or maybe ''clang'' or whatever compiler you prefer. +Often ''cc'' will be replaced with things like ''gcc'' or maybe ''clang'' or whatever compiler you prefer. A compiler will run the source through the pre-processor and then convert your source code into a binary form that your CPU and Os can actually understand and run. Now let's take a detour back to the machine that is running your very first C application. @@ -147,7 +147,7 @@ You can even tell the compiler to make sure it has an initial value. If you don' int bob = 42; -Once you have declared a variable, you can now use it. You can group values together in repeating sequences using arrays or in mixed groups called "structs". +Once you have declared a variable, you can now use it. You can group values together in repeating sequences using //arrays// or in mixed groups called //structs// that contain a sequence of variables structured as indicated. Order is important and is maintained in memory. You can at times take advantage of this ordering for doing things like "inheritance". Arrays also have strict ordering in memory, so you can later on use pointers and simple arithmetic to walk up and down an array to ac [...] int bobs[100]; @@ -158,13 +158,64 @@ double things[200]; struct mydata { int count; - double items[100] + double items[100]; }; struct mydata bob; +Structs (structured data) are very important and allow C to become rather complex and powerful when it comes to data storage, and don't forget you can embed structs inside structs, have arrays of structs, structs with arrays and use pointers to indirect from one struct to another, arrays of pointers to structs and so on. + Functions + +A function is a basic unit of execution. Conceptually a function hides an implementation of how to do something and exposes this as a higher level command. "Go make me a sandwich, using butter, cheese and ham" could be seen as calling the "make me a sandwich" function, with the input parameters (or arguments) being butter, cheese and ham, and the function returns a sandwich (for example). In C we might express this as follows: + + +struct sandwich + { +struct bread_slice top; +struct
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=e259945c0ea20ecf8bbc8bf0b1dd90fab8396d68 commit e259945c0ea20ecf8bbc8bf0b1dd90fab8396d68 Author: Raster Date: Sat May 2 08:15:53 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 136 +++-- 1 file changed, 109 insertions(+), 27 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 8bdfd03..bc70b0c 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -3,35 +3,129 @@ Preface -//This is not a theoretical C language specifications document. It is a practical primer for the vast majority of real life cases of C usage that are relevant to EFL. It covers application executables and shared library concepts and is written from a Linux/UNIX perspective where you would have your code running with an OS doing memory mappings and probably protection for you. It really is fundamentally not much different on Android, iOS, OSX or even Windows.// +//This is not a theoretical C language specifications document. It is a practical primer for the vast majority of real life cases of C usage that are relevant to EFL on todays common architectures. It covers application executables and shared library concepts and is written from a Linux/UNIX perspective where you would have your code running with an OS doing memory mappings and probably protection for you. It really is fundamentally not much different on Android, iOS, OSX or even Windows.// -//It won't cover esoteric details of "strange architectures" which may, in theory exist, but in real life are long dead, never existed, or are so rare that you won't need to know. It pretty much thinks of C as a high level assembly language that is portable across a range of modern architectures.// +//It won't cover esoteric details of "strange architectures". It pretty much covers C as a high level assembly language that is portable across a range of modern architectures.// -//Keep this in mind when reading, and know that some facets of C have been adapted to take this view of things. It simply makes everything easier and more practical to learn, along with actually being relevant day-to-day in usage of C.// + Your first program + +Let's start with the traditional "Hello world" C application. This is about as simple as it gets for an application that does something you can see. + + +#include + +int +main(int argc, char **argv) +{ + printf("Hello world!\n"); + return 0; +} + + +You would compile this on a command-line as follows: + + cc hello.c -o hello + +Run the application with: + + ./hello + +You should then see this output: + + Hello world! + +So what has happened here? Let's first look at the code itself. The first line: + + +#include + + +This tells the compiler to literally include the **stdio.h** file into your application. The compiler will find this file in the standard locations to look for include files and literally "paste" it there where the include line is. This file provides some "standard I/O" features, such as ''printf()''. + +The next thing is something every application will have - a ''main()'' function. This function must exist only once in the application because this is the function that is run //AS// the application. When this function exits, the application does. + + +int +main(int argc, char **argv) +{ +} + + +The ''main()'' function always returns an ''integer'' value, and is given 2 parameters on start. Those are an integer ''argc'' and then an array of strings. In C an array is generally just a pointer to the first element. A String is generally a pointer to a series of bytes (chars) which ends in a byte value of 0 to indicate the end of the string. We'll come back to this later, but as we don't use these, just ignore this for now. + +The next thing that happens is for the code to call a function ''printf()'' with a string "Hello world!\n". Why the "\n" at the end? This is an "escape". A way of indicating a special character. In this case this is the //newline// character. Strings in C can contain some special characters like this, and "\" is used to begin the escaped string. + + +printf("Hello world!\n"); + + +Now finally we return from the main function with the value 0. The ''main()'' function of an application is special. It always returns an integer that indicates the "success" of the application. This is used by the shell executing the process to determine success. A return of ''0'' indicates the process ran successfully. + + +return 0; + + +You will notice a few things. First lines starting with ''#'' are commands, but don't have a '';''. This is normal because these lines are processed by the pre-processor. All code in C goes through the C pre-processor and this basically generates more code. Other lines that are not sta
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=9809d441a74ab40da351a2e065fb4d71bbe4cee8 commit 9809d441a74ab40da351a2e065fb4d71bbe4cee8 Author: Raster Date: Thu Apr 30 03:15:28 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/c/start.txt | 100 - 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/pages/docs/c/start.txt b/pages/docs/c/start.txt index 0aaa79a..8bdfd03 100644 --- a/pages/docs/c/start.txt +++ b/pages/docs/c/start.txt @@ -1,9 +1,105 @@ ~~Title: C Primer~~ ~~CODE-c~~ -{{page>index}} + Preface - Also See +//This is not a theoretical C language specifications document. It is a practical primer for the vast majority of real life cases of C usage that are relevant to EFL. It covers application executables and shared library concepts and is written from a Linux/UNIX perspective where you would have your code running with an OS doing memory mappings and probably protection for you. It really is fundamentally not much different on Android, iOS, OSX or even Windows.// + +//It won't cover esoteric details of "strange architectures" which may, in theory exist, but in real life are long dead, never existed, or are so rare that you won't need to know. It pretty much thinks of C as a high level assembly language that is portable across a range of modern architectures.// + +//Keep this in mind when reading, and know that some facets of C have been adapted to take this view of things. It simply makes everything easier and more practical to learn, along with actually being relevant day-to-day in usage of C.// + + The machine + +Reality is that you are dealing with a machine. It's real. It has its personality and ways of working thanks to the people who designed the CPU and its components. Most machines are fairly similar these days, of course with their variations on personality, size etc. + +All machines have at least a single processor to execute a series of instructions. If you write an application (a common case) this is the model you will see right in front of you. An applications begins by executing a list of instructions at the CPU level. + +The C compiler takes the C code files you write and converts them into "machine code" (which is really just a series of numbers that end up stored in memory, and these numbers have meanings like "0" is "do nothing", "1" is "add the next 2 numbers together and store the result". "2" is "compare result with next number, store comparison in result", "3" is "if result is 'equal to' then start executing instructions at the memory location in the next number" etc.). Somewhere these numbers are [...] + +CPUs will do arithmetic, logic operations, change what it is they execute, and read from or write to memory to deal with data. In the end, everything to a CPU is effectively a number, and some operation you do to it. + +To computers, numbers are a string of "bits". A bit can be on or off. Just like you may be used to numbers, with each digit having 10 values (0 through to 9), A computer sees numbers more simply. It is 0, or it is 1. Just like you can have a bigger number by adding a digit (1 digit can encode 10 values, 2 digits can encode 100 values, 3 can encode 1000 values etc.), So too with the binary (0 or 1) numbering system computers use. Every binary digit you add doubles the number of values you [...] + +Numbers to a computer normally come in sizes that indicate how many bits they use. The sizes that really matter are bytes (8 bits), shorts (16 bits), integers (32 bits), long integers (32 or 64 bits), long long integers (64 bits), floats (32 bits) doubles (64 bits) and pointers (32 or 64 bits). The terms here are those similar to what C uses for clarity and ease of explanation. The sizes here are the **COMMON SIZES** found across real life architectures today. //(This does gloss over so [...] + +Bytes (chars) can encode numbers from 0 through to 255. Shorts can do 0 through to 65535, integers can do 0 through to about 4 billion, long integers if 64 bit or long long integers can encode values up to about 18 qunitillion (a very big number). Pointers are also just integers. Either 32 or 64 bits. Floats and doubles can encode numbers with "a decimal place". Like 3.14159. Thus both floats and doubles consist of a mantissa and exponent. The mantissa determines the digits of the numbe [...] + +When we want signed numbers, we center our ranges AROUND 0. So bytes (chars) can go from -128 to 127, shorts from -32768 to 32767, integers from around -2 billion to 2 billion, and the long long integers and 64 bit versions of integers can go from about -9 quintillion to about 9 quinitillion. By default all of the types are signed (except pointers) UNLESS you put an "unsigned" in front of them. You can also place "signed" in front
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=3170e7d2d9cd620533a4f411c191021c9c28a84e commit 3170e7d2d9cd620533a4f411c191021c9c28a84e Author: Raster Date: Thu Apr 30 01:40:46 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/efl/start.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pages/docs/efl/start.txt b/pages/docs/efl/start.txt index 3e1c876..33ab758 100644 --- a/pages/docs/efl/start.txt +++ b/pages/docs/efl/start.txt @@ -39,9 +39,7 @@ Emotion, Ecore_Con, Ecore_IPC, Eio, Eldbus, Elocation, Ecore_Audio, Ecore_File and Efreet. We will make an assumption that you have a reasonable grasp of the C -programming language here. Perhaps you might want to read -[[http://www.cprogramming.com/tutorial/c-tutorial.html|this C introduction tutorial]] -if you are new to C, or need a refresher. +programming language here. Perhaps you might want to read the [[docs/c/start]] if you are new to C, or need a refresher. --
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=23e670fcd86c5d108c8c0226b030597599dc8a1b commit 23e670fcd86c5d108c8c0226b030597599dc8a1b Author: Raster Date: Fri Apr 24 17:35:09 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/efl/start.txt | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pages/docs/efl/start.txt b/pages/docs/efl/start.txt index a32419b..3e1c876 100644 --- a/pages/docs/efl/start.txt +++ b/pages/docs/efl/start.txt @@ -1,6 +1,8 @@ ~~Title: EFL~~ ~~CODE-c~~ +{{page>index}} + EFL EFL is a range of libraries that cover APIs to solve every day @@ -45,13 +47,13 @@ if you are new to C, or need a refresher. === Application Mainloop === -It is assumed every application has a __Mainloop__, and that EFL is +It is assumed every application has a [[mainloop]], and that EFL is in charge of that. If you are writing a library, then that assumption would be made ultimately of the application using that library as well. For the purposes of this introduction to EFL, we will talk about an application, how it starts, runs and shuts down. -Every application is expected to have a lifecycle as follows. If you +Every application is expected to have a life-cycle as follows. If you have a design that is significantly different then you will be struggling against EFL and what it is pushing you to use. This does not mean we do not support threads, we just push you into a specific @@ -60,10 +62,10 @@ design pattern. {{ :docs:efl:mainloop.svg?nolink |Application Mainloop}} An application would spend almost it's entire life inside the -__Mainloop__ sleeping, processing events and then updating it's UI, +[[mainloop]] sleeping, processing events and then updating it's UI, until it decides to exit. All of this would take place inside the -__Mainloop__ processing function elm_run() which will only return -once the __Mainloop__ voluntarily exits if an elm_exit() function is +[[mainloop]] processing function elm_run() which will only return +once the [[mainloop]] voluntarily exits if an elm_exit() function is called while it runs, which marks the loop to exit, next time it has a chance. Before and after this, will be initialization and shutdown of the application. Your most basic application that just does nothing but @@ -133,7 +135,7 @@ elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); The first thing we do is enable a policy where if our last window is -deleted, the __Mainloop__ started by elm_run() is automatically +deleted, the [[mainloop]] started by elm_run() is automatically quit when this last window is closed. This is really handy for applications with multiple windows that want to just go away when they are no longer presenting any UI. @@ -204,13 +206,13 @@ evas_object_smart_callback_add(btn, "clicked", on_click, win); We now add a callback for the "clicked" smart event on the button. This will call the ''on_click'' function when a user clicks on the -button. The __Mainloop__ drives event handling and thus calling of +button. The [[mainloop]] drives event handling and thus calling of this callback. All event callbacks can pass in an arbitrary pointer to anything the like. This will be passed as the first data pointer to -the callback above. In this case we will passin our window pointer as +the callback above. In this case we will passing our window pointer as we want to delete the window when someone presses the button. Due to our policy settings, this will end up deleting the last window we have -and automatically exiting the __Mainloop__, and then of course the +and automatically exiting the [[mainloop]], and then of course the application. The example works this way to show how it might be extended to open multiple windows and only have the window you click the button in be deleted, until all windows are gone and application @@ -231,18 +233,18 @@ evas_object_show(win); Now we show the window. It is best to show it last just before you -jump into the __Mainloop__ to process everything. This means all +jump into the [[mainloop]] to process everything. This means all window setup is invisible until it is finished. elm_run(); -Finally we begin the __Mainloop__. This function will not exit until -the __Mainloop__ is done and exits (with an elm_exit() being +Finally we begin the [[mainloop]]. This function will not exit until +the [[mainloop]] is done and exits (with an elm_exit() being called from inside some callback there). So at this point your application is handing full control over it's execution to EFL and the -__Mainloop__ to deal with events and rendering of updates. +[[mainloop]] to deal with events and rendering of updates. From inside the mainloop function run by EFL, all your callbacks (functions you register to be called when events, state changes
[EGIT] [website/www-content] master 01/01: Wiki page start changed with summary [] by Raster
WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=b1b16b1077e6fe9b8dc0459efe0c99c7447c169f commit b1b16b1077e6fe9b8dc0459efe0c99c7447c169f Author: Raster Date: Thu Apr 16 18:01:14 2015 -0700 Wiki page start changed with summary [] by Raster --- pages/docs/efl/start.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/docs/efl/start.txt b/pages/docs/efl/start.txt index f5f05ef..fdacb2e 100644 --- a/pages/docs/efl/start.txt +++ b/pages/docs/efl/start.txt @@ -13,7 +13,7 @@ and cleanly. We will cover these topics here: * Data structures (lists, hash tables, growable buffers/strings etc.) * Main loop event, I/O and timing core - * Event queue and callhandling + * Event queue and call handling * Canvas scene graph and rendering * UI object element layout, animation and theme abstraction * Widgets/controls (buttons, sliders, scrollers etc.) --