Commits

Kevin Smith  committed 97044c4

Adding commits from main erlang_js repo

  • Participants
  • Parent commits de58905

Comments (0)

Files changed (15)

File apps/erlang_js/Makefile

 	./rebar compile
 
 clean:
+	rm -rf tests_ebin
 	./rebar clean
-	cd c_src;make jsclean dist
+	cd c_src;make jsclean
+
+realclean: clean
+	cd c_src;make dist
 
 test: all
+	@mkdir -p tests_ebin
 	@cd tests;erl -make
-	@erl -noshell -boot start_sasl -pa ebin -s erlang_js -eval 'test_suite:test().' -s init stop
+	@erl -noshell -boot start_sasl -pa ebin -pa tests_ebin -s erlang_js -eval 'test_suite:test().' -s init stop
 	@rm -f ebin/test_* ebin/*_tests.erl

File apps/erlang_js/c_src/driver_comm.c

-/*
-Copyright (c) 2009 Hypothetical Labs, Inc.
+/* author Kevin Smith <ksmith@basho.com>
+   copyright 2009-2010 Basho Technologies
 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+       http://www.apache.org/licenses/LICENSE-2.0
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License. */
 
 #define COMMAND_SIZE 2
 

File apps/erlang_js/c_src/driver_comm.h

+/* author Kevin Smith <ksmith@basho.com>
+   copyright 2009-2010 Basho Technologies
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License. */
+
 #ifndef __DRIVER_COMM__
 #define __DRIVER_COMM__
 

File apps/erlang_js/c_src/spidermonkey.c

+/* author Kevin Smith <ksmith@basho.com>
+   copyright 2009-2010 Basho Technologies
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License. */
+
 #include <string.h>
 #include <erl_driver.h>
 

File apps/erlang_js/c_src/spidermonkey.h

+/* author Kevin Smith <ksmith@basho.com>
+   copyright 2009-2010 Basho Technologies
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License. */
+
 #ifndef __SPIDERMONKEY_INTERFACE_
 #define __SPIDERMONKEY_INTERFACE_
 

File apps/erlang_js/c_src/spidermonkey_drv.c

+/* author Kevin Smith <ksmith@basho.com>
+   copyright 2009-2010 Basho Technologies
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License. */
+
 #include <string.h>
 #include <erl_driver.h>
-/* #include <ei.h> */
 
 #include "spidermonkey.h"
 #include "config.h"

File apps/erlang_js/src/erlang_js.erl

+%% @author Kevin Smith <ksmith@basho.com>
+%% @copyright 2009-2010 Basho Technologies
+%%
+%%    Licensed under the Apache License, Version 2.0 (the "License");
+%%    you may not use this file except in compliance with the License.
+%%    You may obtain a copy of the License at
+%%
+%%        http://www.apache.org/licenses/LICENSE-2.0
+%%
+%%    Unless required by applicable law or agreed to in writing, software
+%%    distributed under the License is distributed on an "AS IS" BASIS,
+%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%    See the License for the specific language governing permissions and
+%%    limitations under the License.
+
 -module(erlang_js).
 
 -behaviour(application).

File apps/erlang_js/src/erlang_js_sup.erl

+%% @author Kevin Smith <ksmith@basho.com>
+%% @copyright 2009-2010 Basho Technologies
+%%
+%%    Licensed under the Apache License, Version 2.0 (the "License");
+%%    you may not use this file except in compliance with the License.
+%%    You may obtain a copy of the License at
+%%
+%%        http://www.apache.org/licenses/LICENSE-2.0
+%%
+%%    Unless required by applicable law or agreed to in writing, software
+%%    distributed under the License is distributed on an "AS IS" BASIS,
+%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%    See the License for the specific language governing permissions and
+%%    limitations under the License.
+
 -module(erlang_js_sup).
 
 -behaviour(supervisor).

File apps/erlang_js/src/js.erl

+%% @author Kevin Smith <ksmith@basho.com>
+%% @copyright 2009-2010 Basho Technologies
+%%
+%%    Licensed under the Apache License, Version 2.0 (the "License");
+%%    you may not use this file except in compliance with the License.
+%%    You may obtain a copy of the License at
+%%
+%%        http://www.apache.org/licenses/LICENSE-2.0
+%%
+%%    Unless required by applicable law or agreed to in writing, software
+%%    distributed under the License is distributed on an "AS IS" BASIS,
+%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%    See the License for the specific language governing permissions and
+%%    limitations under the License.
+
 -module(js).
 
 -export([define/2, define/3, eval/2, call/3, call/4]).

File apps/erlang_js/src/js_benchmark.erl

+%% @author Kevin Smith <ksmith@basho.com>
+%% @copyright 2009-2010 Basho Technologies
+%%
+%%    Licensed under the Apache License, Version 2.0 (the "License");
+%%    you may not use this file except in compliance with the License.
+%%    You may obtain a copy of the License at
+%%
+%%        http://www.apache.org/licenses/LICENSE-2.0
+%%
+%%    Unless required by applicable law or agreed to in writing, software
+%%    distributed under the License is distributed on an "AS IS" BASIS,
+%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%    See the License for the specific language governing permissions and
+%%    limitations under the License.
+
 -module(js_benchmark).
 
 -define(COUNTS, [1000, 10000, 100000]).

File apps/erlang_js/src/js_cache.erl

+%% @author Kevin Smith <ksmith@basho.com>
+%% @copyright 2009-2010 Basho Technologies
+%%
+%%    Licensed under the Apache License, Version 2.0 (the "License");
+%%    you may not use this file except in compliance with the License.
+%%    You may obtain a copy of the License at
+%%
+%%        http://www.apache.org/licenses/LICENSE-2.0
+%%
+%%    Unless required by applicable law or agreed to in writing, software
+%%    distributed under the License is distributed on an "AS IS" BASIS,
+%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%    See the License for the specific language governing permissions and
+%%    limitations under the License.
+
 -module(js_cache).
 
 -behaviour(gen_server).
 
 %% API
--export([start_link/0, store/2, delete/1, fetch/1, call_id/0]).
+-export([start_link/0, store/2, delete/1, fetch/1]).
 
 %% gen_server callbacks
 -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
 
 -define(SERVER, ?MODULE).
 
--record(state, {cache=gb_trees:empty(), call_id=0}).
+-record(state, {cache=gb_trees:empty()}).
 
 start_link() ->
     gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
 fetch(Key) ->
     gen_server:call(?SERVER, {fetch, Key}).
 
-call_id() ->
-    gen_server:call(?SERVER, call_id).
-
 init([]) ->
     {ok, #state{}}.
 
-handle_call(call_id, _From, #state{call_id=CurrVal}=State) ->
-    Id = list_to_binary(["$js", integer_to_list(CurrVal)]),
-    NewVal = if
-                 CurrVal == 1000000 ->
-                     0;
-                 true ->
-                     CurrVal + 1
-             end,
-    {reply, Id, State#state{call_id=NewVal}};
-
 handle_call({fetch, Key}, _From, #state{cache=Cache}=State) ->
     Result = case gb_trees:lookup(Key, Cache) of
                  {value, Value} ->

File apps/erlang_js/src/js_driver.erl

+%% @author Kevin Smith <ksmith@basho.com>
+%% @copyright 2009-2010 Basho Technologies
+%%
+%%    Licensed under the Apache License, Version 2.0 (the "License");
+%%    you may not use this file except in compliance with the License.
+%%    You may obtain a copy of the License at
+%%
+%%        http://www.apache.org/licenses/LICENSE-2.0
+%%
+%%    Unless required by applicable law or agreed to in writing, software
+%%    distributed under the License is distributed on an "AS IS" BASIS,
+%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%    See the License for the specific language governing permissions and
+%%    limitations under the License.
+
 -module(js_driver).
 
 -export([load_driver/0, new/0, new/1, destroy/1, shutdown/1]).
 -export([define_js/2, define_js/3, eval_js/2, eval_js/3]).
 
 -define(SCRIPT_TIMEOUT, 5000).
+-define(CALL_TOKEN, <<"$js">>).
 -define(DRIVER_NAME, "spidermonkey_drv").
 
 load_driver() ->
     end.
 
 call_driver(Ctx, Command, Args, Timeout) ->
-    CallId = js_cache:call_id(),
-    Marshalled = js_drv_comm:pack(Command, [CallId] ++ Args),
+    Marshalled = js_drv_comm:pack(Command, [?CALL_TOKEN] ++ Args),
     port_command(Ctx, Marshalled),
     Result = receive
-                 {CallId, ok} ->
+                 {?CALL_TOKEN, ok} ->
                      ok;
-                 {CallId, ok, R} ->
+                 {?CALL_TOKEN, ok, R} ->
                      {ok, R};
-                 {CallId, error, Error} ->
+                 {?CALL_TOKEN, error, Error} ->
                      {error, Error}
              after Timeout ->
                      {error, timeout}

File apps/erlang_js/src/js_drv_comm.erl

+%% @author Kevin Smith <ksmith@basho.com>
+%% @copyright 2009-2010 Basho Technologies
+%%
+%%    Licensed under the Apache License, Version 2.0 (the "License");
+%%    you may not use this file except in compliance with the License.
+%%    You may obtain a copy of the License at
+%%
+%%        http://www.apache.org/licenses/LICENSE-2.0
+%%
+%%    Unless required by applicable law or agreed to in writing, software
+%%    distributed under the License is distributed on an "AS IS" BASIS,
+%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%    See the License for the specific language governing permissions and
+%%    limitations under the License.
+
 -module(js_drv_comm).
 
 -export([pack/2]).

File apps/erlang_js/src/js_memory.erl

+%% @author Kevin Smith <ksmith@basho.com>
+%% @copyright 2009-2010 Basho Technologies
+%%
+%%    Licensed under the Apache License, Version 2.0 (the "License");
+%%    you may not use this file except in compliance with the License.
+%%    You may obtain a copy of the License at
+%%
+%%        http://www.apache.org/licenses/LICENSE-2.0
+%%
+%%    Unless required by applicable law or agreed to in writing, software
+%%    distributed under the License is distributed on an "AS IS" BASIS,
+%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%%    See the License for the specific language governing permissions and
+%%    limitations under the License.
+
 -module(js_memory).
 
 -define(COUNT, 1000000).

File apps/erlang_js/tests/Emakefile

 {"*", [warn_obsolete_guard, warn_unused_import,
        warn_shadow_vars, warn_export_vars, debug_info,
        {i, "../include"},
-       {outdir, "../ebin"}]}.
+       {outdir, "../tests_ebin"}]}.