Commit 6c4f4351 authored by Etienne Toussaint's avatar Etienne Toussaint

Début de hierarchie / Makefile

parent dde02337
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.7
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
public class SWIGTYPE_p_my_struct {
private transient long swigCPtr;
protected SWIGTYPE_p_my_struct(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_my_struct() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_my_struct obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}
/* File : example.c */
#include <time.h>
#include <tcl.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <err.h>
#include <stdlib.h>
typedef int(*method)(void);
struct my_struct{
int x;
int y;
int z;
int pv;
int mana;
int endu;
method met; // Marche pas, on peu pas le fumer :)
};
struct my_struct * My_variable;
void init(){
int fd = 0;
if ((fd = open("/tmp/zero", O_RDWR, 0)) == -1)
err(1, "open");
My_variable = (struct my_struct*) mmap(NULL, sizeof(struct my_struct), PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, 0);
if (My_variable == MAP_FAILED){
err(1,"why :");
errx(1, "either mmap");
}
/* My_variable->x = 8; */
}
int call(){
return My_variable->met();
}
int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}
int my_mod(int x, int y) {
return (x%y);
}
void set_x(int x){
My_variable->x = x;
}
int get_x(){
return My_variable->x;
}
void init2(){
My_variable->met = get_x;
}
void set_y(int x){
My_variable->y = x;
}
int get_y(){
return My_variable->y;
}
void set_z(int x){
My_variable->z = x;
}
int get_z(){
return My_variable->z;
}
char *get_time()
{
time_t ltime;
time(&ltime);
return ctime(&ltime);
}
/* example.i */
%module example
%{
/* Put header files here or function declarations like below */
extern struct my_struct * My_variable;
extern void init2();
extern void init();
extern int fact(int n);
extern int call();
extern int get_x();
extern void set_x(int x);
extern int get_y();
extern void set_y(int x);
extern int get_z();
extern void set_z(int x);
extern int my_mod(int x, int y);
extern char *get_time();
%}
extern int call();
extern void init();
extern void init2();
extern struct my_struct * My_variable;
extern int get_x();
extern void set_x(int x);
extern int get_y();
extern void set_y(int x);
extern int get_z();
extern void set_z(int x);
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.7
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
public class example {
public static void init() {
exampleJNI.init();
}
public static void setMy_variable(SWIGTYPE_p_my_struct value) {
exampleJNI.My_variable_set(SWIGTYPE_p_my_struct.getCPtr(value));
}
public static SWIGTYPE_p_my_struct getMy_variable() {
long cPtr = exampleJNI.My_variable_get();
return (cPtr == 0) ? null : new SWIGTYPE_p_my_struct(cPtr, false);
}
public static int get_x() {
return exampleJNI.get_x();
}
public static void set_x(int x) {
exampleJNI.set_x(x);
}
public static int get_y() {
return exampleJNI.get_y();
}
public static void set_y(int x) {
exampleJNI.set_y(x);
}
public static int get_z() {
return exampleJNI.get_z();
}
public static void set_z(int x) {
exampleJNI.set_z(x);
}
public static int fact(int n) {
return exampleJNI.fact(n);
}
public static int my_mod(int x, int y) {
return exampleJNI.my_mod(x, y);
}
public static String get_time() {
return exampleJNI.get_time();
}
}
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.7
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_example', [dirname(__file__)])
except ImportError:
import _example
return _example
if fp is not None:
try:
_mod = imp.load_module('_example', fp, pathname, description)
finally:
fp.close()
return _mod
_example = swig_import_helper()
del swig_import_helper
else:
import _example
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def call():
return _example.call()
call = _example.call
def init():
return _example.init()
init = _example.init
def init2():
return _example.init2()
init2 = _example.init2
def get_x():
return _example.get_x()
get_x = _example.get_x
def set_x(x):
return _example.set_x(x)
set_x = _example.set_x
def get_y():
return _example.get_y()
get_y = _example.get_y
def set_y(x):
return _example.set_y(x)
set_y = _example.set_y
def get_z():
return _example.get_z()
get_z = _example.get_z
def set_z(x):
return _example.set_z(x)
set_z = _example.set_z
def fact(n):
return _example.fact(n)
fact = _example.fact
def my_mod(x, y):
return _example.my_mod(x, y)
my_mod = _example.my_mod
def get_time():
return _example.get_time()
get_time = _example.get_time
# This file is compatible with both classic and new-style classes.
cvar = _example.cvar
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.7
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
public class exampleJNI {
public final static native void init();
public final static native void My_variable_set(long jarg1);
public final static native long My_variable_get();
public final static native int get_x();
public final static native void set_x(int jarg1);
public final static native int get_y();
public final static native void set_y(int jarg1);
public final static native int get_z();
public final static native void set_z(int jarg1);
public final static native int fact(int jarg1);
public final static native int my_mod(int jarg1, int jarg2);
public final static native String get_time();
}
This source diff could not be displayed because it is too large. You can view the blob instead.
public class main {
public static void main(String argv[]) {
System.setProperty("java.library.path", "/Users/etouss/Documents/CoursEns/M1/GenieLog/test");
System.out.println(System.getProperty("java.library.path"));
System.loadLibrary("example");
example.init();
System.out.println(example.get_x());
System.out.println(example.fact(5));
System.out.println(example.get_time());
}
}
#include <sys/types.h>
#include <sys/mman.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(void)
{
int fd;
int myint;
/* if ((fd = open("/tmp/zero", O_RDWR, 0)) == -1) */
/* err(1, "open"); */
/* myint = (int*) mmap(NULL, sizeof(int), PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, 0); */
/* if (myint == MAP_FAILED){ */
/* err(1,"why :"); */
/* errx(1, "either mmap"); */
/* } */
/* */
for(int i = 0;i<1000000000;i++){
myint = i;
(myint)++;
}
printf("%d",myint);
return (EXIT_SUCCESS);
}
# Makefile author: Joseph Anderson <jtanderson@ratiocaeli.com>
# This is where you specify the necessary source files
# Program packages and files
# - The packages should be the path inside your src directory. eg: package1 package2/package3
PACKAGES = core graphics map_generation network user_interface
# Java compiler
JAVAC = javac
JVM = 1.8
# Directory for compiled binaries
# - trailing slash is important!
BIN = bin/
# Directory of source files
# - trailing slash is important!
SRC = src/
# Java compiler flags
# JAVAFLAGS = -g -cp $(SRC)
JAVAFLAGS = -g -d $(BIN) -cp $(SRC) -target $(JVM)
# Creating a .class file
COMPILE = $(JAVAC) $(JAVAFLAGS)
EMPTY =
JAVA_FILES = $(subst $(SRC), $(EMPTY), $(wildcard $(SRC)*.java))
ifdef PACKAGES
PACKAGEDIRS = $(addprefix $(SRC), $(PACKAGES))
PACKAGEFILES = $(subst $(SRC), $(EMPTY), $(foreach DIR, $(PACKAGEDIRS), $(wildcard $(DIR)/*.java)))
ALL_FILES = $(PACKAGEFILES) $(JAVA_FILES)
else
#ALL_FILES = $(wildcard $(SRC).java)
ALL_FILES = $(JAVA_FILES)
endif
# One of these should be the "main" class listed in Runfile
CLASS_FILES = $(subst $(SRC), $(BIN), $(ALL_FILES:.java=.class))
# CLASS_FILES = $(ALL_FILES:.java=.class)
# The first target is the one that is executed when you invoke
# "make".
all : $(addprefix $(BIN), $(CLASS_FILES))
# The line describing the action starts with <TAB>
$(BIN)%.class : $(SRC)%.java
$(COMPILE) $<
clean :
rm -rf $(BIN)*
File added
package core;
public class Core {
public Core(){
}
}
import core.*;
import graphics.*;
class Main {
public static void main (String[] args){
System.out.println("Hello World");
Core c = new Core();
}
}
package graphics;
public class Graphics {
// public static void main (String[] args){
// System.out.println("Hello World");
// }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment