libsheepy

C lib for handling text files, strings and json like data structure with an object oriented system
git clone https://spartatek.se/git/libsheepy.git
Log | Files | Refs | README | LICENSE

smallObjects.c (2495B)


      1 //
      2 
      3 #include "../release/libsheepyObject.h"
      4 
      5 #define internal static
      6 
      7 #include <stdbool.h>
      8 #include <stdio.h>
      9 
     10 #ifndef unitTest
     11 #endif
     12 int MAIN(int ARGC, char** ARGV);
     13 
     14 int argc; char **argv;
     15 
     16 #ifndef unitTest
     17 // Remove main when running the unit tests
     18 #define MAIN   main
     19 #endif
     20 int MAIN(int ARGC, char** ARGV) {
     21   char **list UNUSED = NULL;
     22 
     23   argc = ARGC; argv = ARGV;;// printf("%s\n", object type strings);
     24 
     25   // Steps
     26   // create objects
     27   // add type string to stringArrayt strArray
     28   // copy strArray to anotherStringArray
     29   // add effects
     30   // print anotherStringArray
     31   // print again types without effects
     32   // free all objects
     33 
     34   // create objects
     35   cleanSmallBoolP(cBool) = allocSmallBool(true);
     36   cleanSmallContainerP(container) = allocSmallContainer(NULL);
     37   cleanSmallDictP(dict) = allocSmallDict();
     38   cleanSmallDoubleP(cDouble) = allocSmallDouble(10);
     39   cleanSmallIntP(cInt) = allocSmallInt(255);
     40   cleanSmallJsonP(json) = allocSmallJson();
     41   cleanSmallStringP(string) = allocSmallString("libsheepy");
     42   cleanAllocateSmallArray(strArray);
     43   cleanSmallArrayP(tommy) = allocSmallArray();
     44   cleanUndefinedP(undef) = allocUndefined();
     45 
     46   // add type string to stringArrayt strArray
     47   pushG(strArray, (char *)cBool->type);
     48   pushG(strArray, (char *)container->type);
     49   pushG(strArray, (char *)dict->type);
     50   pushG(strArray, (char *)cDouble->type);
     51   pushG(strArray, (char *)cInt->type);
     52   pushG(strArray, (char *)json->type);
     53   pushG(strArray, (char *)string->type);
     54   pushG(strArray, (char *)strArray->type);
     55   pushG(strArray, (char *)tommy->type);
     56   pushG(strArray, (char *)undef->type);
     57 
     58   // copy strArray to anotherStringArray
     59   cleanSmallArrayP(anotherStringArray);
     60 
     61   anotherStringArray = duplicateG(strArray);
     62 
     63   // add effects
     64   smallStringt *st;
     65 
     66   st   = getG(anotherStringArray, rtSmallStringt, 0);
     67   colorG(st, BLD BGRED);
     68   setPG(anotherStringArray, 0, st);
     69 
     70   st   = getG(anotherStringArray, rtSmallStringt, 1);
     71   colorG(st, FNT BGBLU YLW);
     72   setPG(anotherStringArray, 1, st);
     73 
     74   st   = getG(anotherStringArray, rtSmallStringt, 2);
     75   colorG(st, INV);
     76   setPG(anotherStringArray, 2, st);
     77 
     78   st   = getG(anotherStringArray, rtSmallStringt, 3);
     79   colorG(st, COC);
     80   setPG(anotherStringArray, 3, st);
     81 
     82   st   = getG(anotherStringArray, rtSmallStringt, 4);
     83   colorG(st, CRD BGMGT);
     84   setPG(anotherStringArray, 4, st);
     85 
     86   // print anotherStringArray
     87   logG(anotherStringArray);
     88 
     89   // print again types without effects
     90   puts(UDL "\nObject Types:" RST);
     91   logG(strArray);
     92 }
     93