mirror of
https://gitlab.com/klmp200/LO41.git
synced 2024-12-21 23:31:12 +00:00
On test les objets, attention, les listes ne sont pas fonctionelles
This commit is contained in:
commit
551bf2cd51
229
.gitignore
vendored
Normal file
229
.gitignore
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# CMake
|
||||
cmake-build-debug/
|
||||
cmake-build-release/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
### Vim template
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-v][a-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
*~
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
### C template
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
### macOS template
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
### Emacs template
|
||||
# -*- mode: gitignore; -*-
|
||||
*~
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
auto-save-list
|
||||
tramp
|
||||
.\#*
|
||||
|
||||
# Org-mode
|
||||
.org-id-locations
|
||||
*_archive
|
||||
|
||||
# flymake-mode
|
||||
*_flymake.*
|
||||
|
||||
# eshell files
|
||||
/eshell/history
|
||||
/eshell/lastdir
|
||||
|
||||
# elpa packages
|
||||
/elpa/
|
||||
|
||||
# reftex files
|
||||
*.rel
|
||||
|
||||
# AUCTeX auto folder
|
||||
/auto/
|
||||
|
||||
# cask packages
|
||||
.cask/
|
||||
dist/
|
||||
|
||||
# Flycheck
|
||||
flycheck_*.el
|
||||
|
||||
# server auth directory
|
||||
/server/
|
||||
|
||||
# projectiles files
|
||||
.projectile
|
||||
|
||||
# directory configuration
|
||||
.dir-locals.el
|
||||
### SublimeText template
|
||||
# Cache files for Sublime Text
|
||||
*.tmlanguage.cache
|
||||
*.tmPreferences.cache
|
||||
*.stTheme.cache
|
||||
|
||||
# Workspace files are user-specific
|
||||
*.sublime-workspace
|
||||
|
||||
# Project files should be checked into the repository, unless a significant
|
||||
# proportion of contributors will probably not be using Sublime Text
|
||||
# *.sublime-project
|
||||
|
||||
# SFTP configuration file
|
||||
sftp-config.json
|
||||
|
||||
# Package control specific files
|
||||
Package Control.last-run
|
||||
Package Control.ca-list
|
||||
Package Control.ca-bundle
|
||||
Package Control.system-ca-bundle
|
||||
Package Control.cache/
|
||||
Package Control.ca-certs/
|
||||
Package Control.merged-ca-bundle
|
||||
Package Control.user-ca-bundle
|
||||
oscrypto-ca-bundle.crt
|
||||
bh_unicode_properties.cache
|
||||
|
||||
# Sublime-github package stores a github token in this file
|
||||
# https://packagecontrol.io/packages/sublime-github
|
||||
GitHub.sublime-settings
|
||||
|
2
.idea/LO41.iml
generated
Normal file
2
.idea/LO41.iml
generated
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
29
.idea/codeStyles/Project.xml
generated
Normal file
29
.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,29 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<Objective-C-extensions>
|
||||
<file>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||
</file>
|
||||
<class>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||
</class>
|
||||
<extensions>
|
||||
<pair source="cpp" header="h" fileNamingConvention="NONE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
</extensions>
|
||||
</Objective-C-extensions>
|
||||
</code_scheme>
|
||||
</component>
|
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/LO41.iml" filepath="$PROJECT_DIR$/.idea/LO41.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
7
CMakeLists.txt
Normal file
7
CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(LO41 C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
|
||||
add_executable(LO41 main.c List/List.h List/List.c Objects.h List/Element.c List/Element.h Objects.c)
|
37
List/Element.c
Normal file
37
List/Element.c
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Created by Antoine Bartuccio on 22/05/2018.
|
||||
//
|
||||
|
||||
#include <string.h>
|
||||
#include "List.h"
|
||||
|
||||
GETTER(Element, Element*, next)
|
||||
GETTER(Element, Element*, previous)
|
||||
GETTER(Element, void*, data)
|
||||
|
||||
void set_previous_Element(THIS(Element), Element *previous){
|
||||
this->previous = previous;
|
||||
}
|
||||
|
||||
void set_next_Element(THIS(Element), Element *next){
|
||||
this->next = next;
|
||||
}
|
||||
|
||||
void $_free__Element(THIS(Element)){
|
||||
free(this);
|
||||
}
|
||||
|
||||
Element *_init_element(void *data, size_t size, List *list){
|
||||
Element *el = (Element*) malloc_or_die(sizeof(Element));
|
||||
void *newData = malloc_or_die(sizeof(size));
|
||||
|
||||
memcpy(newData, data, size);
|
||||
el->list = list;
|
||||
el->data = newData;
|
||||
el->previous = NULL;
|
||||
el->next = NULL;
|
||||
|
||||
LINK_ALL(Element, el, get_next, get_previous, get_data, set_next, set_previous)
|
||||
|
||||
return el;
|
||||
}
|
30
List/Element.h
Normal file
30
List/Element.h
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Created by Antoine Bartuccio on 22/05/2018.
|
||||
//
|
||||
|
||||
#ifndef LO41_ELEMENT_H
|
||||
#define LO41_ELEMENT_H
|
||||
|
||||
typedef struct o_List List;
|
||||
|
||||
#include "List.h"
|
||||
|
||||
struct o_Element {
|
||||
List *list;
|
||||
void *data;
|
||||
struct o_Element *next;
|
||||
struct o_Element *previous;
|
||||
|
||||
struct o_Element *(*get_next)(O_THIS(Element));
|
||||
struct o_Element *(*get_previous)(O_THIS(Element));
|
||||
void *(*get_data)(O_THIS(Element));
|
||||
|
||||
void (*set_previous)(O_THIS(Element), struct o_Element *previous);
|
||||
void (*set_next)(O_THIS(Element), struct o_Element *next);
|
||||
|
||||
void (*$_free_)(O_THIS(Element));
|
||||
};
|
||||
|
||||
Element *$_init_Element(void *data, size_t size, List *list);
|
||||
|
||||
#endif //LO41_ELEMENT_H
|
23
List/List.c
Normal file
23
List/List.c
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// Created by Antoine Bartuccio on 22/05/2018.
|
||||
//
|
||||
#include "List.h"
|
||||
|
||||
GETTER(List, Element*, head)
|
||||
GETTER(List, Element*, tail)
|
||||
GETTER(List, int, size)
|
||||
|
||||
void $_free__List(THIS(List)){
|
||||
free(this);
|
||||
}
|
||||
|
||||
List *$_init_List(){
|
||||
List *l = (List*) malloc_or_die(sizeof(List));
|
||||
l->size = 0;
|
||||
l->head = NULL;
|
||||
l->tail = NULL;
|
||||
|
||||
LINK_ALL(List, l, get_head, get_tail, get_size)
|
||||
return l;
|
||||
}
|
||||
|
29
List/List.h
Normal file
29
List/List.h
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by Antoine Bartuccio on 22/05/2018.
|
||||
//
|
||||
|
||||
#ifndef LO41_LIST_H
|
||||
#define LO41_LIST_H
|
||||
|
||||
#include "../Objects.h"
|
||||
|
||||
typedef struct o_Element Element;
|
||||
|
||||
#include "Element.h"
|
||||
|
||||
#define WRONG_ELEMENT CRASH("This element is not within the list\n")
|
||||
|
||||
struct o_List {
|
||||
Element *head;
|
||||
Element *tail;
|
||||
int size;
|
||||
|
||||
Element *(*get_head)(O_THIS(List));
|
||||
Element *(*get_tail)(O_THIS(List));
|
||||
int (*get_size)(O_THIS(List));
|
||||
void (*$_free_)(O_THIS(List));
|
||||
};
|
||||
|
||||
List *$_init_List();
|
||||
|
||||
#endif //LO41_LIST_H
|
12
Objects.c
Normal file
12
Objects.c
Normal file
@ -0,0 +1,12 @@
|
||||
//
|
||||
// Created by Antoine Bartuccio on 22/05/2018.
|
||||
//
|
||||
|
||||
#include "Objects.h"
|
||||
|
||||
void *malloc_or_die(size_t size){
|
||||
void *ptr = malloc(size);
|
||||
if (ptr == NULL)
|
||||
perror("Error allocating object");
|
||||
return ptr;
|
||||
}
|
53
Objects.h
Normal file
53
Objects.h
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// Created by Antoine Bartuccio on 22/05/2018.
|
||||
//
|
||||
|
||||
#ifndef LO41_OBJECTS_H
|
||||
#define LO41_OBJECTS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define NEW(type, ...) $_init_##type(__VA_ARGS__)
|
||||
#define DELETE(obj) obj->$_free_(obj)
|
||||
#define THIS(type) type *this
|
||||
#define O_THIS(type) struct o_##type *this
|
||||
#define CRASH(message) perror(message)
|
||||
|
||||
#define SYNCHRONIZE
|
||||
|
||||
#define LINK(type, obj, method) obj->method = method##_##type;
|
||||
#define GETTER(obj_type, variable_type, variable) variable_type get_##variable##_##obj_type(obj_type *this){\
|
||||
return this->variable; }
|
||||
|
||||
void * malloc_or_die(size_t size);
|
||||
|
||||
/* Link all method from variadic list, support max 20 args */
|
||||
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
|
||||
#define VA_NUM_ARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, N, ...) N
|
||||
#define LINK_NB_(N) LINK_ALL_##N
|
||||
#define LINK_NB(N) LINK_NB_(N)
|
||||
#define LINK_ALL(type, obj, ...) LINK(type, obj, $_free_) LINK_NB(VA_NUM_ARGS(__VA_ARGS__))(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_1(type, obj, method, ...) LINK(type, obj, method)
|
||||
#define LINK_ALL_2(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_1(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_3(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_2(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_4(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_3(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_5(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_4(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_6(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_5(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_7(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_6(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_8(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_7(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_9(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_8(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_10(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_9(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_11(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_10(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_12(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_11(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_13(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_12(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_14(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_13(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_15(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_14(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_16(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_15(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_17(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_16(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_18(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_17(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_19(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_18(type, obj, __VA_ARGS__)
|
||||
#define LINK_ALL_20(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_19(type, obj, method, __VA_ARGS__)
|
||||
|
||||
|
||||
#endif //LO41_OBJECTS_H
|
Loading…
Reference in New Issue
Block a user