@@ -492,12 +492,14 @@ class ContextifyScript : public BaseObject {
492492
493493 TryCatch try_catch (env->isolate ());
494494 Local<String> code = args[0 ]->ToString (env->isolate ());
495- Local<String> filename = GetFilenameArg (env, args, 1 );
496- Local<Integer> lineOffset = GetLineOffsetArg (args, 1 );
497- Local<Integer> columnOffset = GetColumnOffsetArg (args, 1 );
498- bool display_errors = GetDisplayErrorsArg (env, args, 1 );
499- MaybeLocal<Uint8Array> cached_data_buf = GetCachedData (env, args, 1 );
500- bool produce_cached_data = GetProduceCachedData (env, args, 1 );
495+
496+ Local<Value> options = args[1 ];
497+ Local<String> filename = GetFilenameArg (env, options);
498+ Local<Integer> lineOffset = GetLineOffsetArg (env, options);
499+ Local<Integer> columnOffset = GetColumnOffsetArg (env, options);
500+ bool display_errors = GetDisplayErrorsArg (env, options);
501+ MaybeLocal<Uint8Array> cached_data_buf = GetCachedData (env, options);
502+ bool produce_cached_data = GetProduceCachedData (env, options);
501503 if (try_catch.HasCaught ()) {
502504 try_catch.ReThrow ();
503505 return ;
@@ -570,9 +572,9 @@ class ContextifyScript : public BaseObject {
570572
571573 // Assemble arguments
572574 TryCatch try_catch (args.GetIsolate ());
573- uint64_t timeout = GetTimeoutArg (env, args, 0 );
574- bool display_errors = GetDisplayErrorsArg (env, args, 0 );
575- bool break_on_sigint = GetBreakOnSigintArg (env, args, 0 );
575+ uint64_t timeout = GetTimeoutArg (env, args[ 0 ] );
576+ bool display_errors = GetDisplayErrorsArg (env, args[ 0 ] );
577+ bool break_on_sigint = GetBreakOnSigintArg (env, args[ 0 ] );
576578 if (try_catch.HasCaught ()) {
577579 try_catch.ReThrow ();
578580 return ;
@@ -600,9 +602,9 @@ class ContextifyScript : public BaseObject {
600602 Local<Object> sandbox = args[0 ].As <Object>();
601603 {
602604 TryCatch try_catch (env->isolate ());
603- timeout = GetTimeoutArg (env, args, 1 );
604- display_errors = GetDisplayErrorsArg (env, args, 1 );
605- break_on_sigint = GetBreakOnSigintArg (env, args, 1 );
605+ timeout = GetTimeoutArg (env, args[ 1 ] );
606+ display_errors = GetDisplayErrorsArg (env, args[ 1 ] );
607+ break_on_sigint = GetBreakOnSigintArg (env, args[ 1 ] );
606608 if (try_catch.HasCaught ()) {
607609 try_catch.ReThrow ();
608610 return ;
@@ -676,36 +678,31 @@ class ContextifyScript : public BaseObject {
676678 True (env->isolate ()));
677679 }
678680
679- static bool GetBreakOnSigintArg (Environment* env,
680- const FunctionCallbackInfo<Value>& args,
681- const int i) {
682- if (args[i]->IsUndefined () || args[i]->IsString ()) {
681+ static bool GetBreakOnSigintArg (Environment* env, Local<Value> options) {
682+ if (options->IsUndefined () || options->IsString ()) {
683683 return false ;
684684 }
685- if (!args[i] ->IsObject ()) {
685+ if (!options ->IsObject ()) {
686686 env->ThrowTypeError (" options must be an object" );
687687 return false ;
688688 }
689689
690- Local<String> key = FIXED_ONE_BYTE_STRING (args.GetIsolate (),
691- " breakOnSigint" );
692- Local<Value> value = args[i].As <Object>()->Get (key);
690+ Local<String> key = FIXED_ONE_BYTE_STRING (env->isolate (), " breakOnSigint" );
691+ Local<Value> value = options.As <Object>()->Get (key);
693692 return value->IsTrue ();
694693 }
695694
696- static int64_t GetTimeoutArg (Environment* env,
697- const FunctionCallbackInfo<Value>& args,
698- const int i) {
699- if (args[i]->IsUndefined () || args[i]->IsString ()) {
695+ static int64_t GetTimeoutArg (Environment* env, Local<Value> options) {
696+ if (options->IsUndefined () || options->IsString ()) {
700697 return -1 ;
701698 }
702- if (!args[i] ->IsObject ()) {
699+ if (!options ->IsObject ()) {
703700 env->ThrowTypeError (" options must be an object" );
704701 return -1 ;
705702 }
706703
707- Local<String> key = FIXED_ONE_BYTE_STRING (args. GetIsolate (), " timeout" );
708- Local<Value> value = args[i] .As <Object>()->Get (key);
704+ Local<String> key = FIXED_ONE_BYTE_STRING (env-> isolate (), " timeout" );
705+ Local<Value> value = options .As <Object>()->Get (key);
709706 if (value->IsUndefined ()) {
710707 return -1 ;
711708 }
@@ -719,59 +716,52 @@ class ContextifyScript : public BaseObject {
719716 }
720717
721718
722- static bool GetDisplayErrorsArg (Environment* env,
723- const FunctionCallbackInfo<Value>& args,
724- const int i) {
725- if (args[i]->IsUndefined () || args[i]->IsString ()) {
719+ static bool GetDisplayErrorsArg (Environment* env, Local<Value> options) {
720+ if (options->IsUndefined () || options->IsString ()) {
726721 return true ;
727722 }
728- if (!args[i] ->IsObject ()) {
723+ if (!options ->IsObject ()) {
729724 env->ThrowTypeError (" options must be an object" );
730725 return false ;
731726 }
732727
733- Local<String> key = FIXED_ONE_BYTE_STRING (args.GetIsolate (),
734- " displayErrors" );
735- Local<Value> value = args[i].As <Object>()->Get (key);
728+ Local<String> key = FIXED_ONE_BYTE_STRING (env->isolate (), " displayErrors" );
729+ Local<Value> value = options.As <Object>()->Get (key);
736730
737731 return value->IsUndefined () ? true : value->BooleanValue ();
738732 }
739733
740734
741- static Local<String> GetFilenameArg (Environment* env,
742- const FunctionCallbackInfo<Value>& args,
743- const int i) {
735+ static Local<String> GetFilenameArg (Environment* env, Local<Value> options) {
744736 Local<String> defaultFilename =
745- FIXED_ONE_BYTE_STRING (args. GetIsolate (), " evalmachine.<anonymous>" );
737+ FIXED_ONE_BYTE_STRING (env-> isolate (), " evalmachine.<anonymous>" );
746738
747- if (args[i] ->IsUndefined ()) {
739+ if (options ->IsUndefined ()) {
748740 return defaultFilename;
749741 }
750- if (args[i] ->IsString ()) {
751- return args[i] .As <String>();
742+ if (options ->IsString ()) {
743+ return options .As <String>();
752744 }
753- if (!args[i] ->IsObject ()) {
745+ if (!options ->IsObject ()) {
754746 env->ThrowTypeError (" options must be an object" );
755747 return Local<String>();
756748 }
757749
758- Local<String> key = FIXED_ONE_BYTE_STRING (args. GetIsolate (), " filename" );
759- Local<Value> value = args[i] .As <Object>()->Get (key);
750+ Local<String> key = FIXED_ONE_BYTE_STRING (env-> isolate (), " filename" );
751+ Local<Value> value = options .As <Object>()->Get (key);
760752
761753 if (value->IsUndefined ())
762754 return defaultFilename;
763- return value->ToString (args. GetIsolate ());
755+ return value->ToString (env-> isolate ());
764756 }
765757
766758
767- static MaybeLocal<Uint8Array> GetCachedData (
768- Environment* env,
769- const FunctionCallbackInfo<Value>& args,
770- const int i) {
771- if (!args[i]->IsObject ()) {
759+ static MaybeLocal<Uint8Array> GetCachedData (Environment* env,
760+ Local<Value> options) {
761+ if (!options->IsObject ()) {
772762 return MaybeLocal<Uint8Array>();
773763 }
774- Local<Value> value = args[i] .As <Object>()->Get (env->cached_data_string ());
764+ Local<Value> value = options .As <Object>()->Get (env->cached_data_string ());
775765 if (value->IsUndefined ()) {
776766 return MaybeLocal<Uint8Array>();
777767 }
@@ -785,48 +775,42 @@ class ContextifyScript : public BaseObject {
785775 }
786776
787777
788- static bool GetProduceCachedData (
789- Environment* env,
790- const FunctionCallbackInfo<Value>& args,
791- const int i) {
792- if (!args[i]->IsObject ()) {
778+ static bool GetProduceCachedData (Environment* env, Local<Value> options) {
779+ if (!options->IsObject ()) {
793780 return false ;
794781 }
795782 Local<Value> value =
796- args[i] .As <Object>()->Get (env->produce_cached_data_string ());
783+ options .As <Object>()->Get (env->produce_cached_data_string ());
797784
798785 return value->IsTrue ();
799786 }
800787
801788
802- static Local<Integer> GetLineOffsetArg (
803- const FunctionCallbackInfo<Value>& args,
804- const int i) {
805- Local<Integer> defaultLineOffset = Integer::New (args.GetIsolate (), 0 );
789+ static Local<Integer> GetLineOffsetArg (Environment* env,
790+ Local<Value> options) {
791+ Local<Integer> defaultLineOffset = Integer::New (env->isolate (), 0 );
806792
807- if (!args[i] ->IsObject ()) {
793+ if (!options ->IsObject ()) {
808794 return defaultLineOffset;
809795 }
810796
811- Local<String> key = FIXED_ONE_BYTE_STRING (args. GetIsolate (), " lineOffset" );
812- Local<Value> value = args[i] .As <Object>()->Get (key);
797+ Local<String> key = FIXED_ONE_BYTE_STRING (env-> isolate (), " lineOffset" );
798+ Local<Value> value = options .As <Object>()->Get (key);
813799
814800 return value->IsUndefined () ? defaultLineOffset : value->ToInteger ();
815801 }
816802
817803
818- static Local<Integer> GetColumnOffsetArg (
819- const FunctionCallbackInfo<Value>& args,
820- const int i) {
821- Local<Integer> defaultColumnOffset = Integer::New (args.GetIsolate (), 0 );
804+ static Local<Integer> GetColumnOffsetArg (Environment* env,
805+ Local<Value> options) {
806+ Local<Integer> defaultColumnOffset = Integer::New (env->isolate (), 0 );
822807
823- if (!args[i] ->IsObject ()) {
808+ if (!options ->IsObject ()) {
824809 return defaultColumnOffset;
825810 }
826811
827- Local<String> key = FIXED_ONE_BYTE_STRING (args.GetIsolate (),
828- " columnOffset" );
829- Local<Value> value = args[i].As <Object>()->Get (key);
812+ Local<String> key = FIXED_ONE_BYTE_STRING (env->isolate (), " columnOffset" );
813+ Local<Value> value = options.As <Object>()->Get (key);
830814
831815 return value->IsUndefined () ? defaultColumnOffset : value->ToInteger ();
832816 }
0 commit comments