Skip to content

Commit

Permalink
builds on windows!
Browse files Browse the repository at this point in the history
  • Loading branch information
freethenation committed Jul 3, 2013
1 parent 2edba7d commit 9e44f0f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 116 deletions.
2 changes: 1 addition & 1 deletion binding.gyp
Expand Up @@ -7,7 +7,7 @@
"./nlopt-2.3/api/"
],
"dependencies": [
"./nlopt-2.3/binding.gyp:nlopt"
"./nlopt-2.3/nlopt.gyp:nloptlib"
]
}
]
Expand Down
107 changes: 0 additions & 107 deletions nlopt-2.3/binding.gyp

This file was deleted.

18 changes: 12 additions & 6 deletions nlopt-2.3/config.h
Expand Up @@ -11,7 +11,8 @@
/* #undef HAVE_BSDGETTIMEOFDAY */

/* Define if the copysign function/macro is available. */
#define HAVE_COPYSIGN 1
//in binding.gyp
//#define HAVE_COPYSIGN 1

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
Expand All @@ -26,16 +27,19 @@
#define HAVE_GETTID_SYSCALL 1

/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
//in binding.gyp
//#define HAVE_GETTIMEOFDAY 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define if the isinf() function/macro is available. */
#define HAVE_ISINF 1
//in binding.gyp
//#define HAVE_ISINF 1

/* Define if the isnan() function/macro is available. */
#define HAVE_ISNAN 1
//in binding.gyp
//#define HAVE_ISNAN 1

/* Define to 1 if you have the `m' library (-lm). */
#define HAVE_LIBM 1
Expand Down Expand Up @@ -118,10 +122,12 @@

/* Define to C thread-local keyword, or to nothing if this is not supported in
your compiler. */
#define THREADLOCAL __thread
//in binding.gyp
//#define THREADLOCAL __thread

/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
//in binding.gyp
//#define TIME_WITH_SYS_TIME 1

/* Version number of package */
#define VERSION "2.3"
Expand Down
6 changes: 4 additions & 2 deletions nlopt.cc
Expand Up @@ -134,7 +134,7 @@ double optimizationFunc(unsigned n, const double* x, double* grad, void* ptrCall
Handle<Value> Optimize(const Arguments& args) {
HandleScope scope;
Local<Object> ret = Local<Object>::New(Object::New());
nlopt_result code;
nlopt_result code = NLOPT_SUCCESS;
Local<String> key;

//There is not much validation in this function... should be done in js.
Expand Down Expand Up @@ -214,7 +214,8 @@ Handle<Value> Optimize(const Arguments& args) {
}

//setup parms for optimization
double input[n];
double* input;
input = new double[n];
for (unsigned i = 0; i < n; ++i) {
input[i] = 0;
}
Expand All @@ -231,6 +232,7 @@ Handle<Value> Optimize(const Arguments& args) {
double output[1] = {0};
checkNloptErrorCode(ret, key, nlopt_optimize(opt, input, output));
ret->Set(String::NewSymbol("parameterValues"), cArrayToV8Array(n, input));
delete input;
ret->Set(String::NewSymbol("outputValue"), Number::New(output[0]));
nlopt_destroy(opt);//cleanup
return scope.Close(ret);
Expand Down

0 comments on commit 9e44f0f

Please sign in to comment.